From: Lukas Mai Date: Tue, 19 Jun 2012 02:52:48 +0000 (+0200) Subject: test syntactic properties of generated code X-Git-Tag: v0.06~4^2~1^2~1^2~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9642eea071aac3fd29d8cdecc2c359589b6d3014;p=p5sagit%2FFunction-Parameters.git test syntactic properties of generated code --- diff --git a/t/precedence.t b/t/precedence.t new file mode 100644 index 0000000..c988bab --- /dev/null +++ b/t/precedence.t @@ -0,0 +1,31 @@ +#!perl + +use Test::More tests => 11; + +use warnings FATAL => 'all'; +use strict; + +use Function::Parameters; + +fun four { 2 + 2 } fun five() { 1 + four } + +fun quantum :() {; 0xf00d +} + +is four, 4, "basic sanity 1"; +is five, 5, "basic sanity 2"; +is quantum, 0xf00d, "basic sanity 3"; +is quantum / 2 #/ +, 0xf00d / 2, "basic sanity 4 - () proto"; + +is eval('my $x = fun forbidden {}'), undef, "statements aren't expressions"; +like $@, qr/syntax error/; + +is eval('my $x = { fun forbidden {} }'), undef, "statements aren't expressions 2 - electric boogaloo"; +like $@, qr/syntax error/; + +is fun { join '.', five, four }->(), '5.4', "can immedicall anon subs"; + +is 0 * fun {} + 42, 42, "* binds tighter than +"; +is 0 * fun { quantum / q#/ } +# } + 42, 42, "* binds tighter than + 2 - electric boogaloo";