autocurry tests
[p5sagit/Function-Parameters.git] / t / autocurry.t
CommitLineData
fd57283a 1use strict;
2use warnings;
3use Test::More;
4
5use Function::Parameters;
6
7fun const($x)() { $x }
8
9fun whatev($x)($y1, $y2)($z) { $x + $y1 * $y2 - $z }
10
11fun 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
21is const(42)->(0), 42;
22is_deeply [cprod('A', 'B')->(1, 2, 3)], [['A', 1], ['A', 2], ['A', 3], ['B', 1], ['B', 2], ['B', 3]];
23is whatev(100)->(6, 7)(5), 137;
24
25my $add = fun ($x)($y) { $x + $y };
26my $succ = $add->(1);
27
28is $succ->(1), 2;
29is $succ->(9), 10;
30is $succ->(2), 3;
31
32done_testing;