From 05eda416580ff9be12a6cf87238c8047a1699dd3 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 1 Sep 2023 14:31:01 +0200 Subject: [PATCH] Add tests for type-based search --- tests/rustdoc-js-std/full-path-function.js | 7 ++++++ tests/rustdoc-js/full-path-function.js | 25 ++++++++++++++++++++++ tests/rustdoc-js/full-path-function.rs | 16 ++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 tests/rustdoc-js-std/full-path-function.js create mode 100644 tests/rustdoc-js/full-path-function.js create mode 100644 tests/rustdoc-js/full-path-function.rs diff --git a/tests/rustdoc-js-std/full-path-function.js b/tests/rustdoc-js-std/full-path-function.js new file mode 100644 index 00000000000..ac157b3aadf --- /dev/null +++ b/tests/rustdoc-js-std/full-path-function.js @@ -0,0 +1,7 @@ +const EXPECTED = { + 'query': 'vec::vec -> usize', + 'others': [ + { 'path': 'std::vec::Vec', 'name': 'len' }, + { 'path': 'std::vec::Vec', 'name': 'capacity' }, + ], +}; diff --git a/tests/rustdoc-js/full-path-function.js b/tests/rustdoc-js/full-path-function.js new file mode 100644 index 00000000000..9d3c3a4506c --- /dev/null +++ b/tests/rustdoc-js/full-path-function.js @@ -0,0 +1,25 @@ +// exact-check + +const EXPECTED = [ + { + 'query': 'sac -> usize', + 'others': [ + { 'path': 'full_path_function::b::Sac', 'name': 'bar' }, + { 'path': 'full_path_function::b::Sac', 'name': 'len' }, + { 'path': 'full_path_function::sac::Sac', 'name': 'len' }, + ], + }, + { + 'query': 'b::sac -> usize', + 'others': [ + { 'path': 'full_path_function::b::Sac', 'name': 'bar' }, + { 'path': 'full_path_function::b::Sac', 'name': 'len' }, + ], + }, + { + 'query': 'b::sac -> u32', + 'others': [ + { 'path': 'full_path_function::b::Sac', 'name': 'bar2' }, + ], + }, +]; diff --git a/tests/rustdoc-js/full-path-function.rs b/tests/rustdoc-js/full-path-function.rs new file mode 100644 index 00000000000..c1ec1e1731b --- /dev/null +++ b/tests/rustdoc-js/full-path-function.rs @@ -0,0 +1,16 @@ +pub mod sac { + pub struct Sac; + + impl Sac { + pub fn len(&self) -> usize { 0 } + } +} + +pub mod b { + pub struct Sac; + impl Sac { + pub fn len(&self) -> usize { 0 } + pub fn bar(&self, w: u32) -> usize { 0 } + pub fn bar2(&self, w: u32) -> u32 { 0 } + } +}