Skip to content

Commit 028045f

Browse files
committed
Tidy indents and leading whitespace
Since we'll probably be doing a lot of work on this file, let's start by standardizing on 4 spaces for indents, uncuddling else's, etc.
1 parent b003602 commit 028045f

File tree

1 file changed

+66
-60
lines changed

1 file changed

+66
-60
lines changed

t/op/goto.t

Lines changed: 66 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ BEGIN {
66
chdir 't' if -d 't';
77
require "./test.pl";
88
set_up_inc( qw(. ../lib) );
9-
require './charset_tools.pl';
9+
require './charset_tools.pl';
1010
}
1111

1212
use warnings;
@@ -22,7 +22,8 @@ while ($?) {
2222
label1:
2323
$foo = 2;
2424
goto label2;
25-
} continue {
25+
}
26+
continue {
2627
$foo = 0;
2728
goto label4;
2829
label3:
@@ -67,20 +68,20 @@ my $count = 0;
6768
my $cond = 1;
6869
for (1) {
6970
if ($cond == 1) {
70-
$cond = 0;
71-
goto OTHER;
71+
$cond = 0;
72+
goto OTHER;
7273
}
7374
elsif ($cond == 0) {
7475
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;
7980
}
8081
else {
81-
THIRD:
82-
is($count, 1, 'THIRD');
83-
$count++;
82+
THIRD:
83+
is($count, 1, 'THIRD');
84+
$count++;
8485
}
8586
}
8687
is($count, 2, 'end of loop');
@@ -89,9 +90,9 @@ is($count, 2, 'end of loop');
8990
# (BUG ID 20010309.004 (#5998))
9091

9192
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');
9596
}
9697

9798
# Does goto work correctly going *to* a for(;;) loop?
@@ -100,55 +101,57 @@ for(my $i=0;!$i++;) {
100101
my ($z, $y) = (0);
101102
FORL1: for ($y=1; $z;) {
102103
ok($y, 'goto a for(;;) loop, from outside (does initializer)');
103-
goto TEST19}
104+
goto TEST19
105+
}
104106
($y,$z) = (0, 1);
105107
goto FORL1;
106108

107109
# Even from within the loop?
108110
TEST19: $z = 0;
109111
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;
116118
}
117119

118120
# Does goto work correctly within a try block?
119121
# (BUG ID 20000313.004) - [perl #2359]
120122
my $ok = 0;
121123
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;
125127
};
126128
ok($ok, 'works correctly within a try block');
127129
is($@, "", '...and $@ not set');
128130

129131
# And within an eval-string?
130132
$ok = 0;
131133
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;
135137
};
136138
ok($ok, 'works correctly within an eval string');
137139
is($@, "", '...and $@ still not set');
138140

139141

140142
# Test that goto works in nested eval-string
141143
$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 $@;
152155
}
153156
ok($ok, 'works correctly in a nested eval string');
154157

@@ -169,7 +172,7 @@ ok($ok, 'works correctly in a nested eval string');
169172

170173
$ok = 0;
171174
sub a {
172-
A: { if ($false) { redo A; B: $ok = 1; redo A; } }
175+
A: { if ($false) { redo A; B: $ok = 1; redo A; } }
173176
}
174177
a();
175178

@@ -244,22 +247,22 @@ sub DEBUG_TIME() {
244247
my $out = "";
245248
$out .= 'perl rules';
246249
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');
249252
};
250253
}
251254

252255
{
253256
my $r = runperl(
254-
stderr => 1,
255-
prog =>
257+
stderr => 1,
258+
prog =>
256259
'for ($_=0;$_<3;$_++){A: if($_==1){next} if($_==2){$_++;goto A}}print qq(ok\n)'
257260
);
258261
is($r, "ok\n", 'next and goto');
259262

260263
$r = runperl(
261-
stderr => 1,
262-
prog =>
264+
stderr => 1,
265+
prog =>
263266
'for ($_=0;$_<3;$_++){A: if($_==1){$_++;redo} if($_==2){$_++;goto A}}print qq(ok\n)'
264267
);
265268
is($r, "ok\n", 'redo and goto');
@@ -327,9 +330,11 @@ if($foo eq $foo) {
327330
}
328331
$foo .= "[9]";
329332
bulgaria:
333+
330334
package Tomsk;
331335
$foo .= "[1:".__PACKAGE__."]";
332336
$foo .= "[2:".__PACKAGE__."]";
337+
333338
package main;
334339
$foo .= "[3:".__PACKAGE__."]";
335340
is($foo, "[0:main][1:Tomsk][2:Tomsk][3:main]", "label before package decl");
@@ -339,6 +344,7 @@ if($foo eq $foo) {
339344
goto adelaide;
340345
}
341346
$foo .= "[Z]";
347+
342348
adelaide:
343349
package Cairngorm {
344350
$foo .= "[B:".__PACKAGE__."]";
@@ -435,37 +441,37 @@ eval { goto "\0" };
435441
like $@, qr/^Can't find label \0 at /, 'goto "\0"';
436442

437443
TODO: {
438-
local $::TODO = 'RT #45091: goto in CORE::GLOBAL::exit unsupported';
439-
fresh_perl_is(<<'EOC', "before\ndie 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\ndie handler\n", {stderr => 1}, 'RT #45091: goto in CORE::GLOBAL::EXIT');
446+
BEGIN {
441447
*CORE::GLOBAL::exit = sub {
442-
goto FASTCGI_NEXT_REQUEST;
448+
goto FASTCGI_NEXT_REQUEST;
443449
};
444-
}
445-
while (1) {
450+
}
451+
while (1) {
446452
eval { that_cgi_script() };
447453
FASTCGI_NEXT_REQUEST:
448454
last;
449-
}
450-
451-
sub that_cgi_script {
455+
}
456+
457+
sub that_cgi_script {
452458
local $SIG{__DIE__} = sub { print "die handler\n"; exit; print "exit failed?\n"; };
453459
print "before\n";
454460
eval { buggy_code() };
455461
print "after\n";
456-
}
457-
sub buggy_code {
462+
}
463+
sub buggy_code {
458464
die "error!";
459465
print "after die\n";
460-
}
466+
}
461467
EOC
462468
}
463469

464470
sub revnumcmp ($$) {
465-
goto FOO;
466-
die;
467-
FOO:
468-
return $_[1] <=> $_[0];
471+
goto FOO;
472+
die;
473+
FOO:
474+
return $_[1] <=> $_[0];
469475
}
470476
is eval { join(":", sort revnumcmp (9,5,1,3,7)) }, "9:7:5:3:1",
471477
"can goto at top level of multicalled sub";

0 commit comments

Comments
 (0)