about summary refs log tree commit diff
path: root/src/test/rustdoc-js
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2022-05-09 11:46:24 -0700
committerMichael Howell <michael@notriddle.com>2022-05-09 11:49:05 -0700
commit360d6e4b7ddcfbb203dced9883532bc4f39137e0 (patch)
treeec34dc7e9394ae28343e96097476d054d6c46660 /src/test/rustdoc-js
parent0e345b76a5550d82caff5540649ee0ba6e3b4f3f (diff)
downloadrust-360d6e4b7ddcfbb203dced9883532bc4f39137e0.tar.gz
rust-360d6e4b7ddcfbb203dced9883532bc4f39137e0.zip
rustdoc: search result ranking fix
Diffstat (limited to 'src/test/rustdoc-js')
-rw-r--r--src/test/rustdoc-js/path-ordering.js14
-rw-r--r--src/test/rustdoc-js/path-ordering.rs9
2 files changed, 23 insertions, 0 deletions
diff --git a/src/test/rustdoc-js/path-ordering.js b/src/test/rustdoc-js/path-ordering.js
new file mode 100644
index 00000000000..4aee569b0f4
--- /dev/null
+++ b/src/test/rustdoc-js/path-ordering.js
@@ -0,0 +1,14 @@
+// exact-check
+
+const QUERY = 'b::ccccccc';
+
+const EXPECTED = {
+    'others': [
+        // `ccccccc` is an exact match for all three of these.
+        // However `b` is a closer match for `bb` than for any
+        // of the others, so it ought to go first.
+        { 'path': 'path_ordering::bb', 'name': 'Ccccccc' },
+        { 'path': 'path_ordering::aa', 'name': 'Ccccccc' },
+        { 'path': 'path_ordering::dd', 'name': 'Ccccccc' },
+    ],
+};
diff --git a/src/test/rustdoc-js/path-ordering.rs b/src/test/rustdoc-js/path-ordering.rs
new file mode 100644
index 00000000000..7843cf7f9dc
--- /dev/null
+++ b/src/test/rustdoc-js/path-ordering.rs
@@ -0,0 +1,9 @@
+pub mod dd {
+    pub struct Ccccccc;
+}
+pub mod aa {
+    pub struct Ccccccc;
+}
+pub mod bb {
+    pub struct Ccccccc;
+}