Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
More multi-dim method/sub tests.
  • Loading branch information
jnthn committed Dec 13, 2015
1 parent 91eaba2 commit 8b9ae0a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 8 additions & 2 deletions S09-multidim/methods.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 72;
plan 78;

# Object array
{
Expand Down Expand Up @@ -56,6 +56,9 @@ plan 72;
ok 'a' le @arr.roll le 'd', '.roll is over leaves';
is @arr.rotor(2 => -1), <a b c d>.rotor(2 => -1), '.rotor is over leaves';
is @arr.join(','), 'a,b,c,d', '.join is over leaves';
is @arr.map(* x 2), <aa bb cc dd>, '.map is over leaves';
is @arr.sort, <a b c d>, '.sort is over leaves';
is @arr.Slip, <a b c d>.Slip, '.Slip is over leaves';

is @arr.gist, '[[a b] [c d]]', '.gist represents structure';
is @arr.perl, 'Array.new(:shape(2, 2), ["a", "b"], ["c", "d"])',
Expand Down Expand Up @@ -116,7 +119,10 @@ plan 72;
ok 42 <= @arr.roll <= 45, '.roll is over leaves (native)';
is @arr.rotor(2 => -1), (42, 43, 44, 45).rotor(2 => -1), '.rotor is over leaves (native)';
is @arr.join(','), '42,43,44,45', '.join is over leaves (native)';

is @arr.map(* + 2), (44,45,46,47), '.map is over leaves (native)';
is @arr.sort(-*), (45,44,43,42), '.sort is over leaves (native)';
is @arr.Slip, (42, 43, 44, 45).Slip, '.Slip is over leaves (native)';

is @arr.gist, '[[42 43] [44 45]]', '.gist represents structure (native)';
is @arr.perl, 'array[int].new(:shape(2, 2), [42, 43], [44, 45])',
'.perl retains structure (native)';
Expand Down
6 changes: 5 additions & 1 deletion S09-multidim/subs.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 38;
plan 42;

# Object array
{
Expand Down Expand Up @@ -37,6 +37,8 @@ plan 38;

is flat(@arr), <a b c d>, '.flat gives the leaves';
is join(',', @arr), 'a,b,c,d', '.join is over leaves';
is map(* x 2, @arr), <aa bb cc dd>, '.map is over leaves';
is sort(@arr), <a b c d>, '.sort is over leaves';
}

# Native array
Expand Down Expand Up @@ -74,4 +76,6 @@ plan 38;

is flat(@arr), (42, 43, 44, 45), '.flat gives the leaves (native)';
is join(',', @arr), '42,43,44,45', '.join is over leaves (native)';
is map(* + 2, @arr), (44,45,46,47), '.map is over leaves (native)';
is sort(-*, @arr), (45,44,43,42), '.sort is over leaves (native)';
}

0 comments on commit 8b9ae0a

Please sign in to comment.