File: regress.t

package info (click to toggle)
libfunction-parameters-perl 2.002005-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 624 kB
  • sloc: perl: 3,945; makefile: 3
file content (44 lines) | stat: -rw-r--r-- 668 bytes parent folder | download | duplicates (3)
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
#!perl

use Test::More tests => 21;

use warnings FATAL => 'all';
use strict;

use Function::Parameters qw(:lax);

fun mk_counter($i) {
    fun () { $i++ }
}

method nop() {}
fun fnop($x, $y, $z) {
}

is_deeply [nop], [];
is_deeply [main->nop], [];
is_deeply [nop 1], [];
is scalar(nop), undef;
is scalar(nop 2), undef;

is_deeply [fnop], [];
is_deeply [fnop 3, 4], [];
is scalar(fnop), undef;
is scalar(fnop 5, 6), undef;

my $f = mk_counter 0;
my $g = mk_counter 10;
my $h = mk_counter 50;

is $f->(), 0;
is $g->(), 10;
is $h->(), 50;
is $f->(), 1;
is $g->(), 11;
is $h->(), 51;
is $f->(), 2;
is $f->(), 3;
is $f->(), 4;
is $g->(), 12;
is $h->(), 52;
is $g->(), 13;