From: Tomas Doran (t0m) Date: Fri, 23 Oct 2009 16:37:33 +0000 (+0100) Subject: Fix bug when handling upper/mixedcase accessors X-Git-Tag: 0.24~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7b56639430ec14029d6b52455e75f90cf6e9f016;p=gitmo%2FMooseX-Getopt.git Fix bug when handling upper/mixedcase accessors --- diff --git a/lib/MooseX/Getopt.pm b/lib/MooseX/Getopt.pm index ae791c0..055eee3 100644 --- a/lib/MooseX/Getopt.pm +++ b/lib/MooseX/Getopt.pm @@ -133,7 +133,7 @@ sub _traditional_spec { foreach my $opt ( @{ $params{options} } ) { push @options, $opt->{opt_string}; - my $identifier = $opt->{name}; + my $identifier = lc($opt->{name}); $identifier =~ s/\W/_/g; # Getopt::Long does this to all option names $name_to_init_arg{$identifier} = $opt->{init_arg}; @@ -165,7 +165,7 @@ sub _gld_spec { }, ]; - my $identifier = $opt->{name}; + my $identifier = lc($opt->{name}); $identifier =~ s/\W/_/g; # Getopt::Long does this to all option names $name_to_init_arg{$identifier} = $opt->{init_arg}; diff --git a/t/103_uc_bug.t b/t/103_uc_bug.t new file mode 100644 index 0000000..79f5598 --- /dev/null +++ b/t/103_uc_bug.t @@ -0,0 +1,31 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More tests => 3; + +{ + package App; + use Moose; + with qw(MooseX::Getopt); + + has 'TrackingNumber' => ( + is => 'rw', + isa => 'Str', + ); + + has 'otherparam' => ( + is => 'rw', + isa => 'Str', + ); +} + +{ + local @ARGV = ('--TrackingNumber','1Z1234567812345670','--otherparam','foo'); + + my $app = App->new_with_options; + isa_ok($app, 'App'); + is($app->TrackingNumber, '1Z1234567812345670', '... TrackingNumber is as expected'); + is($app->otherparam, 'foo', '... otherparam is as expected'); +}