File: 009_gld_and_explicit_options.t

package info (click to toggle)
libmousex-getopt-perl 0.38-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 364 kB
  • sloc: perl: 1,550; makefile: 2
file content (49 lines) | stat: -rw-r--r-- 801 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/perl

use strict;
use warnings;

use Test::More;
use Test::Exception;

BEGIN {
    eval 'use Getopt::Long::Descriptive;';
    plan skip_all => "Getopt::Long::Descriptive required for this test" if $@;
    plan tests => 5;
    use_ok('MouseX::Getopt');
}

{
    package Testing::Foo;
    use Mouse;

    with 'MouseX::Getopt';

    has 'bar' => (
        is       => 'ro',
        isa      => 'Int',
        required => 1,
    );

    has 'baz' => (
        is       => 'ro',
        isa      => 'Int',
        required => 1,
    );
}

@ARGV = qw(--bar 10);

my $foo;
lives_ok {
    $foo = Testing::Foo->new_with_options(baz => 100);
} '... this should work';
isa_ok($foo, 'Testing::Foo');

is($foo->bar, 10, '... got the right values');
is($foo->baz, 100, '... got the right values');