Skip to content

Commit 95f6082

Browse files
committed
Add a test for 1 to n dimensional shaped arrays
Considering the bugs: rakudo/rakudo#2350 rakudo/rakudo#2352 there need to be tests that are done for higher dimensions than what is usually used to make sure that these cases are also supported.
1 parent d395f0d commit 95f6082

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

S02-types/multi_dimensional_array.t

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Multi-Dimensional Arrays
77
88
=end pod
99

10-
plan 58;
10+
plan 59;
1111

1212
# multi-dimensional array
1313
# L<S09/Multidimensional arrays/Perl 6 arrays are not restricted to being one-dimensional>
@@ -156,4 +156,22 @@ is @multi3[0;0;1], (<cute-cats>), 'assigned the right thing to [0;0;1]';
156156
is @multi3[0;1;1], (<cute-dogs>), 'assigned the right thing to [0;1;1]';
157157
is @multi3[0;2;1], (<cute-squirrels>), 'assigned the right thing to [0;2;1]';
158158

159+
160+
subtest 'Insertion and reading of shaped array elements' => {
161+
constant MAX_CHECKED_DIM = 3; # Can be increased after https://github.com/rakudo/rakudo/issues/2352
162+
plan ([*] 1..$_ for (1..MAX_CHECKED_DIM)).sum + MAX_CHECKED_DIM;
163+
for 1..MAX_CHECKED_DIM {
164+
my @md[(1..$_).reverse];
165+
for @md.keys -> $k {
166+
@md.AT-POS(|$k) = $k.sum;
167+
}
168+
169+
for @md.keys -> $k {
170+
is @md.AT-POS(|$k), $k.sum, "got the right value from array with dim $_ at $k";
171+
}
172+
173+
is @md.elems, $_, ".elems for a shaped array (dim $_) returns the first dimension";
174+
}
175+
}
176+
159177
# vim: ft=perl6

0 commit comments

Comments
 (0)