summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/perl/ext/PerlIO-encoding/t/fallback.t
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/usr.bin/perl/ext/PerlIO-encoding/t/fallback.t')
-rwxr-xr-xgnu/usr.bin/perl/ext/PerlIO-encoding/t/fallback.t27
1 files changed, 17 insertions, 10 deletions
diff --git a/gnu/usr.bin/perl/ext/PerlIO-encoding/t/fallback.t b/gnu/usr.bin/perl/ext/PerlIO-encoding/t/fallback.t
index 17c241c17a0..3abdfd3f37c 100755
--- a/gnu/usr.bin/perl/ext/PerlIO-encoding/t/fallback.t
+++ b/gnu/usr.bin/perl/ext/PerlIO-encoding/t/fallback.t
@@ -16,7 +16,7 @@ BEGIN {
import Encode qw(:fallback_all);
}
-use Test::More tests => 9;
+use Test::More tests => 10;
# $PerlIO::encoding = 0; # WARN_ON_ERR|PERLQQ;
@@ -33,7 +33,7 @@ my $file = "fallback$$.txt";
like($message, qr/does not map to iso-8859-1/o, "FB_WARN message");
}
-open($fh,$file) || die "File cannot be re-opened";
+open($fh,'<',$file) || die "File cannot be re-opened";
my $line = <$fh>;
is($line,"\\x{20ac}0.02\n","perlqq escapes");
close($fh);
@@ -45,14 +45,14 @@ my $str = "\x{20AC}";
print $fh $str,"0.02\n";
close($fh);
-open($fh,$file) || die "File cannot be re-opened";
+open($fh,'<',$file) || die "File cannot be re-opened";
my $line = <$fh>;
is($line,"&#8364;0.02\n","HTML escapes");
close($fh);
{
no utf8;
- open($fh,">$file") || die "File cannot be re-opened";
+ open($fh,'>',$file) || die "File cannot be re-opened";
binmode($fh);
print $fh "\xA30.02\n";
close($fh);
@@ -64,13 +64,20 @@ printf "# %x\n",ord($line);
is($line,"\\xA30.02\n","Escaped non-mapped char");
close($fh);
-$PerlIO::encoding::fallback = Encode::WARN_ON_ERROR;
+{
+ my $message = '';
+ local $SIG{__WARN__} = sub { $message = $_[0] };
-ok(open($fh,"<encoding(US-ASCII)",$file),"Opened as ASCII");
-my $line = <$fh>;
-printf "# %x\n",ord($line);
-is($line,"\x{FFFD}0.02\n","Unicode replacement char");
-close($fh);
+ $PerlIO::encoding::fallback = Encode::WARN_ON_ERR;
+
+ ok(open($fh,"<encoding(US-ASCII)",$file),"Opened as ASCII");
+ my $line = <$fh>;
+ printf "# %x\n",ord($line);
+ is($line,"\x{FFFD}0.02\n","Unicode replacement char");
+ close($fh);
+
+ like($message, qr/does not map to Unicode/o, "FB_WARN message");
+}
END {
1 while unlink($file);