Commit | Line | Data |
88587957 |
1 | #!./perl |
2 | |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
5 | @INC = '../lib'; |
6 | } |
7 | |
4d0ed6f7 |
8 | use integer; |
9 | |
10 | use Test::More tests => 11; |
11 | use Config; |
12 | |
13 | my $x = 4.5; |
14 | my $y = 5.6; |
15 | my $z; |
16 | |
17 | $z = $x + $y; |
18 | is($z, 9, "plus"); |
19 | |
20 | $z = $x - $y; |
21 | is($z, -1, "minus"); |
22 | |
23 | $z = $x * $y; |
24 | is($z, 20, "times"); |
25 | |
26 | $z = $x / $y; |
27 | is($z, 0, "divide"); |
28 | |
29 | $z = $x / $y; |
30 | is($z, 0, "modulo"); |
31 | |
32 | is($x, 4.5, "scalar still floating point"); |
33 | |
34 | isnt(sqrt($x), 2, "functions still floating point"); |
35 | |
36 | isnt($x ** .5, 2, "power still floating point"); |
37 | |
38 | is(++$x, 5.5, "++ still floating point"); |
39 | |
40 | SKIP: { |
41 | my $ivsize = $Config{ivsize}; |
42 | skip "ivsize == $ivsize", 2 unless $ivsize == 4 || $ivsize == 8; |
43 | |
44 | if ($ivsize == 4) { |
45 | $z = 2**31 - 1; |
46 | is($z + 1, -2147483648, "left shift"); |
47 | } elsif ($ivsize == 8) { |
48 | $z = 2**63 - 1; |
49 | is($z + 1, -9223372036854775808, "left shift"); |
50 | } |
51 | } |
52 | |
05f18d1e |
53 | is(~0, -1, "signed instead of unsigned"); |