make all warnings fatal in tests
[gitmo/MooseX-Getopt.git] / t / 010_dashes.t
CommitLineData
5f78e881 1use strict;
aec09248 2use warnings FATAL => 'all';
5f78e881 3
9fbb5be9 4use Test::More tests => 8;
aabf4179 5use Test::Fatal;
9fbb5be9 6use Test::NoWarnings 1.04 ':early';
5f78e881 7
8
9BEGIN {
fe193b81 10 use_ok('MooseX::Getopt');
5f78e881 11}
12
13{
fe193b81 14 package App;
15 use Moose;
5f78e881 16
fe193b81 17 with 'MooseX::Getopt::Dashes';
5f78e881 18
fe193b81 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' ], );
5f78e881 21}
22
23{
fe193b81 24 local @ARGV = (qw/--some-thingy bar/);
aabf4179 25 ok ! exception { is( App->new_with_options->some_thingy, 'bar') }, 'Dash in option name';
5f78e881 26}
27
28{
fe193b81 29 local @ARGV = (qw/--some_thingy bar/);
aabf4179 30 like exception { App->new_with_options }, qr/Unknown option: some_thingy/;
ceeaabeb 31}
32
33{
fe193b81 34 local @ARGV = (qw/--another_thingy bar/);
aabf4179 35 ok ! exception { is( App->new_with_options->another_thingy, 'bar' ) }, 'Underscore in option name';
ceeaabeb 36}
37
38{
fe193b81 39 local @ARGV = (qw/--another-thingy bar/);
aabf4179 40 like exception { App->new_with_options }, qr/Unknown option: another-thingy/;
5f78e881 41}