Commit | Line | Data |
---|---|---|
fd57283a | 1 | use strict; |
2 | use warnings; | |
3 | use Test::More; | |
4 | ||
5 | use Function::Parameters; | |
6 | ||
7 | fun const($x)() { $x } | |
8 | ||
9 | fun whatev($x)($y1, $y2)($z) { $x + $y1 * $y2 - $z } | |
10 | ||
11 | fun cprod(@x)(@y) { | |
12 | my @r; | |
13 | for my $x (@x) { | |
14 | for my $y (@y) { | |
15 | push @r, [$x, $y]; | |
16 | } | |
17 | } | |
18 | @r | |
19 | } | |
20 | ||
21 | is const(42)->(0), 42; | |
22 | is_deeply [cprod('A', 'B')->(1, 2, 3)], [['A', 1], ['A', 2], ['A', 3], ['B', 1], ['B', 2], ['B', 3]]; | |
23 | is whatev(100)->(6, 7)(5), 137; | |
24 | ||
25 | my $add = fun ($x)($y) { $x + $y }; | |
26 | my $succ = $add->(1); | |
27 | ||
28 | is $succ->(1), 2; | |
29 | is $succ->(9), 10; | |
30 | is $succ->(2), 3; | |
31 | ||
32 | done_testing; |