SYN SYN
[p5sagit/p5-mst-13.2.git] / t / op / int.t
CommitLineData
8d063cd8 1#!./perl
2
146174a9 3BEGIN {
4 chdir 't' if -d 't';
22d4bb9c 5 @INC = '../lib';
146174a9 6}
8d063cd8 7
22d4bb9c 8print "1..7\n";
8d063cd8 9
10# compile time evaluation
11
12if (int(1.234) == 1) {print "ok 1\n";} else {print "not ok 1\n";}
13
14if (int(-1.234) == -1) {print "ok 2\n";} else {print "not ok 2\n";}
15
16# run time evaluation
17
18$x = 1.234;
19if (int($x) == 1) {print "ok 3\n";} else {print "not ok 3\n";}
20if (int(-$x) == -1) {print "ok 4\n";} else {print "not ok 4\n";}
146174a9 21
22$x = length("abc") % -10;
23print $x == -7 ? "ok 5\n" : "# expected -7, got $x\nnot ok 5\n";
24
25{
26 use integer;
27 $x = length("abc") % -10;
28 $y = (3/-10)*-10;
29 print $x+$y == 3 && abs($x) < 10 ? "ok 6\n" : "not ok 6\n";
30}
22d4bb9c 31
32# check bad strings still get converted
33
34@x = ( 6, 8, 10);
35print "not " if $x["1foo"] != 8;
36print "ok 7\n";