forked from intellij-rust/intellij-rust
/
RsDoctestInjectionResolveTest.kt
92 lines (84 loc) · 2.42 KB
/
RsDoctestInjectionResolveTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package org.rust.lang.core.resolve
import org.rust.ProjectDescriptor
import org.rust.WithDependencyRustProjectDescriptor
import org.rust.WithStdlibAndDependencyRustProjectDescriptor
import org.rust.stdext.BothEditions
class RsDoctestInjectionResolveTest : RsResolveTestBase() {
@ProjectDescriptor(WithDependencyRustProjectDescriptor::class)
fun `test resolve outer element`() = checkByCode("""
/// ```
/// use test_package::foo;
/// foo();
/// //^
/// ```
pub fn foo() {}
//X
""", "lib.rs")
@ProjectDescriptor(WithStdlibAndDependencyRustProjectDescriptor::class)
fun `test resolve std element`() = stubOnlyResolve("""
//- lib.rs
/// ```
/// Vec::new()
/// //^ ...vec.rs
/// ```
pub fn foo() {}
""")
@ProjectDescriptor(WithDependencyRustProjectDescriptor::class)
fun `test outer crate dependency`() = stubOnlyResolve("""
//- lib.rs
/// ```
/// extern crate dep_lib_target;
/// fn main() {
/// use dep_lib_target::bar;
/// //^ dep-lib/lib.rs
/// }
/// ```
pub fn foo() {}
//- dep-lib/lib.rs
pub fn bar() {}
""")
@ProjectDescriptor(WithDependencyRustProjectDescriptor::class)
fun `test macro`() = stubOnlyResolve("""
//- lib.rs
/// ```
/// #[macro_use]
/// extern crate test_package;
/// fn main() {
/// foo!();
/// //^ lib.rs
/// }
/// ```
#[macro_export]
macro_rules! foo {
() => {};
}
""")
@BothEditions
@ProjectDescriptor(WithStdlibAndDependencyRustProjectDescriptor::class)
fun `test macro from stdlib`() = stubOnlyResolve("""
//- lib.rs
/// ```
/// fn main() {
/// println!("Hello, World!");
/// } //^ ...libstd/macros.rs
/// ```
pub fn foo() {}
""")
@ProjectDescriptor(WithDependencyRustProjectDescriptor::class)
fun `test extra extern crate`() = stubOnlyResolve("""
//- lib.rs
/// ```
/// extern crate test_package;
/// fn main() {
/// use test_package::foo;
/// foo();
/// //^ lib.rs
/// }
/// ```
pub fn foo() {}
""")
}