summary refs log tree commit diff stats
path: root/tests/stdlib/tstrformat.nim
diff options
context:
space:
mode:
authorskilchen <skilchen@users.noreply.github.com>2018-06-05 06:09:07 +0200
committerVarriount <Varriount@users.noreply.github.com>2018-06-05 00:09:07 -0400
commit230692a22f92ed010e04ba8c1b2b95f86350f1a5 (patch)
tree6d874783342c6fc578b197a6685ff2ba7f12a891 /tests/stdlib/tstrformat.nim
parentfd102f39bb8c969d33015654422ff4541f211b51 (diff)
downloadNim-230692a22f92ed010e04ba8c1b2b95f86350f1a5.tar.gz
Fix strformat neg zero (#7954)
* fix strformat handling of neg zero with sign

* better tests for neg zero with sign

* use inplace insertion of the sign as suggested by Varriount
Diffstat (limited to 'tests/stdlib/tstrformat.nim')
-rw-r--r--tests/stdlib/tstrformat.nim8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/stdlib/tstrformat.nim b/tests/stdlib/tstrformat.nim
index 919158ac4..db76899d4 100644
--- a/tests/stdlib/tstrformat.nim
+++ b/tests/stdlib/tstrformat.nim
@@ -46,3 +46,11 @@ doAssert fmt"{-1.5:0>8}" == "0000-1.5" # even that does not work for negative fl
 doAssert fmt"{-1.5:08}" == "-00001.5" # works
 doAssert fmt"{1.5:+08}" == "+00001.5" # works
 doAssert fmt"{1.5: 08}" == " 00001.5" # works
+
+# only add explicitly requested sign if value != -0.0 (neg zero)
+doAssert fmt"{-0.0:g}" == "-0"
+doassert fmt"{-0.0:+g}" == "-0"
+doassert fmt"{-0.0: g}" == "-0"
+doAssert fmt"{0.0:g}" == "0"
+doAssert fmt"{0.0:+g}" == "+0"
+doAssert fmt"{0.0: g}" == " 0"