multitest more perl versions; also list successes
[p5sagit/Function-Parameters.git] / t / rename.t
CommitLineData
60682a8e 1use strict;
2use warnings;
3use Test::More;
4
5use Function::Parameters 'f';
6
7my $add = f ($x, $y) { $x + $y };
8
9is $add->(2, 4), 6;
10
5bf140a1 11ok !eval { Function::Parameters->import('g', 'h', 'i'); 1 };
2a5e8ebe 12
13for my $kw ('', '42', 'A::B', 'a b') {
14 ok !eval{ Function::Parameters->import($kw); 1 };
15 like $@, qr/valid identifier /;
16}
17
5bf140a1 18use Function::Parameters 'func_a', 'meth_a';
19
20func_a cat_a($x, $y) {
21 $x . $y
22}
23
24meth_a tac_a($x) {
25 $x . $self
26}
27
28is cat_a('ab', 'cde'), 'abcde';
29is tac_a('ab', 'cde'), 'cdeab';
30
31use Function::Parameters {
32 meth_b => 'method',
33 func_b => 'function',
34};
35
36func_b cat_b($x, $y) {
37 $x . $y
38}
39
40meth_b tac_b($x) {
41 $x . $self
42}
43
44is cat_b('ab', 'cde'), 'abcde';
45is tac_b('ab', 'cde'), 'cdeab';
46
60682a8e 47done_testing;