switch to Test::Exception, add failing test for MooseX::Method::Signatures
[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;
6use Test::Exception;
7
8eval { require MooseX::Method::Signatures };
9plan skip_all => "No MooseX::Method::Signatures" if $@;
10
11plan tests => 2;
12
13{
14 package MyClass;
15 use Moose;
16 use MooseX::Method::Signatures;
17 use MooseX::AlwaysCoerce;
18 use Moose::Util::TypeConstraints;
19
20 BEGIN {
21 subtype 'MyType', as 'Int';
22 coerce 'MyType', from 'Str', via { length $_ };
23
24 subtype 'Uncoerced', as 'Int';
25 }
26
27 method foo (MyType :$foo, Uncoerced :$bar) {
28 return "$foo $bar";
29 }
30}
31
32ok( (my $instance = MyClass->new), 'instance' );
33
34lives_and {
35 is $instance->foo(foo => "text", bar => 42), '4 42';
36} 'method called with coerced and uncoerced parameters';