This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
was Re: [PATCH] Shared hash keys
[perl5.git] / t / op / inc.t
CommitLineData
760ac839
LW
1#!./perl
2
9b0e499b 3print "1..12\n";
760ac839
LW
4
5# Verify that addition/subtraction properly upgrade to doubles.
1eb770ff
PP
6# These tests are only significant on machines with 32 bit longs,
7# and two's complement negation, but shouldn't fail anywhere.
760ac839
LW
8
9$a = 2147483647;
1eb770ff 10$c=$a++;
760ac839
LW
11if ($a == 2147483648)
12 {print "ok 1\n"}
13else
14 {print "not ok 1\n";}
15
16$a = 2147483647;
17$c=++$a;
18if ($a == 2147483648)
19 {print "ok 2\n"}
20else
21 {print "not ok 2\n";}
22
23$a = 2147483647;
24$a=$a+1;
25if ($a == 2147483648)
26 {print "ok 3\n"}
27else
28 {print "not ok 3\n";}
29
30$a = -2147483648;
31$c=$a--;
32if ($a == -2147483649)
33 {print "ok 4\n"}
34else
35 {print "not ok 4\n";}
36
37$a = -2147483648;
38$c=--$a;
39if ($a == -2147483649)
40 {print "ok 5\n"}
41else
42 {print "not ok 5\n";}
43
44$a = -2147483648;
45$a=$a-1;
46if ($a == -2147483649)
47 {print "ok 6\n"}
48else
49 {print "not ok 6\n";}
9b0e499b
GS
50
51$a = 2147483648;
52$a = -$a;
53$c=$a--;
54if ($a == -2147483649)
55 {print "ok 7\n"}
56else
57 {print "not ok 7\n";}
58
59$a = 2147483648;
60$a = -$a;
61$c=--$a;
62if ($a == -2147483649)
63 {print "ok 8\n"}
64else
65 {print "not ok 8\n";}
66
67$a = 2147483648;
68$a = -$a;
69$a=$a-1;
70if ($a == -2147483649)
71 {print "ok 9\n"}
72else
73 {print "not ok 9\n";}
74
75$a = 2147483648;
76$b = -$a;
77$c=$b--;
78if ($b == -$a-1)
79 {print "ok 10\n"}
80else
81 {print "not ok 10\n";}
82
83$a = 2147483648;
84$b = -$a;
85$c=--$b;
86if ($b == -$a-1)
87 {print "ok 11\n"}
88else
89 {print "not ok 11\n";}
90
91$a = 2147483648;
92$b = -$a;
93$b=$b-1;
94if ($b == -(++$a))
95 {print "ok 12\n"}
96else
97 {print "not ok 12\n";}