X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F010_dashes.t;h=68f9a34735c80225ea0e198d3a6f0a9905407e4a;hb=refs%2Ftags%2Fv0.56;hp=4ec12485e3ef18a02a59a5d37432355749a92eda;hpb=5f78e8817a86a1178b4880d40da6cc2027c78a7a;p=gitmo%2FMooseX-Getopt.git diff --git a/t/010_dashes.t b/t/010_dashes.t index 4ec1248..68f9a34 100644 --- a/t/010_dashes.t +++ b/t/010_dashes.t @@ -1,32 +1,41 @@ -#!/usr/bin/perl - use strict; -use warnings; - -use Test::More tests => 3; +use warnings FATAL => 'all'; -use Test::Exception; +use Test::More tests => 8; +use Test::Fatal; +use Test::NoWarnings 1.04 ':early'; BEGIN { - use_ok('MooseX::Getopt'); + use_ok('MooseX::Getopt'); } { - package App; - use Moose; + package App; + use Moose; - with 'MooseX::Getopt::Dashes'; + with 'MooseX::Getopt::Dashes'; - has 'some_thingy' => ( is => 'ro', isa => 'Str', default => 'foo' ); + has 'some_thingy' => ( is => 'ro', isa => 'Str', default => 'foo' ); + has 'another_thingy' => ( is => 'ro', isa => 'Str', default => 'foo', cmd_flag => 'another_thingy', traits => [ 'Getopt' ], ); } { - local @ARGV = (qw/--some-thingy bar/); - lives_and { is( App->new_with_options->some_thingy, 'bar') } 'Dash in option name'; + local @ARGV = (qw/--some-thingy bar/); + ok ! exception { is( App->new_with_options->some_thingy, 'bar') }, 'Dash in option name'; } { local @ARGV = (qw/--some_thingy bar/); - throws_ok { App->new_with_options } qr/Unknown option: some_thingy/; + like exception { App->new_with_options }, qr/Unknown option: some_thingy/; +} + +{ + local @ARGV = (qw/--another_thingy bar/); + ok ! exception { is( App->new_with_options->another_thingy, 'bar' ) }, 'Underscore in option name'; +} + +{ + local @ARGV = (qw/--another-thingy bar/); + like exception { App->new_with_options }, qr/Unknown option: another-thingy/; }