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