From 795044ed2b9efd20ea220104ffc2894421930b2c Mon Sep 17 00:00:00 2001 From: Araq Date: Mon, 27 May 2019 15:57:20 +0200 Subject: [PATCH] make tests green again --- tests/assign/tvariantasgn.nim | 6 ++---- tests/ccgbugs/tcgbug.nim | 5 ++--- tests/compilerapi/tcompilerapi.nim | 1 + tests/destructor/topt.nim | 5 ++--- tests/dll/server.nim | 8 +++----- tests/fields/tfielditerator.nim | 4 +--- tests/gc/gctest.nim | 11 +++-------- tests/misc/tshadow_magic_type.nim | 4 +--- tests/objvariant/tvariantstack.nim | 8 ++------ tests/threads/threadex.nim | 2 +- 10 files changed, 18 insertions(+), 36 deletions(-) diff --git a/tests/assign/tvariantasgn.nim b/tests/assign/tvariantasgn.nim index 2278957ac5..1c3deeae15 100644 --- a/tests/assign/tvariantasgn.nim +++ b/tests/assign/tvariantasgn.nim @@ -15,12 +15,10 @@ type of nkString: strVal: string var s: TAny -s.kind = nkString -s.strVal = "test" +s = TAny(kind: nkString, strVal: "test") var nr: TAny -nr.kind = nkint -nr.intVal = 78 +s = TAny(kind: nkInt, intVal: 78) # s = nr # works diff --git a/tests/ccgbugs/tcgbug.nim b/tests/ccgbugs/tcgbug.nim index eda475d4fd..ba0c16fa89 100644 --- a/tests/ccgbugs/tcgbug.nim +++ b/tests/ccgbugs/tcgbug.nim @@ -59,7 +59,7 @@ type of M3: c:cstring proc newMyObject(kind: MyKind, val: string): MyObject = - result.kind = kind + result = MyObject(kind: kind) case kind of M1: result.a = parseInt(val) @@ -67,8 +67,7 @@ proc newMyObject(kind: MyKind, val: string): MyObject = of M3: result.c = val proc newMyObjectRef(kind: MyKind, val: string): MyObjectRef = - new(result) - result.kind = kind + result = MyObjectRef(kind: kind) case kind of M1: result.a = parseInt(val) of M2: result.b = parseFloat(val) diff --git a/tests/compilerapi/tcompilerapi.nim b/tests/compilerapi/tcompilerapi.nim index 2a7db04eb9..494765a8ba 100644 --- a/tests/compilerapi/tcompilerapi.nim +++ b/tests/compilerapi/tcompilerapi.nim @@ -5,6 +5,7 @@ my secret 11 12 ''' + joinable: "false" """ ## Example program that demonstrates how to use the diff --git a/tests/destructor/topt.nim b/tests/destructor/topt.nim index 3851a42834..4adda1914c 100644 --- a/tests/destructor/topt.nim +++ b/tests/destructor/topt.nim @@ -14,8 +14,7 @@ type proc some*[T](val: sink T): opt[T] {.inline.} = ## Returns an ``opt`` that has the value. ## nil is considered as none for reference types - result.exists = true - result.val = val + result = opt[T](exists: true, val: val) proc none*(T: typedesc): opt[T] {.inline.} = ## Returns an ``opt`` for this type that has no value. @@ -32,7 +31,7 @@ proc unsafeGet*[T](self: opt[T]): lent T {.inline.} = type VSeq*[T] = object - len: int + len: int data: ptr UncheckedArray[T] proc `=destroy`*[T](m: var VSeq[T]) {.inline.} = diff --git a/tests/dll/server.nim b/tests/dll/server.nim index 5ce1976ce9..2b7791d4b4 100644 --- a/tests/dll/server.nim +++ b/tests/dll/server.nim @@ -13,16 +13,14 @@ type PNode = ref TNode proc newLit(x: int): PNode {.exportc: "newLit", dynlib.} = - new(result) - result.x = x + result = PNode(k: nkLit, x: x) proc newOp(k: TNodeKind, a, b: PNode): PNode {.exportc: "newOp", dynlib.} = assert a != nil assert b != nil - new(result) + result = PNode(k: nkSub, a: a, b: b) + # now overwrite with the real value: result.k = k - result.a = a - result.b = b proc buildTree(x: int): PNode {.exportc: "buildTree", dynlib.} = result = newOp(nkMul, newOp(nkAdd, newLit(x), newLit(x)), newLit(x)) diff --git a/tests/fields/tfielditerator.nim b/tests/fields/tfielditerator.nim index b1c3579972..877e4454c4 100644 --- a/tests/fields/tfielditerator.nim +++ b/tests/fields/tfielditerator.nim @@ -104,9 +104,7 @@ block titerator2: for key, val in fieldPairs(x): echo key, ": ", val - var co: TMyCaseObj - co.myDisc = enC - co.c = 'Z' + var co = TMyCaseObj(myDisc: enC, c: 'Z') for key, val in fieldPairs(co): echo key, ": ", val diff --git a/tests/gc/gctest.nim b/tests/gc/gctest.nim index 25d57ff0e4..78b78934c0 100644 --- a/tests/gc/gctest.nim +++ b/tests/gc/gctest.nim @@ -45,19 +45,14 @@ var flip: int proc newCaseNode(data: string): PCaseNode = - new(result) if flip == 0: - result.kind = nkStr - result.data = data + result = PCaseNode(kind: nkStr, data: data) else: - result.kind = nkWhole - result.unused = @["", "abc", "abdc"] + result = PCaseNode(kind: nkWhole, unused: @["", "abc", "abdc"]) flip = 1 - flip proc newCaseNode(a, b: PCaseNode): PCaseNode = - new(result) - result.kind = nkList - result.sons = @[a, b] + result = PCaseNode(kind: nkList, sons: @[a, b]) proc caseTree(lvl: int = 0): PCaseNode = if lvl == 3: result = newCaseNode("data item") diff --git a/tests/misc/tshadow_magic_type.nim b/tests/misc/tshadow_magic_type.nim index 3176a45961..8b2d261330 100644 --- a/tests/misc/tshadow_magic_type.nim +++ b/tests/misc/tshadow_magic_type.nim @@ -21,9 +21,7 @@ proc seq*() = discard proc lrange*(key: string): TRedisList = - var foo: TListItem - foo.kind = RedisString - foo.str = key + var foo = TListItem(kind: RedisString, str: key) result = @[foo] var p = lrange("mylist") diff --git a/tests/objvariant/tvariantstack.nim b/tests/objvariant/tvariantstack.nim index 31a0d8b827..7fd41b4764 100644 --- a/tests/objvariant/tvariantstack.nim +++ b/tests/objvariant/tvariantstack.nim @@ -32,15 +32,11 @@ proc pop(Stack: var TStack): TAny = var stack = newStack() -var s: TAny -s.kind = nkString -s.strVal = "test" +var s = TAny(kind: nkString, strVal: "test") stack.push(s) -var nr: TAny -nr.kind = nkint -nr.intVal = 78 +var nr = TAny(kind: nkInt, intVal: 78) stack.push(nr) diff --git a/tests/threads/threadex.nim b/tests/threads/threadex.nim index e61ce5c9c8..50a1a4d343 100644 --- a/tests/threads/threadex.nim +++ b/tests/threads/threadex.nim @@ -34,7 +34,7 @@ proc produce() {.thread.} = m.data = line chan.send(m) close(input) - m.k = mEof + m = TMsg(k: mEof) chan.send(m) open(chan)