Commit | Line | Data |
0cfe08a4 |
1 | # See also http://rt.cpan.org/Public/Bug/Display.html?id=55048 |
1f1ccccd |
2 | package MyInteger; |
3 | use Mouse; |
4 | |
5 | has a_int => ( |
6 | is => 'rw', |
7 | isa => 'Int', |
8 | ); |
9 | |
10 | has a_num => ( |
11 | is => 'rw', |
12 | isa => 'Num', |
13 | ); |
14 | |
15 | package main; |
0cfe08a4 |
16 | use Test::More tests => 24; |
1f1ccccd |
17 | |
0cfe08a4 |
18 | foreach 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 | |