]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/formatting/formatting-tests.factor
formatting: fix strftime %U and %W
[factor.git] / basis / formatting / formatting-tests.factor
old mode 100755 (executable)
new mode 100644 (file)
index 543eff4..8b4bf16
@@ -106,6 +106,9 @@ IN: formatting.tests
 { "9.877e+417" } [ 987654321098765432 10 400 ^ * "%.3e" sprintf ] unit-test
 { "9.88e+417" } [ 987654321098765432 10 400 ^ * "%.2e" sprintf ] unit-test
 { "9.9e+417" } [ 987654321098765432 10 400 ^ * "%.1e" sprintf ] unit-test
+! This works even on windows (even though %.0e is special on
+! windows) because it doesn't use the fast formatter from the
+! system
 { "1e+418" } [ 987654321098765432 10 400 ^ * "%.0e" sprintf ] unit-test
 { "9e+417" } [ 937654321098765432 10 400 ^ * "%.0e" sprintf ] unit-test
 { "1.0e+418" } [ 997654321098765432 10 400 ^ * "%.1e" sprintf ] unit-test
@@ -140,6 +143,7 @@ IN: formatting.tests
 { "[####monkey]" } [ "monkey" "[%'#10s]" sprintf ] unit-test
 { "[many monke]" } [ "many monkeys" "[%10.10s]" sprintf ] unit-test
 
+{ "{ 1, 2, 3 }" } [ BV{ 1 2 3 } "%[%d, %]" sprintf ] unit-test
 { "{ 1, 2, 3 }" } [ { 1 2 3 } "%[%s, %]" sprintf ] unit-test
 { "{ 1:2, 3:4 }" } [ H{ { 1 2 } { 3 4 } } "%[%s: %s %]" sprintf ] unit-test
 
@@ -167,5 +171,26 @@ ${ os windows? "3" "2" ? } [ 5/2 "%.0f" sprintf ] unit-test
 ! Differences on Windows due to setprecision(0)
 ${ os windows? "2.500000e+00" "2e+00" ? } [ 5/2 "%.0e" sprintf ] unit-test
 ${ os windows? "3.500000e+00" "4e+00" ? } [ 7/2 "%.0e" sprintf ] unit-test
+${ os windows? "1.000000e+00" "1e+00" ? } [ 1.0 "%.0e" sprintf ] unit-test
 
-{ "1e+00" } [ 1.0 "%.0e" sprintf ] unit-test
+{ "00" } [ 2020 1 1 <date> "%U" strftime ] unit-test
+{ "00" } [ 2020 1 1 <date> "%W" strftime ] unit-test
+
+{ "44" } [ 2020 11 6 <date> "%U" strftime ] unit-test
+{ "44" } [ 2020 11 6 <date> "%W" strftime ] unit-test
+
+{ "00" } [ 2022 1 1 <date> "%U" strftime ] unit-test
+{ "01" } [ 2022 1 2 <date> "%U" strftime ] unit-test
+{ "01" } [ 2022 1 3 <date> "%U" strftime ] unit-test
+
+{ "00" } [ 2022 1 1 <date> "%W" strftime ] unit-test
+{ "00" } [ 2022 1 2 <date> "%W" strftime ] unit-test
+{ "01" } [ 2022 1 3 <date> "%W" strftime ] unit-test
+
+{ "34" } [ 2022 8 27 <date> "%U" strftime ] unit-test
+{ "35" } [ 2022 8 28 <date> "%U" strftime ] unit-test
+{ "35" } [ 2022 8 29 <date> "%U" strftime ] unit-test
+
+{ "34" } [ 2022 8 27 <date> "%W" strftime ] unit-test
+{ "34" } [ 2022 8 28 <date> "%W" strftime ] unit-test
+{ "35" } [ 2022 8 29 <date> "%W" strftime ] unit-test