Skip to content

Commit 7ea3554

Browse files
committed
rustdoc: add tests for raw pointers in type-based search
1 parent b7bcb4f commit 7ea3554

File tree

2 files changed

+280
-0
lines changed

2 files changed

+280
-0
lines changed

tests/rustdoc-js/pointer.js

Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
// exact-check
2+
3+
const EXPECTED = [
4+
// pinkie with explicit names
5+
{
6+
'query': 'usize, usize -> ()',
7+
'others': [
8+
{ 'path': 'pointer', 'name': 'pinky' },
9+
],
10+
},
11+
{
12+
'query': 'pointer<usize>, usize -> ()',
13+
'others': [
14+
{ 'path': 'pointer', 'name': 'pinky' },
15+
],
16+
},
17+
{
18+
'query': 'pointer<usize>, pointer<usize> -> ()',
19+
'others': [],
20+
},
21+
{
22+
'query': 'pointer<mut, usize>, usize -> ()',
23+
'others': [],
24+
},
25+
// thumb with explicit names
26+
{
27+
'query': 'thumb, thumb -> ()',
28+
'others': [
29+
{ 'path': 'pointer::Thumb', 'name': 'up' },
30+
],
31+
},
32+
{
33+
'query': 'pointer<thumb>, thumb -> ()',
34+
'others': [
35+
{ 'path': 'pointer::Thumb', 'name': 'up' },
36+
],
37+
},
38+
{
39+
'query': 'pointer<thumb>, pointer<thumb> -> ()',
40+
'others': [],
41+
},
42+
{
43+
'query': 'pointer<mut, thumb>, thumb -> ()',
44+
'others': [],
45+
},
46+
// index with explicit names
47+
{
48+
'query': 'index, index -> ()',
49+
'others': [
50+
{ 'path': 'pointer::Index', 'name': 'point' },
51+
],
52+
},
53+
{
54+
'query': 'pointer<index>, index -> ()',
55+
'others': [
56+
{ 'path': 'pointer::Index', 'name': 'point' },
57+
],
58+
},
59+
{
60+
'query': 'pointer<index>, pointer<index> -> ()',
61+
'others': [],
62+
},
63+
{
64+
'query': 'pointer<mut, index>, index -> ()',
65+
'others': [],
66+
},
67+
// ring with explicit names
68+
{
69+
'query': 'ring, ring -> ()',
70+
'others': [
71+
{ 'path': 'pointer::Ring', 'name': 'wear' },
72+
],
73+
},
74+
{
75+
'query': 'pointer<ring>, ring -> ()',
76+
'others': [
77+
{ 'path': 'pointer::Ring', 'name': 'wear' },
78+
],
79+
},
80+
{
81+
'query': 'pointer<ring>, pointer<ring> -> ()',
82+
// can't leave out the `mut`, because can't reorder like that
83+
'others': [],
84+
},
85+
{
86+
'query': 'pointer<mut, ring>, pointer<ring> -> ()',
87+
'others': [
88+
{ 'path': 'pointer::Ring', 'name': 'wear' },
89+
],
90+
},
91+
{
92+
'query': 'pointer<mut, ring>, pointer<mut, ring> -> ()',
93+
'others': [],
94+
},
95+
// middle with explicit names
96+
{
97+
'query': 'middle, middle -> ()',
98+
'others': [
99+
{ 'path': 'pointer', 'name': 'show' },
100+
],
101+
},
102+
{
103+
'query': 'pointer<middle>, pointer<middle> -> ()',
104+
// can't leave out the mut
105+
'others': [],
106+
},
107+
{
108+
'query': 'pointer<mut, middle>, pointer<mut, middle> -> ()',
109+
'others': [
110+
{ 'path': 'pointer', 'name': 'show' },
111+
],
112+
},
113+
{
114+
'query': 'pointer<pointer<mut, middle>>, pointer<mut, pointer<middle>> -> ()',
115+
'others': [
116+
{ 'path': 'pointer', 'name': 'show' },
117+
],
118+
},
119+
{
120+
'query': 'pointer<mut, pointer<middle>>, pointer<pointer<mut, middle>> -> ()',
121+
'others': [
122+
{ 'path': 'pointer', 'name': 'show' },
123+
],
124+
},
125+
{
126+
'query': 'pointer<pointer<mut, middle>>, pointer<pointer<mut, middle>> -> ()',
127+
'others': [],
128+
},
129+
{
130+
'query': 'pointer<mut, pointer<middle>>, pointer<mut, pointer<middle>> -> ()',
131+
'others': [],
132+
},
133+
// pinkie with shorthand
134+
{
135+
'query': '*const usize, usize -> ()',
136+
'others': [
137+
{ 'path': 'pointer', 'name': 'pinky' },
138+
],
139+
},
140+
// you can omit the `const`, if you want.
141+
{
142+
'query': '*usize, usize -> ()',
143+
'others': [
144+
{ 'path': 'pointer', 'name': 'pinky' },
145+
],
146+
},
147+
{
148+
'query': '*const usize, *const usize -> ()',
149+
'others': [],
150+
},
151+
{
152+
'query': '*mut usize, usize -> ()',
153+
'others': [],
154+
},
155+
// thumb with shorthand
156+
{
157+
'query': '*const thumb, thumb -> ()',
158+
'others': [
159+
{ 'path': 'pointer::Thumb', 'name': 'up' },
160+
],
161+
},
162+
{
163+
'query': '*const thumb, *const thumb -> ()',
164+
'others': [],
165+
},
166+
{
167+
'query': '*mut thumb, thumb -> ()',
168+
'others': [],
169+
},
170+
// index with explicit names
171+
{
172+
'query': '*const index, index -> ()',
173+
'others': [
174+
{ 'path': 'pointer::Index', 'name': 'point' },
175+
],
176+
},
177+
{
178+
'query': '*const index, *const index -> ()',
179+
'others': [],
180+
},
181+
{
182+
'query': '*mut index, index -> ()',
183+
'others': [],
184+
},
185+
// ring with shorthand
186+
{
187+
'query': '*const ring, ring -> ()',
188+
'others': [
189+
{ 'path': 'pointer::Ring', 'name': 'wear' },
190+
],
191+
},
192+
{
193+
'query': '*const ring, ring -> ()',
194+
'others': [
195+
{ 'path': 'pointer::Ring', 'name': 'wear' },
196+
],
197+
},
198+
{
199+
'query': '*mut ring, *const ring -> ()',
200+
'others': [
201+
{ 'path': 'pointer::Ring', 'name': 'wear' },
202+
],
203+
},
204+
{
205+
'query': '*mut ring, *mut ring -> ()',
206+
'others': [],
207+
},
208+
// middle with shorthand
209+
{
210+
'query': '*const middle, *const middle -> ()',
211+
// can't leave out the mut
212+
'others': [],
213+
},
214+
{
215+
'query': '*mut middle, *mut middle -> ()',
216+
'others': [
217+
{ 'path': 'pointer', 'name': 'show' },
218+
],
219+
},
220+
{
221+
'query': '*const *mut middle, *mut *const middle -> ()',
222+
'others': [
223+
{ 'path': 'pointer', 'name': 'show' },
224+
],
225+
},
226+
{
227+
'query': '*mut *const middle, *const *mut middle -> ()',
228+
'others': [
229+
{ 'path': 'pointer', 'name': 'show' },
230+
],
231+
},
232+
{
233+
'query': '*const *mut middle, *const *mut middle -> ()',
234+
'others': [],
235+
},
236+
{
237+
'query': '*mut *const middle, *mut *const middle -> ()',
238+
'others': [],
239+
},
240+
];

tests/rustdoc-js/pointer.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#![feature(extern_types)]
2+
3+
pub fn pinky(input: *const usize, manage: usize) {
4+
unimplemented!()
5+
}
6+
7+
pub struct Thumb;
8+
9+
impl Thumb {
10+
pub fn up(this: *const Self, finger: Thumb) {
11+
unimplemented!()
12+
}
13+
}
14+
15+
pub enum Index {}
16+
17+
impl Index {
18+
pub fn point(self, data: *const Index) {
19+
unimplemented!()
20+
}
21+
}
22+
23+
pub union Ring {
24+
magic: u32,
25+
marriage: f32,
26+
}
27+
28+
impl Ring {
29+
pub fn wear(this: *mut Self, extra: *const Ring) {
30+
unimplemented!()
31+
}
32+
}
33+
34+
extern "C" {
35+
pub type Middle;
36+
}
37+
38+
pub fn show(left: *const *mut Middle, right: *mut *const Middle) {
39+
unimplemented!()
40+
}

0 commit comments

Comments
 (0)