Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / t / 900_mouse_bugs / 005_large_int.t
CommitLineData
0cfe08a4 1# See also http://rt.cpan.org/Public/Bug/Display.html?id=55048
bdef60b4 2use strict;
3use Test::More tests => 24;
1f1ccccd 4
bdef60b4 5{
6 package MyInteger;
7 use Mouse;
1f1ccccd 8
bdef60b4 9 has a_int => (
10 is => 'rw',
11 isa => 'Int',
12 );
1f1ccccd 13
bdef60b4 14 has a_num => (
15 is => 'rw',
16 isa => 'Num',
17 );
18}
1f1ccccd 19
0cfe08a4 20foreach my $i(2**32, 2**40, 2**46) {
21 for my $sig(1, -1) {
22 my $value = $i * $sig;
1f1ccccd 23
0cfe08a4 24 my $int = MyInteger->new( a_int => $value )->a_int;
25 cmp_ok($int, '==', $value, "Mouse groked the Int $i");
26
27
28 my $num = MyInteger->new( a_num => $value )->a_num;
29 cmp_ok($num, '==', $value, "Mouse groked the Num $i");
30
31 $value += 0.5;
32
33 eval { MyInteger->new( a_int => $value ) };
34 like $@, qr/does not pass the type constraint/, "Mouse does not regard $value as Int";
35 eval { MyInteger->new( a_num => $value ) };
36 is $@, '', "Mouse regards $value as Num";
37 }
1f1ccccd 38}
0cfe08a4 39