6
6
chdir ' t' if -d ' t' ;
7
7
require " ./test.pl" ;
8
8
set_up_inc( qw( . ../lib) );
9
- require ' ./charset_tools.pl' ;
9
+ require ' ./charset_tools.pl' ;
10
10
}
11
11
12
12
use warnings;
@@ -22,7 +22,8 @@ while ($?) {
22
22
label1:
23
23
$foo = 2;
24
24
goto label2;
25
- } continue {
25
+ }
26
+ continue {
26
27
$foo = 0;
27
28
goto label4;
28
29
label3:
@@ -67,20 +68,20 @@ my $count = 0;
67
68
my $cond = 1;
68
69
for (1) {
69
70
if ($cond == 1) {
70
- $cond = 0;
71
- goto OTHER;
71
+ $cond = 0;
72
+ goto OTHER;
72
73
}
73
74
elsif ($cond == 0) {
74
75
OTHER:
75
- $cond = 2;
76
- is($count , 0, ' OTHER' );
77
- $count ++;
78
- goto THIRD;
76
+ $cond = 2;
77
+ is($count , 0, ' OTHER' );
78
+ $count ++;
79
+ goto THIRD;
79
80
}
80
81
else {
81
- THIRD:
82
- is($count , 1, ' THIRD' );
83
- $count ++;
82
+ THIRD:
83
+ is($count , 1, ' THIRD' );
84
+ $count ++;
84
85
}
85
86
}
86
87
is($count , 2, ' end of loop' );
@@ -89,9 +90,9 @@ is($count, 2, 'end of loop');
89
90
# (BUG ID 20010309.004 (#5998))
90
91
91
92
for (my $i =0;!$i ++;) {
92
- my $x =1;
93
- goto label;
94
- label: is($x , 1, ' goto inside a for(;;) loop body from inside the body' );
93
+ my $x =1;
94
+ goto label;
95
+ label: is($x , 1, ' goto inside a for(;;) loop body from inside the body' );
95
96
}
96
97
97
98
# Does goto work correctly going *to* a for(;;) loop?
@@ -100,55 +101,57 @@ for(my $i=0;!$i++;) {
100
101
my ($z , $y ) = (0);
101
102
FORL1: for ($y =1; $z ;) {
102
103
ok($y , ' goto a for(;;) loop, from outside (does initializer)' );
103
- goto TEST19}
104
+ goto TEST19
105
+ }
104
106
($y ,$z ) = (0, 1);
105
107
goto FORL1;
106
108
107
109
# Even from within the loop?
108
110
TEST19: $z = 0;
109
111
FORL2: for ($y =1; 1;) {
110
- if ($z ) {
111
- ok($y , ' goto a for(;;) loop, from inside (does initializer)' );
112
- last ;
113
- }
114
- ($y , $z ) = (0, 1);
115
- goto FORL2;
112
+ if ($z ) {
113
+ ok($y , ' goto a for(;;) loop, from inside (does initializer)' );
114
+ last ;
115
+ }
116
+ ($y , $z ) = (0, 1);
117
+ goto FORL2;
116
118
}
117
119
118
120
# Does goto work correctly within a try block?
119
121
# (BUG ID 20000313.004) - [perl #2359]
120
122
my $ok = 0;
121
123
eval {
122
- my $variable = 1;
123
- goto LABEL20;
124
- LABEL20: $ok = 1 if $variable ;
124
+ my $variable = 1;
125
+ goto LABEL20;
126
+ LABEL20: $ok = 1 if $variable ;
125
127
};
126
128
ok($ok , ' works correctly within a try block' );
127
129
is($@ , " " , ' ...and $@ not set' );
128
130
129
131
# And within an eval-string?
130
132
$ok = 0;
131
133
eval q{
132
- my $variable = 1;
133
- goto LABEL21;
134
- LABEL21: $ok = 1 if $variable;
134
+ my $variable = 1;
135
+ goto LABEL21;
136
+ LABEL21: $ok = 1 if $variable;
135
137
} ;
136
138
ok($ok , ' works correctly within an eval string' );
137
139
is($@ , " " , ' ...and $@ still not set' );
138
140
139
141
140
142
# Test that goto works in nested eval-string
141
143
$ok = 0;
142
- {eval q{
143
- eval q{
144
- goto LABEL22;
145
- };
146
- $ok = 0;
147
- last;
148
-
149
- LABEL22: $ok = 1;
150
- } ;
151
- $ok = 0 if $@ ;
144
+ {
145
+ eval q{
146
+ eval q{
147
+ goto LABEL22;
148
+ };
149
+ $ok = 0;
150
+ last;
151
+
152
+ LABEL22: $ok = 1;
153
+ } ;
154
+ $ok = 0 if $@ ;
152
155
}
153
156
ok($ok , ' works correctly in a nested eval string' );
154
157
@@ -169,7 +172,7 @@ ok($ok, 'works correctly in a nested eval string');
169
172
170
173
$ok = 0;
171
174
sub a {
172
- A: { if ($false ) { redo A; B: $ok = 1; redo A; } }
175
+ A: { if ($false ) { redo A; B: $ok = 1; redo A; } }
173
176
}
174
177
a();
175
178
@@ -244,22 +247,22 @@ sub DEBUG_TIME() {
244
247
my $out = " " ;
245
248
$out .= ' perl rules' ;
246
249
goto no_list;
247
- no_list:
248
- is($out , ' perl rules' , ' $out has not been erroneously reset to undef' );
250
+ no_list:
251
+ is($out , ' perl rules' , ' $out has not been erroneously reset to undef' );
249
252
};
250
253
}
251
254
252
255
{
253
256
my $r = runperl(
254
- stderr => 1,
255
- prog =>
257
+ stderr => 1,
258
+ prog =>
256
259
' for ($_=0;$_<3;$_++){A: if($_==1){next} if($_==2){$_++;goto A}}print qq(ok\n)'
257
260
);
258
261
is($r , " ok\n " , ' next and goto' );
259
262
260
263
$r = runperl(
261
- stderr => 1,
262
- prog =>
264
+ stderr => 1,
265
+ prog =>
263
266
' for ($_=0;$_<3;$_++){A: if($_==1){$_++;redo} if($_==2){$_++;goto A}}print qq(ok\n)'
264
267
);
265
268
is($r , " ok\n " , ' redo and goto' );
@@ -327,9 +330,11 @@ if($foo eq $foo) {
327
330
}
328
331
$foo .= " [9]" ;
329
332
bulgaria:
333
+
330
334
package Tomsk ;
331
335
$foo .= " [1:" .__PACKAGE__ ." ]" ;
332
336
$foo .= " [2:" .__PACKAGE__ ." ]" ;
337
+
333
338
package main ;
334
339
$foo .= " [3:" .__PACKAGE__ ." ]" ;
335
340
is($foo , " [0:main][1:Tomsk][2:Tomsk][3:main]" , " label before package decl" );
@@ -339,6 +344,7 @@ if($foo eq $foo) {
339
344
goto adelaide;
340
345
}
341
346
$foo .= " [Z]" ;
347
+
342
348
adelaide:
343
349
package Cairngorm {
344
350
$foo .= " [B:" .__PACKAGE__ ." ]" ;
@@ -435,37 +441,37 @@ eval { goto "\0" };
435
441
like $@ , qr / ^Can't find label \0 at / , ' goto "\0"' ;
436
442
437
443
TODO: {
438
- local $: :TODO = ' RT #45091: goto in CORE::GLOBAL::exit unsupported' ;
439
- fresh_perl_is(<<'EOC' , " before\n die handler\n " , {stderr => 1}, ' RT #45091: goto in CORE::GLOBAL::EXIT' );
440
- BEGIN {
444
+ local $: :TODO = ' RT #45091: goto in CORE::GLOBAL::exit unsupported' ;
445
+ fresh_perl_is(<<'EOC' , " before\n die handler\n " , {stderr => 1}, ' RT #45091: goto in CORE::GLOBAL::EXIT' );
446
+ BEGIN {
441
447
*CORE::GLOBAL::exit = sub {
442
- goto FASTCGI_NEXT_REQUEST;
448
+ goto FASTCGI_NEXT_REQUEST;
443
449
};
444
- }
445
- while (1) {
450
+ }
451
+ while (1) {
446
452
eval { that_cgi_script() };
447
453
FASTCGI_NEXT_REQUEST:
448
454
last;
449
- }
450
-
451
- sub that_cgi_script {
455
+ }
456
+
457
+ sub that_cgi_script {
452
458
local $SIG{__DIE__} = sub { print "die handler\n"; exit; print "exit failed?\n"; };
453
459
print "before\n";
454
460
eval { buggy_code() };
455
461
print "after\n";
456
- }
457
- sub buggy_code {
462
+ }
463
+ sub buggy_code {
458
464
die "error!";
459
465
print "after die\n";
460
- }
466
+ }
461
467
EOC
462
468
}
463
469
464
470
sub revnumcmp ($$) {
465
- goto FOO;
466
- die ;
467
- FOO:
468
- return $_ [1] <=> $_ [0];
471
+ goto FOO;
472
+ die ;
473
+ FOO:
474
+ return $_ [1] <=> $_ [0];
469
475
}
470
476
is eval { join (" :" , sort revnumcmp (9,5,1,3,7)) }, " 9:7:5:3:1" ,
471
477
" can goto at top level of multicalled sub" ;
0 commit comments