convert to using Test::Requires
[gitmo/MooseX-Getopt.git] / t / 100_gld_default_bug.t
CommitLineData
630657d5 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6a378fbd 6use Test::More tests => 5;
630657d5 7use Test::Exception;
8
6a378fbd 9use Test::Requires {
10 'Getopt::Long::Descriptive' => 0.01, # skip all if not installed
11};
12
13use_ok('MooseX::Getopt');
630657d5 14
15{
16 package Engine::Foo;
17 use Moose;
2557b526 18
630657d5 19 with 'MooseX::Getopt';
2557b526 20
630657d5 21 has 'nproc' => (
22 metaclass => 'Getopt',
23 is => 'ro',
24 isa => 'Int',
25 default => sub { 1 },
26 cmd_aliases => 'n',
27 );
28}
29
30@ARGV = ();
31
32{
33 my $foo = Engine::Foo->new_with_options(nproc => 10);
34 isa_ok($foo, 'Engine::Foo');
35
36 is($foo->nproc, 10, '... got the right value (10), not the default (1)');
37}
38
39{
40 my $foo = Engine::Foo->new_with_options();
41 isa_ok($foo, 'Engine::Foo');
42
43 is($foo->nproc, 1, '... got the right value (1), without GLD needing to handle defaults');
44}
45
46
47