@@ -2,40 +2,42 @@ use v6;
2
2
3
3
use Test ;
4
4
5
- plan 13 ;
5
+ plan 16 ;
6
6
7
7
# L<S09/Autovivification/In Perl 6 these read-only operations are indeed non-destructive:>
8
8
{
9
- my % a ;
10
- my $ b = % a < b >< c >;
9
+ my % h ;
10
+ my $ b = % h < a >< b >;
11
11
# ?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' ;
14
14
}
15
15
16
- # ?rakudo skip 'Undef to integer'
17
16
# ?pugs skip ':exists'
18
17
{
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' ;
23
22
}
24
23
25
24
# L<S09/Autovivification/But these bindings do autovivify:>
26
25
# ?pugs todo
27
26
{
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." ;
31
30
}
32
31
33
- # ?rakudo skip 'get_pmc_keyed() not implemented in class Undef'
34
32
{
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' ;
39
41
}
40
42
41
43
# ?rakudo todo 'prefix:<\\>'
0 commit comments