about summary refs log tree commit diff
path: root/tests/rustdoc-js-std/parser-tuple.js
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2023-09-29 12:52:30 -0700
committerMichael Howell <michael@notriddle.com>2023-12-26 12:54:17 -0700
commitf6a045cc6b24dd033c207dd63d8adccdedf672d2 (patch)
tree7ccbf87bff8e0dc808f45d9d9393cbab4a093be3 /tests/rustdoc-js-std/parser-tuple.js
parenta75fed74b62f95d1659ff70bea7895ed5c85bdba (diff)
downloadrust-f6a045cc6b24dd033c207dd63d8adccdedf672d2.tar.gz
rust-f6a045cc6b24dd033c207dd63d8adccdedf672d2.zip
rustdoc: search for tuples and unit by type with `()`
Diffstat (limited to 'tests/rustdoc-js-std/parser-tuple.js')
-rw-r--r--tests/rustdoc-js-std/parser-tuple.js365
1 files changed, 365 insertions, 0 deletions
diff --git a/tests/rustdoc-js-std/parser-tuple.js b/tests/rustdoc-js-std/parser-tuple.js
new file mode 100644
index 00000000000..eb16289d3c0
--- /dev/null
+++ b/tests/rustdoc-js-std/parser-tuple.js
@@ -0,0 +1,365 @@
+const PARSED = [
+    {
+        query: '(((D, ()))',
+        elems: [],
+        foundElems: 0,
+        original: '(((D, ()))',
+        returned: [],
+        userQuery: '(((d, ()))',
+        error: 'Unclosed `(`',
+    },
+    {
+        query: '(((D, ())))',
+        elems: [
+            {
+                name: "()",
+                fullPath: ["()"],
+                pathWithoutLast: [],
+                pathLast: "()",
+                generics: [
+                    {
+                        name: "d",
+                        fullPath: ["d"],
+                        pathWithoutLast: [],
+                        pathLast: "d",
+                        generics: [],
+                        typeFilter: -1,
+                    },
+                    {
+                        name: "()",
+                        fullPath: ["()"],
+                        pathWithoutLast: [],
+                        pathLast: "()",
+                        generics: [],
+                        typeFilter: 1,
+                    },
+                ],
+                typeFilter: 1,
+            }
+        ],
+        foundElems: 1,
+        original: '(((D, ())))',
+        returned: [],
+        userQuery: '(((d, ())))',
+        error: null,
+    },
+    {
+        query: '(),u8',
+        elems: [
+            {
+                name: "()",
+                fullPath: ["()"],
+                pathWithoutLast: [],
+                pathLast: "()",
+                generics: [],
+                typeFilter: 1,
+            },
+            {
+                name: "u8",
+                fullPath: ["u8"],
+                pathWithoutLast: [],
+                pathLast: "u8",
+                generics: [],
+                typeFilter: -1,
+            },
+        ],
+        foundElems: 2,
+        original: "(),u8",
+        returned: [],
+        userQuery: "(),u8",
+        error: null,
+    },
+    // Parens act as grouping operators when:
+    // - there's no commas directly nested within
+    // - there's at least two child types (zero means unit)
+    // - it's not tagged with a type filter
+    // Otherwise, they represent unit and/or tuple. To search for
+    // unit or tuple specifically, use `primitive:unit` or `primitive:tuple<...>`.
+    {
+        query: '(u8)',
+        elems: [
+            {
+                name: "u8",
+                fullPath: ["u8"],
+                pathWithoutLast: [],
+                pathLast: "u8",
+                generics: [],
+                typeFilter: -1,
+            },
+        ],
+        foundElems: 1,
+        original: "(u8)",
+        returned: [],
+        userQuery: "(u8)",
+        error: null,
+    },
+    {
+        query: '(u8,)',
+        elems: [
+            {
+                name: "()",
+                fullPath: ["()"],
+                pathWithoutLast: [],
+                pathLast: "()",
+                generics: [
+                    {
+                        name: "u8",
+                        fullPath: ["u8"],
+                        pathWithoutLast: [],
+                        pathLast: "u8",
+                        generics: [],
+                        typeFilter: -1,
+                    },
+                ],
+                typeFilter: 1,
+            },
+        ],
+        foundElems: 1,
+        original: "(u8,)",
+        returned: [],
+        userQuery: "(u8,)",
+        error: null,
+    },
+    {
+        query: '(,u8)',
+        elems: [
+            {
+                name: "()",
+                fullPath: ["()"],
+                pathWithoutLast: [],
+                pathLast: "()",
+                generics: [
+                    {
+                        name: "u8",
+                        fullPath: ["u8"],
+                        pathWithoutLast: [],
+                        pathLast: "u8",
+                        generics: [],
+                        typeFilter: -1,
+                    },
+                ],
+                typeFilter: 1,
+            },
+        ],
+        foundElems: 1,
+        original: "(,u8)",
+        returned: [],
+        userQuery: "(,u8)",
+        error: null,
+    },
+    {
+        query: 'primitive:(u8)',
+        elems: [
+            {
+                name: "()",
+                fullPath: ["()"],
+                pathWithoutLast: [],
+                pathLast: "()",
+                generics: [
+                    {
+                        name: "u8",
+                        fullPath: ["u8"],
+                        pathWithoutLast: [],
+                        pathLast: "u8",
+                        generics: [],
+                        typeFilter: -1,
+                    },
+                ],
+                typeFilter: 1,
+            },
+        ],
+        foundElems: 1,
+        original: "primitive:(u8)",
+        returned: [],
+        userQuery: "primitive:(u8)",
+        error: null,
+    },
+    {
+        query: '(primitive:u8)',
+        elems: [
+            {
+                name: "u8",
+                fullPath: ["u8"],
+                pathWithoutLast: [],
+                pathLast: "u8",
+                generics: [],
+                typeFilter: 1,
+            },
+        ],
+        foundElems: 1,
+        original: "(primitive:u8)",
+        returned: [],
+        userQuery: "(primitive:u8)",
+        error: null,
+    },
+    {
+        query: '(u8,u8)',
+        elems: [
+            {
+                name: "()",
+                fullPath: ["()"],
+                pathWithoutLast: [],
+                pathLast: "()",
+                generics: [
+                    {
+                        name: "u8",
+                        fullPath: ["u8"],
+                        pathWithoutLast: [],
+                        pathLast: "u8",
+                        generics: [],
+                        typeFilter: -1,
+                    },
+                    {
+                        name: "u8",
+                        fullPath: ["u8"],
+                        pathWithoutLast: [],
+                        pathLast: "u8",
+                        generics: [],
+                        typeFilter: -1,
+                    },
+                ],
+                typeFilter: 1,
+            },
+        ],
+        foundElems: 1,
+        original: "(u8,u8)",
+        returned: [],
+        userQuery: "(u8,u8)",
+        error: null,
+    },
+    {
+        query: '(u8<u8>)',
+        elems: [
+            {
+                name: "u8",
+                fullPath: ["u8"],
+                pathWithoutLast: [],
+                pathLast: "u8",
+                generics: [
+                    {
+                        name: "u8",
+                        fullPath: ["u8"],
+                        pathWithoutLast: [],
+                        pathLast: "u8",
+                        generics: [],
+                        typeFilter: -1,
+                    },
+                ],
+                typeFilter: -1,
+            },
+        ],
+        foundElems: 1,
+        original: "(u8<u8>)",
+        returned: [],
+        userQuery: "(u8<u8>)",
+        error: null,
+    },
+    {
+        query: '()',
+        elems: [
+            {
+                name: "()",
+                fullPath: ["()"],
+                pathWithoutLast: [],
+                pathLast: "()",
+                generics: [],
+                typeFilter: 1,
+            },
+        ],
+        foundElems: 1,
+        original: "()",
+        returned: [],
+        userQuery: "()",
+        error: null,
+    },
+    {
+        query: '(>',
+        elems: [],
+        foundElems: 0,
+        original: "(>",
+        returned: [],
+        userQuery: "(>",
+        error: "Unexpected `>` after `(`",
+    },
+    {
+        query: '(<',
+        elems: [],
+        foundElems: 0,
+        original: "(<",
+        returned: [],
+        userQuery: "(<",
+        error: "Found generics without a path",
+    },
+    {
+        query: '(a>',
+        elems: [],
+        foundElems: 0,
+        original: "(a>",
+        returned: [],
+        userQuery: "(a>",
+        error: "Unexpected `>` after `(`",
+    },
+    {
+        query: '(a<',
+        elems: [],
+        foundElems: 0,
+        original: "(a<",
+        returned: [],
+        userQuery: "(a<",
+        error: "Unclosed `<`",
+    },
+    {
+        query: '(a',
+        elems: [],
+        foundElems: 0,
+        original: "(a",
+        returned: [],
+        userQuery: "(a",
+        error: "Unclosed `(`",
+    },
+    {
+        query: '(',
+        elems: [],
+        foundElems: 0,
+        original: "(",
+        returned: [],
+        userQuery: "(",
+        error: "Unclosed `(`",
+    },
+    {
+        query: ')',
+        elems: [],
+        foundElems: 0,
+        original: ")",
+        returned: [],
+        userQuery: ")",
+        error: "Unexpected `)`",
+    },
+    {
+        query: '(a<b>',
+        elems: [],
+        foundElems: 0,
+        original: "(a<b>",
+        returned: [],
+        userQuery: "(a<b>",
+        error: "Unclosed `(`",
+    },
+    {
+        query: 'a<b>)',
+        elems: [],
+        foundElems: 0,
+        original: "a<b>)",
+        returned: [],
+        userQuery: "a<b>)",
+        error: "Unexpected `)` after `>`",
+    },
+    {
+        query: 'macro:(u8)',
+        elems: [],
+        foundElems: 0,
+        original: "macro:(u8)",
+        returned: [],
+        userQuery: "macro:(u8)",
+        error: "Invalid search type: primitive `()` and `macro` both specified",
+    },
+];