From acbd132f67ad3746742c9e471142632e10bb9acc Mon Sep 17 00:00:00 2001 From: Jarkko Hietaniemi Date: Sat, 8 Apr 2006 21:25:33 +0300 Subject: sv.c, rs.t, perlvar.pod (Coverity finding: did you know what happens with $/=\0?) Message-Id: <20060408152533.C4D5F6D08C@ugli.hut.fi> (although I should add that this version of Coverity is actually raising a false positive here, albeit something still interesting) p4raw-id: //depot/perl@27744 --- t/base/rs.t | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 't/base') diff --git a/t/base/rs.t b/t/base/rs.t index f89c84e3a0..d06fa7346f 100755 --- a/t/base/rs.t +++ b/t/base/rs.t @@ -1,7 +1,7 @@ #!./perl # Test $! -print "1..16\n"; +print "1..17\n"; $teststring = "1\n12\n123\n1234\n1234\n12345\n\n123456\n1234567\n"; @@ -86,6 +86,11 @@ $/ = \$foo; $bar = ; if ($bar eq "78") {print "ok 10\n";} else {print "not ok 10\n";} +# Naughty straight number - should get the rest of the file +$/ = \0; +$bar = ; +if ($bar eq "90123456789012345678901234567890") {print "ok 11\n";} else {print "not ok 11\n";} + close TESTFILE; # Now for the tricky bit--full record reading @@ -110,23 +115,23 @@ if ($^O eq 'VMS') { open TESTFILE, "<./foo.bar"; $/ = \10; $bar = ; - if ($bar eq "foo\n") {print "ok 11\n";} else {print "not ok 11\n";} + if ($bar eq "foo\n") {print "ok 12\n";} else {print "not ok 12\n";} $bar = ; - if ($bar eq "foobar\n") {print "ok 12\n";} else {print "not ok 12\n";} + if ($bar eq "foobar\n") {print "ok 13\n";} else {print "not ok 13\n";} # can we do a short read? $/ = \2; $bar = ; - if ($bar eq "ba") {print "ok 13\n";} else {print "not ok 13\n";} + if ($bar eq "ba") {print "ok 14\n";} else {print "not ok 14\n";} # do we get the rest of the record? $bar = ; - if ($bar eq "z\n") {print "ok 14\n";} else {print "not ok 14\n";} + if ($bar eq "z\n") {print "ok 15\n";} else {print "not ok 15\n";} close TESTFILE; 1 while unlink qw(foo.bar foo.com foo.fdl); } else { # Nobody else does this at the moment (well, maybe OS/390, but they can # put their own tests in) so we just punt - foreach $test (11..14) {print "ok $test # skipped on non-VMS system\n"}; + foreach $test (12..15) {print "ok $test # skipped on non-VMS system\n"}; } $/ = "\n"; @@ -142,7 +147,7 @@ $/ = "\n"; else { print "not "; } - print "ok 15\n"; + print "ok 16\n"; } { @@ -155,7 +160,7 @@ $/ = "\n"; else { print "not "; } - print "ok 16\n"; + print "ok 17\n"; } # Get rid of the temp file -- cgit v1.2.1