File: 15_range.t

package info (click to toggle)
libperlude-perl 0.61-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 360 kB
  • sloc: perl: 903; makefile: 2
file content (19 lines) | stat: -rw-r--r-- 717 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use strict;
use warnings;
use Test::More tests => 12;
use Perlude::Lazy;

is_deeply [ fold range(1, 1, 1)  ], [ 1 ];
is_deeply [ fold range(1, 2, 1)  ], [ 1, 2 ];
is_deeply [ fold range(1, 1)     ], [ 1 ];
is_deeply [ fold range(1, 2)     ], [ 1, 2 ];
is_deeply [ fold range(2, 1, -1) ], [ 2, 1 ];
is_deeply [ fold range(1, 1, -1) ], [ 1 ];
is_deeply [ fold range(1, 0, -1) ], [ 1, 0 ];

diag "infinite ranges";
is_deeply [ fold take 3, range(1, undef)     ], [ 1, 2, 3 ];
is_deeply [ fold take 3, range(1, undef,  1) ], [ 1, 2, 3 ];
is_deeply [ fold take 3, range(1, undef,  2) ], [ 1, 3, 5 ];
is_deeply [ fold take 3, range(5, undef, -1) ], [ 5, 4, 3 ];
is_deeply [ fold take 3, range(5, undef, -2) ], [ 5, 3, 1 ];