multitest more perl versions; also list successes
[p5sagit/Function-Parameters.git] / t / 02-compiles.t
CommitLineData
5bf140a1 1#!perl
2
3use Test::More tests => 10;
4
5use warnings FATAL => 'all';
6use strict;
7
8use Function::Parameters;
9
10method id_1() { $self }
11
12method id_2
13 (
14
15 )
16 : #hello
17 (
18 $
19 )
20 {@_ == 0 or return;
21 $self
22 }
23
24method##
25 id_3 ##
26 ( ##
27 #
28 ) ##AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
29 { ##
c311cef3 30 $self ##
5bf140a1 31 } ##
32
33method add($y) {
34 $self + $y
35}
36
37method mymap(@args) :(&@) {
38 my @res;
39 for (@args) {
40 push @res, $self->($_);
41 }
42 @res
43}
44
45method fac_1() {
46 $self < 2 ? 1 : $self * fac_1 $self - 1
47}
48
49method fac_2() :($) {
50 $self < 2 ? 1 : $self * fac_2 $self - 1
51}
52
53ok id_1 1;
54ok id_1(1), 'basic sanity';
55ok id_2 1, 'simple prototype';
56ok id_3(1), 'definition over multiple lines';
57is add(2, 2), 4, '2 + 2 = 4';
58is add(39, 3), 42, '39 + 3 = 42';
59is_deeply [mymap { $_ * 2 } 2, 3, 5, 9], [4, 6, 10, 18], 'mymap works';
60is fac_1(5), 120, 'fac_1';
61is fac_2 6, 720, 'fac_2';
62is method ($y) { $self . $y }->(method () { $self + 1 }->(3), method () { $self * 2 }->(1)), '42', 'anonyfun';