Automatically set HINT_LOCALIZE_HH whenever %^H is modified.
[p5sagit/p5-mst-13.2.git] / t / comp / fold.t
CommitLineData
a5871da3 1#!./perl
2
3BEGIN {
4 chdir 't';
5 @INC = '../lib';
6 require './test.pl';
7}
8use strict;
9use warnings;
10
11plan (8);
12
13# Historically constant folding was performed by evaluating the ops, and if
14# they threw an exception compilation failed. This was seen as buggy, because
15# even illegal constants in unreachable code would cause failure. So now
16# illegal expressions are reported at runtime, if the expression is reached,
17# making constant folding consistent with many other languages, and purely an
18# optimisation rather than a behaviour change.
19
20my $a;
21$a = eval '$b = 0/0 if 0; 3';
22is ($a, 3);
23is ($@, "");
24
25my $b = 0;
26$a = eval 'if ($b) {return sqrt -3} 3';
27is ($a, 3);
28is ($@, "");
29
30$a = eval q{
31 $b = eval q{if ($b) {return log 0} 4};
32 is ($b, 4);
33 is ($@, "");
34 5;
35};
36is ($a, 5);
37is ($@, "");
38