diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2020-04-30 06:48:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-30 06:48:57 +0200 |
commit | cc60caedb3a1c7043b0f7ef2db5c741ecaa1482f (patch) | |
tree | 92589110580fe4fb6cba0bdab6270b8a887de433 /tests/stdlib | |
parent | d6e1b5c070bf58449bf4af210ec099418d496aa5 (diff) | |
download | Nim-cc60caedb3a1c7043b0f7ef2db5c741ecaa1482f.tar.gz |
fixes #14054 [backport:1.2] (#14061)
* fixes #14054 * make tests green again * more tests are green * maybe now
Diffstat (limited to 'tests/stdlib')
-rw-r--r-- | tests/stdlib/tstrformat.nim | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/stdlib/tstrformat.nim b/tests/stdlib/tstrformat.nim index 403372aed..7db001979 100644 --- a/tests/stdlib/tstrformat.nim +++ b/tests/stdlib/tstrformat.nim @@ -173,3 +173,34 @@ block: y = 234 z = true """ + + +# tests from the very own strformat documentation! + +let msg = "hello" +doAssert fmt"{msg}\n" == "hello\\n" + +doAssert &"{msg}\n" == "hello\n" + +doAssert fmt"{msg}{'\n'}" == "hello\n" +doAssert fmt("{msg}\n") == "hello\n" +doAssert "{msg}\n".fmt == "hello\n" + +doAssert &"""{"abc":>4}""" == " abc" +doAssert &"""{"abc":<4}""" == "abc " + +doAssert fmt"{-12345:08}" == "-0012345" +doAssert fmt"{-1:3}" == " -1" +doAssert fmt"{-1:03}" == "-01" +doAssert fmt"{16:#X}" == "0x10" + +doAssert fmt"{123.456}" == "123.456" +doAssert fmt"{123.456:>9.3f}" == " 123.456" +doAssert fmt"{123.456:9.3f}" == " 123.456" +doAssert fmt"{123.456:9.4f}" == " 123.4560" +doAssert fmt"{123.456:>9.0f}" == " 123." +doAssert fmt"{123.456:<9.4f}" == "123.4560 " + +doAssert fmt"{123.456:e}" == "1.234560e+02" +doAssert fmt"{123.456:>13e}" == " 1.234560e+02" +doAssert fmt"{123.456:13e}" == " 1.234560e+02" |