Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

46 lines (34 sloc) 1.244 kB
use v6;
use Test;
# L<S02/Mutable types/Array>
=begin description
Nested array tests; various interactions of arrayrefs, arrays, flattening and nesting.
=end description
plan 9;
{ # UNSPECCED
my @a = (1,2,[3,4]);
my $a = (1,2,[3,4]);
my @b = [1,2,[3,4]];
my $b = [1,2,[3,4]];
my @c = (1,2,(3,4));
my $c = (1,2,(3,4));
my @d = [1,2,(3,4)];
my $d = [1,2,(3,4)];
is(+@a, 3, 'Array length, nested []');
is(+$a, 3, 'Array object length, nested []');
is(+@b, 1, 'Array length, nested [], outer []s');
is(+$b, 3, 'Array object length, nested [], outer []s');
is(+@c, 4, 'Array length, nested ()');
is(+$c, 3, 'Array object length, nested ()');
is(+@d, 1, 'Array length, nested (), outer []s');
is(+$d, 4, 'Array object length, nested (), outer []s');
}
# RT #98954
#?rakudo todo 'Should we fail, or should we throw RT #124449'
{
my @a = [1], [2], [3];
is (map { @a[1 - $_][0] }, 0 .. 3).perl,
q[(2, 1, Failure.new(exception => X::Subscript::Negative.new(index => -1, type => Array)), Failure.new(exception => X::Subscript::Negative.new(index => -2, type => Array))).list],
'correct Failures for negative subscript of nested array';
}
# vim: ft=perl6
Jump to Line
Something went wrong with that request. Please try again.