fix #15405. deepcopy arc (#15410)

* fix #15405
* fix tests
* deepcopy for ARC has to be enabled via --deepcopy:on

Co-authored-by: Araq <rumpf_a@web.de>
This commit is contained in:
cooldome 2020-10-01 16:39:48 +01:00 • committed by GitHub
commit 531ed2dc36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 52 additions and 5 deletions

View file

@ -30,7 +30,7 @@ closed
destroying variable: 20
destroying variable: 10
'''
cmd: "nim c --gc:arc $file"
cmd: "nim c --gc:arc --deepcopy:on $file"
"""
proc takeSink(x: sink string): bool = true
@ -347,3 +347,34 @@ var data = {
# For ARC listVal is empty for some reason
doAssert data["examples"]["values"].listVal[0].strVal == "test"
###############################################################################
# bug #15405
import parsexml
const test_xml_str = "<A><B>value</B></A>"
var stream = newStringStream(test_xml_str)
var xml: XmlParser
open(xml, stream, "test")
var xml2 = deepCopy(xml)
proc text_parser(xml: var XmlParser) =
var test_passed = false
while true:
xml.next()
case xml.kind
of xmlElementStart:
if xml.elementName == "B":
xml.next()
if xml.kind == xmlCharData and xml.charData == "value":
test_passed = true
of xmlEof: break
else: discard
xml.close()
doAssert(test_passed)
text_parser(xml)
text_parser(xml2)

View file

@ -1,5 +1,5 @@
discard """
cmd: "nim c --gc:arc $file"
cmd: "nim c --gc:arc --deepcopy:on $file"
output: '''13 abc
13 abc
13 abc