diff options
author | doy <doy@tozt.net> | 2008-12-06 18:40:33 -0500 |
---|---|---|
committer | doy <doy@tozt.net> | 2008-12-06 18:40:33 -0500 |
commit | 90baa2991ada3a9b53f8b21b7e4a1991dd55cdc6 (patch) | |
tree | f7995e73ccbca241eba7e5c82ac7b0ce47fc97ea | |
parent | 713ef270e61f12d7134bf03f8419cdbe2bd5096e (diff) | |
download | moosex-role-matcher-90baa2991ada3a9b53f8b21b7e4a1991dd55cdc6.tar.gz moosex-role-matcher-90baa2991ada3a9b53f8b21b7e4a1991dd55cdc6.zip |
more tests
-rw-r--r-- | t/001-basic-matching.t | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/t/001-basic-matching.t b/t/001-basic-matching.t new file mode 100644 index 0000000..c9c589c --- /dev/null +++ b/t/001-basic-matching.t @@ -0,0 +1,25 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More tests => 4; + +package Foo; +use Moose; +with 'MooseX::Role::Matcher'; + +has [qw/a b c/] => ( + is => 'ro', + isa => 'Str', + required => 1, +); + +package main; +my $foo = Foo->new(a => 'foo', b => 'bar', c => 'baz'); +ok($foo->match(a => 'foo', b => 'bar', c => 'baz'), + 'string matching works'); +ok($foo->match(a => qr/o/), + 'regex matching works'); +ok($foo->match(b => sub { length(shift) == 3 }), + 'subroutine matching works'); +ok($foo->match(a => 'foo', b => qr/a/, c => sub { substr(shift, 2) eq 'z' }), + 'combined matching works'); |