diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2002-10-27 22:15:15 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2002-10-27 22:15:15 +0000 |
commit | 74cfb115ac810480c0000dc742b20383c1578bac (patch) | |
tree | 316d96e5123617976f1637b143570c309a662045 /gnu/usr.bin/perl/t/io/crlf.t | |
parent | 453ade492b8e06c619009d6cd52a85cb04e8cf17 (diff) |
stock perl 5.8.0 from CPAN
Diffstat (limited to 'gnu/usr.bin/perl/t/io/crlf.t')
-rw-r--r-- | gnu/usr.bin/perl/t/io/crlf.t | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/gnu/usr.bin/perl/t/io/crlf.t b/gnu/usr.bin/perl/t/io/crlf.t new file mode 100644 index 00000000000..08ab4fe3b09 --- /dev/null +++ b/gnu/usr.bin/perl/t/io/crlf.t @@ -0,0 +1,44 @@ +#!./perl -w + +BEGIN { + chdir 't' if -d 't'; + @INC = qw(. ../lib); +} + +use Config; + +require "test.pl"; + +my $file = "crlf$$.dat"; +END { + unlink($file); +} + +if (find PerlIO::Layer 'perlio') { + 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 $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); + + 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; +} |