From: Ben Morrow Date: Tue, 20 Jan 2009 16:22:03 +0000 (+0000) Subject: Test -X overloads on GLOB and IO refs. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d0c91b6afc4b6996418adda5f2d15f55b36abd90;p=p5sagit%2Fp5-mst-13.2.git Test -X overloads on GLOB and IO refs. --- diff --git a/t/op/filetest.t b/t/op/filetest.t index 69bed0b..59ed0be 100755 --- a/t/op/filetest.t +++ b/t/op/filetest.t @@ -10,7 +10,7 @@ BEGIN { } use Config; -plan(tests => 28 + 27*12); +plan(tests => 28 + 27*14); ok( -d 'op' ); ok( -f 'TEST' ); @@ -137,6 +137,12 @@ my $both = bless [], "OverBoth"; my $neither = bless [], "OverNeither"; my $nstr = overload::StrVal($neither); +open my $gv, "<", "TEST"; +bless $gv, "OverString"; +open my $io, "<", "TEST"; +$io = *{$io}{IO}; +bless $io, "OverString"; + for my $op (split //, "rwxoRWXOezsfdlpSbctugkTMBAC") { $over = []; ok( my $rv = eval "-$op \$ft", "overloaded -$op succeeds" ) @@ -152,6 +158,16 @@ for my $op (split //, "rwxoRWXOezsfdlpSbctugkTMBAC") { is( $rv, eval "-$op 'TEST'", "correct -$op on string overload" ); is( $over, 1, "string overload called for -$op" ); + my ($exp, $is) = $op eq "l" ? (1, "is") : (0, "not"); + + $over = 0; + eval "-$op \$gv"; + is( $over, $exp, "string overload $is called for -$op on GLOB" ); + + $over = 0; + eval "-$op \$io"; + is( $over, $exp, "string overload $is called for -$op on IO"); + $rv = eval "-$op \$both"; is( $rv, "-$op", "correct -$op on string/-X overload" );