From: Lukas Mai Date: Wed, 18 Jul 2012 18:59:04 +0000 (+0200) Subject: test invalid prototype detection X-Git-Tag: v0.08~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b4f770c1d79568c6c9537579a4f917ab98eccfde;p=p5sagit%2FFunction-Parameters.git test invalid prototype detection --- diff --git a/t/prototype.t b/t/prototype.t new file mode 100644 index 0000000..35b6925 --- /dev/null +++ b/t/prototype.t @@ -0,0 +1,48 @@ +#!perl +use Test::More tests => 27; + +use warnings FATAL => 'all'; +use strict; + +use Function::Parameters; + +is eval 'fun :([) {}', undef; +like $@, qr/Illegal character in prototype/; + +is eval 'fun :([) {}', undef; +like $@, qr/Illegal character in prototype/; + +is eval 'fun :(][[[[[[) {}', undef; +like $@, qr/Illegal character in prototype/; + +is eval 'fun :(\;) {}', undef; +like $@, qr/Illegal character after '\\' in prototype/; + +is eval 'fun :(\[_;@]) {}', undef; +like $@, qr/Illegal character after '\\' in prototype/; + +is eval 'fun :(\+) {}', undef; +like $@, qr/Illegal character after '\\' in prototype/; + +is eval 'fun :(\\\\) {}', undef; +like $@, qr/Illegal character after '\\' in prototype/; + +is eval 'fun :([$]) {}', undef; +like $@, qr/Illegal character in prototype/; + +is eval 'fun :(\[_$]) {}', undef; +like $@, qr/Illegal character after '\\' in prototype/; + +{ + no warnings qw(illegalproto); + + ok eval 'fun :([) {}'; + ok eval 'fun :([) {}'; + ok eval 'fun :(][[[[[[) {}'; + ok eval 'fun :(\;) {}'; + ok eval 'fun :(\[_;@]) {}'; + ok eval 'fun :(\+) {}'; + ok eval 'fun :(\\\\) {}'; + ok eval 'fun :([$]) {}'; + ok eval 'fun :(\[_$]) {}'; +}