This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
sprintf(): handle mangled formats better with utf8
[perl5.git] / t / op / sprintf.t
index 7ccb88d..551f5ac 100644 (file)
 
 BEGIN {
     chdir 't' if -d 't';
-    @INC = qw '../lib ../cpan/version/lib';
+    require './test.pl';
+    set_up_inc(qw '../lib ../cpan/version/lib');
 }
 use warnings;
 use version;
 use Config;
 use strict;
-require './test.pl';
+
 
 my @tests = ();
 my ($template, $data, $result, $comment, $w, $x, $evalData, $n, $p);
@@ -32,6 +33,9 @@ if ($^O eq 'VMS') {
 # No %Config.
 my $Is_Ultrix_VAX = $^O eq 'ultrix' && `uname -m` =~ /^VAX$/;
 
+# The most generic VAX catcher.
+my $Is_VAX_Float = (pack("d", 1) =~ /^[\x80\x10]\x40/);
+
 our $IS_EBCDIC = $::IS_EBCDIC;  # Solely to avoid the 'used once' warning
 our $IS_ASCII = $::IS_ASCII;   # Solely to avoid the 'used once' warning
 
@@ -51,7 +55,7 @@ while (<DATA>) {
         $data   =~ s/([eE])\-101$/${1}-56/;  # larger exponents
         $result =~ s/([eE])\-102$/${1}-57/;  #  "       "
     }
-    if ($Is_VMS_VAX || $Is_Ultrix_VAX) {
+    if ($Is_VMS_VAX || $Is_Ultrix_VAX || $Is_VAX_Float) {
        # VAX DEC C 5.3 at least since there is no
        # ccflags =~ /float=ieee/ on VAX.
        # AXP is unaffected whether or not it is using ieee.
@@ -111,25 +115,41 @@ for (@tests) {
     if ($comment =~ s/\s+skip:\s*(.*)//) {
        my $os  = $1;
        my $osv = exists $Config{osvers} ? $Config{osvers} : "0";
+       my $archname = $Config{archname};
        # >comment skip: all<
-       if ($os =~ /\ball\b/i) {
-           $skip = 1;
-       # >comment skip: VMS hpux:10.20<
-       } elsif ($os =~ /\b$^O(?::(\S+))?\b/i) {
-           my $vsn = defined $1 ? $1 : "0";
-           # Only compare on the the first pair of digits, as numeric
-           # compares do not like 2.6.10-3mdksmp or 2.6.8-24.10-default
-           s/^(\d+(\.\d+)?).*/$1/ for $osv, $vsn;
-           $skip = $vsn ? ($osv <= $vsn ? 1 : 0) : 1;
+       # >comment skip: solaris<
+        # >comment skip: x86_64-linux-ld<
+       if ($os =~ /\b(?:all|\Q$^O\E|\Q$archname\E)\b/i) {
+            $skip = 1;
+       } elsif ($os =~ /\b\Q$^O\E(?::(\S+))\b/i) {
+            # We can have the $^O followed by an optional condition.
+            # The condition, if present, can be one of:
+            # (1) starts with a digit...
+            #     the first pair of dot-separated digits is
+            #     tested numerically against $Config{osvers}
+            # (2) otherwise...
+            #     tested as a \b/i regex against $Config{archname}
+            my $cond = $1;
+            if ($cond =~ /^\d/) {
+                # >comment skip: hpux:10.20<
+                my $vsn = $cond;
+                # Only compare on the the first pair of digits, as numeric
+                # compares do not like 2.6.10-3mdksmp or 2.6.8-24.10-default
+                s/^(\d+(\.\d+)?).*/$1/ for $osv, $vsn;
+                $skip = $vsn ? ($osv <= $vsn ? 1 : 0) : 1;
+            } else {
+                # >comment skip: netbsd:vax-netbsd<
+                $skip = $archname =~ /\b\Q$cond\E\b/i;
+            }
        }
-       $skip and $comment =~ s/$/, failure expected on $^O $osv/;
+       $skip and $comment =~ s/$/, failure expected on $^O $osv $archname/;
     }
 
     if ($x eq ">$result<") {
         ok(1, join ' ', grep length, ">$result<", $comment);
     }
     elsif ($skip) {
-        ok(1, "skip $comment");
+      SKIP: { skip($comment, 1) }
     }
     elsif ($y eq ">$result<")  # Some C libraries always give
     {                          # three-digit exponent
@@ -163,9 +183,11 @@ for (@tests) {
 #
 # Tests that are expected to fail on a certain OS can be marked as such
 # by trailing the comment with a skip: section. Skips are tags separated
-# bu space consisting of a $^O optionally trailed with :osvers. In the
-# latter case, all os-levels below that are expected to fail. A special
-# tag 'all' is allowed for todo tests that should fail on any system
+# by space consisting of a $^O optionally trailed with :osvers or :archname.
+# In the osvers case, all os-levels below that are expected to fail.
+# In the archname case, an exact match is expected, unless the archname
+# begins (and ends) with a "/", in which case a regexp is expected.
+# A special tag 'all' is allowed for todo tests that should fail on any system
 #
 # >%G<   >1234567e96<  >1.23457E+102<   >exponent too big skip: os390<
 # >%.0g< >-0.0<        >-0<             >No minus skip: MSWin32 VMS hpux:10.20<
@@ -420,7 +442,7 @@ __END__
 > %.0g<     >[]<          > 0 MISSING<
 >%.2g<      >[]<          >0 MISSING<
 >%.2gC<      >[]<          >0C MISSING<
->%.0g<      >-0.0<        >-0<            >C99 standard mandates minus sign but C89 does not skip: MSWin32 VMS hpux:10.20 openbsd netbsd:1.5 irix darwin freebsd:4.9 android<
+>%.0g<      >-0.0<        >-0<            >C99 standard mandates minus sign but C89 does not skip: MSWin32 VMS netbsd:vax-netbsd hpux:10.20 openbsd netbsd:1.5 irix darwin freebsd:4.9 android<
 >%.0g<      >12345.6789<  >1e+04<
 >%#.0g<     >12345.6789<  >1.e+04<
 >%.2g<      >12345.6789<  >1.2e+04<
@@ -667,7 +689,7 @@ __END__
 >%*2$1d<       >[12, 3]<       >%*2$1d INVALID REDUNDANT<
 >%0v2.2d<      >''<    ><
 >%vc,%d<       >[63, 64, 65]<  >%vc,63 INVALID REDUNDANT<
->%v%,%d<       >[63, 64, 65]<  >%v%,63 INVALID REDUNDANT<
+>%v%,%d<       >[63, 64, 65]<  >%v%,63 INVALID INVALID REDUNDANT<
 >%vd,%d<       >["\x1", 2, 3]< >1,2 REDUNDANT<
 >%vf,%d<       >[1, 2, 3]<     >%vf,1 INVALID REDUNDANT<
 >%vF,%d<       >[1, 2, 3]<     >%vF,1 INVALID REDUNDANT<