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