summaryrefslogtreecommitdiff
path: root/ext/PerlIO-encoding
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2016-06-21 13:28:19 +0100
committerDavid Mitchell <davem@iabyn.com>2016-06-21 13:28:19 +0100
commit00ac85b948033a963c2554006b5836e7ffb379c9 (patch)
treec7b1165ff3f45133baca6a9c2795d082691bc03f /ext/PerlIO-encoding
parent76744982a904f21ca6ade6b1e09f5dd764508ca4 (diff)
downloadperl-00ac85b948033a963c2554006b5836e7ffb379c9.tar.gz
PerlIO-encoding/t/fallback.t: test for warning
The previous commit fixed a typo that had been present since this test script was created: WARN_ON_ERR misspelt as WARN_ON_ERROR. This means that one of the tests is now (correctly) issuing a warning. Rather than that spilling out onto STDERR, capture it and test it instead.
Diffstat (limited to 'ext/PerlIO-encoding')
-rw-r--r--ext/PerlIO-encoding/t/fallback.t21
1 files changed, 14 insertions, 7 deletions
diff --git a/ext/PerlIO-encoding/t/fallback.t b/ext/PerlIO-encoding/t/fallback.t
index d46e181a3c..cf3fdc325e 100644
--- a/ext/PerlIO-encoding/t/fallback.t
+++ b/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;
@@ -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_ERR;
+{
+ 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);