Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 63c4f609dd
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 67 lines (54 sloc) 1.421 kb
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
use v6;

use Test;

plan 7;

#?rakudo skip 'Undef to integer'
{
    # L<S09/Autovivification/In Perl 6 these read-only operations are indeed non-destructive:>
    my %a;
    my $b = %a<b><c>;
    is %a.keys.elems, 0, "fetching doesn't autovivify.";
}

#?rakudo skip 'Undef to integer'
{
    # L<S09/Autovivification/In Perl 6 these read-only operations are indeed non-destructive:>
    my %a;
    my $b = exists %a<b><c>;
    is %a.keys.elems, 0, "exists doesn't autovivify.";
}

{
    # L<S09/Autovivification/But these bindings do autovivify:>
    my %a;
    bar(%a<b><c>);
    is %a.keys.elems, 0, "in ro arguments doesn't autovivify.";
}

{
    # L<S09/Autovivification/But these bindings do autovivify:>
    my %a;
    my $b := %a<b><c>;
    is %a.keys.elems, 1, 'binding autovivifies.';
}

#?rakudo skip 'prefix:<\\>'
{
    # L<S09/Autovivification/But these bindings do autovivify:>
    my %a;
    my $b = \%a<b><c>;
    is %a.keys.elems, 1, 'capturing autovivifies.';
}

{
    # L<S09/Autovivification/But these bindings do autovivify:>
    my %a;
    foo(%a<b><c>);
    is %a.keys.elems, 1, 'in rw arguments autovivifies.';
}

{
    # L<S09/Autovivification/But these bindings do autovivify:>
    my %a;
    %a<b><c> = 1;
    is %a.keys.elems, 1, 'store autovivify.';
}


sub foo ($baz is rw) {
    # just some random subroutine.
}

sub bar ($baz is readonly) {
    # readonly signature, should it autovivify?
}
Something went wrong with that request. Please try again.