summaryrefslogtreecommitdiff
path: root/t/op/sprintf2.t
diff options
context:
space:
mode:
authorHugo van der Sanden <hv@crypt.org>2008-11-08 13:29:57 +0000
committerMarcus Holland-Moritz <mhx-perl@gmx.net>2008-11-09 04:22:15 +0000
commit53f65a9ef4a04e5ea5160b41d8a2658d35d8f4e5 (patch)
treebb4730c128ffb44ce052c2ff303525467a725bcc /t/op/sprintf2.t
parent8d06e08c4f7bbcd6ede7e25da37c216be42278e5 (diff)
downloadperl-53f65a9ef4a04e5ea5160b41d8a2658d35d8f4e5.tar.gz
"Perl_newSVpvf("%lld")" is broken
Message-Id: <200811081329.mA8DTv7e018896@zen.crypt.org> Plus some test cases. p4raw-id: //depot/perl@34780
Diffstat (limited to 't/op/sprintf2.t')
-rw-r--r--t/op/sprintf2.t28
1 files changed, 27 insertions, 1 deletions
diff --git a/t/op/sprintf2.t b/t/op/sprintf2.t
index 397c19ebf2..3e608d801e 100644
--- a/t/op/sprintf2.t
+++ b/t/op/sprintf2.t
@@ -6,7 +6,10 @@ BEGIN {
require './test.pl';
}
-plan tests => 1295;
+plan tests => 1319;
+
+use strict;
+use Config;
is(
sprintf("%.40g ",0.01),
@@ -139,3 +142,26 @@ foreach my $n (2**1e100, -2**1e100, 2**1e100/2**1e100) { # +Inf, -Inf, NaN
eval { my $f = sprintf("%f", $n); };
is $@, "", "sprintf(\"%f\", $n)";
}
+
+# test %ll formats with and without HAS_QUAD
+eval { my $q = pack "q", 0 };
+my $Q = $@ eq '';
+
+my @tests = (
+ [ '%lld' => '%d', [qw( 4294967296 -100000000000000 )] ],
+ [ '%lli' => '%i', [qw( 4294967296 -100000000000000 )] ],
+ [ '%llu' => '%u', [qw( 4294967296 100000000000000 )] ],
+ [ '%Ld' => '%d', [qw( 4294967296 -100000000000000 )] ],
+ [ '%Li' => '%i', [qw( 4294967296 -100000000000000 )] ],
+ [ '%Lu' => '%u', [qw( 4294967296 100000000000000 )] ],
+);
+
+for my $t (@tests) {
+ my($fmt, $conv) = @$t;
+ for my $num (@{$t->[2]}) {
+ my $w; local $SIG{__WARN__} = sub { $w = shift };
+ is(sprintf($fmt, $num), $Q ? $num : $fmt, "quad: $fmt -> $num");
+ like($w, $Q ? '' : qr/Invalid conversion in sprintf: "$conv"/, "warning: $fmt");
+ }
+}
+