summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authordoy <doy@tozt.net>2008-12-06 18:40:33 -0500
committerdoy <doy@tozt.net>2008-12-06 18:40:33 -0500
commit90baa2991ada3a9b53f8b21b7e4a1991dd55cdc6 (patch)
treef7995e73ccbca241eba7e5c82ac7b0ce47fc97ea /t
parent713ef270e61f12d7134bf03f8419cdbe2bd5096e (diff)
downloadmoosex-role-matcher-90baa2991ada3a9b53f8b21b7e4a1991dd55cdc6.tar.gz
moosex-role-matcher-90baa2991ada3a9b53f8b21b7e4a1991dd55cdc6.zip
more tests
Diffstat (limited to 't')
-rw-r--r--t/001-basic-matching.t25
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');