use warnings tester with fewer dependencies, issues
[gitmo/MooseX-Getopt.git] / t / 010_dashes.t
1 use strict;
2 use warnings FATAL => 'all';
3
4 use Test::More tests => 8;
5 use Test::Fatal;
6 use Test::Warnings;
7
8
9 BEGIN {
10     use_ok('MooseX::Getopt');
11 }
12
13 {
14     package App;
15     use Moose;
16
17     with 'MooseX::Getopt::Dashes';
18
19     has 'some_thingy' => ( is => 'ro', isa => 'Str', default => 'foo' );
20     has 'another_thingy'   => ( is => 'ro', isa => 'Str', default => 'foo', cmd_flag => 'another_thingy', traits => [ 'Getopt' ], );
21 }
22
23 {
24     local @ARGV = (qw/--some-thingy bar/);
25     ok ! exception { is( App->new_with_options->some_thingy, 'bar') }, 'Dash in option name';
26 }
27
28 {
29     local @ARGV = (qw/--some_thingy bar/);
30     like exception { App->new_with_options }, qr/Unknown option: some_thingy/;
31 }
32
33 {
34     local @ARGV = (qw/--another_thingy bar/);
35     ok ! exception { is( App->new_with_options->another_thingy, 'bar' ) }, 'Underscore in option name';
36 }
37
38 {
39     local @ARGV = (qw/--another-thingy bar/);
40     like exception { App->new_with_options }, qr/Unknown option: another-thingy/;
41 }