11 # compile time evaluation
13 my $test1_descr = 'compile time evaluation 1.234';
14 if (int(1.234) == 1) {pass($test1_descr)} else {fail($test1_descr)}
16 my $test2_descr = 'compile time evaluation -1.234';
17 if (int(-1.234) == -1) {pass($test2_descr)} else {fail($test2_descr)}
22 cmp_ok(int($x), '==', 1, 'run time evaluation 1');
23 cmp_ok(int(-$x), '==', -1, 'run time evaluation -1');
25 $x = length("abc") % -10;
26 cmp_ok($x, '==', -7, 'subtract from string length');
31 $x = length("abc") % -10;
33 ok($x+$y == 3, 'x+y equals 3') or ++$fail;
34 ok(abs($x) < 10, 'abs(x) < 10') or ++$fail;
36 diag("\$x == $x", "\$y == $y");
41 cmp_ok($x["1foo"], '==', 8, 'check bad strings still get converted');
43 # 4,294,967,295 is largest unsigned 32 bit integer
47 is($y, "4294967303", 'check values > 32 bits work');
51 is($y, "-4294967303", 'negative value more than maximum unsigned 32 bit value');
56 is($y, "4294967294", 'floating point value slightly less than the largest unsigned 32 bit');
61 is($y, "4294967295", 'floating point value slightly more than largest unsigned 32 bit');
63 $x = 4294967296.11312;
66 is($y, "4294967296", 'floating point value more than largest unsigned 32 bit');
68 $y = int(279964589018079/59);
69 cmp_ok($y, '==', 4745162525730, 'compile time division, result of about 42 bits');
73 cmp_ok($y, '==', 4745162525730, 'run time divison, result of about 42 bits');