11 sub f($$_) { my $x = shift; is("@_", $x) }
17 f("FOO xy", $foo, "xy");
18 f("BAR zt", $bar, "zt");
21 f("y 42", substr("xy",1,1));
22 f("1 42", ("abcdef" =~ /abc/));
23 f("not undef 42", $undef || "not undef");
24 f(" 42", -f "no_such_file");
25 f("FOOBAR 42", ($foo . $bar));
26 f("FOOBAR 42", ($foo .= $bar));
30 like( $@, qr/Not enough arguments for main::f at/ );
32 like( $@, qr/Too many arguments for main::f at/ );
35 my $_ = "quarante-deux";
38 f("FOO quarante-deux", $foo);
39 f("BAR quarante-deux", $bar);
40 f("y quarante-deux", substr("xy",1,1));
41 f("1 quarante-deux", ("abcdef" =~ /abc/));
42 f("not undef quarante-deux", $undef || "not undef");
43 f(" quarante-deux", -f "no_such_file");
44 f("FOOBAR quarante-deux", ($foo . $bar));
45 f("FOOBAR quarante-deux", ($foo .= $bar));
46 f("FOOBAR quarante-deux", $foo);
51 sub g(_) { is(shift, $expected) }
58 undef $expected; &g; # $_ not passed
59 { $expected = my $_ = "bar"; g() }
61 eval q{ sub wrong1 (_$); wrong1(1,2) };
62 like( $@, qr/Malformed prototype for main::wrong1/, 'wrong1' );
64 eval q{ sub wrong2 ($__); wrong2(1,2) };
65 like( $@, qr/Malformed prototype for main::wrong2/, 'wrong2' );
67 sub opt ($;_) { is($_[0], "seen"); ok(!defined $_[1], "; has precedence over _") }
70 sub unop (_) { is($_[0], 11, "unary op") }
71 unop 11, 22; # takes only the first parameter into account
73 sub mymkdir (_;$) { is("@_", $expected, "mymkdir") }
74 $expected = $_ = "mydir"; mymkdir();
75 mymkdir($expected = "foo");
76 $expected = "foo 493"; mymkdir foo => 0755;