summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-09-25 18:20:39 +0200
committerLaurenz <laurmaedje@gmail.com>2022-09-25 18:20:39 +0200
commitf6adc45638409aaa0feb1f70883c11ed553efe4f (patch)
tree3691cec70698a1952f2b315ed8b602912739acce /tests
parentfffb55f79a3369fa2dcf39371091c48ff61f55a8 (diff)
XML reading
Diffstat (limited to 'tests')
-rw-r--r--tests/res/bad.xml3
-rw-r--r--tests/res/data.xml7
-rw-r--r--tests/typ/utility/data.typ29
3 files changed, 39 insertions, 0 deletions
diff --git a/tests/res/bad.xml b/tests/res/bad.xml
new file mode 100644
index 00000000..7fa6a6ed
--- /dev/null
+++ b/tests/res/bad.xml
@@ -0,0 +1,3 @@
+<data>
+ <hello name="hi">1
+</data>
diff --git a/tests/res/data.xml b/tests/res/data.xml
new file mode 100644
index 00000000..9ae409ee
--- /dev/null
+++ b/tests/res/data.xml
@@ -0,0 +1,7 @@
+<data>
+ <hello name="hi">1</hello>
+ <data>
+ <hello>World</hello>
+ <hello>World</hello>
+ </data>
+</data>
diff --git a/tests/typ/utility/data.typ b/tests/typ/utility/data.typ
index 4fdb84c2..e90c1b0d 100644
--- a/tests/typ/utility/data.typ
+++ b/tests/typ/utility/data.typ
@@ -27,3 +27,32 @@
---
// Error: 7-22 failed to parse json file: syntax error in line 3
#json("/res/bad.json")
+
+---
+// Test reading XML data.
+#let data = xml("/res/data.xml")
+#test(data, ((
+ tag: "data",
+ attrs: (:),
+ children: (
+ "\n ",
+ (tag: "hello", attrs: (name: "hi"), children: ("1",)),
+ "\n ",
+ (
+ tag: "data",
+ attrs: (:),
+ children: (
+ "\n ",
+ (tag: "hello", attrs: (:), children: ("World",)),
+ "\n ",
+ (tag: "hello", attrs: (:), children: ("World",)),
+ "\n ",
+ ),
+ ),
+ "\n",
+ ),
+),))
+
+---
+// Error: 6-20 failed to parse xml file: found closing tag 'data' instead of 'hello' in line 3
+#xml("/res/bad.xml")