From: Abhijit Menon-Sen Date: Wed, 22 May 2002 05:47:35 +0000 (+0000) Subject: Integrate #16731 from //depot/macperl. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=887ede57d83d328c637502d4fb5599647674a16b;p=p5sagit%2Fp5-mst-13.2.git Integrate #16731 from //depot/macperl. p4raw-id: //depot/perl@16732 p4raw-integrated: from //depot/macperl@16729 'copy in' t/io/crlf.t (@16255..) --- diff --git a/t/io/crlf.t b/t/io/crlf.t index 0968b36..08ab4fe 100644 --- a/t/io/crlf.t +++ b/t/io/crlf.t @@ -15,29 +15,30 @@ END { } if (find PerlIO::Layer 'perlio') { - plan(tests => 6); + plan(tests => 7); ok(open(FOO,">:crlf",$file)); ok(print FOO 'a'.((('a' x 14).qq{\n}) x 2000) || close(FOO)); ok(open(FOO,"<:crlf",$file)); - my $seen = 0; - my $cr = "\r"; - while () - { - $seen += tr/[\015]//; - } - is($seen,0); + + my $text; + { local $/; $text = } + is(count_chars($text, "\015\012"), 0); + is(count_chars($text, "\n"), 2000); + binmode(FOO); seek(FOO,0,0); - $seen = 0; - while () - { - $seen += tr/[\015]//; - } - is($seen,2000); + { local $/; $text = } + is(count_chars($text, "\015\012"), 2000); + ok(close(FOO)); } else { skip_all("No perlio, so no :crlf"); } - +sub count_chars { + my($text, $chars) = @_; + my $seen = 0; + $seen++ while $text =~ /$chars/g; + return $seen; +}