File: rotate_in_place.t

package info (click to toggle)
liblist-objects-withutils-perl 2.028003-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,292 kB
  • sloc: perl: 1,957; makefile: 17; sh: 1
file content (34 lines) | stat: -rw-r--r-- 813 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use Test::More;
use strict; use warnings FATAL => 'all';

use List::Objects::WithUtils 'array';

my $arr = array(1 .. 4);
ok $arr->rotate_in_place == $arr, 
  'rotate_in_place returned self ok';
is_deeply
  [ $arr->all ],
  [ 2, 3, 4, 1 ],
  'rotate_in_place default opts ok';

ok $arr->rotate_in_place(right => 1) == $arr,
  'rotate_in_place rightwards returned self ok';
is_deeply
  [ $arr->all ],
  [ 1, 2, 3, 4 ],
  'rotate_in_place rightwards ok';

ok $arr->rotate_in_place(left => 1) == $arr,
  'rotate_in_place leftwards returned self ok';
is_deeply [ $arr->all ],
  [ 2, 3, 4, 1 ],
  'rotate_in_place leftwards ok';


ok array->rotate_in_place->is_empty, 'empty array rotate_in_place ok';


eval {; $arr->rotate_in_place(left => 1, right => 1) };
like $@, qr/direction/, 'bad opts die ok';

done_testing;