Skip to content

Commit a4fd477

Browse files
committed
add tests for wrapping multi-argument pipeline steps
1 parent 8884ab1 commit a4fd477

3 files changed

+107
-0
lines changed

compiler-core/src/language_server/tests/action.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9934,6 +9934,49 @@ fn wobble(i) {
99349934
);
99359935
}
99369936

9937+
#[test]
9938+
fn wrap_multiargument_pipeline_step_in_anonymous_function() {
9939+
assert_code_action!(
9940+
WRAP_IN_ANONYMOUS_FUNCTION,
9941+
"pub fn main() {
9942+
1 |> wibble(2) |> wobble
9943+
}
9944+
9945+
fn wibble(a, b) {
9946+
todo
9947+
}
9948+
9949+
fn wobble(i) {
9950+
todo
9951+
}
9952+
9953+
",
9954+
find_position_of("wibble").to_selection()
9955+
);
9956+
}
9957+
9958+
#[test]
9959+
fn wrap_capturing_pipeline_step_in_anonymous_function() {
9960+
assert_code_action!(
9961+
WRAP_IN_ANONYMOUS_FUNCTION,
9962+
"pub fn main() {
9963+
1 |> wibble(2, _) |> wobble
9964+
}
9965+
9966+
fn wibble(a, b) {
9967+
todo
9968+
}
9969+
9970+
fn wobble(i) {
9971+
todo
9972+
}
9973+
9974+
",
9975+
find_position_of("wibble").to_selection()
9976+
);
9977+
}
9978+
9979+
99379980
#[test]
99389981
fn wrap_final_pipeline_step_in_anonymous_function() {
99399982
assert_code_action!(
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
source: compiler-core/src/language_server/tests/action.rs
3+
expression: "pub fn main() {\n 1 |> wibble(2, _) |> wobble\n}\n\nfn wibble(a, b) {\n todo\n}\n\nfn wobble(i) {\n todo\n}\n\n"
4+
---
5+
----- BEFORE ACTION
6+
pub fn main() {
7+
1 |> wibble(2, _) |> wobble
8+
9+
}
10+
11+
fn wibble(a, b) {
12+
todo
13+
}
14+
15+
fn wobble(i) {
16+
todo
17+
}
18+
19+
20+
21+
----- AFTER ACTION
22+
pub fn main() {
23+
1 |> fn(int) { wibble(2, _)(int) } |> wobble
24+
}
25+
26+
fn wibble(a, b) {
27+
todo
28+
}
29+
30+
fn wobble(i) {
31+
todo
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
source: compiler-core/src/language_server/tests/action.rs
3+
expression: "pub fn main() {\n 1 |> wibble(2) |> wobble\n}\n\nfn wibble(a, b) {\n todo\n}\n\nfn wobble(i) {\n todo\n}\n\n"
4+
---
5+
----- BEFORE ACTION
6+
pub fn main() {
7+
1 |> wibble(2) |> wobble
8+
9+
}
10+
11+
fn wibble(a, b) {
12+
todo
13+
}
14+
15+
fn wobble(i) {
16+
todo
17+
}
18+
19+
20+
21+
----- AFTER ACTION
22+
pub fn main() {
23+
1 |> fn(int, int_2) { wibble(int, int_2) }(2) |> wobble
24+
}
25+
26+
fn wibble(a, b) {
27+
todo
28+
}
29+
30+
fn wobble(i) {
31+
todo
32+
}

0 commit comments

Comments
 (0)