add Test::NoWarnings; add (failing) tests for the use of MX::AlwaysCoerce from a...
[gitmo/MooseX-AlwaysCoerce.git] / t / 02-mx-m-s.t
CommitLineData
df491f72 1#!/usr/bin/env perl
2use strict;
3use warnings;
4
5use Test::More;
df491f72 6
7f427a8a 7BEGIN {
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 15use Test::Exception;
16use 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
37ok( (my $instance = MyClass->new), 'instance' );
38
4239a8b1 39TODO: {
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}