Skip to content

Commit

Permalink
add sprintf tests from RT tickets
Browse files Browse the repository at this point in the history
  • Loading branch information
FROGGS committed Aug 23, 2013
1 parent ffb801f commit 2647c16
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions S32-str/sprintf.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 128;
plan 135;

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

Expand Down Expand Up @@ -204,11 +204,28 @@ is sprintf('%s', -Inf), -Inf, 'sprintf %s handles Inf';

is sprintf('%d %1$x %1$o', 12), '12 c 14', 'positional argument specifier $';

# RT #74610
dies_ok {sprintf "%s"}, 'missing sprintf string argument';

# RT 117547
is sprintf('%10s', "" x 3), ' ☃☃☃', 'multi-byte characters are counted correctly for %Ns strings';

is sprintf("%x %x", 301281685344656640, 301281685344656669), '42e5e18b84c9d00 42e5e18b84c9d1d', 'RT #118601';
is sprintf("%d", 42**20), '291733167875766667063796853374976', 'RT #118253';
is map({chars sprintf "[%18s]\n", "" x $_ }, 0..6), [21, 21, 21, 21, 21, 21, 21], 'RT #117547';
is Date.new(-13_000_000_000, 1, 1), '-13000000000-01-01', 'RT #114760';

# RT #116280
{
#?rakudo.parrot todo "sprintf printf numbers before NaN"
#?rakudo.jvm 3 skip "java.lang.NumberFormatException"
is sprintf('%12.5f', NaN), ' NaN', 'RT #116280';
#?rakudo.parrot 2 skip "sprintf hangs when printing Inf/-Inf"
is sprintf('%12.5f', Inf), ' Inf', 'RT #116280';
is sprintf('%12.5f', -Inf), ' -Inf', 'RT #116280';
}

# RT #106594, #62316, #74610
{
try sprintf("%d-%s", 42);
is $!, 'Too many directives: found 2, but only 1 arguments after the format string', 'RT #106594, #62316, #74610';
}

# vim: ft=perl6

0 comments on commit 2647c16

Please sign in to comment.