summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordoy <doy@tozt.net>2008-12-07 01:07:57 -0500
committerdoy <doy@tozt.net>2008-12-07 01:07:57 -0500
commitfc8ee5015443c4316945f2994a3fdcf97546e301 (patch)
treed61b5a6d7a6f679a8c0b4d862af662adbd7fd518
parent4d86e8c87c080f2a744559fa92cd5f0894637095 (diff)
downloadmoosex-role-matcher-fc8ee5015443c4316945f2994a3fdcf97546e301.tar.gz
moosex-role-matcher-fc8ee5015443c4316945f2994a3fdcf97546e301.zip
add default match parameter in match, not in _apply_to_matches
-rw-r--r--lib/MooseX/Role/Matcher.pm2
-rw-r--r--t/101-parameterized.t6
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');