add begin.t from Method::Signatures
[p5sagit/Function-Parameters.git] / t / regress.t
1 #!perl
2
3 use Test::More tests => 21;
4
5 use warnings FATAL => 'all';
6 use strict;
7
8 use Function::Parameters;
9
10 fun mk_counter($i) {
11         fun () { $i++ }
12 }
13
14 method nop() {}
15 fun fnop($x, $y, $z) {
16 }
17
18 is_deeply [nop], [];
19 is_deeply [main->nop], [];
20 is_deeply [nop 1], [];
21 is scalar(nop), undef;
22 is scalar(nop 2), undef;
23
24 is_deeply [fnop], [];
25 is_deeply [fnop 3, 4], [];
26 is scalar(fnop), undef;
27 is scalar(fnop 5, 6), undef;
28
29 my $f = mk_counter 0;
30 my $g = mk_counter 10;
31 my $h = mk_counter 50;
32
33 is $f->(), 0;
34 is $g->(), 10;
35 is $h->(), 50;
36 is $f->(), 1;
37 is $g->(), 11;
38 is $h->(), 51;
39 is $f->(), 2;
40 is $f->(), 3;
41 is $f->(), 4;
42 is $g->(), 12;
43 is $h->(), 52;
44 is $g->(), 13;