summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2003-09-10 06:57:16 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2003-09-10 06:57:16 +0000
commitd3b4e16f4348ab55ddb8e9e8a4e27b46567d2855 (patch)
tree3a9d2dc19b5101a9ef5b5fa5ed2972ba62d9f83e /t
parent81cd54e3d8dc0f62b7c4bf5206036c9493ef5300 (diff)
downloadperl-d3b4e16f4348ab55ddb8e9e8a4e27b46567d2855.tar.gz
[perl #23770] Reading a latin1 file with open(... "<:utf8") will freeze
is no more valid, the script doesn't freeze, but I noticed that neither does the <FILE> complain about bad UTF-8 as it should and as it does with :encoding(utf8). p4raw-id: //depot/perl@21153
Diffstat (limited to 't')
-rwxr-xr-xt/io/utf8.t19
1 files changed, 16 insertions, 3 deletions
diff --git a/t/io/utf8.t b/t/io/utf8.t
index 50cc012fbc..aade3bd323 100755
--- a/t/io/utf8.t
+++ b/t/io/utf8.t
@@ -13,7 +13,7 @@ no utf8; # needed for use utf8 not griping about the raw octets
require "./test.pl";
-plan(tests => 51);
+plan(tests => 52);
$| = 1;
@@ -306,15 +306,28 @@ ok( 1 );
open F, ">a";
binmode F, ":utf8";
syswrite(F, $a = chr(0x100));
- close A;
+ close F;
is( ord($a), 0x100, '23428 syswrite should not downgrade scalar' );
like( $a, qr/^\w+/, '23428 syswrite should not downgrade scalar' );
}
# sysread() and syswrite() tested in lib/open.t since Fcntl is used
+{
+ # <FH> on a :utf8 stream should complain immediately
+ # if it finds bad UTF-8 (:encoding(utf8) works this way)
+ local $SIG{__WARN__} = sub { $@ = shift };
+ open F, ">a";
+ binmode F;
+ print F "foo", chr(0xE4), "\n";
+ close F;
+ open F, "<:utf8", "a";
+ my $line = <F>;
+ like( $@, qr/utf8 "\\xE4" does not map to Unicode/ );
+ close F;
+}
+
END {
1 while unlink "a";
1 while unlink "b";
}
-