Skip to content

Commit 167cc73

Browse files
committed
Begin overhaul of t/op/goto.t
Of 134 tests to begin with, 25 were directly affected by changing a deprecation warning into a fatal exception. These 25 have been temporarily commented out (with '##') so that we can decide how to proceed. 9 of the 109 remaining unit tests are failing; many others are emitting warnings. Other test files with failures: comp/package_block.t lib/croak.t porting/deprecation.t porting/diag.t uni/labels.t Mark tests which failed with 2 '#' signs
1 parent af99ddd commit 167cc73

File tree

1 file changed

+70
-69
lines changed

1 file changed

+70
-69
lines changed

t/op/goto.t

Lines changed: 70 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ BEGIN {
1212
use warnings;
1313
use strict;
1414
use Config;
15-
plan tests => 134;
15+
#plan tests => 134;
16+
plan tests => 109;
1617
our $TODO;
1718

18-
my $deprecated = 0;
19+
my $fatalized = 0;
1920

20-
local $SIG{__WARN__} = sub {
21-
if ($_[0] =~ m/jump into a construct.*?, and will become fatal in Perl 5\.42/) {
22-
$deprecated++;
21+
local $SIG{__DIE__} = sub {
22+
if ($_[0] =~ m/jump into a construct is no longer permitted/) {
23+
$fatalized++;
2324
}
2425
else { warn $_[0] }
2526
};
@@ -28,28 +29,28 @@ our $foo;
2829
while ($?) {
2930
$foo = 1;
3031
label1:
31-
is($deprecated, 1, "following label1");
32-
$deprecated = 0;
32+
is($fatalized, 1, "following label1");
33+
$fatalized = 0;
3334
$foo = 2;
3435
goto label2;
3536
} continue {
3637
$foo = 0;
3738
goto label4;
3839
label3:
39-
is($deprecated, 1, "following label3");
40-
$deprecated = 0;
40+
is($fatalized, 1, "following label3");
41+
$fatalized = 0;
4142
$foo = 4;
4243
goto label4;
4344
}
44-
is($deprecated, 0, "after 'while' loop");
45-
goto label1;
45+
is($fatalized, 0, "after 'while' loop");
46+
##goto label1;
4647

4748
$foo = 3;
4849

4950
label2:
5051
is($foo, 2, 'escape while loop');
51-
is($deprecated, 0, "following label2");
52-
goto label3;
52+
is($fatalized, 0, "following label2");
53+
##goto label3;
5354

5455
label4:
5556
is($foo, 4, 'second escape while loop');
@@ -189,20 +190,20 @@ ok($ok, 'works correctly in a nested eval string');
189190
$ok = 0;
190191
sub a {
191192
A: { if ($false) { redo A; B: $ok = 1; redo A; } }
192-
goto B unless $count++;
193+
#goto B unless $count++;
193194
}
194-
is($deprecated, 0, "before calling sub a()");
195+
is($fatalized, 0, "before calling sub a()");
195196
a();
196197
ok($ok, '#19061 loop label wiped away by goto');
197-
is($deprecated, 1, "after calling sub a()");
198-
$deprecated = 0;
198+
is($fatalized, 1, "after calling sub a()");
199+
$fatalized = 0;
199200

200201
$ok = 0;
201202
my $p;
202-
for ($p=1;$p && goto A;$p=0) { A: $ok = 1 }
203+
#for ($p=1;$p && goto A;$p=0) { A: $ok = 1 }
203204
ok($ok, 'weird case of goto and for(;;) loop');
204-
is($deprecated, 1, "following goto and for(;;) loop");
205-
$deprecated = 0;
205+
is($fatalized, 1, "following goto and for(;;) loop");
206+
$fatalized = 0;
206207
}
207208

208209
# bug #9990 - don't prematurely free the CV we're &going to.
@@ -492,7 +493,7 @@ sub DEBUG_TIME() {
492493
};
493494
}
494495

495-
is($deprecated, 0, 'no warning was emmitted');
496+
is($fatalized, 0, 'no warning was emmitted');
496497

497498
# deep recursion with gotos eventually caused a stack reallocation
498499
# which messed up buggy internals that didn't expect the stack to move
@@ -616,7 +617,7 @@ TODO: {
616617
}
617618
}
618619

