File: role.t

package info (click to toggle)
libmoosex-multimethods-perl 0.10-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 148 kB
  • sloc: perl: 179; makefile: 7
file content (28 lines) | stat: -rw-r--r-- 472 bytes parent folder | download | duplicates (3)
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
28
use strict;
use warnings;
use Test::More tests => 3;

{
    package MyRole;
    use Moose::Role;
    use MooseX::MultiMethods;

    multi method foo (Int $x) { 'Int' }
    multi method foo (Str $x) { 'Str' }
}
{
    package MyClass;
    use Moose;
    with 'MyRole';
}

use Test::Exception;

my $obj = MyClass->new;
is $obj->foo(1),       'Int';
is $obj->foo('Hello'), 'Str';
throws_ok {
    is $obj->foo([]),      'Array';
} qr/no variant of method 'foo' found for/;

1;