Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a bare minimum of tests for %e, %E, %f, %F, %g, and %G.

More tests here are definitely needed.
  • Loading branch information...
commit eb74863a6472badfbbf15b235ce48ba8e13e8b3d 1 parent 8a68931
@colomon colomon authored
Showing with 11 additions and 1 deletion.
  1. +11 −1 S32-str/sprintf.t
View
12 S32-str/sprintf.t
@@ -2,7 +2,7 @@ use v6;
use Test;
-plan 43;
+plan 51;
# L<S32::Str/Str/"identical to" "C library sprintf">
@@ -50,6 +50,16 @@ is sprintf('%03x', 42.6), '02a', '0-padded decimal %x';
is sprintf('%X', 12), 'C', 'simple %X';
is sprintf('%03X', 42.6), '02A', '0-padded decimal %X';
+is sprintf('%5.2f', 3.1415), ' 3.14', 'padded %f';
+is sprintf('%5.2F', 3.1415), ' 3.14', 'padded %F';
+is sprintf('%5.2g', 3.1415), ' 3.14', 'padded %g';
+is sprintf('%5.2G', 3.1415), ' 3.14', 'padded %G';
+ok sprintf('%5.2e', 3.1415) ~~ /"3.14e+" "0"{2..3}/, 'padded %e';
+ok sprintf('%5.2E', 3.1415) ~~ /"3.14E+" "0"{2..3}/, 'padded %E';
+
+ok sprintf('%5.2g', 3.1415e30) ~~ /"3.14e+" "0"? "30"/, 'padded %g';
+ok sprintf('%5.2G', 3.1415e30) ~~ /"3.14E+" "0"? "30"/, 'padded %G';
+
# L<S32::Str/"Str"/"The special directive, %n does not work in Perl 6">
dies_ok(sub {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?"
Please sign in to comment.
Something went wrong with that request. Please try again.