File: 13_traverse.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 (22 lines) | stat: -rw-r--r-- 407 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use strict;
use warnings;
use 5.10.0;
use Test::More;
use Perlude::Lazy;

sub sum { now {state $sum = 0; $sum += $_ } shift }

my @tests =
( [ undef, enlist {} ]
, [ 10 => take 10, enlist {1} ]
, [ 15 => unfold 1 .. 5 ]
, [ 0  => take 10, cycle -1, 1 ]
);

plan tests => 0+ @tests;

for my $t (@tests) {
    my ( $sum, $i ) = @$t;
    is( sum($i), $sum, "sum = @{[ defined $sum ? $sum : '<undef>' ]}" );
}