Skip to content

Commit e312743

Browse files
committed
todo test for GH 18669 (dereferencing ternary skips autovivification)
1 parent 4caba6a commit e312743

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
@@ -101,6 +101,27 @@ TODO: {
101101
is($?, 0, "No assertion failure");
102102
}
103103

104+
TODO: {
105+
local $::TODO = 'GH 18669';
106+
107+
my $results = fresh_perl(<<~'EOF', {});
108+
my $x = { arr => undef };
109+
push(@{ $x->{ decide } ? $x->{ not_here } : $x->{ new } }, "mana");
110+
print $x->{ new }[0];
111+
EOF
112+
is($?, 0, "No assertion failure");
113+
is($results, 'mana', 'push on non-existant hash entry from ternary autovivifies array ref');
114+
115+
$results = fresh_perl(<<~'EOF', {});
116+
my $x = { arr => undef };
117+
push(@{ $x->{ decide } ? $x->{ not_here } : $x->{ arr } }, "mana");
118+
print $x->{ arr }[0];
119+
EOF
120+
is($?, 0, "No assertion failure");
121+
is($results, 'mana', 'push on undef hash entry from ternary autovivifies array ref');
122+
123+
}
124+
104125
{
105126
fresh_perl('use re "eval";
106127
my @r;

0 commit comments

Comments
 (0)