From 3501e4f3f2a0501d353fb97ca823443203095682 Mon Sep 17 00:00:00 2001 From: binarycat Date: Thu, 21 Aug 2025 17:43:04 -0500 Subject: rustdoc: add tests for raw pointers in type-based search --- tests/rustdoc-js/pointer.js | 240 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 240 insertions(+) create mode 100644 tests/rustdoc-js/pointer.js (limited to 'tests/rustdoc-js/pointer.js') diff --git a/tests/rustdoc-js/pointer.js b/tests/rustdoc-js/pointer.js new file mode 100644 index 00000000000..b2b556858fd --- /dev/null +++ b/tests/rustdoc-js/pointer.js @@ -0,0 +1,240 @@ +// exact-check + +const EXPECTED = [ + // pinkie with explicit names + { + 'query': 'usize, usize -> ()', + 'others': [ + { 'path': 'pointer', 'name': 'pinky' }, + ], + }, + { + 'query': 'pointer, usize -> ()', + 'others': [ + { 'path': 'pointer', 'name': 'pinky' }, + ], + }, + { + 'query': 'pointer, pointer -> ()', + 'others': [], + }, + { + 'query': 'pointer, usize -> ()', + 'others': [], + }, + // thumb with explicit names + { + 'query': 'thumb, thumb -> ()', + 'others': [ + { 'path': 'pointer::Thumb', 'name': 'up' }, + ], + }, + { + 'query': 'pointer, thumb -> ()', + 'others': [ + { 'path': 'pointer::Thumb', 'name': 'up' }, + ], + }, + { + 'query': 'pointer, pointer -> ()', + 'others': [], + }, + { + 'query': 'pointer, thumb -> ()', + 'others': [], + }, + // index with explicit names + { + 'query': 'index, index -> ()', + 'others': [ + { 'path': 'pointer::Index', 'name': 'point' }, + ], + }, + { + 'query': 'pointer, index -> ()', + 'others': [ + { 'path': 'pointer::Index', 'name': 'point' }, + ], + }, + { + 'query': 'pointer, pointer -> ()', + 'others': [], + }, + { + 'query': 'pointer, index -> ()', + 'others': [], + }, + // ring with explicit names + { + 'query': 'ring, ring -> ()', + 'others': [ + { 'path': 'pointer::Ring', 'name': 'wear' }, + ], + }, + { + 'query': 'pointer, ring -> ()', + 'others': [ + { 'path': 'pointer::Ring', 'name': 'wear' }, + ], + }, + { + 'query': 'pointer, pointer -> ()', + // can't leave out the `mut`, because can't reorder like that + 'others': [], + }, + { + 'query': 'pointer, pointer -> ()', + 'others': [ + { 'path': 'pointer::Ring', 'name': 'wear' }, + ], + }, + { + 'query': 'pointer, pointer -> ()', + 'others': [], + }, + // middle with explicit names + { + 'query': 'middle, middle -> ()', + 'others': [ + { 'path': 'pointer', 'name': 'show' }, + ], + }, + { + 'query': 'pointer, pointer -> ()', + // can't leave out the mut + 'others': [], + }, + { + 'query': 'pointer, pointer -> ()', + 'others': [ + { 'path': 'pointer', 'name': 'show' }, + ], + }, + { + 'query': 'pointer>, pointer> -> ()', + 'others': [ + { 'path': 'pointer', 'name': 'show' }, + ], + }, + { + 'query': 'pointer>, pointer> -> ()', + 'others': [ + { 'path': 'pointer', 'name': 'show' }, + ], + }, + { + 'query': 'pointer>, pointer> -> ()', + 'others': [], + }, + { + 'query': 'pointer>, pointer> -> ()', + 'others': [], + }, + // pinkie with shorthand + { + 'query': '*const usize, usize -> ()', + 'others': [ + { 'path': 'pointer', 'name': 'pinky' }, + ], + }, + // you can omit the `const`, if you want. + { + 'query': '*usize, usize -> ()', + 'others': [ + { 'path': 'pointer', 'name': 'pinky' }, + ], + }, + { + 'query': '*const usize, *const usize -> ()', + 'others': [], + }, + { + 'query': '*mut usize, usize -> ()', + 'others': [], + }, + // thumb with shorthand + { + 'query': '*const thumb, thumb -> ()', + 'others': [ + { 'path': 'pointer::Thumb', 'name': 'up' }, + ], + }, + { + 'query': '*const thumb, *const thumb -> ()', + 'others': [], + }, + { + 'query': '*mut thumb, thumb -> ()', + 'others': [], + }, + // index with explicit names + { + 'query': '*const index, index -> ()', + 'others': [ + { 'path': 'pointer::Index', 'name': 'point' }, + ], + }, + { + 'query': '*const index, *const index -> ()', + 'others': [], + }, + { + 'query': '*mut index, index -> ()', + 'others': [], + }, + // ring with shorthand + { + 'query': '*const ring, ring -> ()', + 'others': [ + { 'path': 'pointer::Ring', 'name': 'wear' }, + ], + }, + { + 'query': '*const ring, ring -> ()', + 'others': [ + { 'path': 'pointer::Ring', 'name': 'wear' }, + ], + }, + { + 'query': '*mut ring, *const ring -> ()', + 'others': [ + { 'path': 'pointer::Ring', 'name': 'wear' }, + ], + }, + { + 'query': '*mut ring, *mut ring -> ()', + 'others': [], + }, + // middle with shorthand + { + 'query': '*const middle, *const middle -> ()', + // can't leave out the mut + 'others': [], + }, + { + 'query': '*mut middle, *mut middle -> ()', + 'others': [ + { 'path': 'pointer', 'name': 'show' }, + ], + }, + { + 'query': '*const *mut middle, *mut *const middle -> ()', + 'others': [ + { 'path': 'pointer', 'name': 'show' }, + ], + }, + { + 'query': '*mut *const middle, *const *mut middle -> ()', + 'others': [ + { 'path': 'pointer', 'name': 'show' }, + ], + }, + { + 'query': '*const *mut middle, *const *mut middle -> ()', + 'others': [], + }, + { + 'query': '*mut *const middle, *mut *const middle -> ()', + 'others': [], + }, +]; -- cgit 1.4.1-3-g733a5