-
-
Save FROGGS/0fdcdde74679e512f097 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/sprintf.nqp b/sprintf.nqp | |
index 41942ab..ea9ebee 100644 | |
--- a/sprintf.nqp | |
+++ b/sprintf.nqp | |
@@ -80,6 +80,9 @@ grammar sprintf::Grammar { | |
token directive:sym<b> { '%' <flags>* <size>? [ '.' <precision=.size> ]? $<sym>=<[bB]> } | |
token directive:sym<c> { '%' <flags>* <size>? <sym> } | |
token directive:sym<d> { '%' <flags>* <size>? <[di]> } | |
+ token directive:sym<f> { '%' <flags>* <size>? [ '.' <precision=.size> ]? $<sym>=<[fF]> } | |
+ token directive:sym<e> { '%' <flags>* <size>? [ '.' <precision=.size> ]? $<sym>=<[eE]> } | |
+ token directive:sym<g> { '%' <flags>* <size>? [ '.' <precision=.size> ]? $<sym>=<[gG]> } | |
token directive:sym<o> { '%' <flags>* <size>? [ '.' <precision=.size> ]? <sym> } | |
token directive:sym<s> { '%' <flags>* <size>? <sym> } | |
token directive:sym<u> { '%' <flags>* <size>? <sym> } | |
@@ -144,7 +147,8 @@ class sprintf::Actions { | |
sub padding_char($st) { | |
my $padding_char := ' '; | |
- unless $st<precision> || has_flag($st, 'minus') { | |
+ if (!$st<precision> && !has_flag($st, 'minus')) | |
+ || $st<sym> ~~ /<[fF]>/ { | |
$padding_char := '0' if $_<zero> for $st<flags>; | |
} | |
make $padding_char | |
@@ -190,6 +194,39 @@ class sprintf::Actions { | |
} | |
method directive:sym<d>($/) { | |
my $int := intify(next_argument()); | |
+ my $pad := padding_char($/); | |
+ if $pad ne ' ' && $<size> { | |
+ my $sign := $int < 0 ?? '-' !! ''; | |
+ $int := nqp::abs_i($int); | |
+ $int := $sign ~ infix_x($pad, $<size>.ast - nqp::chars($int) - 1) ~ $int | |
+ } | |
+ make $int | |
+ } | |
+ method directive:sym<f>($/) { | |
+ my $int := next_argument(); | |
+ my $precision := nqp::pow_n(10, $<precision> ?? $<precision>.ast !! 6); | |
+ $int := $int * $precision; | |
+ $int := $int - nqp::floor_n($int) >= 0.5 ?? nqp::ceil_n($int) !! nqp::floor_n($int); | |
+ $int := $int / $precision; | |
+ my $pad := padding_char($/); | |
+ if $pad ne ' ' && $<size> { | |
+ my $sign := $int < 0 ?? '-' !! ''; | |
+ $int := nqp::abs_n($int); | |
+ $int := $sign ~ infix_x($pad, $<size>.ast - nqp::chars($int) - 1) ~ $int | |
+ } | |
+ make $int | |
+ } | |
+ method directive:sym<e>($/) { | |
+ my $int := intify(next_argument()); | |
+ if $<size> { | |
+ my $sign := $int < 0 ?? '-' !! ''; | |
+ $int := nqp::abs_i($int); | |
+ $int := $sign ~ infix_x(padding_char($/), $<size>.ast - nqp::chars($int) - 1) ~ $int | |
+ } | |
+ make $int | |
+ } | |
+ method directive:sym<g>($/) { | |
+ my $int := intify(next_argument()); | |
if $<size> { | |
my $sign := $int < 0 ?? '-' !! ''; | |
$int := nqp::abs_i($int); | |
@@ -399,3 +436,243 @@ is(sprintf('%#3.2b', 1), '0b01', '%b, width and precision and value'); | |
is(sprintf('%#3.3b', 1), '0b001', '%b, width and precision and value'); | |
is(sprintf('%#3.4b', 1), '0b0001', '%b, width and precision and value'); | |
is(sprintf('%#b', 0), '0', 'simple %b with zero value'); | |
+ | |
+ | |
+ | |
+is(sprintf("Hi"), "Hi", "sprintf() works with zero args"); | |
+is(sprintf("%%"), "%", "sprintf() escapes % correctly"); | |
+is(sprintf("%03d", 3), "003", "sprintf() works with one arg"); | |
+is(sprintf("%03d %02d", 3, 1), "003 01", "sprintf() works with two args"); | |
+is(sprintf("%d %d %d", 3,1,4), "3 1 4", "sprintf() works with three args"); | |
+is(sprintf("%d%d%d%d", 3,1,4,1), "3141", "sprintf() works with four args"); | |
+ | |
+# nqp has no eval | |
+#ok(eval('sprintf("%b",1)'), 'eval of sprintf() with %b'); | |
+ | |
+is(sprintf("%04b",3), '0011', '0-padded sprintf() with %b'); | |
+is(sprintf("%4b",3), ' 11', '" "-padded sprintf() with %b'); | |
+is(sprintf("%b",30), '11110', 'longer string, no padding'); | |
+is(sprintf("%2b",30), '11110', 'padding specified, not needed'); | |
+is(sprintf("%03b",7), '111', '0 padding, longer string'); | |
+is(sprintf("%b %b",3,3), '11 11', 'two args %b'); | |
+ | |
+is(sprintf('%c', 97), 'a', '%c test'); | |
+ | |
+is(sprintf('%s', 'string'), 'string', '%s test'); | |
+is(sprintf('%10s', 'string'), ' string', '%s right-justified'); | |
+is(sprintf('%-10s', 'string'), 'string ', '%s left-justified'); | |
+ | |
+is(sprintf('%d', 12), '12', 'simple %d'); | |
+is(sprintf('%d', -22), '-22', 'negative %d'); | |
+is(sprintf('%04d', 32), '0032', '0-padded %d'); | |
+is(sprintf('%04d', -42), '-042', '0-padded negative %d'); | |
+is(sprintf('%i', -22), '-22', 'negative %i'); | |
+is(sprintf('%04i', -42), '-042', '0-padded negative %i'); | |
+is(sprintf('%4d', 32), ' 32', 'space-padded %d'); | |
+is(sprintf('%4d', -42), ' -42', 'space-padded negative %d'); | |
+is(sprintf('%4i', -42), ' -42', 'space-padded negative %i'); | |
+is(sprintf('%-4i', -42), '-42 ', 'left-justified negative %i'); | |
+ | |
+is(sprintf('%u', 12), '12', 'simple %u'); | |
+is(sprintf('%u', 22.01), '22', 'decimal %u'); | |
+is(sprintf('%04u', 32), '0032', '0-padded %u'); | |
+is(sprintf('%04u', 42.6), '0042', '0-padded decimal %u'); | |
+ | |
+is(sprintf('%o', 12), '14', 'simple %o'); | |
+is(sprintf('%o', 22.01), '26', 'decimal %o'); | |
+is(sprintf('%03o', 32), '040', '0-padded %o'); | |
+is(sprintf('%03o', 42.6), '052', '0-padded decimal %o'); | |
+ | |
+is(sprintf('%x', 0), '0', 'simple %x'); | |
+is(sprintf('%x', 12), 'c', 'simple %x'); | |
+is(sprintf('%x', 22.01), '16', 'decimal %x'); | |
+is(sprintf('%03x', 32), '020', '0-padded %x'); | |
+is(sprintf('%03x', 42.6), '02a', '0-padded decimal %x'); | |
+# tests for %X | |
+is(sprintf('%X', 12), 'C', 'simple %X'); | |
+is(sprintf('%03X', 42.6), '02A', '0-padded decimal %X'); | |
+ | |
+#~ #?rakudo todo "sprintf does not handle bigints yet" | |
+#~ { | |
+ #~ is(sprintf('%d', 453973694165307953197296969697410619233826), | |
+ #~ "453973694165307953197296969697410619233826", | |
+ #~ '%d works for big ints'); | |
+ #~ is(sprintf('%d', -453973694165307953197296969697410619233826), | |
+ #~ "-453973694165307953197296969697410619233826", | |
+ #~ '%d works for negative big ints'); | |
+ #~ is(sprintf('%b', 453973694165307953197296969697410619233826), | |
+ #~ "1010011011000011011110110010010011111011100010110000111011001101110011001010011001110100101011101101011001111110001010100110101011000100010", | |
+ #~ '%b works for big ints'); | |
+ #~ is(sprintf('%b', -453973694165307953197296969697410619233826), | |
+ #~ "-1010011011000011011110110010010011111011100010110000111011001101110011001010011001110100101011101101011001111110001010100110101011000100010", | |
+ #~ '%b works for negative big ints'); | |
+ #~ is(sprintf('%o', 453973694165307953197296969697410619233826), | |
+ #~ "12330336622373426073156312316453553176124653042", | |
+ #~ '%o works for big ints'); | |
+ #~ is(sprintf('%o', -453973694165307953197296969697410619233826), | |
+ #~ "-12330336622373426073156312316453553176124653042", | |
+ #~ '%o works for negative big ints'); | |
+ #~ is(sprintf('%x', 453973694165307953197296969697410619233826), | |
+ #~ "5361bd927dc58766e6533a576b3f1535622", | |
+ #~ '%x works for big ints'); | |
+ #~ is(sprintf('%x', -453973694165307953197296969697410619233826), | |
+ #~ "-5361bd927dc58766e6533a576b3f1535622", | |
+ #~ '%x works for negative big ints'); | |
+ #~ is(sprintf('%X', 453973694165307953197296969697410619233826), | |
+ #~ "5361BD927DC58766E6533A576B3F1535622", | |
+ #~ '%X works for big ints'); | |
+ #~ is(sprintf('%X', -453973694165307953197296969697410619233826), | |
+ #~ "-5361BD927DC58766E6533A576B3F1535622", | |
+ #~ '%X works for negative big ints'); | |
+#~ } | |
+ | |
+#?rakudo todo "sprintf does not handle big Rats yet" | |
+#~ { | |
+#~ Error while compiling block : Error while compiling op call (source text: "sprintf('%d', 453973694165307953197296969697410619233826 + .1),\n | |
+#~ \"4539736941653079531972969..."): Error while compiling op call (source text: "'%d', 453973694165307953197296969697410619233826 + .1"): | |
+#~ Error while compiling op add_n (source text: "+"): Cannot infer type from '-9223372036854775808' | |
+ | |
+ #~ is(sprintf('%d', 453973694165307953197296969697410619233826 + .1), | |
+ #~ "453973694165307953197296969697410619233826", | |
+ #~ '%d works for big Rats'); | |
+ #~ is(sprintf('%d', -453973694165307953197296969697410619233826 - .1), | |
+ #~ "-453973694165307953197296969697410619233826", | |
+ #~ '%d works for negative big Rats'); | |
+ #~ is(sprintf('%b', 453973694165307953197296969697410619233826 + .1), | |
+ #~ "1010011011000011011110110010010011111011100010110000111011001101110011001010011001110100101011101101011001111110001010100110101011000100010", | |
+ #~ '%b works for big Rats'); | |
+ #~ is(sprintf('%b', -453973694165307953197296969697410619233826 - .1), | |
+ #~ "-1010011011000011011110110010010011111011100010110000111011001101110011001010011001110100101011101101011001111110001010100110101011000100010", | |
+ #~ '%b works for negative big Rats'); | |
+ #~ is(sprintf('%o', 453973694165307953197296969697410619233826 + .1), | |
+ #~ "12330336622373426073156312316453553176124653042", | |
+ #~ '%o works for big Rats'); | |
+ #~ is(sprintf('%o', -453973694165307953197296969697410619233826 - .1), | |
+ #~ "-12330336622373426073156312316453553176124653042", | |
+ #~ '%o works for negative big Rats'); | |
+ #~ is(sprintf('%x', 453973694165307953197296969697410619233826 + .1), | |
+ #~ "5361bd927dc58766e6533a576b3f1535622", | |
+ #~ '%x works for big Rats'); | |
+ #~ is(sprintf('%x', -453973694165307953197296969697410619233826 - .1), | |
+ #~ "-5361bd927dc58766e6533a576b3f1535622", | |
+ #~ '%x works for negative big Rats'); | |
+ #~ is(sprintf('%X', 453973694165307953197296969697410619233826 + .1), | |
+ #~ "5361BD927DC58766E6533A576B3F1535622", | |
+ #~ '%X works for big Rats'); | |
+ #~ is(sprintf('%X', -453973694165307953197296969697410619233826 - .1), | |
+ #~ "-5361BD927DC58766E6533A576B3F1535622", | |
+ #~ '%X works for negative big Rats'); | |
+#~ } | |
+ | |
+is(sprintf('%5.2f', 3.1415), ' 3.14', '5.2 %f'); | |
+#?rakudo skip 'sprintf %F NYI' | |
+is(sprintf('%5.2F', 3.1415), ' 3.14', '5.2 %F'); | |
+#~ is(sprintf('%5.2g', 3.1415), ' 3.1', '5.2 %g'); | |
+#~ is(sprintf('%5.2G', 3.1415), ' 3.1', '5.2 %G'); | |
+ | |
+#~ ok(sprintf('%5.2e', 3.1415) ~~ /^ "3.14e+" "0"? "00" $/, '5.2 %e'); | |
+#~ ok(sprintf('%5.2E', 3.1415) ~~ /^ "3.14E+" "0"? "00" $/, '5.2 %E'); | |
+#~ ok(sprintf('%5.2g', 3.1415e30) ~~ /^ "3.1e+" "0"? "30" $/, '5.2 %g'); | |
+#~ ok(sprintf('%5.2G', 3.1415e30) ~~ /^ "3.1E+" "0"? "30" $/, '5.2 %G'); | |
+#~ ok(sprintf('%5.2g', 3.1415e-30) ~~ /^ "3.1e-" "0"? "30" $/, '5.2 %g'); | |
+#~ ok(sprintf('%5.2G', 3.1415e-30) ~~ /^ "3.1E-" "0"? "30" $/, '5.2 %G'); | |
+ | |
+is(sprintf('%20.2f', 3.1415), ' 3.14', '20.2 %f'); | |
+#~ #?rakudo skip 'sprintf %F NYI' | |
+is(sprintf('%20.2F', 3.1415), ' 3.14', '20.2 %F'); | |
+#~ is(sprintf('%20.2g', 3.1415), ' 3.1', '20.2 %g'); | |
+#~ is(sprintf('%20.2G', 3.1415), ' 3.1', '20.2 %G'); | |
+ | |
+#~ my $test := sprintf('%20.2e', 3.1415); | |
+#~ ok($test eq ' 3.14e+000' || $test eq ' 3.14e+00', '20.2 %e'); | |
+#~ $test := sprintf('%20.2E', 3.1415); | |
+#~ ok($test eq ' 3.14E+000' || $test eq ' 3.14E+00', '20.2 %E'); | |
+#~ $test := sprintf('%20.2g', 3.1415e30); | |
+#~ ok($test eq ' 3.1e+030' || $test eq ' 3.1e+30', '20.2 %g'); | |
+#~ $test := sprintf('%20.2G', 3.1415e30); | |
+#~ ok($test eq ' 3.1E+030' || $test eq ' 3.1E+30', '20.2 %G'); | |
+#~ $test := sprintf('%20.2g', 3.1415e-30); | |
+#~ ok($test eq ' 3.1e-030' || $test eq ' 3.1e-30', '20.2 %g'); | |
+#~ $test := sprintf('%20.2G', 3.1415e-30); | |
+#~ ok($test eq ' 3.1E-030' || $test eq ' 3.1E-30', '20.2 %G'); | |
+ | |
+is(sprintf('%20.2f', -3.1415), ' -3.14', 'negative 20.2 %f'); | |
+#?rakudo skip 'sprintf %F NYI' | |
+is(sprintf('%20.2F', -3.1415), ' -3.14', 'negative 20.2 %F'); | |
+#~ is(sprintf('%20.2g', -3.1415), ' -3.1', 'negative 20.2 %g'); | |
+#~ is(sprintf('%20.2G', -3.1415), ' -3.1', 'negative 20.2 %G'); | |
+ | |
+#~ $test := sprintf('%20.2e', -3.1415); | |
+#~ ok($test eq ' -3.14e+000' || $test eq ' -3.14e+00', 'negative 20.2 %e'); | |
+#~ $test := sprintf('%20.2E', -3.1415); | |
+#~ ok($test eq ' -3.14E+000' || $test eq ' -3.14E+00', 'negative 20.2 %E'); | |
+#~ $test := sprintf('%20.2g', -3.1415e30); | |
+#~ ok($test eq ' -3.1e+030' || $test eq ' -3.1e+30', 'negative 20.2 %g'); | |
+#~ $test := sprintf('%20.2G', -3.1415e30); | |
+#~ ok($test eq ' -3.1E+030' || $test eq ' -3.1E+30', 'negative 20.2 %G'); | |
+#~ $test := sprintf('%20.2g', -3.1415e-30); | |
+#~ ok($test eq ' -3.1e-030' || $test eq ' -3.1e-30', 'negative 20.2 %g'); | |
+#~ $test := sprintf('%20.2G', -3.1415e-30); | |
+#~ ok($test eq ' -3.1E-030' || $test eq ' -3.1E-30', 'negative 20.2 %G'); | |
+ | |
+is(sprintf('%020.2f', 3.1415), '00000000000000003.14', '020.2 %f'); | |
+#?rakudo skip 'sprintf %F NYI' | |
+is(sprintf('%020.2F', 3.1415), '00000000000000003.14', '020.2 %F'); | |
+#~ is(sprintf('%020.2g', 3.1415), '000000000000000003.1', '020.2 %g'); | |
+#~ is(sprintf('%020.2G', 3.1415), '000000000000000003.1', '020.2 %G'); | |
+ | |
+#~ $test := sprintf('%020.2e', 3.1415); | |
+#~ ok($test eq '000000000003.14e+000' || $test eq '0000000000003.14e+00', '020.2 %e'); | |
+#~ $test := sprintf('%020.2E', 3.1415); | |
+#~ ok($test eq '000000000003.14E+000' || $test eq '0000000000003.14E+00', '020.2 %E'); | |
+#~ $test := sprintf('%020.2g', 3.1415e30); | |
+#~ ok($test eq '0000000000003.1e+030' || $test eq '00000000000003.1e+30', '020.2 %g'); | |
+#~ $test := sprintf('%020.2G', 3.1415e30); | |
+#~ ok($test eq '0000000000003.1E+030' || $test eq '00000000000003.1E+30', '020.2 %G'); | |
+#~ $test := sprintf('%020.2g', 3.1415e-30); | |
+#~ ok($test eq '0000000000003.1e-030' || $test eq '00000000000003.1e-30', '020.2 %g'); | |
+#~ $test := sprintf('%020.2G', 3.1415e-30); | |
+#~ ok($test eq '0000000000003.1E-030' || $test eq '00000000000003.1E-30', '020.2 %G'); | |
+ | |
+is(sprintf('%020.2f', -3.1415), '-0000000000000003.14', 'negative 020.2 %f'); | |
+#?rakudo skip 'sprintf %F NYI' | |
+is(sprintf('%020.2F', -3.1415), '-0000000000000003.14', 'negative 020.2 %F'); | |
+#~ is(sprintf('%020.2g', -3.1415), '-00000000000000003.1', 'negative 020.2 %g'); | |
+#~ is(sprintf('%020.2G', -3.1415), '-00000000000000003.1', 'negative 020.2 %G'); | |
+ | |
+#~ $test := sprintf('%020.2e', -3.1415); | |
+#~ ok($test eq '-00000000003.14e+000' || $test eq '-000000000003.14e+00', 'negative 020.2 %e'); | |
+#~ $test := sprintf('%020.2E', -3.1415); | |
+#~ ok($test eq '-00000000003.14E+000' || $test eq '-000000000003.14E+00', 'negative 020.2 %E'); | |
+#~ $test := sprintf('%020.2g', -3.1415e30); | |
+#~ ok($test eq '-000000000003.1e+030' || $test eq '-0000000000003.1e+30', 'negative 020.2 %g'); | |
+#~ $test := sprintf('%020.2G', -3.1415e30); | |
+#~ ok($test eq '-000000000003.1E+030' || $test eq '-0000000000003.1E+30', 'negative 020.2 %G'); | |
+#~ $test := sprintf('%020.2g', -3.1415e-30); | |
+#~ ok($test eq '-000000000003.1e-030' || $test eq '-0000000000003.1e-30', 'negative 020.2 %g'); | |
+#~ $test := sprintf('%020.2G', -3.1415e-30); | |
+#~ ok($test eq '-000000000003.1E-030' || $test eq '-0000000000003.1E-30', 'negative 020.2 %G'); | |
+ | |
+#~ is(sprintf('%e', 2.718281828459), sprintf('%.6e', 2.718281828459), '%e defaults to .6'); | |
+#~ is(sprintf('%E', 2.718281828459), sprintf('%.6E', 2.718281828459), '%E defaults to .6'); | |
+is(sprintf('%f', 2.718281828459), sprintf('%.6f', 2.718281828459), '%f defaults to .6'); | |
+#~ is(sprintf('%g', 2.718281828459), sprintf('%.6g', 2.718281828459), '%g defaults to .6'); | |
+#~ is(sprintf('%G', 2.718281828459), sprintf('%.6G', 2.718281828459), '%G defaults to .6'); | |
+ | |
+#~ # L<S32::Str/"Str"/"The special directive, %n does not work in Perl 6"> | |
+#~ dies_ok({my $x := sprintf('%n', 1234)}, '%n dies (Perl 5 compatibility)'); #OK not used | |
+#~ #?rakudo todo "%p doesn't yet throw exception - but should it, or just Failure?" | |
+#~ dies_ok({my $x := sprintf('%p', 1234)}, '%p dies (Perl 5 compatibility)'); #OK not used | |
+ | |
+#~ is(sprintf('%s', NaN), NaN, 'sprintf %s handles NaN'); | |
+#~ is(sprintf('%s', -NaN), NaN, 'sprintf %s handles NaN'); | |
+#~ is(sprintf('%s', Inf), Inf, 'sprintf %s handles Inf'); | |
+#~ is(sprintf('%s', -Inf), -Inf, 'sprintf %s handles Inf'); | |
+ | |
+#~ #?rakudo skip "doesn't work in master (as of 2010-07)" | |
+#~ { | |
+ #~ is(sprintf('%d %1$x %1$o', 12), '12 c 14', 'positional argument specifier $'); | |
+#~ } | |
+ | |
+#~ # RT #74610 | |
+#~ #dies_ok({sprintf("%s")}, 'missing sprintf string argument'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1..88 | |
ok 1 - no directives | |
ok 2 - one %s directive | |
ok 3 - two %s directives | |
ok 4 - arguments > directives | |
ok 5 - arguments > directives error message | |
ok 6 - directives > arguments | |
ok 7 - directives > arguments error message | |
ok 8 - directives > 0 arguments | |
ok 9 - directives > 0 arguments error message | |
ok 10 - %% escape | |
ok 11 - unknown directive | |
ok 12 - unknown directive error message | |
ok 13 - right-justified %s with space padding | |
ok 14 - right-justified %% with space padding | |
ok 15 - right-justified %s with 0-padding | |
ok 16 - right-justified %% with 0-padding | |
ok 17 - right-justified %s with space padding, star-specified | |
ok 18 - right-justified %s with 0-padding, star-specified | |
ok 19 - right-justified %% with space padding, star-specified | |
ok 20 - right-justified %% with 0-padding, star-specified | |
ok 21 - %s string longer than specified size | |
ok 22 - %d without size or precision | |
ok 23 - %d on a non-number | |
ok 24 - %d on a float | |
ok 25 - %d on a negative float | |
ok 26 - %d on decimal with 0-padding | |
ok 27 - %d on negative decimal with 0-padding (but nothing to pad) | |
ok 28 - %d on negative decimal with 0-padding | |
ok 29 - %c directive | |
ok 30 - %c directive with space padding | |
ok 31 - %c directive with non-asci codepoints | |
ok 32 - %c directive with 0-padding | |
ok 33 - simple %o | |
ok 34 - decimal %o | |
ok 35 - %o with 0-padding | |
ok 36 - %o with space-padding and leading 0 | |
ok 37 - simple %x | |
ok 38 - simple %x | |
ok 39 - decimal %x | |
ok 40 - simple %X | |
ok 41 - %X, '0X' prepended | |
ok 42 - %x ,'0x prepended' | |
ok 43 - %x, hash and width | |
ok 44 - %x, hash, width and precision | |
ok 45 - %x, no hash, but width and precision | |
ok 46 - %x with zero-padding | |
ok 47 - %x with zero-padding, star-specified | |
ok 48 - simple %u | |
ok 49 - decimal %u | |
ok 50 - max uint32 to %u | |
ok 51 - simple %B | |
ok 52 - simple %B with plus sign | |
ok 53 - %B with 0B prefixed | |
ok 54 - simple %b | |
ok 55 - simple %b with plus sign | |
ok 56 - %b with 0b prefixed | |
ok 57 - %b right justified using space chars | |
ok 58 - %b right justified, 0-padding | |
ok 59 - %b left justified using space chars | |
ok 60 - %b left justified, 0-padding | |
ok 61 - simple %b, padded | |
ok 62 - %b, right justified and precision | |
ok 63 - %b, left justified and precision | |
ok 64 - %b, right justified and precision, plus sign | |
ok 65 - %b, right justified and precision, space char | |
ok 66 - %b, 0 flag with precision: no effect | |
ok 67 - %b with precision but no width | |
ok 68 - %b, precision zero, no value | |
ok 69 - %b, precision zero, plus sign, no value | |
ok 70 - %b, precision zero, space char, no value | |
ok 71 - %b, precision zero, minus, no value | |
ok 72 - %b, precision zero, hash, no value | |
ok 73 - %b, width but zero precision | |
ok 74 - %b, width and precision but zero value | |
ok 75 - %b, width and precision but zero value | |
ok 76 - %b, width and precision but zero value | |
ok 77 - %b, width and precision but zero value, overlong | |
ok 78 - %b, precision zero and value | |
ok 79 - %b, precision zero, plus sign and value | |
ok 80 - %b, precision zero, space char and value | |
ok 81 - %b, precision zero, hash and value | |
ok 82 - %b, width, zero precision, no value | |
ok 83 - %b, width, zero precision but value | |
ok 84 - %b, width and precision and value | |
ok 85 - %b, width and precision and value | |
ok 86 - %b, width and precision and value | |
ok 87 - %b, width and precision and value | |
ok 88 - simple %b with zero value | |
ok 89 - sprintf() works with zero args | |
ok 90 - sprintf() escapes % correctly | |
ok 91 - sprintf() works with one arg | |
ok 92 - sprintf() works with two args | |
ok 93 - sprintf() works with three args | |
ok 94 - sprintf() works with four args | |
ok 95 - 0-padded sprintf() with %b | |
ok 96 - " "-padded sprintf() with %b | |
ok 97 - longer string, no padding | |
ok 98 - padding specified, not needed | |
ok 99 - 0 padding, longer string | |
ok 100 - two args %b | |
ok 101 - %c test | |
ok 102 - %s test | |
ok 103 - %s right-justified | |
ok 104 - %s left-justified | |
ok 105 - simple %d | |
ok 106 - negative %d | |
ok 107 - 0-padded %d | |
ok 108 - 0-padded negative %d | |
ok 109 - negative %i | |
ok 110 - 0-padded negative %i | |
ok 111 - space-padded %d | |
ok 112 - space-padded negative %d | |
ok 113 - space-padded negative %i | |
ok 114 - left-justified negative %i | |
ok 115 - simple %u | |
ok 116 - decimal %u | |
ok 117 - 0-padded %u | |
ok 118 - 0-padded decimal %u | |
ok 119 - simple %o | |
ok 120 - decimal %o | |
ok 121 - 0-padded %o | |
ok 122 - 0-padded decimal %o | |
ok 123 - simple %x | |
ok 124 - simple %x | |
ok 125 - decimal %x | |
ok 126 - 0-padded %x | |
ok 127 - 0-padded decimal %x | |
ok 128 - simple %X | |
ok 129 - 0-padded decimal %X | |
ok 130 - 5.2 %f | |
ok 131 - 5.2 %F | |
ok 132 - 20.2 %f | |
ok 133 - 20.2 %F | |
ok 134 - negative 20.2 %f | |
ok 135 - negative 20.2 %F | |
ok 136 - 020.2 %f | |
ok 137 - 020.2 %F | |
ok 138 - negative 020.2 %f | |
ok 139 - negative 020.2 %F | |
ok 140 - %f defaults to .6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment