summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/perl/t/io/crlf.t
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2003-12-03 02:44:40 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2003-12-03 02:44:40 +0000
commit0121b80e4f69c2ad9631e8d20b5c91f3b2a40434 (patch)
tree49a8ade446c1b6277c06982988700467e1be139c /gnu/usr.bin/perl/t/io/crlf.t
parent184128d6fb928711cdef9d8e6980dc6601fb1f87 (diff)
perl 5.8.2 from CPAN
Diffstat (limited to 'gnu/usr.bin/perl/t/io/crlf.t')
-rw-r--r--gnu/usr.bin/perl/t/io/crlf.t45
1 files changed, 43 insertions, 2 deletions
diff --git a/gnu/usr.bin/perl/t/io/crlf.t b/gnu/usr.bin/perl/t/io/crlf.t
index 08ab4fe3b09..2ee7b831912 100644
--- a/gnu/usr.bin/perl/t/io/crlf.t
+++ b/gnu/usr.bin/perl/t/io/crlf.t
@@ -11,11 +11,11 @@ require "test.pl";
my $file = "crlf$$.dat";
END {
- unlink($file);
+ 1 while unlink($file);
}
if (find PerlIO::Layer 'perlio') {
- plan(tests => 7);
+ plan(tests => 16);
ok(open(FOO,">:crlf",$file));
ok(print FOO 'a'.((('a' x 14).qq{\n}) x 2000) || close(FOO));
ok(open(FOO,"<:crlf",$file));
@@ -30,7 +30,48 @@ if (find PerlIO::Layer 'perlio') {
{ local $/; $text = <FOO> }
is(count_chars($text, "\015\012"), 2000);
+ SKIP:
+ {
+ eval 'use PerlIO::scalar';
+ skip(q/miniperl cannnot load PerlIO::scalar/)
+ if $@ =~ /dynamic loading not available/;
+ my $fcontents = join "", map {"$_\015\012"} "a".."zzz";
+ open my $fh, "<:crlf", \$fcontents;
+ local $/ = "xxx";
+ local $_ = <$fh>;
+ my $pos = tell $fh; # pos must be behind "xxx", before "\nyyy\n"
+ seek $fh, $pos, 0;
+ $/ = "\n";
+ $s = <$fh>.<$fh>;
+ ok($s eq "\nxxy\n");
+ }
+
ok(close(FOO));
+
+ # binmode :crlf should not cumulate.
+ # Try it first once and then twice so that even UNIXy boxes
+ # get to exercise this, for DOSish boxes even once is enough.
+ # Try also pushing :utf8 first so that there are other layers
+ # in between (this should not matter: CRLF layers still should
+ # not accumulate).
+ for my $utf8 ('', ':utf8') {
+ for my $binmode (1..2) {
+ open(FOO, ">$file");
+ # require PerlIO; print PerlIO::get_layers(FOO), "\n";
+ binmode(FOO, "$utf8:crlf") for 1..$binmode;
+ # require PerlIO; print PerlIO::get_layers(FOO), "\n";
+ print FOO "Hello\n";
+ close FOO;
+ open(FOO, "<$file");
+ binmode(FOO);
+ my $foo = scalar <FOO>;
+ close FOO;
+ print join(" ", "#", map { sprintf("%02x", $_) } unpack("C*", $foo)),
+ "\n";
+ ok($foo =~ /\x0d\x0a$/);
+ ok($foo !~ /\x0d\x0d/);
+ }
+ }
}
else {
skip_all("No perlio, so no :crlf");