File: basic.t

package info (click to toggle)
libsub-prototype-perl 0.03-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 276 kB
  • sloc: perl: 190; makefile: 3
file content (20 lines) | stat: -rw-r--r-- 446 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use strict;
use warnings;
use Test::More tests => 4;
use Sub::Prototype;

BEGIN {
    my $my_grep = sub {
        my $code = shift;
        my @ok;
        $code->() and push @ok, $_ for @_;
        return @ok;
    };
    set_prototype($my_grep, '&@');
    is(prototype($my_grep), '&@');
    *main::my_grep = $my_grep;
}

is(prototype('my_grep'), '&@');
is(prototype(\&my_grep), '&@');
is_deeply([ my_grep { $_ % 2 } 1 .. 10 ], [1, 3, 5, 7, 9]);