vim test redux (#11709)
This cleans up the neovim-backed vim tests: - removed exempted tests (we'll rely on bug reports to find missing edge cases) - moved all assertions into non-async fn's so that failures are reporting on the right file/line - removed the NeovimBackedBindingTestContext - renamed a few things to make them clearer - reduced the number of permutations tested in some cases to reduce slowest test from 60s to 5s Release Notes: - N/A
This commit is contained in:
parent
48cba328f2
commit
f550f23b97
38 changed files with 2311 additions and 6505 deletions
|
@ -443,24 +443,30 @@ mod test {
|
|||
|
||||
#[gpui::test]
|
||||
async fn test_h(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["h"]);
|
||||
cx.assert_all(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate_at_each_offset(
|
||||
"h",
|
||||
indoc! {"
|
||||
ˇThe qˇuick
|
||||
ˇbrown"
|
||||
})
|
||||
.await;
|
||||
},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_backspace(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx)
|
||||
.await
|
||||
.binding(["backspace"]);
|
||||
cx.assert_all(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate_at_each_offset(
|
||||
"backspace",
|
||||
indoc! {"
|
||||
ˇThe qˇuick
|
||||
ˇbrown"
|
||||
})
|
||||
.await;
|
||||
},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
@ -468,320 +474,426 @@ mod test {
|
|||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
|
||||
cx.set_shared_state(indoc! {"
|
||||
aaˇaa
|
||||
😃😃"
|
||||
})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["j"]).await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
aaaa
|
||||
😃ˇ😃"
|
||||
aaˇaa
|
||||
😃😃"
|
||||
})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes("j").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
aaaa
|
||||
😃ˇ😃"
|
||||
});
|
||||
|
||||
for marked_position in cx.each_marked_position(indoc! {"
|
||||
ˇThe qˇuick broˇwn
|
||||
ˇfox jumps"
|
||||
}) {
|
||||
cx.assert_neovim_compatible(&marked_position, ["j"]).await;
|
||||
}
|
||||
cx.simulate_at_each_offset(
|
||||
"j",
|
||||
indoc! {"
|
||||
ˇThe qˇuick broˇwn
|
||||
ˇfox jumps"
|
||||
},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_enter(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["enter"]);
|
||||
cx.assert_all(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate_at_each_offset(
|
||||
"enter",
|
||||
indoc! {"
|
||||
ˇThe qˇuick broˇwn
|
||||
ˇfox jumps"
|
||||
})
|
||||
.await;
|
||||
},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_k(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["k"]);
|
||||
cx.assert_all(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate_at_each_offset(
|
||||
"k",
|
||||
indoc! {"
|
||||
ˇThe qˇuick
|
||||
ˇbrown fˇox jumˇps"
|
||||
})
|
||||
.await;
|
||||
},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_l(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["l"]);
|
||||
cx.assert_all(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate_at_each_offset(
|
||||
"l",
|
||||
indoc! {"
|
||||
ˇThe qˇuicˇk
|
||||
ˇbrowˇn"})
|
||||
.await;
|
||||
ˇbrowˇn"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_jump_to_line_boundaries(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.assert_binding_matches_all(
|
||||
["$"],
|
||||
cx.simulate_at_each_offset(
|
||||
"$",
|
||||
indoc! {"
|
||||
ˇThe qˇuicˇk
|
||||
ˇbrowˇn"},
|
||||
)
|
||||
.await;
|
||||
cx.assert_binding_matches_all(
|
||||
["0"],
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate_at_each_offset(
|
||||
"0",
|
||||
indoc! {"
|
||||
ˇThe qˇuicˇk
|
||||
ˇbrowˇn"},
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_jump_to_end(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["shift-g"]);
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
|
||||
cx.assert_all(indoc! {"
|
||||
cx.simulate_at_each_offset(
|
||||
"shift-g",
|
||||
indoc! {"
|
||||
The ˇquick
|
||||
|
||||
brown fox jumps
|
||||
overˇ the lazy doˇg"})
|
||||
.await;
|
||||
cx.assert(indoc! {"
|
||||
overˇ the lazy doˇg"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"shift-g",
|
||||
indoc! {"
|
||||
The quiˇck
|
||||
|
||||
brown"})
|
||||
.await;
|
||||
cx.assert(indoc! {"
|
||||
brown"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"shift-g",
|
||||
indoc! {"
|
||||
The quiˇck
|
||||
|
||||
"})
|
||||
.await;
|
||||
"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_w(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["w"]);
|
||||
cx.assert_all(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate_at_each_offset(
|
||||
"w",
|
||||
indoc! {"
|
||||
The ˇquickˇ-ˇbrown
|
||||
ˇ
|
||||
ˇ
|
||||
ˇfox_jumps ˇover
|
||||
ˇthˇe"})
|
||||
.await;
|
||||
let mut cx = cx.binding(["shift-w"]);
|
||||
cx.assert_all(indoc! {"
|
||||
ˇthˇe"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate_at_each_offset(
|
||||
"shift-w",
|
||||
indoc! {"
|
||||
The ˇquickˇ-ˇbrown
|
||||
ˇ
|
||||
ˇ
|
||||
ˇfox_jumps ˇover
|
||||
ˇthˇe"})
|
||||
.await;
|
||||
ˇthˇe"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_end_of_word(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["e"]);
|
||||
cx.assert_all(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate_at_each_offset(
|
||||
"e",
|
||||
indoc! {"
|
||||
Thˇe quicˇkˇ-browˇn
|
||||
|
||||
|
||||
fox_jumpˇs oveˇr
|
||||
thˇe"})
|
||||
.await;
|
||||
let mut cx = cx.binding(["shift-e"]);
|
||||
cx.assert_all(indoc! {"
|
||||
thˇe"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate_at_each_offset(
|
||||
"shift-e",
|
||||
indoc! {"
|
||||
Thˇe quicˇkˇ-browˇn
|
||||
|
||||
|
||||
fox_jumpˇs oveˇr
|
||||
thˇe"})
|
||||
.await;
|
||||
thˇe"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_b(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["b"]);
|
||||
cx.assert_all(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate_at_each_offset(
|
||||
"b",
|
||||
indoc! {"
|
||||
ˇThe ˇquickˇ-ˇbrown
|
||||
ˇ
|
||||
ˇ
|
||||
ˇfox_jumps ˇover
|
||||
ˇthe"})
|
||||
.await;
|
||||
let mut cx = cx.binding(["shift-b"]);
|
||||
cx.assert_all(indoc! {"
|
||||
ˇthe"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate_at_each_offset(
|
||||
"shift-b",
|
||||
indoc! {"
|
||||
ˇThe ˇquickˇ-ˇbrown
|
||||
ˇ
|
||||
ˇ
|
||||
ˇfox_jumps ˇover
|
||||
ˇthe"})
|
||||
.await;
|
||||
ˇthe"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_gg(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.assert_binding_matches_all(
|
||||
["g", "g"],
|
||||
cx.simulate_at_each_offset(
|
||||
"g g",
|
||||
indoc! {"
|
||||
The qˇuick
|
||||
|
||||
brown fox jumps
|
||||
over ˇthe laˇzy dog"},
|
||||
)
|
||||
.await;
|
||||
cx.assert_binding_matches(
|
||||
["g", "g"],
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"g g",
|
||||
indoc! {"
|
||||
|
||||
|
||||
brown fox jumps
|
||||
over the laˇzy dog"},
|
||||
)
|
||||
.await;
|
||||
cx.assert_binding_matches(
|
||||
["2", "g", "g"],
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"2 g g",
|
||||
indoc! {"
|
||||
ˇ
|
||||
|
||||
brown fox jumps
|
||||
over the lazydog"},
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_end_of_document(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.assert_binding_matches_all(
|
||||
["shift-g"],
|
||||
cx.simulate_at_each_offset(
|
||||
"shift-g",
|
||||
indoc! {"
|
||||
The qˇuick
|
||||
|
||||
brown fox jumps
|
||||
over ˇthe laˇzy dog"},
|
||||
)
|
||||
.await;
|
||||
cx.assert_binding_matches(
|
||||
["shift-g"],
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"shift-g",
|
||||
indoc! {"
|
||||
|
||||
|
||||
brown fox jumps
|
||||
over the laˇzy dog"},
|
||||
)
|
||||
.await;
|
||||
cx.assert_binding_matches(
|
||||
["2", "shift-g"],
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"2 shift-g",
|
||||
indoc! {"
|
||||
ˇ
|
||||
|
||||
brown fox jumps
|
||||
over the lazydog"},
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_a(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["a"]);
|
||||
cx.assert_all("The qˇuicˇk").await;
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate_at_each_offset("a", "The qˇuicˇk")
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_insert_end_of_line(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["shift-a"]);
|
||||
cx.assert_all(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate_at_each_offset(
|
||||
"shift-a",
|
||||
indoc! {"
|
||||
ˇ
|
||||
The qˇuick
|
||||
brown ˇfox "})
|
||||
.await;
|
||||
brown ˇfox "},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_jump_to_first_non_whitespace(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["^"]);
|
||||
cx.assert("The qˇuick").await;
|
||||
cx.assert(" The qˇuick").await;
|
||||
cx.assert("ˇ").await;
|
||||
cx.assert(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate("^", "The qˇuick").await.assert_matches();
|
||||
cx.simulate("^", " The qˇuick").await.assert_matches();
|
||||
cx.simulate("^", "ˇ").await.assert_matches();
|
||||
cx.simulate(
|
||||
"^",
|
||||
indoc! {"
|
||||
The qˇuick
|
||||
brown fox"})
|
||||
.await;
|
||||
cx.assert(indoc! {"
|
||||
brown fox"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"^",
|
||||
indoc! {"
|
||||
ˇ
|
||||
The quick"})
|
||||
.await;
|
||||
The quick"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
// Indoc disallows trailing whitespace.
|
||||
cx.assert(" ˇ \nThe quick").await;
|
||||
cx.simulate("^", " ˇ \nThe quick").await.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_insert_first_non_whitespace(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["shift-i"]);
|
||||
cx.assert("The qˇuick").await;
|
||||
cx.assert(" The qˇuick").await;
|
||||
cx.assert("ˇ").await;
|
||||
cx.assert(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate("shift-i", "The qˇuick").await.assert_matches();
|
||||
cx.simulate("shift-i", " The qˇuick").await.assert_matches();
|
||||
cx.simulate("shift-i", "ˇ").await.assert_matches();
|
||||
cx.simulate(
|
||||
"shift-i",
|
||||
indoc! {"
|
||||
The qˇuick
|
||||
brown fox"})
|
||||
.await;
|
||||
cx.assert(indoc! {"
|
||||
brown fox"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"shift-i",
|
||||
indoc! {"
|
||||
ˇ
|
||||
The quick"})
|
||||
.await;
|
||||
The quick"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_delete_to_end_of_line(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["shift-d"]);
|
||||
cx.assert(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate(
|
||||
"shift-d",
|
||||
indoc! {"
|
||||
The qˇuick
|
||||
brown fox"})
|
||||
.await;
|
||||
cx.assert(indoc! {"
|
||||
brown fox"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"shift-d",
|
||||
indoc! {"
|
||||
The quick
|
||||
ˇ
|
||||
brown fox"})
|
||||
.await;
|
||||
brown fox"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_x(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["x"]);
|
||||
cx.assert_all("ˇTeˇsˇt").await;
|
||||
cx.assert(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate_at_each_offset("x", "ˇTeˇsˇt")
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"x",
|
||||
indoc! {"
|
||||
Tesˇt
|
||||
test"})
|
||||
.await;
|
||||
test"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_delete_left(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["shift-x"]);
|
||||
cx.assert_all("ˇTˇeˇsˇt").await;
|
||||
cx.assert(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate_at_each_offset("shift-x", "ˇTˇeˇsˇt")
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"shift-x",
|
||||
indoc! {"
|
||||
Test
|
||||
ˇtest"})
|
||||
.await;
|
||||
ˇtest"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_o(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["o"]);
|
||||
cx.assert("ˇ").await;
|
||||
cx.assert("The ˇquick").await;
|
||||
cx.assert_all(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate("o", "ˇ").await.assert_matches();
|
||||
cx.simulate("o", "The ˇquick").await.assert_matches();
|
||||
cx.simulate_at_each_offset(
|
||||
"o",
|
||||
indoc! {"
|
||||
The qˇuick
|
||||
brown ˇfox
|
||||
jumps ˇover"})
|
||||
.await;
|
||||
cx.assert(indoc! {"
|
||||
jumps ˇover"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"o",
|
||||
indoc! {"
|
||||
The quick
|
||||
ˇ
|
||||
brown fox"})
|
||||
.await;
|
||||
brown fox"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
|
||||
cx.assert_manual(
|
||||
cx.assert_binding(
|
||||
"o",
|
||||
indoc! {"
|
||||
fn test() {
|
||||
println!(ˇ);
|
||||
|
@ -795,7 +907,8 @@ mod test {
|
|||
Mode::Insert,
|
||||
);
|
||||
|
||||
cx.assert_manual(
|
||||
cx.assert_binding(
|
||||
"o",
|
||||
indoc! {"
|
||||
fn test(ˇ) {
|
||||
println!();
|
||||
|
@ -812,23 +925,31 @@ mod test {
|
|||
|
||||
#[gpui::test]
|
||||
async fn test_insert_line_above(cx: &mut gpui::TestAppContext) {
|
||||
let cx = NeovimBackedTestContext::new(cx).await;
|
||||
let mut cx = cx.binding(["shift-o"]);
|
||||
cx.assert("ˇ").await;
|
||||
cx.assert("The ˇquick").await;
|
||||
cx.assert_all(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate("shift-o", "ˇ").await.assert_matches();
|
||||
cx.simulate("shift-o", "The ˇquick").await.assert_matches();
|
||||
cx.simulate_at_each_offset(
|
||||
"shift-o",
|
||||
indoc! {"
|
||||
The qˇuick
|
||||
brown ˇfox
|
||||
jumps ˇover"})
|
||||
.await;
|
||||
cx.assert(indoc! {"
|
||||
jumps ˇover"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"shift-o",
|
||||
indoc! {"
|
||||
The quick
|
||||
ˇ
|
||||
brown fox"})
|
||||
.await;
|
||||
brown fox"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
|
||||
// Our indentation is smarter than vims. So we don't match here
|
||||
cx.assert_manual(
|
||||
cx.assert_binding(
|
||||
"shift-o",
|
||||
indoc! {"
|
||||
fn test() {
|
||||
println!(ˇ);
|
||||
|
@ -841,7 +962,8 @@ mod test {
|
|||
}"},
|
||||
Mode::Insert,
|
||||
);
|
||||
cx.assert_manual(
|
||||
cx.assert_binding(
|
||||
"shift-o",
|
||||
indoc! {"
|
||||
fn test(ˇ) {
|
||||
println!();
|
||||
|
@ -859,40 +981,51 @@ mod test {
|
|||
#[gpui::test]
|
||||
async fn test_dd(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.assert_neovim_compatible("ˇ", ["d", "d"]).await;
|
||||
cx.assert_neovim_compatible("The ˇquick", ["d", "d"]).await;
|
||||
for marked_text in cx.each_marked_position(indoc! {"
|
||||
cx.simulate("d d", "ˇ").await.assert_matches();
|
||||
cx.simulate("d d", "The ˇquick").await.assert_matches();
|
||||
cx.simulate_at_each_offset(
|
||||
"d d",
|
||||
indoc! {"
|
||||
The qˇuick
|
||||
brown ˇfox
|
||||
jumps ˇover"})
|
||||
{
|
||||
cx.assert_neovim_compatible(&marked_text, ["d", "d"]).await;
|
||||
}
|
||||
cx.assert_neovim_compatible(
|
||||
jumps ˇover"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"d d",
|
||||
indoc! {"
|
||||
The quick
|
||||
ˇ
|
||||
brown fox"},
|
||||
["d", "d"],
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_cc(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["c", "c"]);
|
||||
cx.assert("ˇ").await;
|
||||
cx.assert("The ˇquick").await;
|
||||
cx.assert_all(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate("c c", "ˇ").await.assert_matches();
|
||||
cx.simulate("c c", "The ˇquick").await.assert_matches();
|
||||
cx.simulate_at_each_offset(
|
||||
"c c",
|
||||
indoc! {"
|
||||
The quˇick
|
||||
brown ˇfox
|
||||
jumps ˇover"})
|
||||
.await;
|
||||
cx.assert(indoc! {"
|
||||
jumps ˇover"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"c c",
|
||||
indoc! {"
|
||||
The quick
|
||||
ˇ
|
||||
brown fox"})
|
||||
.await;
|
||||
brown fox"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
@ -900,8 +1033,8 @@ mod test {
|
|||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
|
||||
for count in 1..=5 {
|
||||
cx.assert_binding_matches_all(
|
||||
[&count.to_string(), "w"],
|
||||
cx.simulate_at_each_offset(
|
||||
&format!("{count} w"),
|
||||
indoc! {"
|
||||
ˇThe quˇickˇ browˇn
|
||||
ˇ
|
||||
|
@ -909,14 +1042,17 @@ mod test {
|
|||
ˇthe lazy dog
|
||||
"},
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_h_through_unicode(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["h"]);
|
||||
cx.assert_all("Testˇ├ˇ──ˇ┐ˇTest").await;
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate_at_each_offset("h", "Testˇ├ˇ──ˇ┐ˇTest")
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
@ -931,11 +1067,13 @@ mod test {
|
|||
ˇb
|
||||
"};
|
||||
|
||||
cx.assert_binding_matches_all([&count.to_string(), "f", "b"], test_case)
|
||||
.await;
|
||||
cx.simulate_at_each_offset(&format!("{count} f b"), test_case)
|
||||
.await
|
||||
.assert_matches();
|
||||
|
||||
cx.assert_binding_matches_all([&count.to_string(), "t", "b"], test_case)
|
||||
.await;
|
||||
cx.simulate_at_each_offset(&format!("{count} t b"), test_case)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -951,11 +1089,13 @@ mod test {
|
|||
};
|
||||
|
||||
for count in 1..=3 {
|
||||
cx.assert_binding_matches_all([&count.to_string(), "shift-f", "b"], test_case)
|
||||
.await;
|
||||
cx.simulate_at_each_offset(&format!("{count} shift-f b"), test_case)
|
||||
.await
|
||||
.assert_matches();
|
||||
|
||||
cx.assert_binding_matches_all([&count.to_string(), "shift-t", "b"], test_case)
|
||||
.await;
|
||||
cx.simulate_at_each_offset(&format!("{count} shift-t b"), test_case)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -969,7 +1109,7 @@ mod test {
|
|||
});
|
||||
|
||||
cx.assert_binding(
|
||||
["f", "l"],
|
||||
"f l",
|
||||
indoc! {"
|
||||
ˇfunction print() {
|
||||
console.log('ok')
|
||||
|
@ -985,7 +1125,7 @@ mod test {
|
|||
);
|
||||
|
||||
cx.assert_binding(
|
||||
["t", "l"],
|
||||
"t l",
|
||||
indoc! {"
|
||||
ˇfunction print() {
|
||||
console.log('ok')
|
||||
|
@ -1011,7 +1151,7 @@ mod test {
|
|||
});
|
||||
|
||||
cx.assert_binding(
|
||||
["shift-f", "p"],
|
||||
"shift-f p",
|
||||
indoc! {"
|
||||
function print() {
|
||||
console.ˇlog('ok')
|
||||
|
@ -1027,7 +1167,7 @@ mod test {
|
|||
);
|
||||
|
||||
cx.assert_binding(
|
||||
["shift-t", "p"],
|
||||
"shift-t p",
|
||||
indoc! {"
|
||||
function print() {
|
||||
console.ˇlog('ok')
|
||||
|
@ -1053,7 +1193,7 @@ mod test {
|
|||
});
|
||||
|
||||
cx.assert_binding(
|
||||
["f", "p"],
|
||||
"f p",
|
||||
indoc! {"ˇfmt.Println(\"Hello, World!\")"},
|
||||
Mode::Normal,
|
||||
indoc! {"fmt.ˇPrintln(\"Hello, World!\")"},
|
||||
|
@ -1061,7 +1201,7 @@ mod test {
|
|||
);
|
||||
|
||||
cx.assert_binding(
|
||||
["shift-f", "p"],
|
||||
"shift-f p",
|
||||
indoc! {"fmt.Printlnˇ(\"Hello, World!\")"},
|
||||
Mode::Normal,
|
||||
indoc! {"fmt.ˇPrintln(\"Hello, World!\")"},
|
||||
|
@ -1069,7 +1209,7 @@ mod test {
|
|||
);
|
||||
|
||||
cx.assert_binding(
|
||||
["t", "p"],
|
||||
"t p",
|
||||
indoc! {"ˇfmt.Println(\"Hello, World!\")"},
|
||||
Mode::Normal,
|
||||
indoc! {"fmtˇ.Println(\"Hello, World!\")"},
|
||||
|
@ -1077,7 +1217,7 @@ mod test {
|
|||
);
|
||||
|
||||
cx.assert_binding(
|
||||
["shift-t", "p"],
|
||||
"shift-t p",
|
||||
indoc! {"fmt.Printlnˇ(\"Hello, World!\")"},
|
||||
Mode::Normal,
|
||||
indoc! {"fmt.Pˇrintln(\"Hello, World!\")"},
|
||||
|
@ -1087,11 +1227,16 @@ mod test {
|
|||
|
||||
#[gpui::test]
|
||||
async fn test_percent(cx: &mut TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["%"]);
|
||||
cx.assert_all("ˇconsole.logˇ(ˇvaˇrˇ)ˇ;").await;
|
||||
cx.assert_all("ˇconsole.logˇ(ˇ'var', ˇ[ˇ1, ˇ2, 3ˇ]ˇ)ˇ;")
|
||||
.await;
|
||||
cx.assert_all("let result = curried_funˇ(ˇ)ˇ(ˇ)ˇ;").await;
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate_at_each_offset("%", "ˇconsole.logˇ(ˇvaˇrˇ)ˇ;")
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate_at_each_offset("%", "ˇconsole.logˇ(ˇ'var', ˇ[ˇ1, ˇ2, 3ˇ]ˇ)ˇ;")
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate_at_each_offset("%", "let result = curried_funˇ(ˇ)ˇ(ˇ)ˇ;")
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
@ -1100,16 +1245,16 @@ mod test {
|
|||
|
||||
// goes to current line end
|
||||
cx.set_shared_state(indoc! {"ˇaa\nbb\ncc"}).await;
|
||||
cx.simulate_shared_keystrokes(["$"]).await;
|
||||
cx.assert_shared_state(indoc! {"aˇa\nbb\ncc"}).await;
|
||||
cx.simulate_shared_keystrokes("$").await;
|
||||
cx.shared_state().await.assert_eq("aˇa\nbb\ncc");
|
||||
|
||||
// goes to next line end
|
||||
cx.simulate_shared_keystrokes(["2", "$"]).await;
|
||||
cx.assert_shared_state("aa\nbˇb\ncc").await;
|
||||
cx.simulate_shared_keystrokes("2 $").await;
|
||||
cx.shared_state().await.assert_eq("aa\nbˇb\ncc");
|
||||
|
||||
// try to exceed the final line.
|
||||
cx.simulate_shared_keystrokes(["4", "$"]).await;
|
||||
cx.assert_shared_state("aa\nbb\ncˇc").await;
|
||||
cx.simulate_shared_keystrokes("4 $").await;
|
||||
cx.shared_state().await.assert_eq("aa\nbb\ncˇc");
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
@ -1148,34 +1293,22 @@ mod test {
|
|||
]);
|
||||
});
|
||||
|
||||
cx.assert_binding_normal(
|
||||
["w"],
|
||||
indoc! {"ˇassert_binding"},
|
||||
indoc! {"assert_ˇbinding"},
|
||||
);
|
||||
cx.assert_binding_normal("w", indoc! {"ˇassert_binding"}, indoc! {"assert_ˇbinding"});
|
||||
// Special case: In 'cw', 'w' acts like 'e'
|
||||
cx.assert_binding(
|
||||
["c", "w"],
|
||||
"c w",
|
||||
indoc! {"ˇassert_binding"},
|
||||
Mode::Normal,
|
||||
indoc! {"ˇ_binding"},
|
||||
Mode::Insert,
|
||||
);
|
||||
|
||||
cx.assert_binding_normal(
|
||||
["e"],
|
||||
indoc! {"ˇassert_binding"},
|
||||
indoc! {"asserˇt_binding"},
|
||||
);
|
||||
cx.assert_binding_normal("e", indoc! {"ˇassert_binding"}, indoc! {"asserˇt_binding"});
|
||||
|
||||
cx.assert_binding_normal("b", indoc! {"assert_ˇbinding"}, indoc! {"ˇassert_binding"});
|
||||
|
||||
cx.assert_binding_normal(
|
||||
["b"],
|
||||
indoc! {"assert_ˇbinding"},
|
||||
indoc! {"ˇassert_binding"},
|
||||
);
|
||||
|
||||
cx.assert_binding_normal(
|
||||
["g", "e"],
|
||||
"g e",
|
||||
indoc! {"assert_bindinˇg"},
|
||||
indoc! {"asserˇt_binding"},
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue