about summary refs log tree commit diff
path: root/tests/rustdoc-js-std
diff options
context:
space:
mode:
Diffstat (limited to 'tests/rustdoc-js-std')
-rw-r--r--tests/rustdoc-js-std/alias-1.js6
-rw-r--r--tests/rustdoc-js-std/parser-reference.js527
-rw-r--r--tests/rustdoc-js-std/vec-new.js36
3 files changed, 565 insertions, 4 deletions
diff --git a/tests/rustdoc-js-std/alias-1.js b/tests/rustdoc-js-std/alias-1.js
index b27b3da2179..c31d1a3b1ad 100644
--- a/tests/rustdoc-js-std/alias-1.js
+++ b/tests/rustdoc-js-std/alias-1.js
@@ -1,6 +1,10 @@
 const EXPECTED = {
     'query': '&',
     'others': [
-        { 'path': 'std', 'name': 'reference' },
+        {
+            'path': 'std',
+            'name': 'reference',
+            'desc': "References, <code>&amp;T</code> and <code>&amp;mut T</code>.",
+        },
     ],
 };
diff --git a/tests/rustdoc-js-std/parser-reference.js b/tests/rustdoc-js-std/parser-reference.js
new file mode 100644
index 00000000000..6b1250146be
--- /dev/null
+++ b/tests/rustdoc-js-std/parser-reference.js
@@ -0,0 +1,527 @@
+const PARSED = [
+    {
+        query: '&[',
+        elems: [],
+        foundElems: 0,
+        original: '&[',
+        returned: [],
+        userQuery: '&[',
+        error: 'Unclosed `[`',
+    },
+    {
+        query: '[&',
+        elems: [],
+        foundElems: 0,
+        original: '[&',
+        returned: [],
+        userQuery: '[&',
+        error: 'Unclosed `[`',
+    },
+    {
+        query: '&&&D, []',
+        elems: [
+            {
+                name: "reference",
+                fullPath: ["reference"],
+                pathWithoutLast: [],
+                pathLast: "reference",
+                generics: [
+                    {
+                        name: "reference",
+                        fullPath: ["reference"],
+                        pathWithoutLast: [],
+                        pathLast: "reference",
+                        generics: [
+                            {
+                                name: "reference",
+                                fullPath: ["reference"],
+                                pathWithoutLast: [],
+                                pathLast: "reference",
+                                generics: [
+                                    {
+                                        name: "d",
+                                        fullPath: ["d"],
+                                        pathWithoutLast: [],
+                                        pathLast: "d",
+                                        generics: [],
+                                        typeFilter: -1,
+                                    },
+                                ],
+                                typeFilter: 1,
+                            },
+                        ],
+                        typeFilter: 1,
+                    },
+                ],
+                typeFilter: 1,
+            },
+            {
+                name: "[]",
+                fullPath: ["[]"],
+                pathWithoutLast: [],
+                pathLast: "[]",
+                generics: [],
+                typeFilter: 1,
+            },
+        ],
+        foundElems: 2,
+        original: '&&&D, []',
+        returned: [],
+        userQuery: '&&&d, []',
+        error: null,
+    },
+    {
+        query: '&&&[D]',
+        elems: [
+            {
+                name: "reference",
+                fullPath: ["reference"],
+                pathWithoutLast: [],
+                pathLast: "reference",
+                generics: [
+                    {
+                        name: "reference",
+                        fullPath: ["reference"],
+                        pathWithoutLast: [],
+                        pathLast: "reference",
+                        generics: [
+                            {
+                                name: "reference",
+                                fullPath: ["reference"],
+                                pathWithoutLast: [],
+                                pathLast: "reference",
+                                generics: [
+                                    {
+                                        name: "[]",
+                                        fullPath: ["[]"],
+                                        pathWithoutLast: [],
+                                        pathLast: "[]",
+                                        generics: [
+                                            {
+                                                name: "d",
+                                                fullPath: ["d"],
+                                                pathWithoutLast: [],
+                                                pathLast: "d",
+                                                generics: [],
+                                                typeFilter: -1,
+                                            },
+                                        ],
+                                        typeFilter: 1,
+                                    },
+                                ],
+                                typeFilter: 1,
+                            },
+                        ],
+                        typeFilter: 1,
+                    },
+                ],
+                typeFilter: 1,
+            },
+        ],
+        foundElems: 1,
+        original: '&&&[D]',
+        returned: [],
+        userQuery: '&&&[d]',
+        error: null,
+    },
+    {
+        query: '&',
+        elems: [
+            {
+                name: "reference",
+                fullPath: ["reference"],
+                pathWithoutLast: [],
+                pathLast: "reference",
+                generics: [],
+                typeFilter: 1,
+            },
+        ],
+        foundElems: 1,
+        original: '&',
+        returned: [],
+        userQuery: '&',
+        error: null,
+    },
+    {
+        query: '&mut',
+        elems: [
+            {
+                name: "reference",
+                fullPath: ["reference"],
+                pathWithoutLast: [],
+                pathLast: "reference",
+                generics: [
+                    {
+                        name: "mut",
+                        fullPath: ["mut"],
+                        pathWithoutLast: [],
+                        pathLast: "mut",
+                        generics: [],
+                        typeFilter: 0,
+                    },
+                ],
+                typeFilter: 1,
+            },
+        ],
+        foundElems: 1,
+        original: '&mut',
+        returned: [],
+        userQuery: '&mut',
+        error: null,
+    },
+    {
+        query: '&,u8',
+        elems: [
+            {
+                name: "reference",
+                fullPath: ["reference"],
+                pathWithoutLast: [],
+                pathLast: "reference",
+                generics: [],
+                typeFilter: 1,
+            },
+            {
+                name: "u8",
+                fullPath: ["u8"],
+                pathWithoutLast: [],
+                pathLast: "u8",
+                generics: [],
+                typeFilter: -1,
+            },
+        ],
+        foundElems: 2,
+        original: "&,u8",
+        returned: [],
+        userQuery: "&,u8",
+        error: null,
+    },
+    {
+        query: '&mut,u8',
+        elems: [
+            {
+                name: "reference",
+                fullPath: ["reference"],
+                pathWithoutLast: [],
+                pathLast: "reference",
+                generics: [
+                    {
+                        name: "mut",
+                        fullPath: ["mut"],
+                        pathWithoutLast: [],
+                        pathLast: "mut",
+                        generics: [],
+                        typeFilter: 0,
+                    },
+                ],
+                typeFilter: 1,
+            },
+            {
+                name: "u8",
+                fullPath: ["u8"],
+                pathWithoutLast: [],
+                pathLast: "u8",
+                generics: [],
+                typeFilter: -1,
+            },
+        ],
+        foundElems: 2,
+        original: "&mut,u8",
+        returned: [],
+        userQuery: "&mut,u8",
+        error: null,
+    },
+    {
+        query: '&u8',
+        elems: [
+            {
+                name: "reference",
+                fullPath: ["reference"],
+                pathWithoutLast: [],
+                pathLast: "reference",
+                generics: [
+                    {
+                        name: "u8",
+                        fullPath: ["u8"],
+                        pathWithoutLast: [],
+                        pathLast: "u8",
+                        generics: [],
+                        typeFilter: -1,
+                    },
+                ],
+                typeFilter: 1,
+            },
+        ],
+        foundElems: 1,
+        original: "&u8",
+        returned: [],
+        userQuery: "&u8",
+        error: null,
+    },
+    {
+        query: '&u8<u8>',
+        elems: [
+            {
+                name: "reference",
+                fullPath: ["reference"],
+                pathWithoutLast: [],
+                pathLast: "reference",
+                generics: [
+                    {
+                        name: "u8",
+                        fullPath: ["u8"],
+                        pathWithoutLast: [],
+                        pathLast: "u8",
+                        generics: [
+                            {
+                                name: "u8",
+                                fullPath: ["u8"],
+                                pathWithoutLast: [],
+                                pathLast: "u8",
+                                generics: [],
+                                typeFilter: -1,
+                            },
+                        ],
+                        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: "reference",
+                        fullPath: ["reference"],
+                        pathWithoutLast: [],
+                        pathLast: "reference",
+                        generics: [
+                            {
+                                name: "u8",
+                                fullPath: ["u8"],
+                                pathWithoutLast: [],
+                                pathLast: "u8",
+                                generics: [],
+                                typeFilter: -1,
+                            },
+                        ],
+                        typeFilter: 1,
+                    },
+                ],
+                typeFilter: -1,
+            },
+        ],
+        foundElems: 1,
+        original: "u8<&u8>",
+        returned: [],
+        userQuery: "u8<&u8>",
+        error: null,
+    },
+    {
+        query: 'u8<&u8, u8>',
+        elems: [
+            {
+                name: "u8",
+                fullPath: ["u8"],
+                pathWithoutLast: [],
+                pathLast: "u8",
+                generics: [
+                    {
+                        name: "reference",
+                        fullPath: ["reference"],
+                        pathWithoutLast: [],
+                        pathLast: "reference",
+                        generics: [
+                            {
+                                name: "u8",
+                                fullPath: ["u8"],
+                                pathWithoutLast: [],
+                                pathLast: "u8",
+                                generics: [],
+                                typeFilter: -1,
+                            },
+                        ],
+                        typeFilter: 1,
+                    },
+                    {
+                        name: "u8",
+                        fullPath: ["u8"],
+                        pathWithoutLast: [],
+                        pathLast: "u8",
+                        generics: [],
+                        typeFilter: -1,
+                    },
+                ],
+                typeFilter: -1,
+            },
+        ],
+        foundElems: 1,
+        original: "u8<&u8, u8>",
+        returned: [],
+        userQuery: "u8<&u8, u8>",
+        error: null,
+    },
+    {
+        query: 'u8<&u8>',
+        elems: [
+            {
+                name: "u8",
+                fullPath: ["u8"],
+                pathWithoutLast: [],
+                pathLast: "u8",
+                generics: [
+                    {
+                        name: "reference",
+                        fullPath: ["reference"],
+                        pathWithoutLast: [],
+                        pathLast: "reference",
+                        generics: [
+                            {
+                                name: "u8",
+                                fullPath: ["u8"],
+                                pathWithoutLast: [],
+                                pathLast: "u8",
+                                generics: [],
+                                typeFilter: -1,
+                            },
+                        ],
+                        typeFilter: 1,
+                    },
+                ],
+                typeFilter: -1,
+            },
+        ],
+        foundElems: 1,
+        original: "u8<&u8>",
+        returned: [],
+        userQuery: "u8<&u8>",
+        error: null,
+    },
+    {
+        query: 'u8<&mut u8, u8>',
+        elems: [
+            {
+                name: "u8",
+                fullPath: ["u8"],
+                pathWithoutLast: [],
+                pathLast: "u8",
+                generics: [
+                    {
+                        name: "reference",
+                        fullPath: ["reference"],
+                        pathWithoutLast: [],
+                        pathLast: "reference",
+                        generics: [
+                            {
+                                name: "mut",
+                                fullPath: ["mut"],
+                                pathWithoutLast: [],
+                                pathLast: "mut",
+                                generics: [],
+                                typeFilter: 0,
+                            },
+                            {
+                                name: "u8",
+                                fullPath: ["u8"],
+                                pathWithoutLast: [],
+                                pathLast: "u8",
+                                generics: [],
+                                typeFilter: -1,
+                            },
+                        ],
+                        typeFilter: 1,
+                    },
+                    {
+                        name: "u8",
+                        fullPath: ["u8"],
+                        pathWithoutLast: [],
+                        pathLast: "u8",
+                        generics: [],
+                        typeFilter: -1,
+                    },
+                ],
+                typeFilter: -1,
+            },
+        ],
+        foundElems: 1,
+        original: "u8<&mut u8, u8>",
+        returned: [],
+        userQuery: "u8<&mut u8, u8>",
+        error: null,
+    },
+    {
+        query: 'primitive:&u8',
+        elems: [
+            {
+                name: "reference",
+                fullPath: ["reference"],
+                pathWithoutLast: [],
+                pathLast: "reference",
+                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: 'macro:&u8',
+        elems: [],
+        foundElems: 0,
+        original: "macro:&u8",
+        returned: [],
+        userQuery: "macro:&u8",
+        error: "Invalid search type: primitive `&` and `macro` both specified",
+    },
+    {
+        query: '&macro:u8',
+        elems: [
+            {
+                name: "reference",
+                fullPath: ["reference"],
+                pathWithoutLast: [],
+                pathLast: "reference",
+                generics: [
+                    {
+                        name: "u8",
+                        fullPath: ["u8"],
+                        pathWithoutLast: [],
+                        pathLast: "u8",
+                        generics: [],
+                        typeFilter: 16,
+                    },
+                ],
+                typeFilter: 1,
+            },
+        ],
+        foundElems: 1,
+        original: "&macro:u8",
+        returned: [],
+        userQuery: "&macro:u8",
+        error: null,
+    },
+];
diff --git a/tests/rustdoc-js-std/vec-new.js b/tests/rustdoc-js-std/vec-new.js
index 9823a417a5d..bb122ff4398 100644
--- a/tests/rustdoc-js-std/vec-new.js
+++ b/tests/rustdoc-js-std/vec-new.js
@@ -3,17 +3,47 @@ const EXPECTED = [
         'query': 'Vec::new',
         'others': [
             { 'path': 'std::vec::Vec', 'name': 'new' },
-            { 'path': 'alloc::vec::Vec', 'name': 'new' },
             { 'path': 'std::vec::Vec', 'name': 'new_in' },
-            { 'path': 'alloc::vec::Vec', 'name': 'new_in' },
+        ],
+    },
+    {
+        'query': 'prelude::vec',
+        'others': [
+            { 'path': 'std::prelude::rust_2024', 'name': 'Vec' },
         ],
     },
     {
         'query': 'Vec new',
         'others': [
             { 'path': 'std::vec::Vec', 'name': 'new' },
-            { 'path': 'alloc::vec::Vec', 'name': 'new' },
             { 'path': 'std::vec::Vec', 'name': 'new_in' },
+        ],
+    },
+    {
+        'query': 'std::Vec::new',
+        'others': [
+            { 'path': 'std::vec::Vec', 'name': 'new' },
+            { 'path': 'std::vec::Vec', 'name': 'new_in' },
+        ],
+    },
+    {
+        'query': 'std Vec new',
+        'others': [
+            { 'path': 'std::vec::Vec', 'name': 'new' },
+            { 'path': 'std::vec::Vec', 'name': 'new_in' },
+        ],
+    },
+    {
+        'query': 'alloc::Vec::new',
+        'others': [
+            { 'path': 'alloc::vec::Vec', 'name': 'new' },
+            { 'path': 'alloc::vec::Vec', 'name': 'new_in' },
+        ],
+    },
+    {
+        'query': 'alloc Vec new',
+        'others': [
+            { 'path': 'alloc::vec::Vec', 'name': 'new' },
             { 'path': 'alloc::vec::Vec', 'name': 'new_in' },
         ],
     },