Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions t/op/goto-sub.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ BEGIN {
require './charset_tools.pl';
}

use v5.16;
use warnings;
use strict;
use Config;
plan tests => 40;
plan tests => 41;

# Excerpts from 'perldoc -f goto' as of perl-5.40.1 (Aug 2025)
#
Expand Down Expand Up @@ -61,7 +61,7 @@ our $foo;

sub f1 {
my $x;
goto sub { $x=0; ok(1,"don't prematurely free CV\n") }
goto sub { $x=0; ok(1, "don't prematurely free CV"); };
}
f1();

Expand Down Expand Up @@ -358,6 +358,21 @@ SKIP:
}


# GH 23804 goto __SUB__
{
my $fac = sub {
unshift @_, 1;
goto sub {
my ($acc, $i) = @_;
return $acc if $i < 2;
@_ = ($acc * $i, $i - 1);
goto __SUB__;
};
};

is $fac->(5), 120, 'recursion via goto __SUB__';
}

# Final test: ensure that we saw no deprecation warnings
# ... but rework this to count fatalizations once work is more developed

Expand Down
Loading