From ae0a06d98d138ccd92d6263c8626d4e03bc129c9 Mon Sep 17 00:00:00 2001 From: doy Date: Sat, 6 Dec 2008 20:24:32 -0500 Subject: add another test for the collection matches --- t/100-collection.t | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 t/100-collection.t (limited to 't') 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'); -- cgit v1.2.3-54-g00ecf