summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authordoy <doy@tozt.net>2008-12-06 20:24:32 -0500
committerdoy <doy@tozt.net>2008-12-06 20:24:32 -0500
commitae0a06d98d138ccd92d6263c8626d4e03bc129c9 (patch)
treefb24f5519b2fc4211292afa578e4b3843602948c /t
parent7bb7288a5489b6264680a81d4c5ab31a0ceeea72 (diff)
downloadmoosex-role-matcher-ae0a06d98d138ccd92d6263c8626d4e03bc129c9.tar.gz
moosex-role-matcher-ae0a06d98d138ccd92d6263c8626d4e03bc129c9.zip
add another test for the collection matches
Diffstat (limited to 't')
-rw-r--r--t/100-collection.t44
1 files changed, 44 insertions, 0 deletions
diff --git a/t/100-collection.t b/t/100-collection.t
new file mode 100644
index 0000000..517babb
--- /dev/null
+++ b/t/100-collection.t
@@ -0,0 +1,44 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More tests => 1;
+
+package Foo;
+use Moose;
+with 'MooseX::Role::Matcher';
+
+has [qw/a b c/] => (
+ is => 'ro',
+ isa => 'Str',
+ required => 1,
+);
+
+package FooCollection;
+use Moose;
+
+has foos => (
+ is => 'rw',
+ isa => 'ArrayRef[Foo]',
+ default => sub { [] },
+);
+
+sub each_match {
+ my $self = shift;
+ Foo->each_match($self->foos, @_);
+}
+
+sub first_match {
+ my $self = shift;
+ Foo->first_match($self->foos, @_);
+}
+
+package main;
+my $foos = FooCollection->new;
+my $foo1 = Foo->new(a => 'foo', b => 'bar', c => 'baz');
+my $foo2 = Foo->new(a => '', b => '3', c => 'foobar');
+my $foo3 = Foo->new(a => 'blah', b => 'abc', c => 'foo');
+push @{ $foos->foos }, $foo1;
+push @{ $foos->foos }, $foo2;
+push @{ $foos->foos }, $foo3;
+is($foos->first_match(a => ''), $foo2,
+ 'first_match works');