In perl.git, the branch doy/subroutine-signatures has been updated <http://perl5.git.perl.org/perl.git/commitdiff/33db431570166eef70666e098b8edf1f8ded6c20?hp=74daaf02459a3b24035c9e5bf045dc8aebbf685b>
- Log ----------------------------------------------------------------- commit 33db431570166eef70666e098b8edf1f8ded6c20 Author: Jesse Luehrs <[email protected]> Date: Sat Sep 15 17:22:29 2012 -0500 more tests M t/comp/namedproto.t commit 68a25d063d2c4475751e6839f98cc481f29c469b Author: Jesse Luehrs <[email protected]> Date: Sat Sep 15 17:07:47 2012 -0500 fix test counts M t/comp/namedproto.t ----------------------------------------------------------------------- Summary of changes: t/comp/namedproto.t | 65 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 63 insertions(+), 2 deletions(-) diff --git a/t/comp/namedproto.t b/t/comp/namedproto.t index bc70003..f747cf9 100644 --- a/t/comp/namedproto.t +++ b/t/comp/namedproto.t @@ -57,6 +57,19 @@ sub is { failed($got, "'$expect'", $name); } +sub ok { + my ($got, $name) = @_; + $test = $test + 1; + if ($::TODO) { + $name .= " # TODO: $::TODO"; + } + if ($got) { + print "ok $test - $name\n"; + return 1; + } + failed($got, "a true value", $name); +} + sub skip { my ($desc) = @_; $test = $test + 1; @@ -77,7 +90,6 @@ sub no_warnings { } BEGIN { - print "1..23\n"; $test = 0; if (!is_miniperl) { require Scalar::Util; @@ -207,8 +219,57 @@ BEGIN { is(arg_length(@foo), '4FOO4BAR', "three args passed"); } +{ + my $x = 10; + + sub closure1 ($y) { + return $x * $y; + } + + is(closure1(3), 30, "closures work"); +} + +{ + my $x = 10; + + sub shadowing1 ($x) { + return $x + 5; + } + BEGIN { no_warnings("variable shadowing") } # XXX or do we want one? + + is(shadowing1(3), 8, "variable shadowing works"); +} + +{ + sub shadowing2 ($x) { + my $x = 10; + return $x + 5; + } + BEGIN { no_warnings("variable shadowing") } # XXX or do we want one? + + is(shadowing2(3), 15, "variable shadowing works"); +} + +{ local $TODO = "slurpy parameters not supported yet"; +{ + my $failed = !eval 'sub bad_slurpy_array (@foo, $bar) { }; 1'; + my $err = $@; + ok($failed, "slurpies must come last"); + like($err, qr/slurpy/, "slurpies must come last"); # XXX better regex +} + +{ + my $failed = !eval 'sub bad_slurpy_hash (%foo, $bar) { }; 1'; + my $err = $@; + ok($failed, "slurpies must come last"); + like($err, qr/slurpy/, "slurpies must come last"); # XXX better regex +} +no_warnings("invalid slurpy parameters"); +} + # Test UTF-8 BEGIN { no_warnings("end of compile time") } +no_warnings("end of runtime"); -1; +END { print "1..$test\n" } -- Perl5 Master Repository
