improve test

This commit is contained in:
Andrii Riabushenko
2018-12-07 22:25:32 +00:00
parent d9815574c0
commit 43c70a6b12
2 changed files with 17 additions and 8 deletions

View File

@@ -441,11 +441,15 @@ proc pArg(arg: PNode; c: var Con; isSink: bool): PNode =
elif arg.kind == nkSym and isSinkParam(arg.sym):
# mark the sink parameter as used:
result = destructiveMoveSink(arg, c)
elif arg.kind in {nkStmtListExpr, nkBlockExpr, nkBlockStmt}:
result = copyNode(arg)
for i in 0..arg.len-2:
result.add p(arg[i], c)
result.add pArg(arg[^1], c, isSink)
elif arg.kind in {nkBlockExpr, nkBlockStmt}:
result = copyNode(arg)
result.add arg[0]
result.add pArg(arg[1], c, isSink)
elif arg.kind == nkStmtListExpr:
result = copyNode(arg)
for i in 0..arg.len-2:
result.add p(arg[i], c)
result.add pArg(arg[^1], c, isSink)
elif arg.kind in {nkIfExpr, nkIfStmt}:
result = copyNode(arg)
for i in 0..<arg.len:

View File

@@ -115,8 +115,13 @@ proc myfunc2(x, y: int): tuple[a: MySeqNonCopyable, b:int, c:MySeqNonCopyable] =
z2
elif x > 5: raise newException(ValueError, "new error")
else: newMySeq(x, 1.0),
b:0,
c: if y > 0: move(cc) else: newMySeq(1, 3.0))
b: 0,
c: block:
var tmp = if y > 0: move(cc) else: newMySeq(1, 3.0)
tmp[0] = 5
tmp
)
let (seq1, seq2) = myfunc(2, 3)
doAssert seq1.len == 2
@@ -160,4 +165,4 @@ seq4 =
var ii = 1
let arr2 = [newMySeq(2, 5.0), if i > 1: newMySeq(3, 1.0) else: newMySeq(0, 0.0)]
var seqOfSeq2 = @[newMySeq(2, 5.0), newMySeq(3, 1.0)]
var seqOfSeq2 = @[newMySeq(2, 5.0), newMySeq(3, 1.0)]