IRIX failure with long doubles.
[p5sagit/p5-mst-13.2.git] / t / op / pack.t
index f217934..6b81236 100755 (executable)
@@ -6,7 +6,7 @@ BEGIN {
     require './test.pl';
 }
 
-plan tests => 5179;
+plan tests => 5619;
 
 use strict;
 use warnings;
@@ -751,13 +751,19 @@ foreach (
 }
 
 {  # Repeat count [SUBEXPR]
-   my @codes = qw( x A Z a c C B b H h s v n S i I l V N L p P f F d D
-                  s! S! i! I! l! L! );
+   my @codes = qw( x A Z a c C B b H h s v n S i I l V N L p P f F d
+                  s! S! i! I! l! L! j J);
+   my $G;
    if (eval { pack 'q', 1 } ) {
      push @codes, qw(q Q);
    } else {
      push @codes, qw(c C);     # Keep the count the same
    }
+   if (eval { pack 'D', 1 } ) {
+     push @codes, 'D';
+   } else {
+     push @codes, 'd'; # Keep the count the same
+   }
 
    my %val;
    @val{@codes} = map { / [Xx]  (?{ undef })
@@ -766,7 +772,7 @@ foreach (
                        | c     (?{ 114 })
                        | [Bb]  (?{ '101' })
                        | [Hh]  (?{ 'b8' })
-                       | [svnSiIlVNLqQ]  (?{ 10111 })
+                       | [svnSiIlVNLqQjJ]  (?{ 10111 })
                        | [FfDd]  (?{ 1.36514538e67 })
                        | [pP]  (?{ "try this buffer" })
                        /x; $^R } @codes;
@@ -834,7 +840,9 @@ is(scalar unpack('A /A /A Z20', '3004bcde'), 'bcde');
   ok( length $p);
   my @b = unpack "$t X[$t] $t", $p;    # Extract, step back, extract again
   is(scalar @b, 2 * scalar @a);
-  is("@b", "@a @a");
+  $b = "@b";
+  $b =~ s/(?:17000+|16999+)\d+(e-45) /17$1 /gi; # stringification is gamble
+  is($b, "@a @a");
 
   my $warning;
   local $SIG{__WARN__} = sub {
@@ -844,5 +852,24 @@ is(scalar unpack('A /A /A Z20', '3004bcde'), 'bcde');
 
   is($warning, undef);
   is(scalar @b, scalar @a);
-  is("@b", "@a");
+  $b = "@b";
+  $b =~ s/(?:17000+|16999+)\d+(e-45) /17$1 /gi; # stringification is gamble
+  is($b, "@a");
+}
+
+is(length(pack("j", 0)), $Config{ivsize});
+is(length(pack("J", 0)), $Config{uvsize});
+is(length(pack("F", 0)), $Config{nvsize});
+
+numbers ('j', -2147483648, -1, 0, 1, 2147483647);
+numbers ('J', 0, 1, 2147483647, 2147483648, 4294967295);
+numbers ('F', -(2**34), -1, 0, 1, 2**34);
+SKIP: {
+    my $t = eval { unpack("D*", pack("D", 12.34)) };
+
+    skip "Long doubles not in use", 56 if $@ =~ /Invalid type in pack/;
+
+    is(length(pack("D", 0)), $Config{longdblsize});
+    numbers ('D', -(2**34), -1, 0, 1, 2**34);
 }
+