From: Shlomi Fish Date: Thu, 10 Dec 2009 19:25:16 +0000 (+0200) Subject: Add t/106_no_ignore_case.t . X-Git-Tag: 0.26~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5c6054f94f9682c2dffe1d46c09ca665afce6391;p=gitmo%2FMooseX-Getopt.git Add t/106_no_ignore_case.t . --- diff --git a/ChangeLog b/ChangeLog index aa88f85..36e2cd6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,9 @@ Revision history for Perl extension MooseX-Getopt * MooseX::Getopt::Basic - Fix bug with attribute names containing upper case letters. + * Test suite: + - Add t/106_no_ignore_case.t for testing the compatibility with + no_ignore_case 0.25 Thu. Nov 26 2009 * MooseX::Getopt diff --git a/t/106_no_ignore_case.t b/t/106_no_ignore_case.t new file mode 100644 index 0000000..b8b6f11 --- /dev/null +++ b/t/106_no_ignore_case.t @@ -0,0 +1,57 @@ +use strict; +use warnings; +use Test::More; +use Moose (); +use Moose::Meta::Class; + +foreach my $role (qw/ + MooseX::Getopt + MooseX::Getopt::GLD + MooseX::Getopt::Basic +/) { + Class::MOP::load_class($role); + + my $meta = Moose::Meta::Class->create_anon_class( + superclasses => ['Moose::Object'], + ); + $meta->add_attribute('BigD', traits => ['Getopt'], isa => 'Bool', + cmd_aliases => ['D'], is => 'ro'); + $meta->add_attribute('SmallD', traits => ['Getopt'], isa => 'Bool', + cmd_aliases => ['d'], is => 'ro'); + $role->meta->apply($meta); + + { + my $obj = $meta->name->new_with_options( + { argv => ["-d"], no_ignore_case => 1} + ); + + ok((! $obj->BigD), "BigD was not set for argv -d on $role"); + ok($obj->SmallD, "SmallD was set for argv -d on $role"); + + } + ok($meta->name->new_with_options({ argv => ['-d'], no_ignore_case => 1}) + ->SmallD, + "SmallD was set for argv -d on $role"); + { + local @ARGV = ('-d'); + ok($meta->name->new_with_options()->SmallD, + "SmallD was set for ARGV on $role"); + } + + ok($meta->name->new_with_options({ argv => ['-D'], no_ignore_case => 1}) + ->BigD, + "BigD was set for argv -d on $role"); + + { + my $obj = $meta->name->new_with_options( + { argv => ['-D', "-d"], no_ignore_case => 1} + ); + + ok($obj->BigD, "BigD was set for argv -D -d on $role"); + ok($obj->SmallD, "SmallD was set for argv -D -d on $role"); + + } +} + +done_testing; +