dumpToString: improves on sugar.dump (#16841)

* dumpToString
* _
* fixup
* changelog
* address comment: removed the word "Deprecated"
This commit is contained in:
Timothee Cour
2021-02-01 22:41:33 -08:00
committed by GitHub
parent 15d6be52a1
commit 4b2054a7bf
3 changed files with 44 additions and 4 deletions

View File

@@ -107,4 +107,14 @@ doAssert collect(for d in data.items: {d}) == data.toHashSet
# bug #14332
template foo =
discard collect(newSeq, for i in 1..3: i)
foo()
foo()
block: # dumpToString
template square(x): untyped = x * x
let x = 10
doAssert dumpToString(square(x)) == "square(x): x * x = 100"
let s = dumpToString(doAssert 1+1 == 2)
doAssert "failedAssertImpl" in s
let s2 = dumpToString:
doAssertRaises(AssertionDefect): doAssert false
doAssert "except AssertionDefect" in s2