diff options
-rw-r--r-- | lib/MooseX/Role/Matcher.pm | 2 | ||||
-rw-r--r-- | t/101-parameterized.t | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/lib/MooseX/Role/Matcher.pm b/lib/MooseX/Role/Matcher.pm index f2a01dd..7255607 100644 --- a/lib/MooseX/Role/Matcher.pm +++ b/lib/MooseX/Role/Matcher.pm @@ -74,7 +74,6 @@ method _apply_to_matches => sub { my $on_match = shift; my @list = @{ shift() }; my @matchers = @_; - unshift @matchers, $default if (@_ % 2 == 1); $on_match->(sub { $_->match(@matchers) }, @list); }; @@ -159,6 +158,7 @@ method _match => sub { method match => sub { my $self = shift; + unshift @_, $default if @_ % 2 == 1; my %args = @_; # All the conditions must be true for true to be returned. Return diff --git a/t/101-parameterized.t b/t/101-parameterized.t index 4b02fff..b76ae0f 100644 --- a/t/101-parameterized.t +++ b/t/101-parameterized.t @@ -1,7 +1,7 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 1; +use Test::More tests => 2; use Test::Deep; package Foo; @@ -52,4 +52,6 @@ push @{ $foos->foos }, $foo1; push @{ $foos->foos }, $foo2; push @{ $foos->foos }, $foo3; is($foos->first_match(sub { length() < 3 }), $foo2, - 'default parameter is passed correctly'); + 'default parameter is passed correctly to first_match'); +ok($foo1->match('foo'), + 'default parameter is passed correctly to match'); |