fix accidental C modulo semantics on integer-valued operations
[p5sagit/p5-mst-13.2.git] / t / op / int.t
1 #!./perl
2
3 print "1..6\n";
4
5 # compile time evaluation
6
7 if (int(1.234) == 1) {print "ok 1\n";} else {print "not ok 1\n";}
8
9 if (int(-1.234) == -1) {print "ok 2\n";} else {print "not ok 2\n";}
10
11 # run time evaluation
12
13 $x = 1.234;
14 if (int($x) == 1) {print "ok 3\n";} else {print "not ok 3\n";}
15 if (int(-$x) == -1) {print "ok 4\n";} else {print "not ok 4\n";}
16
17 $x = length("abc") % -10;
18 print $x == -7 ? "ok 5\n" : "# expected -7, got $x\nnot ok 5\n";
19
20 {
21     use integer;
22     $x = length("abc") % -10;
23     print $x == 3 ? "ok 6\n" : "# expected 3, got $x\nnot ok 6\n";
24 }