summaryrefslogtreecommitdiffstats
path: root/t/003-methods.t
blob: c4c0d5fc42a5638195fe091368a375dd66e3ebf7 (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
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More tests => 2;

package Foo;
use Moose;
with 'MooseX::Role::Matcher';

has [qw/a b c/] => (
    is       => 'ro',
    isa      => 'Str',
    required => 1,
);

sub concat {
    my $self = shift;
    return $self->a . $self->b . $self->c;
}

package main;
my $foo = Foo->new(a => 'foo', b => 'bar', c => 'baz');
ok($foo->match(concat => 'foobarbaz'),
   'match handles methods as well as attributes');
ok($foo->match(a => qr/o/, concat => sub { length(shift) > 6 }),
   'match handles methods as well as attributes');