summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>2002-05-22 20:34:55 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>2002-05-22 20:34:55 +0000
commit247fb02e864fbacf2e3a11c336199cde6431ca07 (patch)
tree7c119b3a94c8eb7769d0293d01d76290a247b55b /t
parent8849edfd7e990957ceb72629c600ff2b74b838b1 (diff)
parentfdf4829643c900179386b7b25f562008c3612a69 (diff)
downloadperl-247fb02e864fbacf2e3a11c336199cde6431ca07.tar.gz
Integrate mainline
p4raw-id: //depot/perlio@16738
Diffstat (limited to 't')
-rw-r--r--t/io/crlf.t31
1 files changed, 16 insertions, 15 deletions
diff --git a/t/io/crlf.t b/t/io/crlf.t
index 0968b3653d..08ab4fe3b0 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 (<FOO>)
- {
- $seen += tr/[\015]//;
- }
- is($seen,0);
+
+ my $text;
+ { local $/; $text = <FOO> }
+ is(count_chars($text, "\015\012"), 0);
+ is(count_chars($text, "\n"), 2000);
+
binmode(FOO);
seek(FOO,0,0);
- $seen = 0;
- while (<FOO>)
- {
- $seen += tr/[\015]//;
- }
- is($seen,2000);
+ { local $/; $text = <FOO> }
+ 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;
+}