test symbolic types in import
[p5sagit/Function-Parameters.git] / t / imports.t
1 #!perl
2
3 use Test::More tests => 25;
4
5 use warnings FATAL => 'all';
6 use strict;
7
8 {
9         use Function::Parameters {};  # ZERO BABIES
10
11         is eval('fun foo :() {}; 1'), undef;
12         like $@, qr/syntax error/;
13 }
14
15 {
16         use Function::Parameters { pound => 'function' };
17
18         is eval('fun foo :() {}; 1'), undef;
19         like $@, qr/syntax error/;
20
21         pound foo_1($x) { $x }
22         is foo_1(2 + 2), 4;
23
24         no Function::Parameters qw(pound);
25
26         is eval('pound foo() {}; 1'), undef;
27         like $@, qr/syntax error/;
28 }
29
30 {
31         use Function::Parameters { pound => 'method' };
32
33         is eval('fun foo () {}; 1'), undef;
34         like $@, qr/syntax error/;
35
36         pound foo_2() { $self }
37         is foo_2(2 + 2), 4;
38
39         no Function::Parameters qw(pound);
40
41         is eval('pound unfoo :() {}; 1'), undef;
42         like $@, qr/syntax error/;
43 }
44
45 {
46         is eval('pound unfoo( ){}; 1'), undef;
47         like $@, qr/syntax error/;
48
49         use Function::Parameters { pound => 'classmethod' };
50
51         is eval('fun foo () {}; 1'), undef;
52         like $@, qr/syntax error/;
53
54         pound foo_3() { $class }
55         is foo_3(2 + 2), 4;
56
57         no Function::Parameters;
58
59         is eval('pound unfoo :lvalue{}; 1'), undef;
60         like $@, qr/syntax error/;
61 }
62
63 is eval('Function::Parameters->import(":QQQQ"); 1'), undef;
64 like $@, qr/valid identifier/;
65
66 is eval('Function::Parameters->import({":QQQQ" => "function"}); 1'), undef;
67 like $@, qr/valid identifier/;
68
69 is eval('Function::Parameters->import({"jetsam" => "QQQQ"}); 1'), undef;
70 like $@, qr/valid type/;