mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-01 10:52:14 +00:00
23 lines
625 B
Nim
23 lines
625 B
Nim
discard """
|
|
action: "run"
|
|
"""
|
|
|
|
import strformat
|
|
|
|
type Obj = object
|
|
|
|
proc `$`(o: Obj): string = "foobar"
|
|
|
|
var o: Obj
|
|
doAssert fmt"{o}" == "foobar"
|
|
doAssert fmt"{o:10}" == "foobar "
|
|
|
|
# see issue #7932
|
|
doAssert fmt"{15:08}" == "00000015" # int, works
|
|
doAssert fmt"{1.5:08}" == "000001.5" # float, works
|
|
doAssert fmt"{1.5:0>8}" == "000001.5" # workaround using fill char works for positive floats
|
|
doAssert fmt"{-1.5:0>8}" == "0000-1.5" # even that does not work for negative floats
|
|
doAssert fmt"{-1.5:08}" == "-00001.5" # works
|
|
doAssert fmt"{1.5:+08}" == "+00001.5" # works
|
|
doAssert fmt"{1.5: 08}" == " 00001.5" # works
|