From: Lukas Mai Date: Sat, 23 Jun 2012 14:14:19 +0000 (+0200) Subject: test symbolic types in import X-Git-Tag: v0.06_01~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=247cbd51569ca45f32a541a19612561b950ff166;p=p5sagit%2FFunction-Parameters.git test symbolic types in import --- diff --git a/MANIFEST b/MANIFEST index 30f839a..770da24 100644 --- a/MANIFEST +++ b/MANIFEST @@ -22,6 +22,7 @@ t/eating_strict_error.fail t/eating_strict_error.t t/eating_strict_error_2.fail t/elsewhere.t +t/imports.t t/lexical.t t/lineno-torture.t t/lineno.t diff --git a/t/checkered_2.t b/t/checkered_2.t index 449474a..cc46171 100644 --- a/t/checkered_2.t +++ b/t/checkered_2.t @@ -9,7 +9,7 @@ use Function::Parameters { method => { check_argument_count => 1, shift => '$self', - attrs => ':method', + attributes => ':method', }, cathod => { diff --git a/t/imports.t b/t/imports.t new file mode 100644 index 0000000..526f64b --- /dev/null +++ b/t/imports.t @@ -0,0 +1,70 @@ +#!perl + +use Test::More tests => 25; + +use warnings FATAL => 'all'; +use strict; + +{ + use Function::Parameters {}; # ZERO BABIES + + is eval('fun foo :() {}; 1'), undef; + like $@, qr/syntax error/; +} + +{ + use Function::Parameters { pound => 'function' }; + + is eval('fun foo :() {}; 1'), undef; + like $@, qr/syntax error/; + + pound foo_1($x) { $x } + is foo_1(2 + 2), 4; + + no Function::Parameters qw(pound); + + is eval('pound foo() {}; 1'), undef; + like $@, qr/syntax error/; +} + +{ + use Function::Parameters { pound => 'method' }; + + is eval('fun foo () {}; 1'), undef; + like $@, qr/syntax error/; + + pound foo_2() { $self } + is foo_2(2 + 2), 4; + + no Function::Parameters qw(pound); + + is eval('pound unfoo :() {}; 1'), undef; + like $@, qr/syntax error/; +} + +{ + is eval('pound unfoo( ){}; 1'), undef; + like $@, qr/syntax error/; + + use Function::Parameters { pound => 'classmethod' }; + + is eval('fun foo () {}; 1'), undef; + like $@, qr/syntax error/; + + pound foo_3() { $class } + is foo_3(2 + 2), 4; + + no Function::Parameters; + + is eval('pound unfoo :lvalue{}; 1'), undef; + like $@, qr/syntax error/; +} + +is eval('Function::Parameters->import(":QQQQ"); 1'), undef; +like $@, qr/valid identifier/; + +is eval('Function::Parameters->import({":QQQQ" => "function"}); 1'), undef; +like $@, qr/valid identifier/; + +is eval('Function::Parameters->import({"jetsam" => "QQQQ"}); 1'), undef; +like $@, qr/valid type/;