File: 005_large_int.t

package info (click to toggle)
libmouse-perl 2.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,156 kB
  • sloc: perl: 14,569; ansic: 218; makefile: 8
file content (39 lines) | stat: -rw-r--r-- 910 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# See also http://rt.cpan.org/Public/Bug/Display.html?id=55048
use strict;
use Test::More tests => 24;

{
    package MyInteger;
    use Mouse;

    has a_int => (
        is => 'rw',
        isa => 'Int',
    );

    has a_num => (
        is => 'rw',
        isa => 'Num',
    );
}

foreach my $i(2**32, 2**40, 2**46) {
    for my $sig(1, -1) {
        my $value = $i * $sig;

        my $int = MyInteger->new( a_int => $value )->a_int;
        cmp_ok($int, '==', $value, "Mouse groked the Int $i");


        my $num = MyInteger->new( a_num => $value )->a_num;
        cmp_ok($num, '==', $value, "Mouse groked the Num $i");

        $value += 0.5;

        eval { MyInteger->new( a_int => $value ) };
        like $@, qr/does not pass the type constraint/, "Mouse does not regard $value as Int";
        eval { MyInteger->new( a_num => $value ) };
        is $@, '', "Mouse regards $value as Num";
    }
}