Empty check in shallow [backport] (#9676)

This commit is contained in:
ishowta
2018-11-21 19:56:38 +09:00
committed by Andreas Rumpf
parent b78699917e
commit 6ff596d4f8
2 changed files with 25 additions and 0 deletions

View File

@@ -170,6 +170,30 @@ block tshallowseq:
xxx()
block tshallowemptyseq:
proc test() =
var nilSeq: seq[int] = @[]
var emptySeq: seq[int] = newSeq[int]()
block:
var t = @[1,2,3]
shallow(nilSeq)
t = nilSeq
doAssert t == @[]
block:
var t = @[1,2,3]
shallow(emptySeq)
t = emptySeq
doAssert t == @[]
block:
var t = @[1,2,3]
shallowCopy(t, nilSeq)
doAssert t == @[]
block:
var t = @[1,2,3]
shallowCopy(t, emptySeq)
doAssert t == @[]
test()
import strutils
block ttoseq: