Skip to content

Commit

Permalink
Test sprintf "%d" precision parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
zoffixznet committed Jan 22, 2017
1 parent dba88c9 commit 4e3fd00
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion S32-str/sprintf.t
Expand Up @@ -3,7 +3,7 @@ use lib <t/spec/packages>;
use Test;
use Test::Util;

plan 161;
plan 171;

# L<S32::Str/Str/"identical to" "C library sprintf">

Expand Down Expand Up @@ -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

0 comments on commit 4e3fd00

Please sign in to comment.