Skip to content

Commit ba6db3e

Browse files
committed
Add test for runnables with raw identifiers
1 parent 018266a commit ba6db3e

File tree

1 file changed

+186
-0
lines changed

1 file changed

+186
-0
lines changed

crates/ide/src/runnables.rs

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2225,4 +2225,190 @@ macro_rules! foo {
22252225
"#]],
22262226
);
22272227
}
2228+
2229+
#[test]
2230+
fn test_paths_with_raw_ident() {
2231+
check(
2232+
r#"
2233+
//- /lib.rs
2234+
$0
2235+
mod r#mod {
2236+
#[test]
2237+
fn r#fn() {}
2238+
2239+
/// ```
2240+
/// ```
2241+
fn r#for() {}
2242+
2243+
/// ```
2244+
/// ```
2245+
struct r#struct<r#type>(r#type);
2246+
2247+
/// ```
2248+
/// ```
2249+
impl<r#type> r#struct<r#type> {
2250+
/// ```
2251+
/// ```
2252+
fn r#fn() {}
2253+
}
2254+
2255+
enum r#enum {}
2256+
impl r#struct<r#enum> {
2257+
/// ```
2258+
/// ```
2259+
fn r#fn() {}
2260+
}
2261+
2262+
trait r#trait {}
2263+
2264+
/// ```
2265+
/// ```
2266+
impl<T> r#trait for r#struct<T> {}
2267+
}
2268+
"#,
2269+
&[TestMod, Test, DocTest, DocTest, DocTest, DocTest, DocTest, DocTest],
2270+
expect![[r#"
2271+
[
2272+
Runnable {
2273+
use_name_in_title: false,
2274+
nav: NavigationTarget {
2275+
file_id: FileId(
2276+
0,
2277+
),
2278+
full_range: 1..461,
2279+
focus_range: 5..10,
2280+
name: "r#mod",
2281+
kind: Module,
2282+
description: "mod r#mod",
2283+
},
2284+
kind: TestMod {
2285+
path: "r#mod",
2286+
},
2287+
cfg: None,
2288+
},
2289+
Runnable {
2290+
use_name_in_title: false,
2291+
nav: NavigationTarget {
2292+
file_id: FileId(
2293+
0,
2294+
),
2295+
full_range: 17..41,
2296+
focus_range: 32..36,
2297+
name: "r#fn",
2298+
kind: Function,
2299+
},
2300+
kind: Test {
2301+
test_id: Path(
2302+
"r#mod::r#fn",
2303+
),
2304+
attr: TestAttr {
2305+
ignore: false,
2306+
},
2307+
},
2308+
cfg: None,
2309+
},
2310+
Runnable {
2311+
use_name_in_title: false,
2312+
nav: NavigationTarget {
2313+
file_id: FileId(
2314+
0,
2315+
),
2316+
full_range: 47..84,
2317+
name: "r#for",
2318+
},
2319+
kind: DocTest {
2320+
test_id: Path(
2321+
"r#mod::r#for",
2322+
),
2323+
},
2324+
cfg: None,
2325+
},
2326+
Runnable {
2327+
use_name_in_title: false,
2328+
nav: NavigationTarget {
2329+
file_id: FileId(
2330+
0,
2331+
),
2332+
full_range: 90..146,
2333+
name: "r#struct",
2334+
},
2335+
kind: DocTest {
2336+
test_id: Path(
2337+
"r#mod::r#struct",
2338+
),
2339+
},
2340+
cfg: None,
2341+
},
2342+
Runnable {
2343+
use_name_in_title: false,
2344+
nav: NavigationTarget {
2345+
file_id: FileId(
2346+
0,
2347+
),
2348+
full_range: 152..266,
2349+
focus_range: 189..205,
2350+
name: "impl",
2351+
kind: Impl,
2352+
},
2353+
kind: DocTest {
2354+
test_id: Path(
2355+
"r#struct<r#type>",
2356+
),
2357+
},
2358+
cfg: None,
2359+
},
2360+
Runnable {
2361+
use_name_in_title: false,
2362+
nav: NavigationTarget {
2363+
file_id: FileId(
2364+
0,
2365+
),
2366+
full_range: 216..260,
2367+
name: "r#fn",
2368+
},
2369+
kind: DocTest {
2370+
test_id: Path(
2371+
"r#mod::r#struct<r#type>::r#fn",
2372+
),
2373+
},
2374+
cfg: None,
2375+
},
2376+
Runnable {
2377+
use_name_in_title: false,
2378+
nav: NavigationTarget {
2379+
file_id: FileId(
2380+
0,
2381+
),
2382+
full_range: 323..367,
2383+
name: "r#fn",
2384+
},
2385+
kind: DocTest {
2386+
test_id: Path(
2387+
"r#mod::r#struct<r#enum>::r#fn",
2388+
),
2389+
},
2390+
cfg: None,
2391+
},
2392+
Runnable {
2393+
use_name_in_title: false,
2394+
nav: NavigationTarget {
2395+
file_id: FileId(
2396+
0,
2397+
),
2398+
full_range: 401..459,
2399+
focus_range: 445..456,
2400+
name: "impl",
2401+
kind: Impl,
2402+
},
2403+
kind: DocTest {
2404+
test_id: Path(
2405+
"r#struct<T>",
2406+
),
2407+
},
2408+
cfg: None,
2409+
},
2410+
]
2411+
"#]],
2412+
)
2413+
}
22282414
}

0 commit comments

Comments
 (0)