35 my $expect = ":" . join(":", @expect);
37 fresh_perl_is(<<'SCRIPT', $expect,{switches => [''], stdin => '', stderr => 1 },'Order of execution of special blocks');
42 BEGIN {BEGIN {print ":b3"}; print ":b4"}
46 UNITCHECK {print ":u1"}
47 eval 'BEGIN {print ":b5"}';
48 eval 'UNITCHECK {print ":u2"}';
49 eval 'UNITCHECK {print ":u3"; UNITCHECK {print ":u4"}}';
50 "a" =~ /(?{UNITCHECK {print ":u5-c"};
51 CHECK {print ":c2-c"};
52 BEGIN {print ":b6-c"}})/x;
56 (?{UNITCHECK {print ":u5-r"};
57 CHECK {print ":c2-r"};
58 BEGIN {print ":b6-r"}})/
62 eval {BEGIN {print ":b7"}};
63 eval {UNITCHECK {print ":u6"}};
64 eval {INIT {print ":i2"}};
65 eval {CHECK {print ":c3"}};
71 qw( main bar myfoo foo ),
73 qw( foo myfoo bar main ),
75 qw( foo myfoo bar main ),
77 qw( main bar myfoo foo ),
79 qw(foo myfoo bar main ));
81 $expect = ":" . join(":", @expect);
82 fresh_perl_is(<<'SCRIPT2', $expect,{switches => [''], stdin => '', stderr => 1 },'blocks interact with packages/scopes');
83 BEGIN {$f = 'main'; print ":$f"}
84 UNITCHECK {print ":$f"}
89 BEGIN {$f = 'bar';print ":$f"}
90 UNITCHECK {print ":$f"}
97 BEGIN {$f = 'myfoo'; print ":$f"}
98 UNITCHECK {print ":$f"}
103 BEGIN {$f = "foo";print ":$f"}
104 UNITCHECK {print ":$f"}
110 @expect = qw(begin unitcheck check init end);
111 $expect = ":" . join(":", @expect);
112 fresh_perl_is(<<'SCRIPT3', $expect,{switches => [''], stdin => '', stderr => 1 },'can name blocks as sub FOO');
113 sub BEGIN {print ":begin"}
114 sub UNITCHECK {print ":unitcheck"}
115 sub CHECK {print ":check"}
116 sub INIT {print ":init"}
117 sub END {print ":end"}
120 fresh_perl_is(<<'SCRIPT70614', "still here",{switches => [''], stdin => '', stderr => 1 },'eval-UNITCHECK-eval (bug 70614)');
121 eval "UNITCHECK { eval 0 }"; print "still here";
124 # [perl #78634] Make sure block names can be used as constants.
125 use constant INIT => 5;
126 ::is INIT, 5, 'constant named after a special block';
128 # [perl #108794] context
129 fresh_perl_is(<<'SCRIPT3', <<expEct,{stderr => 1 },'context');
131 print qw[void scalar list][wantarray + defined wantarray], "\n"
146 fresh_perl_is('END { print "ok\n" } INIT { bless {} and exit }', "ok\n",
147 {}, 'null PL_curcop in newGP');
149 fresh_perl_is('BEGIN{exit 0}; print "still here"', '', {}, 'RT #2754: BEGIN{exit 0} should exit');
151 local $TODO = 'RT #2754: CHECK{exit 0} is broken';
152 fresh_perl_is('CHECK{exit 0}; print "still here"', '', {}, 'RT #2754: CHECK{exit 0} should exit');
156 local $TODO = 'RT #2917: INIT{} in eval is wrongly considered too late';
157 fresh_perl_is('eval "INIT { print qq(in init); };";', 'in init', {}, 'RT #2917: No constraint on how late INIT blocks can run');
160 fresh_perl_is('eval "BEGIN {goto end}"; end:', '', {}, 'RT #113934: goto out of BEGIN causes assertion failure');