File: 12_buffer.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 (61 lines) | stat: -rw-r--r-- 1,682 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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use Test::More;
use strict;
use warnings;
use Perlude::Lazy;

ok 1,"some old tests to restore if someone wants to maintain lazy";
done_testing;

__END__

my @tests =
( [ fold => ( apply {@$_} tuple 3, unfold 1 .. 7 ), [ 1 .. 7 ] ]
, [ takeWhile =>
        ( takeWhile { $_ % 2 } apply {@$_} tuple 3, unfold 1, 3, 5, 2, 7, 9 )
  , [ 1, 3, 5 ]
  ]
, [ filter => ( filter { $_ % 2 } apply {@$_} tuple 3, unfold 1 .. 7 )
  , [ 1, 3, 5, 7 ]
  ]
, [ take => ( take 5, apply {@$_} tuple 3, unfold 1 .. 100 ), [ 1 .. 5 ] ]
, [ drop => ( drop 5, apply {@$_} tuple 3, unfold 1 .. 100 ), [ 6 .. 100 ] ]
, [ apply => ( apply {@$_} tuple 17, unfold 1 .. 100 ), [ 1 .. 100 ] ]
, [ traverse => sub { # the state variable ensure the sub runs once only
        ( state $i++ ) ? () : traverse { -$_ } apply {@$_} tuple 5,
            unfold 1 .. 10;
    }
  , [-10]
  ]
, [ tuple => ( tuple 2, apply {@$_} tuple 3, unfold 0 .. 10 ),
  , [ [ 0, 1 ], [ 2, 3 ], [ 4, 5 ], [ 6, 7 ], [ 8, 9 ], [10] ]
  ]
);

plan tests => @tests + 1;

$TODO = '_buffer removed';

# generate the todo list
my %todo = do {
    no strict 'refs';
    map { ( $_ => 1 ) }

        # exception list
        grep { !/^(?:import|carp|confess|croak|_.*|[A-Z_]+|unfold|cycle)$/ }

        # functions in the Perlude:: namespace
        grep { defined ${'Perlude::'}{$_} } keys %Perlude::;
};

# run the tests
for my $t (@tests) {
    my ( $name, $i, $out ) = @$t;
    my $got = [ fold $i ];
    my $ok = is_deeply( $got, $out, $name );
    delete $todo{$name};
}

# check all sub in Perlude:: have been tested
ok( !keys %todo, 'All Perlude functions tested for buffering' )
    or diag "Untested functions: @{[sort keys %todo]}";