X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=blobdiff_plain;f=basis%2Fformatting%2Fformatting-tests.factor;h=8b4bf16b12ca4bd947f012aaa12c125b06b887e0;hp=f018c8bb360de5d062d52b1ba6e43f384455926e;hb=1198695223596ff2306a3204a097c00fad1f1cdc;hpb=0fddbc2af16dec30d7031d146f2a5cabe5ce899e diff --git a/basis/formatting/formatting-tests.factor b/basis/formatting/formatting-tests.factor old mode 100755 new mode 100644 index f018c8bb36..8b4bf16b12 --- a/basis/formatting/formatting-tests.factor +++ b/basis/formatting/formatting-tests.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 John Benediktsson ! See http://factorcode.org/license.txt for BSD license -USING: calendar formatting kernel math math.functions sequences -strings system tools.test ; +USING: calendar formatting kernel literals math math.functions +sequences strings system tools.test ; IN: formatting.tests [ "%s" printf ] must-infer @@ -33,14 +33,10 @@ IN: formatting.tests { "-0.500" } [ -1/2 "%.3f" sprintf ] unit-test { "0.010" } [ 1/100 "%.3f" sprintf ] unit-test { "100000000000000000000000.000000" } [ 23 10^ "%f" sprintf ] unit-test -{ "1.2" } [ 125/100 "%.1f" sprintf ] unit-test { "1.4" } [ 135/100 "%.1f" sprintf ] unit-test -{ "2" } [ 5/2 "%.0f" sprintf ] unit-test { "4" } [ 7/2 "%.0f" sprintf ] unit-test -{ "2e+00" } [ 5/2 "%.0e" sprintf ] unit-test -{ "4e+00" } [ 7/2 "%.0e" sprintf ] unit-test { "1" } [ 1.0 "%.0f" sprintf ] unit-test -{ "1e+00" } [ 1.0 "%.0e" sprintf ] unit-test +{ "0.0e+00" } [ 0 "%.1e" sprintf ] unit-test { " 1.23" } [ 1.23456789 "%6.2f" sprintf ] unit-test { "001100" } [ 12 "%06b" sprintf ] unit-test { "==14" } [ 12 "%'=4o" sprintf ] unit-test @@ -88,7 +84,6 @@ IN: formatting.tests { "-9007199254740991.0" } [ 53 2^ 1 - neg "%.1f" sprintf ] unit-test { "-9007199254740992.0" } [ 53 2^ neg "%.1f" sprintf ] unit-test { "-9007199254740993.0" } [ 53 2^ 1 + neg "%.1f" sprintf ] unit-test - { "987654321098765432" } [ 987654321098765432 "%d" sprintf ] unit-test { "987654321098765432.0" } [ 987654321098765432 "%.1f" sprintf ] unit-test { "987654321098765432" } [ 987654321098765432 "%.0f" sprintf ] unit-test @@ -111,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 @@ -145,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 @@ -165,3 +164,33 @@ IN: formatting.tests { t } [ "October" testtime "%B" strftime = ] unit-test { t } [ "Thu Oct 09 12:03:15 2008" testtime "%c" strftime = ] unit-test { t } [ "PM" testtime "%p" strftime = ] unit-test + +! Differences on Windows due to rounding mode (#1792). +${ os windows? "1.3" "1.2" ? } [ 125/100 "%.1f" sprintf ] unit-test +${ 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 + +{ "00" } [ 2020 1 1 "%U" strftime ] unit-test +{ "00" } [ 2020 1 1 "%W" strftime ] unit-test + +{ "44" } [ 2020 11 6 "%U" strftime ] unit-test +{ "44" } [ 2020 11 6 "%W" strftime ] unit-test + +{ "00" } [ 2022 1 1 "%U" strftime ] unit-test +{ "01" } [ 2022 1 2 "%U" strftime ] unit-test +{ "01" } [ 2022 1 3 "%U" strftime ] unit-test + +{ "00" } [ 2022 1 1 "%W" strftime ] unit-test +{ "00" } [ 2022 1 2 "%W" strftime ] unit-test +{ "01" } [ 2022 1 3 "%W" strftime ] unit-test + +{ "34" } [ 2022 8 27 "%U" strftime ] unit-test +{ "35" } [ 2022 8 28 "%U" strftime ] unit-test +{ "35" } [ 2022 8 29 "%U" strftime ] unit-test + +{ "34" } [ 2022 8 27 "%W" strftime ] unit-test +{ "34" } [ 2022 8 28 "%W" strftime ] unit-test +{ "35" } [ 2022 8 29 "%W" strftime ] unit-test