Skip to content

Commit 151b985

Browse files
committed
add tests for wrapping multi-argument pipeline steps
1 parent ca6a094 commit 151b985

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
@@ -9270,6 +9270,49 @@ fn wobble(i) {
92709270
);
92719271
}
92729272

9273+
#[test]
9274+
fn wrap_multiargument_pipeline_step_in_anonymous_function() {
9275+
assert_code_action!(
9276+
WRAP_IN_ANONYMOUS_FUNCTION,
9277+
"pub fn main() {
9278+
1 |> wibble(2) |> wobble
9279+
}
9280+
9281+
fn wibble(a, b) {
9282+
todo
9283+
}
9284+
9285+
fn wobble(i) {
9286+
todo
9287+
}
9288+
9289+
",
9290+
find_position_of("wibble").to_selection()
9291+
);
9292+
}
9293+
9294+
#[test]
9295+
fn wrap_capturing_pipeline_step_in_anonymous_function() {
9296+
assert_code_action!(
9297+
WRAP_IN_ANONYMOUS_FUNCTION,
9298+
"pub fn main() {
9299+
1 |> wibble(2, _) |> wobble
9300+
}
9301+
9302+
fn wibble(a, b) {
9303+
todo
9304+
}
9305+
9306+
fn wobble(i) {
9307+
todo
9308+
}
9309+
9310+
",
9311+
find_position_of("wibble").to_selection()
9312+
);
9313+
}
9314+
9315+
92739316
#[test]
92749317
fn wrap_final_pipeline_step_in_anonymous_function() {
92759318
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)