From: Gurusamy Sarathy Date: Wed, 12 Jul 2000 07:31:00 +0000 (+0000) Subject: get sprintf.t to adjust properly for 3-digit exponents X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=48237ddebcafead6ccafb1124390a1ce30560e1f;p=p5sagit%2Fp5-mst-13.2.git get sprintf.t to adjust properly for 3-digit exponents p4raw-id: //depot/perl@6380 --- diff --git a/t/op/sprintf.t b/t/op/sprintf.t index 0c2400c..b57eed9 100755 --- a/t/op/sprintf.t +++ b/t/op/sprintf.t @@ -34,29 +34,37 @@ for ($i = 1; @tests; $i++) { $x = sprintf(">$template<", defined @$evalData ? @$evalData : $evalData); substr($x, -1, 0) = $w if $w; - # $y may have 3 exponent digits, not 2 - my $r; - if (($y = $x) =~ s/([Ee][-+])0(\d)/$1$2/g) { - $y =~ s/^>\s+/>/; - $y =~ s/\s+<$/0/>00/; + } + # if result is right-adjusted, prepend extra space + elsif ($result =~ /^ /) { + $y =~ s/^>/> /; + } } if ($x eq ">$result<") { print "ok $i\n"; } - elsif ($r and $y eq ">$r<") # Some C libraries always give + elsif ($y eq ">$result<") # Some C libraries always give { # three-digit exponent print("ok $i >$result< $x # three-digit exponent accepted\n"); } else { - print("not ok $i >$template< >$data< >$result< $x", + $y = ($x eq $y ? "" : " => $y"); + print("not ok $i >$template< >$data< >$result< $x$y", $comment ? " # $comment\n" : "\n"); } } - + # In each of the the following lines, there are three required fields: # printf template, data to be formatted (as a Perl expression), and # expected result of formatting. An optional fourth field can contain