File: autovivification.t

package info (click to toggle)
libperl5i-perl 2.13.2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 996 kB
  • ctags: 343
  • sloc: perl: 6,259; makefile: 5
file content (28 lines) | stat: -rw-r--r-- 509 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/perl -w

use perl5i::latest;

use Test::More;

# Test with a hash ref
{
    my $hash;
    my $val = $hash->{key};
    is $hash, undef, "hash ref does not autoviv";

    $val = $hash->{key1}{key2};
    is $hash, undef, "hash ref does not autoviv";
}


# And a regular hash
{
    my %hash;
    my $val = $hash{key};
    is_deeply scalar %hash->keys, [], "hash key does not autoviv";

    $val = $hash{key1}{key2};
    is_deeply scalar %hash->keys, [], "hash key does not autoviv";
}

done_testing();