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