Skip to content

Commit 7ad4b20

Browse files
committed
Move 3 more tests
1 parent 7dd8ff7 commit 7ad4b20

File tree

2 files changed

+35
-32
lines changed

2 files changed

+35
-32
lines changed

t/op/goto-amp-name.t

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ use warnings;
1111
use strict;
1212
use Config;
1313
#plan tests => 'no_plan'; # yet
14-
plan tests => 22;
14+
plan tests => 25;
15+
1516
our $TODO;
1617

1718
# Excerpts from 'perldoc -f goto' as of perl-5.40.1 (Aug 2025)
@@ -59,14 +60,44 @@ our $foo;
5960

6061
###################
6162

63+
# deep recursion with gotos eventually caused a stack reallocation
64+
# which messed up buggy internals that didn't expect the stack to move
65+
66+
sub recurse1 {
67+
unshift @_, "x";
68+
no warnings 'recursion';
69+
goto &recurse2;
70+
}
71+
sub recurse2 {
72+
my $x = shift;
73+
$_[0] ? +1 + recurse1($_[0] - 1) : 0
74+
}
75+
76+
{
77+
my $w = 0;
78+
local $SIG{__WARN__} = sub { ++$w };
79+
is(recurse1(500), 500, 'recursive goto &foo');
80+
is $w, 0, 'no recursion warnings for "no warnings; goto &sub"';
81+
delete $SIG{__WARN__};
82+
}
83+
84+
# [perl #32039] Chained goto &sub drops data too early.
85+
86+
sub a32039 { @_=("foo"); goto &b32039; }
87+
sub b32039 { goto &c32039; }
88+
sub c32039 { is($_[0], 'foo', 'chained &goto') }
89+
a32039();
90+
91+
###################
92+
6293
# goto &foo not allowed in evals
6394

6495
sub null { 1 };
6596
eval 'goto &null';
6697
like($@, qr/Can't goto subroutine from an eval-string/, 'eval string');
6798
eval { goto &null };
6899
like($@, qr/Can't goto subroutine from an eval-block/, 'eval block');
69-
100+
70101
# goto &foo leaves @_ alone when called from a sub
71102
sub returnarg { $_[0] };
72103
is sub {

t/op/goto.t

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ use warnings;
1313
use strict;
1414
use Config;
1515
#plan tests => 134;
16-
plan tests => 113;
16+
plan tests => 110;
17+
1718
our $TODO;
1819

1920
my $deprecated = 0;
@@ -496,34 +497,6 @@ sub DEBUG_TIME() {
496497

497498
is($deprecated, 0, 'no warning was emitted');
498499

499-
# deep recursion with gotos eventually caused a stack reallocation
500-
# which messed up buggy internals that didn't expect the stack to move
501-
502-
sub recurse1 {
503-
unshift @_, "x";
504-
no warnings 'recursion';
505-
goto &recurse2;
506-
}
507-
sub recurse2 {
508-
my $x = shift;
509-
$_[0] ? +1 + recurse1($_[0] - 1) : 0
510-
}
511-
my $w = 0;
512-
$SIG{__WARN__} = sub { ++$w };
513-
is(recurse1(500), 500, 'recursive goto &foo');
514-
is $w, 0, 'no recursion warnings for "no warnings; goto &sub"';
515-
delete $SIG{__WARN__};
516-
517-
# [perl #32039] Chained goto &sub drops data too early.
518-
519-
sub a32039 { @_=("foo"); goto &b32039; }
520-
sub b32039 { goto &c32039; }
521-
sub c32039 { is($_[0], 'foo', 'chained &goto') }
522-
a32039();
523-
524-
# [perl #35214] next and redo re-entered the loop with the wrong cop,
525-
# causing a subsequent goto to crash
526-
527500
{
528501
my $r = runperl(
529502
stderr => 1,
@@ -540,7 +513,6 @@ a32039();
540513
is($r, "ok\n", 'redo and goto');
541514
}
542515

543-
544516
TODO: {
545517
local $TODO = "[perl #43403] goto() from an if to an else doesn't undo local () changes";
546518
our $global = "unmodified";

0 commit comments

Comments
 (0)