Commit | Line | Data |
630657d5 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More; |
7 | use Test::Exception; |
8 | |
9 | BEGIN { |
10 | eval 'use Getopt::Long::Descriptive;'; |
11 | plan skip_all => "Getopt::Long::Descriptive required for this test" if $@; |
12 | plan tests => 5; |
13 | use_ok('MooseX::Getopt'); |
14 | } |
15 | |
16 | { |
17 | package Engine::Foo; |
18 | use Moose; |
19 | |
20 | with 'MooseX::Getopt'; |
21 | |
22 | has 'nproc' => ( |
23 | metaclass => 'Getopt', |
24 | is => 'ro', |
25 | isa => 'Int', |
26 | default => sub { 1 }, |
27 | cmd_aliases => 'n', |
28 | ); |
29 | } |
30 | |
31 | @ARGV = (); |
32 | |
33 | { |
34 | my $foo = Engine::Foo->new_with_options(nproc => 10); |
35 | isa_ok($foo, 'Engine::Foo'); |
36 | |
37 | is($foo->nproc, 10, '... got the right value (10), not the default (1)'); |
38 | } |
39 | |
40 | { |
41 | my $foo = Engine::Foo->new_with_options(); |
42 | isa_ok($foo, 'Engine::Foo'); |
43 | |
44 | is($foo->nproc, 1, '... got the right value (1), without GLD needing to handle defaults'); |
45 | } |
46 | |
47 | |
48 | |