perl-unicode

[Patch] ext/PerlIO/t/fallback.t gets haircut

2002-05-01 08:15:23
jhi,

A bit of noise from ext/PerlIO/t/fallback.t:

./perl -Ilib ext/PerlIO/t/fallback.t
1..8
ok 1 - opened iso-8859-1 file
"\N{U+20ac}" does not map to iso-8859-1 at ext/PerlIO/t/fallback.t line 21.
ok 2 - perlqq escapes
ok 3 - opened iso-8859-1 file
ok 4 - HTML escapes
ok 5 - Opened as ASCII
# 5c
ok 6 - Escaped non-mapped char
ok 7 - Opened as ASCII
# fffd
ok 8 - Unicode replacement char

The following patch will make it this way.

> ./perl -I./lib ext/PerlIO/t/fallback.t
1..9
ok 1 - opened iso-8859-1 file
ok 2 - FB_WARN message
ok 3 - perlqq escapes
ok 4 - opened iso-8859-1 file
ok 5 - HTML escapes
ok 6 - Opened as ASCII
# 5c
ok 7 - Escaped non-mapped char
ok 8 - Opened as ASCII
# fffd
ok 9 - Unicode replacement char

I know NI-XS will fix and enhance this test soon but for the time being you can use this for peace of mind.

Dan the Perl5 Porter

--- ext/PerlIO/t/fallback.t.prev        Mon Apr 29 02:10:37 2002
+++ ext/PerlIO/t/fallback.t     Thu May  2 00:11:06 2002
@@ -5,7 +5,7 @@
     @INC = '../lib';
     require "../t/test.pl";
     skip_all("No perlio") unless (find PerlIO::Layer 'perlio');
-    plan (8);
+    plan (9);
 }
 use Encode qw(:fallback_all);

@@ -13,12 +13,16 @@

 my $file = "fallback$$.txt";

-$PerlIO::encoding::fallback = Encode::PERLQQ;
-
-ok(open(my $fh,">encoding(iso-8859-1)",$file),"opened iso-8859-1 file");
-my $str = "\x{20AC}";
-print $fh $str,"0.02\n";
-close($fh);
+{
+    my $message = '';
+    local $SIG{__WARN__} = sub { $message = $_[0] };
+    $PerlIO::encoding::fallback = Encode::PERLQQ;
+ ok(open(my $fh,">encoding(iso-8859-1)",$file),"opened iso-8859-1 file");
+    my $str = "\x{20AC}";
+    print $fh $str,"0.02\n";
+    close($fh);
+    like($message, qr/does not map to iso-8859-1/o, "FB_WARN message");
+}

 open($fh,$file) || die "File cannot be re-opened";
 my $line = <$fh>;

<Prev in Thread] Current Thread [Next in Thread>