- my $x = {
- a => 1,
- };
-
- cmpthese $count, {
- fetch_hashref_existing_av => sub { $x->{a} },
- fetch_hashref_existing_noav => sub { no autovivification; $x->{a} },
- };
+ my $x = { a => 1 };
+
+ push @tests, [
+ 'Fetch an existing key from a hash reference',
+ {
+ av => sub { $x->{a} },
+ noav => sub { no autovivification; $x->{a} },
+ noav_manual => sub { defined $x ? $x->{a} : undef },
+ }
+ ];
+}
+
+{
+ my $x = { a => { b => { c => { d => 1 } } } };
+
+ push @tests, [
+ 'Fetch a 4-levels deep existing key from a hash reference',
+ {
+ av => sub { $x->{a}{b}{c}{d} },
+ noav => sub { no autovivification; $x->{a}{b}{c}{d} },
+ noav_manual => sub { my $z; defined $x ? ($z = $x->{a}, defined $z ? ($z = $z->{b}, defined $z ? ($z = $z->{c}, defined $z ? $z->{d} : undef) : undef) : undef) : undef },
+ }
+ ];