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