summaryrefslogtreecommitdiff
path: root/t/io/crlf.t
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-09-27 20:07:32 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-09-27 20:07:32 +0000
commit14b1a0c4873dd26867581787ac2b4ee054e3b2a1 (patch)
tree38978b696797cc491068598fb65116b65d1b1bcd /t/io/crlf.t
parent362eead3a268d127e89be572afb78c2557c1c3ad (diff)
downloadperl-14b1a0c4873dd26867581787ac2b4ee054e3b2a1.tar.gz
Comment nit by Vadim Konovalov
And while we're at it, reindent consistently. p4raw-id: //depot/perl@25625
Diffstat (limited to 't/io/crlf.t')
-rw-r--r--t/io/crlf.t116
1 files changed, 58 insertions, 58 deletions
diff --git a/t/io/crlf.t b/t/io/crlf.t
index be514003a5..c3c23e04ac 100644
--- a/t/io/crlf.t
+++ b/t/io/crlf.t
@@ -15,72 +15,72 @@ END {
}
if (find PerlIO::Layer 'perlio') {
- 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));
+ 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));
- my $text;
- { local $/; $text = <FOO> }
- is(count_chars($text, "\015\012"), 0);
- is(count_chars($text, "\n"), 2000);
+ my $text;
+ { local $/; $text = <FOO> }
+ is(count_chars($text, "\015\012"), 0);
+ is(count_chars($text, "\n"), 2000);
- binmode(FOO);
- seek(FOO,0,0);
- { local $/; $text = <FOO> }
- is(count_chars($text, "\015\012"), 2000);
+ binmode(FOO);
+ seek(FOO,0,0);
+ { local $/; $text = <FOO> }
+ is(count_chars($text, "\015\012"), 2000);
- SKIP:
- {
- skip("miniperl can't rely on loading PerlIO::scalar")
- if $ENV{PERL_CORE_MINITEST};
- skip("no PerlIO::scalar") unless $Config{extensions} =~ m!\bPerlIO/scalar\b!;
- require PerlIO::scalar;
- 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");
- }
+ SKIP:
+ {
+ skip("miniperl can't rely on loading PerlIO::scalar")
+ if $ENV{PERL_CORE_MINITEST};
+ skip("no PerlIO::scalar") unless $Config{extensions} =~ m!\bPerlIO/scalar\b!;
+ require PerlIO::scalar;
+ 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 "\nxxy\n"
+ seek $fh, $pos, 0;
+ $/ = "\n";
+ $s = <$fh>.<$fh>;
+ ok($s eq "\nxxy\n");
+ }
- ok(close(FOO));
+ 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/);
- }
- }
+ # 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");
+ skip_all("No perlio, so no :crlf");
}
sub count_chars {
- my($text, $chars) = @_;
- my $seen = 0;
- $seen++ while $text =~ /$chars/g;
- return $seen;
+ my($text, $chars) = @_;
+ my $seen = 0;
+ $seen++ while $text =~ /$chars/g;
+ return $seen;
}