Skip to content

Commit de58ddf

Browse files
committed
test: add test case extract_with_specified_path_attr
1 parent fafcc77 commit de58ddf

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

src/tools/rust-analyzer/crates/ide-assists/src/handlers/move_module_to_file.rs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,72 @@ mod tests {
116116

117117
use super::*;
118118

119+
#[test]
120+
fn extract_with_specified_path_attr() {
121+
check_assist(
122+
move_module_to_file,
123+
r#"
124+
//- /main.rs
125+
#[path="parser/__mod.rs"]
126+
mod parser;
127+
//- /parser/__mod.rs
128+
fn test() {}
129+
mod $0expr {
130+
struct A {}
131+
}
132+
"#,
133+
r#"
134+
//- /parser/__mod.rs
135+
fn test() {}
136+
mod expr;
137+
//- /parser/expr.rs
138+
struct A {}
139+
"#,
140+
);
141+
142+
check_assist(
143+
move_module_to_file,
144+
r#"
145+
//- /main.rs
146+
#[path="parser/a/__mod.rs"]
147+
mod parser;
148+
//- /parser/a/__mod.rs
149+
fn test() {}
150+
mod $0expr {
151+
struct A {}
152+
}
153+
"#,
154+
r#"
155+
//- /parser/a/__mod.rs
156+
fn test() {}
157+
mod expr;
158+
//- /parser/a/expr.rs
159+
struct A {}
160+
"#,
161+
);
162+
163+
check_assist(
164+
move_module_to_file,
165+
r#"
166+
//- /main.rs
167+
#[path="a.rs"]
168+
mod parser;
169+
//- /a.rs
170+
fn test() {}
171+
mod $0expr {
172+
struct A {}
173+
}
174+
"#,
175+
r#"
176+
//- /a.rs
177+
fn test() {}
178+
mod expr;
179+
//- /expr.rs
180+
struct A {}
181+
"#,
182+
);
183+
}
184+
119185
#[test]
120186
fn extract_from_root() {
121187
check_assist(

0 commit comments

Comments
 (0)