|
2 | 2 |
|
3 | 3 | use Test;
|
4 | 4 |
|
5 |
| -plan 25; |
| 5 | +plan 22; |
6 | 6 |
|
7 | 7 | # L<S09/Autovivification/In Perl 6 these read-only operations are indeed non-destructive:>
|
8 | 8 | {
|
@@ -69,15 +69,34 @@ sub bar ($baz is readonly) { }
|
69 | 69 | #?niecza skip "Unable to resolve method push in type Any"
|
70 | 70 | {
|
71 | 71 | my %h;
|
72 |
| - push %h<a>, 4, 2; |
73 |
| - is %h<a>.join, '42', 'can autovivify in sub form of push'; |
74 |
| - unshift %h<b>, 5, 3; |
75 |
| - is %h<b>.join, '53', 'can autovivify in sub form of unshift'; |
76 |
| - %h<c><d>.push( 7, 8 ); |
77 |
| - is %h<c><d>.join, '78', 'can autovivify in method form of push'; |
78 |
| - %h<e><f>.unshift( 9, 10 ); |
79 |
| - is %h<e><f>.join, '910', 'can autovivify in method form of unshift'; |
80 |
| - is %h.keys.elems, 4, 'successfully autovivified lower level'; |
| 72 | + push %h<s-push><a>, 1, 2; |
| 73 | + unshift %h<s-unsh><b>, 3, 4; |
| 74 | + append %h<s-appe><c>, 5, 6; |
| 75 | + prepend %h<s-prep><d>, 7, 8; |
| 76 | + %h<m-push><1>.push: <a b c>; |
| 77 | + %h<m-unsh><2>.unshift: <d e f>; |
| 78 | + %h<m-appe><3>.append: <g h i>; |
| 79 | + %h<m-prep><4>.prepend: <j k l>; |
| 80 | + |
| 81 | + is %h.keys.elems, 8, 'successfully autovivified lower level'; |
| 82 | + |
| 83 | + subtest 'can autovivify in...' => { |
| 84 | + plan 2; |
| 85 | + subtest '...sub form of...' => { |
| 86 | + plan 4; |
| 87 | + is-deeply %h<s-push><a>, [ 1, 2 ], 'push'; |
| 88 | + is-deeply %h<s-unsh><b>, [ 3, 4 ], 'unshift'; |
| 89 | + is-deeply %h<s-appe><c>, [ 5, 6 ], 'append'; |
| 90 | + is-deeply %h<s-prep><d>, [ 7, 8 ], 'prepend'; |
| 91 | + } |
| 92 | + subtest '...method form of...' => { |
| 93 | + plan 4; |
| 94 | + is-deeply %h<m-push><1>, [ <a b c>,], 'push'; |
| 95 | + is-deeply %h<m-unsh><2>, [ <d e f>,], 'unshift'; |
| 96 | + is-deeply %h<m-appe><3>, [|<g h i> ], 'append'; |
| 97 | + is-deeply %h<m-prep><4>, [|<j k l> ], 'prepend'; |
| 98 | + } |
| 99 | + } |
81 | 100 | }
|
82 | 101 |
|
83 | 102 | {
|
|
0 commit comments