newruntime: added a basic table test
This commit is contained in:
parent
ced0527ae3
commit
51ac2e67bf
1 changed files with 24 additions and 0 deletions
24
tests/destructor/tsimpletable.nim
Normal file
24
tests/destructor/tsimpletable.nim
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
discard """
|
||||||
|
cmd: '''nim c --newruntime $file'''
|
||||||
|
output: '''(field: "value")
|
||||||
|
3 3 new: 0'''
|
||||||
|
"""
|
||||||
|
|
||||||
|
import core / allocators
|
||||||
|
import system / ansi_c
|
||||||
|
|
||||||
|
import tables
|
||||||
|
|
||||||
|
type
|
||||||
|
Node = ref object
|
||||||
|
field: string
|
||||||
|
|
||||||
|
proc main =
|
||||||
|
var w = newTable[string, owned Node]()
|
||||||
|
w["key"] = Node(field: "value")
|
||||||
|
echo w["key"][]
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
let (a, d) = allocCounters()
|
||||||
|
discard cprintf("%ld %ld new: %ld\n", a, d, allocs)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue