Fix 'Int' type constraint for dualvars (like $!)
[gitmo/Mouse.git] / t / 001_mouse / 071_tc_dualvar.t
1 #!perl -w
2 use strict;
3 use Test::More;
4 use Errno qw(ENOENT EPERM);
5 {
6     package Foo;
7     use Mouse;
8     has intval => (
9         is  => 'rw',
10         isa => 'Int',
11     );
12     has numval => (
13         is  => 'rw',
14         isa => 'Num',
15     );
16 }
17
18 my $foo = Foo->new();
19
20 for my $e(ENOENT, EPERM) {
21     $! = $e;
22     eval { $foo->intval($!) };
23     like $@, qr/Validation failed for 'Int'/, 'Int for dualvar';
24
25     $! = $e;
26     eval { $foo->numval($!) };
27     like $@, qr/Validation failed for 'Num'/, 'Num for dualvar';
28 }
29 done_testing;
30