summaryrefslogtreecommitdiff
path: root/t/op/utf8decode.t
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-09-11 02:27:25 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-09-11 02:27:25 +0000
commit35bcd33832d74e56bb99eb6538654e7d815f1ecb (patch)
treec0c43519dc41a137b1ccb0aefeea8b4dc196d1ca /t/op/utf8decode.t
parentb99a9337068178db918a66ac51ed0232330878fc (diff)
downloadperl-35bcd33832d74e56bb99eb6538654e7d815f1ecb.tar.gz
Fix unpack U to be the reverse of pack U
(but implement unpack U0U as a backdoor to get the UTF-8 malformed warnings from un-UTF-8 data) p4raw-id: //depot/perl@11993
Diffstat (limited to 't/op/utf8decode.t')
-rw-r--r--t/op/utf8decode.t34
1 files changed, 15 insertions, 19 deletions
diff --git a/t/op/utf8decode.t b/t/op/utf8decode.t
index cc2b26aaf3..499049aab9 100644
--- a/t/op/utf8decode.t
+++ b/t/op/utf8decode.t
@@ -136,24 +136,21 @@ __EOMK__
# 104..181
{
- my $WARNCNT;
my $id;
- local $SIG{__WARN__} =
- sub {
- print "# $id: @_";
- $WARNCNT++;
- $WARNMSG = "@_";
- };
+ local $SIG{__WARN__} = sub {
+ print "# $id: @_";
+ $@ = "@_";
+ };
sub moan {
print "$id: @_";
}
- sub test_unpack_U {
- $WARNCNT = 0;
- $WARNMSG = "";
- unpack('U*', $_[0]);
+ sub warn_unpack_U {
+ $@ = '';
+ my @null = unpack('U0U*', $_[0]);
+ return $@;
}
for (@MK) {
@@ -161,7 +158,7 @@ __EOMK__
# print "# $_\n";
} elsif (/^(\d+\.\d+\.\d+[bu]?)\s+([yn])\s+"(.+)"\s+([0-9a-f]{1,8}|-)\s+(\d+)\s+([0-9a-f]{2}(?::[0-9a-f]{2})*)(?:\s+((?:\d+|-)(?:\s+(.+))?))?$/) {
$id = $1;
- my ($okay, $bytes, $Unicode, $byteslen, $hex, $charslen, $error) =
+ my ($okay, $bytes, $Unicode, $byteslen, $hex, $charslen, $experr) =
($2, $3, $4, $5, $6, $7, $8);
my @hex = split(/:/, $hex);
unless (@hex == $byteslen) {
@@ -175,20 +172,19 @@ __EOMK__
moan "bytes length() ($bytesbyteslen) not equal to $byteslen\n";
}
}
+ my $warn = warn_unpack_U($bytes);
if ($okay eq 'y') {
- test_unpack_U($bytes);
- if ($WARNCNT) {
- moan "unpack('U*') false negative\n";
+ if ($warn) {
+ moan "unpack('U0U*') false negative\n";
print "not ";
}
} elsif ($okay eq 'n') {
- test_unpack_U($bytes);
- if ($WARNCNT == 0 || ($error ne '' && $WARNMSG !~ /$error/)) {
- moan "unpack('U*') false positive\n";
+ if (not $warn || ($experr ne '' && $warn !~ /$experr/)) {
+ moan "unpack('U0U*') false positive\n";
print "not ";
}
}
- print "ok $test\n";
+ print "ok $test # $id $okay\n";
$test++;
} else {
moan "unknown format\n";