This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Spelling correction for consistency with pod/perldebguts.pod.
[perl5.git] / t / io / crlf.t
index f26ea0d..7fb4c1e 100644 (file)
@@ -2,8 +2,9 @@
 
 BEGIN {
     chdir 't' if -d 't';
-    @INC = qw(. ../lib);
-    require "test.pl";
+    require "./test.pl";
+    set_up_inc('../lib');
+    require "./charset_tools.pl";
     skip_all_without_perlio();
 }
 
@@ -11,6 +12,8 @@ use Config;
 
 
 my $file = tempfile();
+my $crlf = uni_to_native("\015\012");
+my $crcr = uni_to_native("\x0d\x0d");
 
 my $ungetc_count = 8200;    # Somewhat over the likely buffer size
 
@@ -22,13 +25,13 @@ my $ungetc_count = 8200;    # Somewhat over the likely buffer size
 
     my $text;
     { local $/; $text = <FOO> }
-    is(count_chars($text, "\015\012"), 0);
+    is(count_chars($text, $crlf), 0);
     is(count_chars($text, "\n"), 2000);
 
     binmode(FOO);
     seek(FOO,0,0);
     { local $/; $text = <FOO> }
-    is(count_chars($text, "\015\012"), 2000);
+    is(count_chars($text, $crlf), 2000);
 
     SKIP:
     {
@@ -37,7 +40,7 @@ my $ungetc_count = 8200;    # Somewhat over the likely buffer size
        skip("no PerlIO::scalar", 2 * $ungetc_count + 1)
            unless $Config{extensions} =~ m!\bPerlIO/scalar\b!;
        require PerlIO::scalar;
-       my $fcontents = join "", map {"$_\015\012"} "a".."zzz";
+       my $fcontents = join "", map {"$_$crlf"} "a".."zzz";
        open my $fh, "<:crlf", \$fcontents;
        local $/ = "xxx";
        local $_ = <$fh>;
@@ -80,8 +83,8 @@ my $ungetc_count = 8200;    # Somewhat over the likely buffer size
            close FOO;
            print join(" ", "#", map { sprintf("%02x", $_) } unpack("C*", $foo)),
            "\n";
-           like($foo, qr/\x0d\x0a$/);
-           unlike($foo, qr/\x0d\x0d/);
+           like($foo, qr/$crlf$/);
+           unlike($foo, qr/$crcr/);
        }
     }
 }