remove useless shebangs in tests
[gitmo/MooseX-Getopt.git] / t / 004_nogetop.t
CommitLineData
a01f08fb 1use strict;
2use warnings;
3
bff3807b 4use Test::More tests => 9;
7d634446 5use Test::Fatal 0.003;
a01f08fb 6
7BEGIN {
8 use_ok('MooseX::Getopt');
9}
10
11{
a01f08fb 12 package App;
13 use Moose;
14
15 with 'MooseX::Getopt';
16
17 has 'data' => (
0f8232b6 18 metaclass => 'Getopt',
a01f08fb 19 is => 'ro',
20 isa => 'Str',
21 default => 'file.dat',
22 cmd_flag => 'f',
23 );
24
25 has 'cow' => (
26 metaclass => 'Getopt',
27 is => 'ro',
28 isa => 'Str',
29 default => 'moo',
30 cmd_aliases => [qw/ moocow m c /],
31 );
32
33 has 'horse' => (
0f8232b6 34 metaclass => 'Getopt',
a01f08fb 35 is => 'ro',
36 isa => 'Str',
37 default => 'bray',
38 cmd_flag => 'horsey',
39 cmd_aliases => 'x',
40 );
41
42 has 'length' => (
43 is => 'ro',
44 isa => 'Int',
45 default => 24
46 );
47
48 has 'verbose' => (
49 is => 'ro',
50 isa => 'Bool',
51 );
52
53 has 'libs' => (
54 is => 'ro',
55 isa => 'ArrayRef',
56 default => sub { [] },
57 );
58
59 has 'details' => (
60 is => 'ro',
61 isa => 'HashRef',
62 default => sub { {} },
63 );
64
65 has 'private_stuff' => (
0f8232b6 66 metaclass => 'NoGetopt',
a01f08fb 67 is => 'ro',
68 isa => 'Int',
69 default => 713
70 );
71
72 has '_private_stuff_cmdline' => (
0f8232b6 73 metaclass => 'Getopt',
a01f08fb 74 is => 'ro',
75 isa => 'Int',
76 default => 832,
77 cmd_flag => 'p',
78 );
79
80}
81
82{
83 local @ARGV = ();
84
85 my $app = App->new_with_options;
86 isa_ok( $app, 'App' );
87
88 ok( !$app->verbose, '... verbosity is off as expected' );
89 is( $app->length, 24, '... length is 24 as expected' );
90 is( $app->data, 'file.dat', '... data is file.dat as expected' );
91 is_deeply( $app->libs, [], '... libs is [] as expected' );
92 is_deeply( $app->details, {}, '... details is {} as expected' );
93 is($app->private_stuff, 713, '... private stuff is 713 as expected');
94}
bff3807b 95
96{
97 local @ARGV = (qw/--private_stuff 317/);
98
aabf4179 99 like exception { App->new_with_options }, qr/Unknown option: private_stuff/;
bff3807b 100}