From: Lukas Mai Date: Tue, 19 Jun 2012 02:53:59 +0000 (+0200) Subject: test lexicalpragmatude X-Git-Tag: v0.06~4^2~1^2~1^2~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f90b3c0b49f0f30edb8d2328639ee35140ac288d;p=p5sagit%2FFunction-Parameters.git test lexicalpragmatude --- diff --git a/t/lexical.t b/t/lexical.t new file mode 100644 index 0000000..69382ef --- /dev/null +++ b/t/lexical.t @@ -0,0 +1,62 @@ +#!perl + +use Test::More tests => 16; + +use warnings FATAL => 'all'; +use strict; + +sub Burlap::fun (&) { $_[0]->() } + +{ + use Function::Parameters; + + is fun { 2 + 2 }->(), 4; + + package Burlap; + + ::ok fun { 0 }; +} + +{ + package Burlap; + + ::is fun { 'singing' }, 'singing'; +} + +{ + sub proc (&) { &Burlap::fun } + + use Function::Parameters { proc => 'function' }; + + proc add($x, $y) { + return $x + $y; + } + + is add(@{[2, 3]}), 5; + + { + use Function::Parameters; + + is proc () { 'bla' }->(), 'bla'; + is method () { $self }->('der'), 'der'; + + { + no Function::Parameters; + + is proc { 'unk' }, 'unk'; + + is eval('fun foo($x) { $x; } 1'), undef; + like $@, qr/syntax error/; + } + + is proc () { 'bla' }->(), 'bla'; + is method () { $self }->('der'), 'der'; + + no Function::Parameters 'proc'; + is proc { 'unk2' }, 'unk2'; + is method () { $self }->('der2'), 'der2'; + } + is proc () { 'bla3' }->(), 'bla3'; + is eval('fun foo($x) { $x; } 1'), undef; + like $@, qr/syntax error/; +}