From 4e3fd00b260bd6569de015f087251f1e557b9abf Mon Sep 17 00:00:00 2001 From: Zoffix Znet Date: Sat, 21 Jan 2017 21:38:28 -0500 Subject: [PATCH] Test sprintf "%d" precision parameter Rakudo fix: https://github.com/rakudo/rakudo/commit/a1c7d01502 NQP fix: https://github.com/perl6/nqp/commit/1de45e4a3dcd8a9ce --- S32-str/sprintf.t | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/S32-str/sprintf.t b/S32-str/sprintf.t index b1a9346bc3..912d2e9d72 100644 --- a/S32-str/sprintf.t +++ b/S32-str/sprintf.t @@ -3,7 +3,7 @@ use lib ; use Test; use Test::Util; -plan 161; +plan 171; # L @@ -291,4 +291,18 @@ is Date.new(-13_000_000_000, 1, 1), '-13000000000-01-01 }, 'sprintf($format) does not issue spurious warnings'; } +{ # https://irclog.perlgeek.de/perl6-dev/2017-01-22#i_13966753 + is sprintf( '%.3d', [42]), '042', '%.3d'; + is sprintf('%2.4d', [42]), '0042', '%2.4d'; + is sprintf('%5.3d', [42]), ' 042', '%5.3d'; + is sprintf( '%.0d', [42]), '42', '%.0d (non-zero number)'; + is sprintf( '%.0d', [ 0]), '', '%.0d (number is zero)' ; + + is sprintf( '%.*d', [3, 42]), '042', '%.*d'; + is sprintf('%2.*d', [4, 42]), '0042', '%2.*d'; + is sprintf('%5.*d', [3, 42]), ' 042', '%5.*d'; + is sprintf( '%.*d', [0, 42]), '42', '%.*d (non-zero number)'; + is sprintf( '%.*d', [0, 0]), '', '%.*d (number is zero)'; +} + # vim: ft=perl6