X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fop%2Futf8decode.t;h=499049aab93398d8f22c716f4d8e957694ff610e;hb=96d9b9cd40f1d98fda790eb12b5cdbeef8b48a81;hp=cc2b26aaf3c72f293aa386a82e6b60adfc1b2fe0;hpb=ac829cc3fb088ab84d8c0df184b703b601212226;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/op/utf8decode.t b/t/op/utf8decode.t old mode 100755 new mode 100644 index cc2b26a..499049a --- 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";