diff options
author | Nicholas Clark <nick@ccl4.org> | 2006-03-27 20:31:52 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2006-03-27 20:31:52 +0000 |
commit | a5871da3a494d85e46d501e1e38f3d4b9d0f0c01 (patch) | |
tree | ec35670356bcdaec34dff8d2a8816f38fdc79905 /t | |
parent | b7f7fd0bbdc7d1d714e682f9a3250ab7d97ac560 (diff) | |
download | perl-a5871da3a494d85e46d501e1e38f3d4b9d0f0c01.tar.gz |
It helps to actually add the files you add to MANIFEST. (Thanks Dave
for spotting my mistake).
p4raw-id: //depot/perl@27616
Diffstat (limited to 't')
-rw-r--r-- | t/comp/fold.t | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/t/comp/fold.t b/t/comp/fold.t new file mode 100644 index 0000000000..f063c20622 --- /dev/null +++ b/t/comp/fold.t @@ -0,0 +1,38 @@ +#!./perl + +BEGIN { + chdir 't'; + @INC = '../lib'; + require './test.pl'; +} +use strict; +use warnings; + +plan (8); + +# Historically constant folding was performed by evaluating the ops, and if +# they threw an exception compilation failed. This was seen as buggy, because +# even illegal constants in unreachable code would cause failure. So now +# illegal expressions are reported at runtime, if the expression is reached, +# making constant folding consistent with many other languages, and purely an +# optimisation rather than a behaviour change. + +my $a; +$a = eval '$b = 0/0 if 0; 3'; +is ($a, 3); +is ($@, ""); + +my $b = 0; +$a = eval 'if ($b) {return sqrt -3} 3'; +is ($a, 3); +is ($@, ""); + +$a = eval q{ + $b = eval q{if ($b) {return log 0} 4}; + is ($b, 4); + is ($@, ""); + 5; +}; +is ($a, 5); +is ($@, ""); + |