move rest of tests to testament (#16140)

* move rest of tests to testament
* Update tests/stdlib/tsums.nim
This commit is contained in:
flywind 2020-11-28 03:47:49 +08:00 • committed by GitHub
commit bc1db0d6f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 228 additions and 233 deletions

23
tests/stdlib/twith.nim Normal file
View file

@ -0,0 +1,23 @@
import std/with
type
Foo = object
col, pos: string
name: string
proc setColor(f: var Foo; r, g, b: int) = f.col = $(r, g, b)
proc setPosition(f: var Foo; x, y: float) = f.pos = $(x, y)
var f: Foo
with(f, setColor(2, 3, 4), setPosition(0.0, 1.0))
doAssert f.col == "(2, 3, 4)"
doAssert f.pos == "(0.0, 1.0)"
f = Foo()
with f:
col = $(2, 3, 4)
pos = $(0.0, 1.0)
_.name = "bar"
doAssert f.col == "(2, 3, 4)"
doAssert f.pos == "(0.0, 1.0)"
doAssert f.name == "bar"