From: Jarkko Hietaniemi Date: Sun, 3 Feb 2002 15:27:26 +0000 (+0000) Subject: [PATCH t/op/taint.t] remove possible false positive X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1d662fb62e71ab3e37603febfa8212dd1e7e7f7e;p=p5sagit%2Fp5-mst-13.2.git [PATCH t/op/taint.t] remove possible false positive From: Rafael Garcia-Suarez Date: Sat, 2 Feb 2002 13:11:01 +0100 Message-ID: <20020202131101.A722@rafael> Subject: [PATCH t/op/ver.t] another false positive From: Rafael Garcia-Suarez Date: Sat, 2 Feb 2002 13:38:22 +0100 Message-ID: <20020202133822.E722@rafael> Subject: [PATCH] t/test.pl:ok() doesn't work From: sthoenna@efn.org (Yitzchak Scott-Thoennes) Date: Sun, 03 Feb 2002 00:02:38 -0800 Message-ID: p4raw-id: //depot/perl@14529 --- diff --git a/lib/Net/t/netrc.t b/lib/Net/t/netrc.t index 885b515..464794b 100644 --- a/lib/Net/t/netrc.t +++ b/lib/Net/t/netrc.t @@ -58,7 +58,8 @@ SKIP: { $stat[2] = 077; ok( !defined(Net::Netrc::_readrc()), '_readrc() should not read world-writable file' ); - ok( $warn =~ /^Bad permissions:/, '... and should warn about it' ); + ok( scalar( $warn =~ /^Bad permissions:/ ), + '... and should warn about it' ); # the owner field should still not match $stat[2] = 0; @@ -66,7 +67,8 @@ SKIP: { if ($<) { ok( !defined(Net::Netrc::_readrc()), '_readrc() should not read file owned by someone else' ); - ok( $warn =~ /^Not owner:/, '... and should warn about it' ); + ok( scalar( $warn =~ /^Not owner:/ ), + '... and should warn about it' ); } else { ok(1, "Skip - testing as root") for 1..2; } diff --git a/t/op/stat.t b/t/op/stat.t index ad87c25..6bb3315 100755 --- a/t/op/stat.t +++ b/t/op/stat.t @@ -336,14 +336,14 @@ SKIP: { ok(! -B FOO, ' !-B'); $_ = ; - ok(/perl/, 'after readline'); + like($_, qr/perl/, 'after readline'); ok(-T FOO, ' still -T'); ok(! -B FOO, ' still -B'); close(FOO); open(FOO,'op/stat.t'); $_ = ; - ok(/perl/, 'reopened and after readline'); + like($_, qr/perl/, 'reopened and after readline'); ok(-T FOO, ' still -T'); ok(! -B FOO, ' still !-B'); diff --git a/t/op/taint.t b/t/op/taint.t index 7c83019..63fc32e 100755 --- a/t/op/taint.t +++ b/t/op/taint.t @@ -16,7 +16,7 @@ use strict; use Config; my $test = 177; -sub ok { +sub ok ($;$) { my($ok, $name) = @_; # You have to do it this way or VMS will get confused. diff --git a/t/op/ver.t b/t/op/ver.t index a7e57a6..1dc28d2 100755 --- a/t/op/ver.t +++ b/t/op/ver.t @@ -191,7 +191,7 @@ SKIP: { my $ip = v2004.148.0.1; my $host; eval { $host = gethostbyaddr($ip,Socket::AF_INET) }; - ok($@ =~ /Wide character/,"Non-bytes leak to gethostbyaddr"); + like($@, qr/Wide character/, "Non-bytes leak to gethostbyaddr"); } # Chapter 28, pp671 diff --git a/t/test.pl b/t/test.pl index e737665..be052b5 100644 --- a/t/test.pl +++ b/t/test.pl @@ -77,6 +77,7 @@ sub _where { return "at $caller[1] line $caller[2]"; } +# DON'T use this for matches. Use like() instead. sub ok { my ($pass, $name, @mess) = @_; _ok($pass, _where(), $name, @mess);