Skip to content

Commit

Permalink
version 1.03
Browse files Browse the repository at this point in the history
  • Loading branch information
zostay authored and Chris White committed Feb 8, 2019
1 parent ecb0b3f commit ca69063
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ t/extra.t
t/method.t
t/oddoptional.t
t/optional.t
t/semifirst.t
t/sub.t
t/submethod.t
7 changes: 4 additions & 3 deletions Mixed.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ our @ISA = qw(Exporter);

our @EXPORT = qw( parameters );

our $VERSION = '1.02';
our $VERSION = '1.03';

=head1 NAME
Expand Down Expand Up @@ -183,11 +183,12 @@ sub parameters {
for (0 .. $#$spec) {
last if $$spec[$_] eq '*';
if ($$spec[$_] eq ';') {
splice(@$spec, $_);
splice(@$spec, $_, 1);

last;
} elsif ($$spec[$_] =~ /;/) {
my @els = split /;/, $$spec[$_];
shift @els if $els[0] eq '';

croak "Getopt::Mixed specification contains more than one semicolon."
if @els > 2;
Expand All @@ -206,7 +207,7 @@ sub parameters {

# Scan for positional parameters
while (@_ > 0) {
last if $_[0] =~ /^-/; # stop if named
last if defined $_[0] and $_[0] =~ /^-/; # stop if named
if ($$spec[0] eq '*') {
push @{$result{'*'}}, shift;
} else {
Expand Down
28 changes: 28 additions & 0 deletions t/semifirst.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# vim: set ft=perl :

use Test::More tests => 19;
BEGIN { use_ok('Getargs::Mixed'); }

sub foo {
my %args = parameters([ qw( ; x y z ) ], @_);

is($args{x}, 1);
is($args{y}, 2);
is($args{z}, 3);
}

sub bar {
my %args = parameters([ qw( ;x y z ) ], @_);

is($args{x}, 1);
is($args{y}, 2);
is($args{z}, 3);
}

foo(1, 2, 3);
foo(1, -y => 2, -z => 3);
foo(-x => 1, -z => 3, -y => 2);

bar(1, 2, 3);
bar(1, -y => 2, -z => 3);
bar(-x => 1, -z => 3, -y => 2);

0 comments on commit ca69063

Please sign in to comment.