summaryrefslogtreecommitdiffstats
path: root/t/002-complicated-matching.t
blob: 1c0a7b923dd70d1fd6e450972ca6187a11d2ae74 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More tests => 5;

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 => [qr/o/, sub { length(shift) == 4 }]),
   'arrayref matching works');
ok($foo->match(a => [qr/b/, sub { length(shift) == 3 }]),
   'arrayref matching works');
ok(!$foo->match(a => [qr/b/, sub { length(shift) == 4 }]),
   'arrayref matching works');
ok($foo->match('!a' => 'bar', b => 'bar', '!c' => 'bar'),
   'negated matching works');
ok(!$foo->match(a => 'foo', '!b' => 'bar'),
   'negated matching works');