summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authordoy <doy@tozt.net>2008-12-06 21:48:47 -0500
committerdoy <doy@tozt.net>2008-12-06 21:48:47 -0500
commit22dc974bf57926fb29ae2d75f014618b575e47a3 (patch)
tree5b5dc267d64fe5b3e4f421a5001050335a91ce15 /t
parentae0a06d98d138ccd92d6263c8626d4e03bc129c9 (diff)
downloadmoosex-role-matcher-22dc974bf57926fb29ae2d75f014618b575e47a3.tar.gz
moosex-role-matcher-22dc974bf57926fb29ae2d75f014618b575e47a3.zip
test the rest of the collection functions
Diffstat (limited to 't')
-rw-r--r--t/100-collection.t21
1 files changed, 20 insertions, 1 deletions
diff --git a/t/100-collection.t b/t/100-collection.t
index 517babb..68dcec1 100644
--- a/t/100-collection.t
+++ b/t/100-collection.t
@@ -1,7 +1,8 @@
#!/usr/bin/env perl
use strict;
use warnings;
-use Test::More tests => 1;
+use Test::More tests => 4;
+use Test::Deep;
package Foo;
use Moose;
@@ -32,6 +33,16 @@ sub first_match {
Foo->first_match($self->foos, @_);
}
+sub any_match {
+ my $self = shift;
+ Foo->any_match($self->foos, @_);
+}
+
+sub grep_matches {
+ my $self = shift;
+ Foo->grep_matches($self->foos, @_);
+}
+
package main;
my $foos = FooCollection->new;
my $foo1 = Foo->new(a => 'foo', b => 'bar', c => 'baz');
@@ -42,3 +53,11 @@ push @{ $foos->foos }, $foo2;
push @{ $foos->foos }, $foo3;
is($foos->first_match(a => ''), $foo2,
'first_match works');
+is($foos->any_match('!b' => qr/z/), (),
+ 'any_match works');
+is_deeply([shallow($foo2), shallow($foo3)], set($foos->grep_matches(c => qr/o/)),
+ 'grep_matches works');
+my @each;
+$foos->each_match(sub { push @each, $_ }, b => qr/a/);
+is_deeply([shallow($foo1), shallow($foo3)], set(@each),
+ 'each_match works');