about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2023-04-15 11:53:50 -0700
committerMichael Howell <michael@notriddle.com>2023-04-17 12:16:54 -0700
commit4c11822aebd9e9c3bbe798f14fa10ec6db3f3937 (patch)
treece89e933ebd8fb99605784ddf0c97e8f3a22e20d /tests
parent1a7132d4f8dfb2ed6f9267b3bac5391a992d0775 (diff)
downloadrust-4c11822aebd9e9c3bbe798f14fa10ec6db3f3937.tar.gz
rust-4c11822aebd9e9c3bbe798f14fa10ec6db3f3937.zip
rustdoc: restructure type search engine to pick-and-use IDs
This change makes it so, instead of mixing string distance with
type unification, function signature search works by
mapping names to IDs at the start, reporting to the user any
cases where it had to make corrections, and then matches with
IDs when going through the items.

This only changes function searches. Name searches are left alone,
and corrections are only done when there's a single item in the
search query.
Diffstat (limited to 'tests')
-rw-r--r--tests/rustdoc-gui/search-corrections.goml54
-rw-r--r--tests/rustdoc-js/generics-trait.js27
2 files changed, 81 insertions, 0 deletions
diff --git a/tests/rustdoc-gui/search-corrections.goml b/tests/rustdoc-gui/search-corrections.goml
new file mode 100644
index 00000000000..832aa153054
--- /dev/null
+++ b/tests/rustdoc-gui/search-corrections.goml
@@ -0,0 +1,54 @@
+// Checks that the search tab result tell the user about corrections
+// First, try a search-by-name
+go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
+// Intentionally wrong spelling of "NotableStructWithLongName"
+write: (".search-input", "NotableStructWithLongNamr")
+// To be SURE that the search will be run.
+press-key: 'Enter'
+// Waiting for the search results to appear...
+wait-for: "#search-tabs"
+
+// Corrections aren't shown on the "In Names" tab.
+assert: "#search-tabs button.selected:first-child"
+assert-css: (".search-corrections", {
+    "display": "none"
+})
+
+// Corrections do get shown on the "In Parameters" tab.
+click: "#search-tabs button:nth-child(2)"
+assert: "#search-tabs button.selected:nth-child(2)"
+assert-css: (".search-corrections", {
+    "display": "block"
+})
+assert-text: (
+    ".search-corrections",
+    "Showing results for \"notablestructwithlongname\"."
+)
+
+// Corrections do get shown on the "In Return Type" tab.
+click: "#search-tabs button:nth-child(3)"
+assert: "#search-tabs button.selected:nth-child(3)"
+assert-css: (".search-corrections", {
+    "display": "block"
+})
+assert-text: (
+    ".search-corrections",
+    "Showing results for \"notablestructwithlongname\"."
+)
+
+// Now, explicit return values
+go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
+// Intentionally wrong spelling of "NotableStructWithLongName"
+write: (".search-input", "-> NotableStructWithLongNamr")
+// To be SURE that the search will be run.
+press-key: 'Enter'
+// Waiting for the search results to appear...
+wait-for: "#search-tabs"
+
+assert-css: (".search-corrections", {
+    "display": "block"
+})
+assert-text: (
+    ".search-corrections",
+    "Showing results for \"notablestructwithlongname\"."
+)
diff --git a/tests/rustdoc-js/generics-trait.js b/tests/rustdoc-js/generics-trait.js
index 7876622435b..0e84751603e 100644
--- a/tests/rustdoc-js/generics-trait.js
+++ b/tests/rustdoc-js/generics-trait.js
@@ -1,9 +1,21 @@
+// exact-check
+
 const QUERY = [
     'Result<SomeTrait>',
+    'Result<SomeTraiz>',
+    'OtherThingxxxxxxxx',
+    'OtherThingxxxxxxxy',
+];
+
+const CORRECTIONS = [
+    null,
+    null,
+    null,
     'OtherThingxxxxxxxx',
 ];
 
 const EXPECTED = [
+    // Result<SomeTrait>
     {
         'in_args': [
             { 'path': 'generics_trait', 'name': 'beta' },
@@ -12,6 +24,21 @@ const EXPECTED = [
             { 'path': 'generics_trait', 'name': 'bet' },
         ],
     },
+    // Result<SomeTraiz>
+    {
+        'in_args': [],
+        'returned': [],
+    },
+    // OtherThingxxxxxxxx
+    {
+        'in_args': [
+            { 'path': 'generics_trait', 'name': 'alpha' },
+        ],
+        'returned': [
+            { 'path': 'generics_trait', 'name': 'alef' },
+        ],
+    },
+    // OtherThingxxxxxxxy
     {
         'in_args': [
             { 'path': 'generics_trait', 'name': 'alpha' },