summary refs log tree commit diff stats
path: root/tests/arc/tarcmisc.nim
diff options
context:
space:
mode:
authorcooldome <ariabushenko@gmail.com>2020-10-01 16:39:48 +0100
committerGitHub <noreply@github.com>2020-10-01 17:39:48 +0200
commit531ed2dc365d6d33c7bccdfbe22df561cf14af86 (patch)
treed4d88cf40fb7b6f805011c4796e421bffc212fef /tests/arc/tarcmisc.nim
parent3919f0aa544d84c7a236e5095b87d7d0c8fb63b4 (diff)
downloadNim-531ed2dc365d6d33c7bccdfbe22df561cf14af86.tar.gz
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>
Diffstat (limited to 'tests/arc/tarcmisc.nim')
-rw-r--r--tests/arc/tarcmisc.nim33
1 files changed, 32 insertions, 1 deletions
diff --git a/tests/arc/tarcmisc.nim b/tests/arc/tarcmisc.nim
index 542e4f316..b53d49df8 100644
--- a/tests/arc/tarcmisc.nim
+++ b/tests/arc/tarcmisc.nim
@@ -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)
\ No newline at end of file