summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordoy <doy@tozt.net>2009-01-12 23:16:49 -0500
committerdoy <doy@tozt.net>2009-01-12 23:16:49 -0500
commit4f097a307b0e9810e0847286e9711ab4cb6f7ad9 (patch)
treea08ea572fbc12762e33a2e2b70c67bd64be37214
parent3f1a3a0dc5b15d4b038a3075a8df50fda36b0dea (diff)
downloadmoosex-role-matcher-4f097a307b0e9810e0847286e9711ab4cb6f7ad9.tar.gz
moosex-role-matcher-4f097a307b0e9810e0847286e9711ab4cb6f7ad9.zip
a few more tests
-rw-r--r--t/004-submatching.t22
1 files changed, 19 insertions, 3 deletions
diff --git a/t/004-submatching.t b/t/004-submatching.t
index d3bb116..3eb2b96 100644
--- a/t/004-submatching.t
+++ b/t/004-submatching.t
@@ -1,7 +1,7 @@
#!/usr/bin/env perl
use strict;
use warnings;
-use Test::More tests => 9;
+use Test::More tests => 11;
package Bar;
use Moose;
@@ -21,6 +21,9 @@ has [qw/a b c/] => (
required => 1,
);
+package Quux;
+use Moose;
+
package Foo;
use Moose;
with 'MooseX::Role::Matcher';
@@ -74,8 +77,9 @@ package main;
'simple submatching works');
}
{
+ my $quux = Quux->new;
my $bar = Bar->new(a => 4, b => 5, c => 6);
- my $baz = Baz->new(a => $bar, b => 'quux', c => 'cribbage');
+ my $baz = Baz->new(a => $bar, b => $quux, c => 'cribbage');
my $foo = Foo->new(a => 3.14, b => 2.72, c => 1.61,
bar => $bar, baz => $baz);
ok($foo->match(a => 3.14,
@@ -83,7 +87,7 @@ package main;
a => 4,
},
baz => {
- b => sub { length == 4 },
+ c => sub { length == 8 },
a => {
b => 5,
c => qr/\d/,
@@ -102,6 +106,18 @@ package main;
},
}),
'deeper submatching works');
+ ok($foo->match(baz => {
+ '!b' => {
+ c => 1,
+ },
+ }),
+ 'deeper submatching works');
+ ok($foo->match(baz => {
+ '!c' => {
+ b => 1,
+ },
+ }),
+ 'deeper submatching works');
}
{
my $bar = Bar->new(a => 7, b => 'tmp', c => 9);