This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Cleanup utf8_heavy; allow dropping the In prefix from
[perl5.git] / lib / integer.t
CommitLineData
4d0ed6f7
JH
1use integer;
2
3use Test::More tests => 11;
4use Config;
5
6my $x = 4.5;
7my $y = 5.6;
8my $z;
9
10$z = $x + $y;
11is($z, 9, "plus");
12
13$z = $x - $y;
14is($z, -1, "minus");
15
16$z = $x * $y;
17is($z, 20, "times");
18
19$z = $x / $y;
20is($z, 0, "divide");
21
22$z = $x / $y;
23is($z, 0, "modulo");
24
25is($x, 4.5, "scalar still floating point");
26
27isnt(sqrt($x), 2, "functions still floating point");
28
29isnt($x ** .5, 2, "power still floating point");
30
31is(++$x, 5.5, "++ still floating point");
32
33SKIP: {
34 my $ivsize = $Config{ivsize};
35 skip "ivsize == $ivsize", 2 unless $ivsize == 4 || $ivsize == 8;
36
37 if ($ivsize == 4) {
38 $z = 2**31 - 1;
39 is($z + 1, -2147483648, "left shift");
40 } elsif ($ivsize == 8) {
41 $z = 2**63 - 1;
42 is($z + 1, -9223372036854775808, "left shift");
43 }
44}
45
05f18d1e 46is(~0, -1, "signed instead of unsigned");