emit warnings immediately
[gitmo/MooseX-AlwaysCoerce.git] / t / 02-mx-m-s.t
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4
5 use Test::More;
6
7 {
8     package MyClass;
9     use Moose;
10     use Test::Requires {
11         'MooseX::Method::Signatures' => 0.01,
12     };
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
28 use Test::Fatal;
29 use Test::NoWarnings 1.04 ':early';
30 plan tests => 4;
31
32 ok( (my $instance = MyClass->new), 'instance' );
33
34 TODO: {
35     local $TODO = 'need rafl to help with implementation';
36
37     is( exception {
38         is $instance->foo(foo => "text", bar => 42), '4 42';
39     }, undef, 'method called with coerced and uncoerced parameters' )
40         or todo_skip 'is() test never ran', 1;
41 }