diff options
author | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2006-10-18 12:54:34 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2006-10-18 12:54:34 +0000 |
commit | 236b555a187749e9d630e83756e3a33db4d7a249 (patch) | |
tree | 3bb58a247bfa2e93e12db0f23f4c51bb388d4082 /t/comp/uproto.t | |
parent | e573f90328e9db84c5405db01c52908bfac9286d (diff) | |
download | perl-236b555a187749e9d630e83756e3a33db4d7a249.tar.gz |
Improvements and fixes to the _ prototype
p4raw-id: //depot/perl@29035
Diffstat (limited to 't/comp/uproto.t')
-rw-r--r-- | t/comp/uproto.t | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/t/comp/uproto.t b/t/comp/uproto.t index ba7dcd6cd6..16c748a5bb 100644 --- a/t/comp/uproto.t +++ b/t/comp/uproto.t @@ -6,7 +6,7 @@ BEGIN { require "./test.pl"; } -plan(tests => 14); +plan(tests => 28); sub f($$_) { my $x = shift; is("@_", $x) } @@ -31,6 +31,29 @@ like( $@, qr/Not enough arguments for main::f at/ ); eval q{ f(1,2,3,4) }; like( $@, qr/Too many arguments for main::f at/ ); +{ + my $_ = "quarante-deux"; + $foo = "FOO"; + $bar = "BAR"; + f("FOO quarante-deux", $foo); + f("BAR quarante-deux", $bar); + f("y quarante-deux", substr("xy",1,1)); + f("1 quarante-deux", ("abcdef" =~ /abc/)); + f("not undef quarante-deux", $undef || "not undef"); + f(" quarante-deux", -f "no_such_file"); + f("FOOBAR quarante-deux", ($foo . $bar)); + f("FOOBAR quarante-deux", ($foo .= $bar)); + f("FOOBAR quarante-deux", $foo); +} + &f(""); # no error -# TODO: sub g(_) (doesn't work) +sub g(_) { is(shift, $expected) } + +$expected = "foo"; +g("foo"); +g($expected); +$_ = $expected; +g(); +undef $expected; &g; # $_ not passed +{ $expected = my $_ = "bar"; g() } |