about summary refs log tree commit diff
path: root/src/test/rustdoc-js-std/parser-invalid.js
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume.gomez@huawei.com>2021-12-20 17:45:52 +0100
committerGuillaume Gomez <guillaume.gomez@huawei.com>2022-04-18 20:59:08 +0200
commitf5833e759ecd55c03afeb918263cb35fabc91177 (patch)
treef339a8d44570204e26687434d7f89eb05946062f /src/test/rustdoc-js-std/parser-invalid.js
parent7cefee027ae8937058e4109911a4ded2e643399b (diff)
downloadrust-f5833e759ecd55c03afeb918263cb35fabc91177.tar.gz
rust-f5833e759ecd55c03afeb918263cb35fabc91177.zip
Add parser tests
Diffstat (limited to 'src/test/rustdoc-js-std/parser-invalid.js')
-rw-r--r--src/test/rustdoc-js-std/parser-invalid.js128
1 files changed, 128 insertions, 0 deletions
diff --git a/src/test/rustdoc-js-std/parser-invalid.js b/src/test/rustdoc-js-std/parser-invalid.js
new file mode 100644
index 00000000000..a94792b0694
--- /dev/null
+++ b/src/test/rustdoc-js-std/parser-invalid.js
@@ -0,0 +1,128 @@
+// This test is mostly to check that the parser still kinda outputs something
+// (and doesn't enter an infinite loop!) even though the query is completely
+// invalid.
+const QUERY = ['-> <P> (p2)', '(p -> p2', 'a b', 'a,b(c)'];
+
+const PARSED = [
+    {
+        args: [],
+        elemName: null,
+        elems: [],
+        foundElems: 2,
+        id: "-> <P> (p2)",
+        nameSplit: null,
+        original: "-> <P> (p2)",
+        returned: [
+            {
+                name: "",
+                fullPath: [""],
+                pathWithoutLast: [],
+                pathLast: "",
+                generics: [
+                    {
+                        name: "p",
+                        fullPath: ["p"],
+                        pathWithoutLast: [],
+                        pathLast: "p",
+                        generics: [],
+                    },
+                ],
+            },
+            {
+                name: "p2",
+                fullPath: ["p2"],
+                pathWithoutLast: [],
+                pathLast: "p2",
+                generics: [],
+            },
+        ],
+        typeFilter: -1,
+        val: "-> <p> (p2)",
+        error: null,
+    },
+    {
+        args: [
+            {
+                name: "p",
+                fullPath: ["p"],
+                pathWithoutLast: [],
+                pathLast: "p",
+                generics: [],
+            },
+            {
+                name: "p2",
+                fullPath: ["p2"],
+                pathWithoutLast: [],
+                pathLast: "p2",
+                generics: [],
+            },
+        ],
+        elemName: null,
+        elems: [],
+        foundElems: 2,
+        id: "(p -> p2",
+        nameSplit: null,
+        original: "(p -> p2",
+        returned: [],
+        typeFilter: -1,
+        val: "(p -> p2",
+        error: null,
+    },
+    {
+        args: [],
+        elemName: null,
+        elems: [
+            {
+                name: "a b",
+                fullPath: ["a b"],
+                pathWithoutLast: [],
+                pathLast: "a b",
+                generics: [],
+            },
+        ],
+        foundElems: 1,
+        id: "a b",
+        nameSplit: null,
+        original: "a b",
+        returned: [],
+        typeFilter: -1,
+        val: "a b",
+        error: null,
+    },
+    {
+        args: [
+            {
+                name: "c",
+                fullPath: ["c"],
+                pathWithoutLast: [],
+                pathLast: "c",
+                generics: [],
+            },
+        ],
+        elemName: null,
+        elems: [
+            {
+                name: "a",
+                fullPath: ["a"],
+                pathWithoutLast: [],
+                pathLast: "a",
+                generics: [],
+            },
+            {
+                name: "b",
+                fullPath: ["b"],
+                pathWithoutLast: [],
+                pathLast: "b",
+                generics: [],
+            },
+        ],
+        foundElems: 3,
+        id: "a,b(c)",
+        nameSplit: null,
+        original: "a,b(c)",
+        returned: [],
+        typeFilter: -1,
+        val: "a,b(c)",
+        error: null,
+    },
+];