test syntactic properties of generated code
[p5sagit/Function-Parameters.git] / t / precedence.t
1 #!perl
2
3 use Test::More tests => 11;
4
5 use warnings FATAL => 'all';
6 use strict;
7
8 use Function::Parameters;
9
10 fun four { 2 + 2 } fun five() { 1 + four }
11
12 fun quantum :() {; 0xf00d
13 }
14
15 is four, 4, "basic sanity 1";
16 is five, 5, "basic sanity 2";
17 is quantum, 0xf00d, "basic sanity 3";
18 is quantum / 2 #/
19 , 0xf00d / 2, "basic sanity 4 - () proto";
20
21 is eval('my $x = fun forbidden {}'), undef, "statements aren't expressions";
22 like $@, qr/syntax error/;
23
24 is eval('my $x = { fun forbidden {} }'), undef, "statements aren't expressions 2 - electric boogaloo";
25 like $@, qr/syntax error/;
26
27 is fun { join '.', five, four }->(), '5.4', "can immedicall anon subs";
28
29 is 0 * fun {} + 42, 42, "* binds tighter than +";
30 is 0 * fun { quantum / q#/ }
31 # } + 42, 42, "* binds tighter than + 2 - electric boogaloo";