mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-17 21:12:42 +00:00
newruntime: added a basic table test
This commit is contained in:
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)
|
||||
Reference in New Issue
Block a user