diff options
Diffstat (limited to 'tests/destructor/tnewruntime_misc.nim')
-rw-r--r-- | tests/destructor/tnewruntime_misc.nim | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/tests/destructor/tnewruntime_misc.nim b/tests/destructor/tnewruntime_misc.nim index 263ea1bd4..21c70557d 100644 --- a/tests/destructor/tnewruntime_misc.nim +++ b/tests/destructor/tnewruntime_misc.nim @@ -7,7 +7,8 @@ axc ... destroying GenericObj[T] GenericObj[system.int] test -(allocCount: 17, deallocCount: 15)''' +(allocCount: 12, deallocCount: 10) +3''' """ import system / ansi_c @@ -24,8 +25,13 @@ putEnv("HEAPTRASHING", "Indeed") let s1 = getAllocStats() + +proc newTableOwned[A, B](initialSize = defaultInitialSize): owned(TableRef[A, B]) = + new(result) + result[] = initTable[A, B](initialSize) + proc main = - var w = newTable[string, owned Node]() + var w = newTableOwned[string, owned Node]() w["key"] = Node(field: "value") echo w["key"][] echo getEnv("HEAPTRASHING") @@ -131,4 +137,19 @@ proc xx(xml: string): MyObject = discard xx("test") -echo getAllocStats() - s1 + +# Windows has 1 extra allocation in `getEnv` - there it allocates parameter to +# `_wgetenv` (WideCString). Therefore subtract by 1 to match other OSes' +# allocation. +when defined(windows): + import std/importutils + privateAccess(AllocStats) + echo getAllocStats() - s1 - AllocStats(allocCount: 1, deallocCount: 1) +else: + echo getAllocStats() - s1 + +# bug #13457 +var s = "abcde" +s.setLen(3) + +echo s.cstring.len |