summaryrefslogtreecommitdiffstats
path: root/tests/rustdoc-js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/rustdoc-js-std/parser-errors.js34
-rw-r--r--tests/rustdoc-js-std/parser-filter.js47
-rw-r--r--tests/rustdoc-js-std/parser-ident.js40
-rw-r--r--tests/rustdoc-js-std/reference-shrink.js8
-rw-r--r--tests/rustdoc-js-std/regex.js10
-rw-r--r--tests/rustdoc-js-std/typed-query.js4
-rw-r--r--tests/rustdoc-js/doc-alias.js2
-rw-r--r--tests/rustdoc-js/macro-search.js10
-rw-r--r--tests/rustdoc-js/macro-search.rs10
-rw-r--r--tests/rustdoc-js/module-substring.js1
-rw-r--r--tests/rustdoc-json/reexport/same_name_different_types.rs25
11 files changed, 163 insertions, 28 deletions
diff --git a/tests/rustdoc-js-std/parser-errors.js b/tests/rustdoc-js-std/parser-errors.js
index dc42031e0..98c6f27ca 100644
--- a/tests/rustdoc-js-std/parser-errors.js
+++ b/tests/rustdoc-js-std/parser-errors.js
@@ -37,6 +37,9 @@ const QUERY = [
"mod : :",
"a!a",
"a!!",
+ "mod:a!",
+ "a!::a",
+ "a<",
];
const PARSED = [
@@ -65,7 +68,7 @@ const PARSED = [
returned: [],
typeFilter: -1,
userQuery: "a<\"p\">",
- error: "`\"` cannot be used in generics",
+ error: "Unexpected `\"` in generics",
},
{
elems: [],
@@ -371,7 +374,7 @@ const PARSED = [
returned: [],
typeFilter: -1,
userQuery: "a!a",
- error: '`!` can only be at the end of an ident',
+ error: 'Unexpected `!`: it can only be at the end of an ident',
},
{
elems: [],
@@ -382,4 +385,31 @@ const PARSED = [
userQuery: "a!!",
error: 'Cannot have more than one `!` in an ident',
},
+ {
+ elems: [],
+ foundElems: 0,
+ original: "mod:a!",
+ returned: [],
+ typeFilter: -1,
+ userQuery: "mod:a!",
+ error: 'Invalid search type: macro `!` and `mod` both specified',
+ },
+ {
+ elems: [],
+ foundElems: 0,
+ original: "a!::a",
+ returned: [],
+ typeFilter: -1,
+ userQuery: "a!::a",
+ error: 'Cannot have associated items in macros',
+ },
+ {
+ elems: [],
+ foundElems: 0,
+ original: "a<",
+ returned: [],
+ typeFilter: -1,
+ userQuery: "a<",
+ error: "Unclosed `<`",
+ },
];
diff --git a/tests/rustdoc-js-std/parser-filter.js b/tests/rustdoc-js-std/parser-filter.js
index e5a87a415..01f65b478 100644
--- a/tests/rustdoc-js-std/parser-filter.js
+++ b/tests/rustdoc-js-std/parser-filter.js
@@ -1,4 +1,4 @@
-const QUERY = ['fn:foo', 'enum : foo', 'macro<f>:foo'];
+const QUERY = ['fn:foo', 'enum : foo', 'macro<f>:foo', 'macro!', 'macro:mac!', 'a::mac!'];
const PARSED = [
{
@@ -40,4 +40,49 @@ const PARSED = [
userQuery: "macro<f>:foo",
error: "Unexpected `:`",
},
+ {
+ elems: [{
+ name: "macro",
+ fullPath: ["macro"],
+ pathWithoutLast: [],
+ pathLast: "macro",
+ generics: [],
+ }],
+ foundElems: 1,
+ original: "macro!",
+ returned: [],
+ typeFilter: 14,
+ userQuery: "macro!",
+ error: null,
+ },
+ {
+ elems: [{
+ name: "mac",
+ fullPath: ["mac"],
+ pathWithoutLast: [],
+ pathLast: "mac",
+ generics: [],
+ }],
+ foundElems: 1,
+ original: "macro:mac!",
+ returned: [],
+ typeFilter: 14,
+ userQuery: "macro:mac!",
+ error: null,
+ },
+ {
+ elems: [{
+ name: "a::mac",
+ fullPath: ["a", "mac"],
+ pathWithoutLast: ["a"],
+ pathLast: "mac",
+ generics: [],
+ }],
+ foundElems: 1,
+ original: "a::mac!",
+ returned: [],
+ typeFilter: 14,
+ userQuery: "a::mac!",
+ error: null,
+ },
];
diff --git a/tests/rustdoc-js-std/parser-ident.js b/tests/rustdoc-js-std/parser-ident.js
index 4b5ab01ac..6c17d00f1 100644
--- a/tests/rustdoc-js-std/parser-ident.js
+++ b/tests/rustdoc-js-std/parser-ident.js
@@ -3,6 +3,7 @@ const QUERY = [
"!",
"a!",
"a!::b",
+ "!::b",
"a!::b!",
];
@@ -47,47 +48,50 @@ const PARSED = [
},
{
elems: [{
- name: "a!",
- fullPath: ["a!"],
+ name: "a",
+ fullPath: ["a"],
pathWithoutLast: [],
- pathLast: "a!",
+ pathLast: "a",
generics: [],
}],
foundElems: 1,
original: "a!",
returned: [],
- typeFilter: -1,
+ typeFilter: 14,
userQuery: "a!",
error: null,
},
{
- elems: [{
- name: "a!::b",
- fullPath: ["a!", "b"],
- pathWithoutLast: ["a!"],
- pathLast: "b",
- generics: [],
- }],
- foundElems: 1,
+ elems: [],
+ foundElems: 0,
original: "a!::b",
returned: [],
typeFilter: -1,
userQuery: "a!::b",
- error: null,
+ error: "Cannot have associated items in macros",
},
{
elems: [{
- name: "a!::b!",
- fullPath: ["a!", "b!"],
- pathWithoutLast: ["a!"],
- pathLast: "b!",
+ name: "!::b",
+ fullPath: ["!", "b"],
+ pathWithoutLast: ["!"],
+ pathLast: "b",
generics: [],
}],
foundElems: 1,
+ original: "!::b",
+ returned: [],
+ typeFilter: -1,
+ userQuery: "!::b",
+ error: null,
+ },
+ {
+ elems: [],
+ foundElems: 0,
original: "a!::b!",
returned: [],
typeFilter: -1,
userQuery: "a!::b!",
- error: null,
+ error: "Cannot have associated items in macros",
},
];
diff --git a/tests/rustdoc-js-std/reference-shrink.js b/tests/rustdoc-js-std/reference-shrink.js
new file mode 100644
index 000000000..f90be6d1b
--- /dev/null
+++ b/tests/rustdoc-js-std/reference-shrink.js
@@ -0,0 +1,8 @@
+// exact-check
+
+const QUERY = 'reference::shrink';
+
+const EXPECTED = {
+ // avoid including the method that's not going to be in the HTML
+ 'others': [],
+};
diff --git a/tests/rustdoc-js-std/regex.js b/tests/rustdoc-js-std/regex.js
new file mode 100644
index 000000000..a6843c595
--- /dev/null
+++ b/tests/rustdoc-js-std/regex.js
@@ -0,0 +1,10 @@
+// exact-check
+
+// https://github.com/rust-lang/rust/issues/103357
+const QUERY = 'regex';
+
+const EXPECTED = {
+ 'others': [],
+ 'in_args': [],
+ 'returned': [],
+};
diff --git a/tests/rustdoc-js-std/typed-query.js b/tests/rustdoc-js-std/typed-query.js
index fd5c5489d..eeb3e1888 100644
--- a/tests/rustdoc-js-std/typed-query.js
+++ b/tests/rustdoc-js-std/typed-query.js
@@ -9,9 +9,5 @@ const EXPECTED = {
{ 'path': 'std', 'name': 'println' },
{ 'path': 'std', 'name': 'eprint' },
{ 'path': 'std', 'name': 'eprintln' },
- { 'path': 'std::pin', 'name': 'pin' },
- { 'path': 'std::future', 'name': 'join' },
- { 'path': 'std', 'name': 'line' },
- { 'path': 'std', 'name': 'write' },
],
};
diff --git a/tests/rustdoc-js/doc-alias.js b/tests/rustdoc-js/doc-alias.js
index 7bb0cbe38..62c8e7a74 100644
--- a/tests/rustdoc-js/doc-alias.js
+++ b/tests/rustdoc-js/doc-alias.js
@@ -1,5 +1,3 @@
-// exact-check
-
const QUERY = [
'StructItem',
'StructFieldItem',
diff --git a/tests/rustdoc-js/macro-search.js b/tests/rustdoc-js/macro-search.js
new file mode 100644
index 000000000..2b179ce14
--- /dev/null
+++ b/tests/rustdoc-js/macro-search.js
@@ -0,0 +1,10 @@
+// exact-check
+
+const QUERY = 'abracadabra!';
+
+const EXPECTED = {
+ 'others': [
+ { 'path': 'macro_search', 'name': 'abracadabra' },
+ { 'path': 'macro_search', 'name': 'abracadabra_b' },
+ ],
+};
diff --git a/tests/rustdoc-js/macro-search.rs b/tests/rustdoc-js/macro-search.rs
new file mode 100644
index 000000000..dc397490c
--- /dev/null
+++ b/tests/rustdoc-js/macro-search.rs
@@ -0,0 +1,10 @@
+#[macro_export]
+macro_rules! abracadabra {
+ () => {}
+}
+#[macro_export]
+macro_rules! abracadabra_b {
+ () => {}
+}
+pub fn abracadabra() {}
+pub fn abracadabra_c() {}
diff --git a/tests/rustdoc-js/module-substring.js b/tests/rustdoc-js/module-substring.js
index a446c39eb..f17a97f13 100644
--- a/tests/rustdoc-js/module-substring.js
+++ b/tests/rustdoc-js/module-substring.js
@@ -4,6 +4,5 @@ const EXPECTED = {
'others': [
{ 'path': 'module_substring::Sig', 'name': 'pc' },
{ 'path': 'module_substring::Si', 'name': 'pc' },
- { 'path': 'module_substring::Si', 'name': 'pa' },
],
};
diff --git a/tests/rustdoc-json/reexport/same_name_different_types.rs b/tests/rustdoc-json/reexport/same_name_different_types.rs
new file mode 100644
index 000000000..2314a4eb9
--- /dev/null
+++ b/tests/rustdoc-json/reexport/same_name_different_types.rs
@@ -0,0 +1,25 @@
+// Regression test for <https://github.com/rust-lang/rust/issues/107677>.
+
+#![feature(no_core)]
+#![no_core]
+
+pub mod nested {
+ // @set foo_struct = "$.index[*][?(@.docs == 'Foo the struct')].id"
+
+ /// Foo the struct
+ pub struct Foo {}
+
+ // @set foo_fn = "$.index[*][?(@.docs == 'Foo the function')].id"
+
+ #[allow(non_snake_case)]
+ /// Foo the function
+ pub fn Foo() {}
+}
+
+// @ismany "$.index[*][?(@.inner.name == 'Foo' && @.kind == 'import')].inner.id" $foo_fn $foo_struct
+// @ismany "$.index[*][?(@.inner.name == 'Bar' && @.kind == 'import')].inner.id" $foo_fn $foo_struct
+
+// @count "$.index[*][?(@.inner.name == 'Foo' && @.kind == 'import')]" 2
+pub use nested::Foo;
+// @count "$.index[*][?(@.inner.name == 'Bar' && @.kind == 'import')]" 2
+pub use Foo as Bar;