3 # Tests the scoping of $^H and %^H
11 BEGIN { print "1..17\n"; }
13 print "not " if exists $^H{foo};
14 print "ok 1 - \$^H{foo} doesn't exist initially\n";
16 print "not " unless $^H & 0x00020000;
17 print "ok 2 - \$^H contains HINT_LOCALIZE_HH initially with ${^OPEN}\n";
19 print "not " if $^H & 0x00020000;
20 print "ok 2 - \$^H doesn't contain HINT_LOCALIZE_HH initially\n";
24 # simulate a pragma -- don't forget HINT_LOCALIZE_HH
25 BEGIN { $^H |= 0x04020000; $^H{foo} = "a"; }
27 print "not " if $^H{foo} ne "a";
28 print "ok 3 - \$^H{foo} is now 'a'\n";
29 print "not " unless $^H & 0x00020000;
30 print "ok 4 - \$^H contains HINT_LOCALIZE_HH while compiling\n";
33 BEGIN { $^H |= 0x00020000; $^H{foo} = "b"; }
35 print "not " if $^H{foo} ne "b";
36 print "ok 5 - \$^H{foo} is now 'b'\n";
40 print "not " if $^H{foo} ne "a";
41 print "ok 6 - \$H^{foo} restored to 'a'\n";
43 # The pragma settings disappear after compilation
44 # (test at CHECK-time and at run-time)
46 print "not " if exists $^H{foo};
47 print "ok 9 - \$^H{foo} doesn't exist when compilation complete\n";
49 print "not " unless $^H & 0x00020000;
50 print "ok 10 - \$^H contains HINT_LOCALIZE_HH when compilation complete with ${^OPEN}\n";
52 print "not " if $^H & 0x00020000;
53 print "ok 10 - \$^H doesn't contain HINT_LOCALIZE_HH when compilation complete\n";
56 print "not " if exists $^H{foo};
57 print "ok 11 - \$^H{foo} doesn't exist at runtime\n";
59 print "not " unless $^H & 0x00020000;
60 print "ok 12 - \$^H contains HINT_LOCALIZE_HH at run-time with ${^OPEN}\n";
62 print "not " if $^H & 0x00020000;
63 print "ok 12 - \$^H doesn't contain HINT_LOCALIZE_HH at run-time\n";
65 # op_entereval should keep the pragmas it was compiled with
67 print "not " if $^H{foo} ne "a";
68 print "ok 13 - \$^H{foo} is 'a' at eval-\"\" time\n";
69 print "not " unless $^H & 0x00020000;
70 print "ok 14 - \$^H contains HINT_LOCALIZE_HH at eval\"\"-time\n";
74 print "not " if exists $^H{foo};
75 print "ok 7 - \$^H{foo} doesn't exist while finishing compilation\n";
77 print "not " unless $^H & 0x00020000;
78 print "ok 8 - \$^H contains HINT_LOCALIZE_HH while finishing compilation with ${^OPEN}\n";
80 print "not " if $^H & 0x00020000;
81 print "ok 8 - \$^H doesn't contain HINT_LOCALIZE_HH while finishing compilation\n";
87 # bug #27040: hints hash was being double-freed
89 prog => '$^H |= 0x20000; eval q{BEGIN { $^H |= 0x20000 }}',
92 print "not " if length $result;
93 print "ok 15 - double-freeing hints hash\n";
94 print "# got: $result\n" if length $result;
100 print $^H{x}==1 && !$^H{y} ? "ok\n" : "not ok\n";
104 (my $str = $@)=~s/^/# /gm;
105 print "not ok\n$str\n";