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