Skip to content

Commit 5d79c38

Browse files
1-1samkhwilliamson
authored andcommitted
todo test for GH 18669 (dereferencing ternary skips autovivification)
1 parent 5265c66 commit 5d79c38

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

t/run/todo.t

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,27 @@ TODO: {
8686
is($?, 0, "No assertion failure");
8787
}
8888

89+
TODO: {
90+
local $::TODO = 'GH 18669';
91+
92+
my $results = fresh_perl(<<~'EOF', {});
93+
my $x = { arr => undef };
94+
push(@{ $x->{ decide } ? $x->{ not_here } : $x->{ new } }, "mana");
95+
print $x->{ new }[0];
96+
EOF
97+
is($?, 0, "No assertion failure");
98+
is($results, 'mana', 'push on non-existent hash entry from ternary autovivifies array ref');
99+
100+
$results = fresh_perl(<<~'EOF', {});
101+
my $x = { arr => undef };
102+
push(@{ $x->{ decide } ? $x->{ not_here } : $x->{ arr } }, "mana");
103+
print $x->{ arr }[0];
104+
EOF
105+
is($?, 0, "No assertion failure");
106+
is($results, 'mana', 'push on undef hash entry from ternary autovivifies array ref');
107+
108+
}
109+
89110
{
90111
fresh_perl('use re "eval";
91112
my @r;

0 commit comments

Comments
 (0)