This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
APItest/t/utf8_warn_base.pl: Do formatting outside loop
authorKarl Williamson <khw@cpan.org>
Thu, 15 Jun 2017 21:45:14 +0000 (15:45 -0600)
committerKarl Williamson <khw@cpan.org>
Thu, 13 Jul 2017 03:14:24 +0000 (21:14 -0600)
To save extra effort

ext/XS-APItest/t/utf8_warn_base.pl

index ffd6af8..875bd26 100644 (file)
@@ -500,6 +500,8 @@ foreach my $test (@tests) {
     my $length = length $bytes;
     my $will_overflow = $allowed_uv < 0;
 
+    my $uv_string = sprintf(($allowed_uv < 0x100) ? "%02X" : "%04X", $allowed_uv);
+
     # The convention is that the got flag is the same value as the disallow
     # one, and the warn flag is the next bit over.  If this were violated, the
     # tests here should start failing.  We could do an eval under no strict to
@@ -786,7 +788,7 @@ foreach my $test (@tests) {
                     else {
                         is($ret_ref->[0], $expected_uv,
                                 "$this_name: Returns expected uv: "
-                                . sprintf("0x%04X", $expected_uv))
+                                . $uv_string)
                           or diag "Call was: " . utf8n_display_call($eval_text);
                     }
                     is($ret_ref->[1], $this_expected_len,