Commit | Line | Data |
df491f72 |
1 | #!/usr/bin/env perl |
2 | use strict; |
3 | use warnings; |
4 | |
5 | use Test::More; |
df491f72 |
6 | |
7f427a8a |
7 | BEGIN { |
8 | if (eval { require MooseX::Method::Signatures }) { |
0d42c8e8 |
9 | plan tests => 3; |
7f427a8a |
10 | } else { |
11 | plan skip_all => 'This test needs MooseX::Method::Signatures'; |
12 | } |
13 | } |
df491f72 |
14 | |
0d42c8e8 |
15 | use Test::Exception; |
16 | use Test::NoWarnings; |
17 | |
df491f72 |
18 | { |
19 | package MyClass; |
20 | use Moose; |
21 | use MooseX::Method::Signatures; |
22 | use MooseX::AlwaysCoerce; |
23 | use Moose::Util::TypeConstraints; |
24 | |
25 | BEGIN { |
26 | subtype 'MyType', as 'Int'; |
27 | coerce 'MyType', from 'Str', via { length $_ }; |
28 | |
29 | subtype 'Uncoerced', as 'Int'; |
30 | } |
31 | |
32 | method foo (MyType :$foo, Uncoerced :$bar) { |
33 | return "$foo $bar"; |
34 | } |
35 | } |
36 | |
37 | ok( (my $instance = MyClass->new), 'instance' ); |
38 | |
4239a8b1 |
39 | TODO: { |
40 | local $TODO = 'need rafl to help with implementation'; |
41 | |
42 | lives_and { |
43 | is $instance->foo(foo => "text", bar => 42), '4 42'; |
44 | } 'method called with coerced and uncoerced parameters'; |
45 | } |