Skip to content

Commit c7b431f

Browse files
committed
Fix scoping issue in nested_for_loops.t test
- Fix variable scoping problem where @output was not accessible to test_nested subroutine - Pass @output as parameter reference to test_nested to resolve lexical scope issue - Test now passes with both direct execution and prove
1 parent 86d6e70 commit c7b431f

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/test/resources/unit/nested_for_loops.t

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ subtest 'nested for loops with global $_' => sub {
77

88
# Test nested for loops where both use default $_
99
sub test_nested {
10-
for (@_) {
11-
push @output, "arg: $_";
10+
my ($output_ref, @args) = @_;
11+
for (@args) {
12+
push @$output_ref, "arg: $_";
1213
for (split(//, $_)) {
13-
push @output, " part: $_";
14+
push @$output_ref, " part: $_";
1415
}
1516
}
1617
}
1718

18-
test_nested("ab", "cd");
19+
test_nested(\@output, "ab", "cd");
1920

2021
is_deeply(\@output, [
2122
"arg: ab",

0 commit comments

Comments
 (0)