X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fop%2Futf8decode.t;h=499049aab93398d8f22c716f4d8e957694ff610e;hb=584420f022db57225e9644b9c6668ff9f567984a;hp=494aa8cfb812aa6d8586766a36baca3c6262195f;hpb=ffbc6a930f7d2050ba54ac6bb9f15db93c1fab59;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/op/utf8decode.t b/t/op/utf8decode.t index 494aa8c..499049a 100644 --- a/t/op/utf8decode.t +++ b/t/op/utf8decode.t @@ -3,7 +3,6 @@ BEGIN { chdir 't' if -d 't'; @INC = '../lib'; - } { @@ -137,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) { @@ -162,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) { @@ -176,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";