Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Test rotate/reverse on 1-dimensional arrays.
  • Loading branch information
jnthn committed Dec 13, 2015
1 parent 8b9ae0a commit 30a3a5f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion S09-multidim/methods.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 78;
plan 82;

# Object array
{
Expand Down Expand Up @@ -63,6 +63,13 @@ plan 78;
is @arr.gist, '[[a b] [c d]]', '.gist represents structure';
is @arr.perl, 'Array.new(:shape(2, 2), ["a", "b"], ["c", "d"])',
'.perl retains structure';

my @one-dim := Array.new(:shape(4));
@one-dim = 1..4;
is @one-dim.reverse, [4,3,2,1], 'can reverse a 1-dim fixed size array';
is @one-dim.reverse.shape, (4,), 'reverse on fixed-dim array retains shape';
is @one-dim.rotate(-1), [4,1,2,3], 'can rotate a 1-dim fixed size array';
is @one-dim.rotate(-1).shape, (4,), 'rotate a 1-dim fixed size array retains shape';
}

# Native array
Expand Down
9 changes: 8 additions & 1 deletion S09-multidim/subs.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 42;
plan 46;

# Object array
{
Expand Down Expand Up @@ -39,6 +39,13 @@ plan 42;
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';

my @one-dim := Array.new(:shape(4));
@one-dim = 1..4;
is reverse(@one-dim), [4,3,2,1], 'can reverse a 1-dim fixed size array';
is reverse(@one-dim).shape, (4,), 'reverse on fixed-dim array retains shape';
is rotate(@one-dim, -1), [4,1,2,3], 'can rotate a 1-dim fixed size array';
is rotate(@one-dim, -1).shape, (4,), 'rotate a 1-dim fixed size array retains shape';
}

# Native array
Expand Down

0 comments on commit 30a3a5f

Please sign in to comment.