From 90baa2991ada3a9b53f8b21b7e4a1991dd55cdc6 Mon Sep 17 00:00:00 2001 From: doy Date: Sat, 6 Dec 2008 18:40:33 -0500 Subject: more tests --- t/001-basic-matching.t | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 t/001-basic-matching.t (limited to 't') 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'); -- cgit v1.2.3-54-g00ecf