619-
is($deprecated, 0, "following TODOed test for #43403");
620+
is($fatalized, 0, "following TODOed test for #43403");
620621

621622
#74290
622623
{
@@ -821,54 +822,54 @@ is eval { join(":", sort revnumcmp (9,5,1,3,7)) }, "9:7:5:3:1",
821822
# A bit strange, but goingto these constructs should not cause any stack
822823
# problems. Let’s test them to make sure that is the case.
823824
no warnings 'deprecated';
824-
is \sub :lvalue { goto d; ${*{scalar(do { d: \*foo })}} }->(), \$foo,
825-
'goto into rv2sv, rv2gv and scalar';
826-
is sub { goto e; $#{; do { e: \@_ } } }->(1..7), 6,
827-
'goto into $#{...}';
828-
is sub { goto f; prototype \&{; do { f: sub ($) {} } } }->(), '$',
829-
'goto into srefgen, prototype and rv2cv';
830-
is sub { goto g; ref do { g: [] } }->(), 'ARRAY',
831-
'goto into ref';
832-
is sub { goto j; defined undef ${; do { j: \(my $foo = "foo") } } }->(),'',
833-
'goto into defined and undef';
834-
is sub { goto k; study ++${; do { k: \(my $foo = "foo") } } }->(),'1',
835-
'goto into study and preincrement';
836-
is sub { goto l; ~-!${; do { l: \(my $foo = 0) } }++ }->(),~-1,
837-
'goto into complement, not, negation and postincrement';
838-
like sub { goto n; sin cos exp log sqrt do { n: 1 } }->(),qr/^0\.51439/,
839-
'goto into sin, cos, exp, log, and sqrt';
840-
ok sub { goto o; srand do { o: 0 } }->(),
841-
'goto into srand';
842-
cmp_ok sub { goto p; rand do { p: 1 } }->(), '<', 1,
843-
'goto into rand';
844-
is sub { goto r; chr ord length int hex oct abs do { r: -15.5 } }->(), 2,
845-
'goto into chr, ord, length, int, hex, oct and abs';
846-
is sub { goto t; ucfirst lcfirst uc lc do { t: "q" } }->(), 'Q',
847-
'goto into ucfirst, lcfirst, uc and lc';
825+
##is \sub :lvalue { goto d; ${*{scalar(do { d: \*foo })}} }->(), \$foo,
826+
## 'goto into rv2sv, rv2gv and scalar';
827+
##is sub { goto e; $#{; do { e: \@_ } } }->(1..7), 6,
828+
## 'goto into $#{...}';
829+
##is sub { goto f; prototype \&{; do { f: sub ($) {} } } }->(), '$',
830+
## 'goto into srefgen, prototype and rv2cv';
831+
##is sub { goto g; ref do { g: [] } }->(), 'ARRAY',
832+
## 'goto into ref';
833+
##is sub { goto j; defined undef ${; do { j: \(my $foo = "foo") } } }->(),'',
834+
## 'goto into defined and undef';
835+
##is sub { goto k; study ++${; do { k: \(my $foo = "foo") } } }->(),'1',
836+
## 'goto into study and preincrement';
837+
##is sub { goto l; ~-!${; do { l: \(my $foo = 0) } }++ }->(),~-1,
838+
## 'goto into complement, not, negation and postincrement';
839+
##like sub { goto n; sin cos exp log sqrt do { n: 1 } }->(),qr/^0\.51439/,
840+
## 'goto into sin, cos, exp, log, and sqrt';
841+
##ok sub { goto o; srand do { o: 0 } }->(),
842+
## 'goto into srand';
843+
##cmp_ok sub { goto p; rand do { p: 1 } }->(), '<', 1,
844+
## 'goto into rand';
845+
##is sub { goto r; chr ord length int hex oct abs do { r: -15.5 } }->(), 2,
846+
## 'goto into chr, ord, length, int, hex, oct and abs';
847+
##is sub { goto t; ucfirst lcfirst uc lc do { t: "q" } }->(), 'Q',
848+
## 'goto into ucfirst, lcfirst, uc and lc';
848849
{ no strict;
849-
is sub { goto u; \@{; quotemeta do { u: "." } } }->(), \@{'\.'},
850-
'goto into rv2av and quotemeta';
851-
}
852-
is join(" ",sub { goto v; %{; do { v: +{1..2} } } }->()), '1 2',
853-
'goto into rv2hv';
854-
is join(" ",sub { goto w; $_ || do { w: "w" } }->()), 'w',
855-
'goto into rhs of or';
856-
is join(" ",sub { goto x; $_ && do { x: "w" } }->()), 'w',
857-
'goto into rhs of and';
858-
is join(" ",sub { goto z; $_ ? do { z: "w" } : 0 }->()), 'w',
859-
'goto into first leg of ?:';
860-
is join(" ",sub { goto z; $_ ? 0 : do { z: "w" } }->()), 'w',
861-
'goto into second leg of ?:';
862-
is sub { goto z; caller do { z: 0 } }->(), 'main',
863-
'goto into caller';
864-
is sub { goto z; exit do { z: return "foo" } }->(), 'foo',
865-
'goto into exit';
866-
is sub { goto z; eval do { z: "'foo'" } }->(), 'foo',
867-
'goto into eval';
850+
## is sub { goto u; \@{; quotemeta do { u: "." } } }->(), \@{'\.'},
851+
## 'goto into rv2av and quotemeta';
852+
}
853+
##is join(" ",sub { goto v; %{; do { v: +{1..2} } } }->()), '1 2',
854+
## 'goto into rv2hv';
855+
##is join(" ",sub { goto w; $_ || do { w: "w" } }->()), 'w',
856+
## 'goto into rhs of or';
857+
##is join(" ",sub { goto x; $_ && do { x: "w" } }->()), 'w',
858+
## 'goto into rhs of and';
859+
##is join(" ",sub { goto z; $_ ? do { z: "w" } : 0 }->()), 'w',
860+
## 'goto into first leg of ?:';
861+
##is join(" ",sub { goto z; $_ ? 0 : do { z: "w" } }->()), 'w',
862+
## 'goto into second leg of ?:';
863+
##is sub { goto z; caller do { z: 0 } }->(), 'main',
864+
## 'goto into caller';
865+
##is sub { goto z; exit do { z: return "foo" } }->(), 'foo',
866+
## 'goto into exit';
867+
##is sub { goto z; eval do { z: "'foo'" } }->(), 'foo',
868+
## 'goto into eval';
868869
TODO: {
869870
local $TODO = "glob() does not currently return a list on VMS" if $^O eq 'VMS';
870-
is join(",",sub { goto z; glob do { z: "foo bar" } }->()), 'foo,bar',
871-
'goto into glob';
871+
## is join(",",sub { goto z; glob do { z: "foo bar" } }->()), 'foo,bar',
872+
## 'goto into glob';
872873
}
873874
# [perl #132799]
874875
# Erroneous inward goto warning, followed by crash.
@@ -879,8 +880,8 @@ sub _routine {
879880
L2:
880881
}
881882
}
882-
_routine();
883-
pass("bug 132799");
883+
##_routine();
884+
##pass("bug 132799");
884885

885886
# [perl #132854]
886887
# Goto the *first* parameter of a binary expression, which is harmless.

0 commit comments

Comments
 (0)