Skip to content

Commit cb5beb6

Browse files
committed
Some more test passing now that we have Any.exists
1 parent 9442ea7 commit cb5beb6

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

S02-types/autovivification.t

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,42 @@ use v6;
22

33
use Test;
44

5-
plan 13;
5+
plan 16;
66

77
# L<S09/Autovivification/In Perl 6 these read-only operations are indeed non-destructive:>
88
{
9-
my %a;
10-
my $b = %a<b><c>;
9+
my %h;
10+
my $b = %h<a><b>;
1111
#?pugs todo
12-
is %a.keys.elems, 0, "fetching doesn't autovivify.";
13-
ok !defined($b), 'and the return value is not defined';
12+
is %h.keys.elems, 0, "fetching doesn't autovivify.";
13+
ok $b === Any, 'and the return value is not defined';
1414
}
1515

16-
#?rakudo skip 'Undef to integer'
1716
#?pugs skip ':exists'
1817
{
19-
my %a;
20-
my $b = so %a<b><c>:exists;
21-
is %a.keys.elems, 0, "exists doesn't autovivify.";
22-
nok $b, '... and it returns the right value';
18+
my %h;
19+
my $exists = %h<a><b>:exists;
20+
is %h.keys.elems, 0, "exists doesn't autovivify.";
21+
ok $exists === False, '... and it returns the right value';
2322
}
2423

2524
# L<S09/Autovivification/But these bindings do autovivify:>
2625
#?pugs todo
2726
{
28-
my %a;
29-
bar(%a<b><c>);
30-
is %a.keys.elems, 0, "in ro arguments doesn't autovivify.";
27+
my %h;
28+
bar(%h<a><b>);
29+
is %h.keys.elems, 0, "in ro arguments doesn't autovivify.";
3130
}
3231

33-
#?rakudo skip 'get_pmc_keyed() not implemented in class Undef'
3432
{
35-
my %a;
36-
my $b := %a<b><c>;
37-
is %a.keys.elems, 1, 'binding autovivifies.';
38-
nok defined($b), '... to an undefined value';
33+
my %h;
34+
my $b := %h<a><b>;
35+
is %h.keys.elems, 0, 'binding does not immediately autovivify';
36+
ok $b === Any, '... to an undefined value';
37+
$b = 1;
38+
is %h.keys.elems, 1, '.. but autovivifies after assignment';
39+
is %h<a><b>, 1, 'having it in there';
40+
ok %h<a><b> =:= $b, 'check binding';
3941
}
4042

4143
#?rakudo todo 'prefix:<\\>'

0 commit comments

Comments
 (0)