summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2020-04-30 06:48:57 +0200
committerGitHub <noreply@github.com>2020-04-30 06:48:57 +0200
commitcc60caedb3a1c7043b0f7ef2db5c741ecaa1482f (patch)
tree92589110580fe4fb6cba0bdab6270b8a887de433 /lib
parentd6e1b5c070bf58449bf4af210ec099418d496aa5 (diff)
downloadNim-cc60caedb3a1c7043b0f7ef2db5c741ecaa1482f.tar.gz
fixes #14054 [backport:1.2] (#14061)
* fixes #14054

* make tests green again

* more tests are green

* maybe now
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/strformat.nim4
-rw-r--r--lib/pure/strutils.nim7
2 files changed, 4 insertions, 7 deletions
diff --git a/lib/pure/strformat.nim b/lib/pure/strformat.nim
index 838baaf02..5f7ef380d 100644
--- a/lib/pure/strformat.nim
+++ b/lib/pure/strformat.nim
@@ -692,11 +692,11 @@ when isMainModule:
   check &"{-123.456:.3f}", "-123.456"
   check &"{123.456:1g}", "123.456"
   check &"{123.456:.1f}", "123.5"
-  check &"{123.456:.0f}", "123"
+  check &"{123.456:.0f}", "123."
   check &"{123.456:>9.3f}", "  123.456"
   check &"{123.456:9.3f}", "  123.456"
   check &"{123.456:>9.4f}", " 123.4560"
-  check &"{123.456:>9.0f}", "      123"
+  check &"{123.456:>9.0f}", "     123."
   check &"{123.456:<9.4f}", "123.4560 "
 
   # Float (scientific) tests
diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim
index ff76fa94f..a1f80ad76 100644
--- a/lib/pure/strutils.nim
+++ b/lib/pure/strutils.nim
@@ -2430,10 +2430,6 @@ proc formatBiggestFloat*(f: BiggestFloat, format: FloatFormatMode = ffDefault,
       # but nothing else is possible:
       if buf[i] in {'.', ','}: result[i] = decimalSep
       else: result[i] = buf[i]
-    since (1, 1):
-      # remove trailing dot, compatible with Python's formatter and JS backend
-      if result[^1] == decimalSep:
-        result.setLen(len(result)-1)
     when defined(windows):
       # VS pre 2015 violates the C standard: "The exponent always contains at
       # least two digits, and only as many more digits as necessary to
@@ -2936,7 +2932,8 @@ proc isNilOrWhitespace*(s: string): bool {.noSideEffect, procvar, rtl,
 when isMainModule:
   proc nonStaticTests =
     doAssert formatBiggestFloat(1234.567, ffDecimal, -1) == "1234.567000"
-    doAssert formatBiggestFloat(1234.567, ffDecimal, 0) == "1235" # bugs 8242, 12586
+    when not defined(js):
+      doAssert formatBiggestFloat(1234.567, ffDecimal, 0) == "1235." # bugs 8242, 12586
     doAssert formatBiggestFloat(1234.567, ffDecimal, 1) == "1234.6"
     doAssert formatBiggestFloat(0.00000000001, ffDecimal, 11) == "0.00000000001"
     doAssert formatBiggestFloat(0.00000000001, ffScientific, 1, ',') in