mirror of
https://github.com/zed-industries/zed.git
synced 2024-10-26 16:37:58 +00:00
Remove supported exception
(and refactor tests to be more linear)
This commit is contained in:
parent
7daed1b2c3
commit
dcaba9d9e7
3 changed files with 123 additions and 105 deletions
|
@ -121,7 +121,7 @@ fn expand_changed_word_selection(
|
||||||
mod test {
|
mod test {
|
||||||
use indoc::indoc;
|
use indoc::indoc;
|
||||||
|
|
||||||
use crate::test::{ExemptionFeatures, NeovimBackedTestContext};
|
use crate::test::NeovimBackedTestContext;
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
async fn test_change_h(cx: &mut gpui::TestAppContext) {
|
async fn test_change_h(cx: &mut gpui::TestAppContext) {
|
||||||
|
@ -239,150 +239,178 @@ mod test {
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
async fn test_change_0(cx: &mut gpui::TestAppContext) {
|
async fn test_change_0(cx: &mut gpui::TestAppContext) {
|
||||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["c", "0"]);
|
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||||
cx.assert(indoc! {"
|
|
||||||
|
cx.assert_neovim_compatible(
|
||||||
|
indoc! {"
|
||||||
The qˇuick
|
The qˇuick
|
||||||
brown fox"})
|
brown fox"},
|
||||||
.await;
|
["c", "0"],
|
||||||
cx.assert(indoc! {"
|
)
|
||||||
|
.await;
|
||||||
|
cx.assert_neovim_compatible(
|
||||||
|
indoc! {"
|
||||||
The quick
|
The quick
|
||||||
ˇ
|
ˇ
|
||||||
brown fox"})
|
brown fox"},
|
||||||
.await;
|
["c", "0"],
|
||||||
|
)
|
||||||
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
async fn test_change_k(cx: &mut gpui::TestAppContext) {
|
async fn test_change_k(cx: &mut gpui::TestAppContext) {
|
||||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["c", "k"]);
|
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||||
cx.assert(indoc! {"
|
|
||||||
|
cx.assert_neovim_compatible(
|
||||||
|
indoc! {"
|
||||||
The quick
|
The quick
|
||||||
brown ˇfox
|
brown ˇfox
|
||||||
jumps over"})
|
jumps over"},
|
||||||
.await;
|
["c", "k"],
|
||||||
cx.assert(indoc! {"
|
)
|
||||||
|
.await;
|
||||||
|
cx.assert_neovim_compatible(
|
||||||
|
indoc! {"
|
||||||
The quick
|
The quick
|
||||||
brown fox
|
brown fox
|
||||||
jumps ˇover"})
|
jumps ˇover"},
|
||||||
.await;
|
["c", "k"],
|
||||||
cx.assert_exempted(
|
)
|
||||||
|
.await;
|
||||||
|
cx.assert_neovim_compatible(
|
||||||
indoc! {"
|
indoc! {"
|
||||||
The qˇuick
|
The qˇuick
|
||||||
brown fox
|
brown fox
|
||||||
jumps over"},
|
jumps over"},
|
||||||
ExemptionFeatures::OperatorAbortsOnFailedMotion,
|
["c", "k"],
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
cx.assert_exempted(
|
cx.assert_neovim_compatible(
|
||||||
indoc! {"
|
indoc! {"
|
||||||
ˇ
|
ˇ
|
||||||
brown fox
|
brown fox
|
||||||
jumps over"},
|
jumps over"},
|
||||||
ExemptionFeatures::OperatorAbortsOnFailedMotion,
|
["c", "k"],
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
async fn test_change_j(cx: &mut gpui::TestAppContext) {
|
async fn test_change_j(cx: &mut gpui::TestAppContext) {
|
||||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["c", "j"]);
|
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||||
cx.assert(indoc! {"
|
cx.assert_neovim_compatible(
|
||||||
|
indoc! {"
|
||||||
The quick
|
The quick
|
||||||
brown ˇfox
|
brown ˇfox
|
||||||
jumps over"})
|
jumps over"},
|
||||||
.await;
|
["c", "j"],
|
||||||
cx.assert_exempted(
|
)
|
||||||
|
.await;
|
||||||
|
cx.assert_neovim_compatible(
|
||||||
indoc! {"
|
indoc! {"
|
||||||
The quick
|
The quick
|
||||||
brown fox
|
brown fox
|
||||||
jumps ˇover"},
|
jumps ˇover"},
|
||||||
ExemptionFeatures::OperatorAbortsOnFailedMotion,
|
["c", "j"],
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
cx.assert(indoc! {"
|
cx.assert_neovim_compatible(
|
||||||
|
indoc! {"
|
||||||
The qˇuick
|
The qˇuick
|
||||||
brown fox
|
brown fox
|
||||||
jumps over"})
|
jumps over"},
|
||||||
.await;
|
["c", "j"],
|
||||||
cx.assert_exempted(
|
)
|
||||||
|
.await;
|
||||||
|
cx.assert_neovim_compatible(
|
||||||
indoc! {"
|
indoc! {"
|
||||||
The quick
|
The quick
|
||||||
brown fox
|
brown fox
|
||||||
ˇ"},
|
ˇ"},
|
||||||
ExemptionFeatures::OperatorAbortsOnFailedMotion,
|
["c", "j"],
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
async fn test_change_end_of_document(cx: &mut gpui::TestAppContext) {
|
async fn test_change_end_of_document(cx: &mut gpui::TestAppContext) {
|
||||||
let mut cx = NeovimBackedTestContext::new(cx)
|
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||||
.await
|
cx.assert_neovim_compatible(
|
||||||
.binding(["c", "shift-g"]);
|
indoc! {"
|
||||||
cx.assert(indoc! {"
|
|
||||||
The quick
|
The quick
|
||||||
brownˇ fox
|
brownˇ fox
|
||||||
jumps over
|
jumps over
|
||||||
the lazy"})
|
the lazy"},
|
||||||
.await;
|
["c", "shift-g"],
|
||||||
cx.assert(indoc! {"
|
)
|
||||||
|
.await;
|
||||||
|
cx.assert_neovim_compatible(
|
||||||
|
indoc! {"
|
||||||
The quick
|
The quick
|
||||||
brownˇ fox
|
brownˇ fox
|
||||||
jumps over
|
jumps over
|
||||||
the lazy"})
|
the lazy"},
|
||||||
.await;
|
["c", "shift-g"],
|
||||||
cx.assert_exempted(
|
)
|
||||||
|
.await;
|
||||||
|
cx.assert_neovim_compatible(
|
||||||
indoc! {"
|
indoc! {"
|
||||||
The quick
|
The quick
|
||||||
brown fox
|
brown fox
|
||||||
jumps over
|
jumps over
|
||||||
the lˇazy"},
|
the lˇazy"},
|
||||||
ExemptionFeatures::OperatorAbortsOnFailedMotion,
|
["c", "shift-g"],
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
cx.assert_exempted(
|
cx.assert_neovim_compatible(
|
||||||
indoc! {"
|
indoc! {"
|
||||||
The quick
|
The quick
|
||||||
brown fox
|
brown fox
|
||||||
jumps over
|
jumps over
|
||||||
ˇ"},
|
ˇ"},
|
||||||
ExemptionFeatures::OperatorAbortsOnFailedMotion,
|
["c", "shift-g"],
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
async fn test_change_gg(cx: &mut gpui::TestAppContext) {
|
async fn test_change_gg(cx: &mut gpui::TestAppContext) {
|
||||||
let mut cx = NeovimBackedTestContext::new(cx)
|
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||||
.await
|
cx.assert_neovim_compatible(
|
||||||
.binding(["c", "g", "g"]);
|
indoc! {"
|
||||||
cx.assert(indoc! {"
|
|
||||||
The quick
|
The quick
|
||||||
brownˇ fox
|
brownˇ fox
|
||||||
jumps over
|
jumps over
|
||||||
the lazy"})
|
the lazy"},
|
||||||
.await;
|
["c", "g", "g"],
|
||||||
cx.assert(indoc! {"
|
)
|
||||||
|
.await;
|
||||||
|
cx.assert_neovim_compatible(
|
||||||
|
indoc! {"
|
||||||
The quick
|
The quick
|
||||||
brown fox
|
brown fox
|
||||||
jumps over
|
jumps over
|
||||||
the lˇazy"})
|
the lˇazy"},
|
||||||
.await;
|
["c", "g", "g"],
|
||||||
cx.assert_exempted(
|
)
|
||||||
|
.await;
|
||||||
|
cx.assert_neovim_compatible(
|
||||||
indoc! {"
|
indoc! {"
|
||||||
The qˇuick
|
The qˇuick
|
||||||
brown fox
|
brown fox
|
||||||
jumps over
|
jumps over
|
||||||
the lazy"},
|
the lazy"},
|
||||||
ExemptionFeatures::OperatorAbortsOnFailedMotion,
|
["c", "g", "g"],
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
cx.assert_exempted(
|
cx.assert_neovim_compatible(
|
||||||
indoc! {"
|
indoc! {"
|
||||||
ˇ
|
ˇ
|
||||||
brown fox
|
brown fox
|
||||||
jumps over
|
jumps over
|
||||||
the lazy"},
|
the lazy"},
|
||||||
ExemptionFeatures::OperatorAbortsOnFailedMotion,
|
["c", "g", "g"],
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
@ -427,27 +455,17 @@ mod test {
|
||||||
async fn test_repeated_cb(cx: &mut gpui::TestAppContext) {
|
async fn test_repeated_cb(cx: &mut gpui::TestAppContext) {
|
||||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||||
|
|
||||||
cx.add_initial_state_exemptions(
|
|
||||||
indoc! {"
|
|
||||||
ˇThe quick brown
|
|
||||||
|
|
||||||
fox jumps-over
|
|
||||||
the lazy dog
|
|
||||||
"},
|
|
||||||
ExemptionFeatures::OperatorAbortsOnFailedMotion,
|
|
||||||
);
|
|
||||||
|
|
||||||
for count in 1..=5 {
|
for count in 1..=5 {
|
||||||
cx.assert_binding_matches_all(
|
for marked_text in cx.each_marked_position(indoc! {"
|
||||||
["c", &count.to_string(), "b"],
|
ˇThe quˇickˇ browˇn
|
||||||
indoc! {"
|
ˇ
|
||||||
ˇThe quˇickˇ browˇn
|
ˇfox ˇjumpsˇ-ˇoˇver
|
||||||
ˇ
|
ˇthe lazy dog
|
||||||
ˇfox ˇjumpsˇ-ˇoˇver
|
"})
|
||||||
ˇthe lazy dog
|
{
|
||||||
"},
|
cx.assert_neovim_compatible(&marked_text, ["c", &count.to_string(), "b"])
|
||||||
)
|
.await;
|
||||||
.await;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -278,37 +278,41 @@ mod test {
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
async fn test_delete_end_of_document(cx: &mut gpui::TestAppContext) {
|
async fn test_delete_end_of_document(cx: &mut gpui::TestAppContext) {
|
||||||
let mut cx = NeovimBackedTestContext::new(cx)
|
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||||
.await
|
cx.assert_neovim_compatible(
|
||||||
.binding(["d", "shift-g"]);
|
indoc! {"
|
||||||
cx.assert(indoc! {"
|
|
||||||
The quick
|
The quick
|
||||||
brownˇ fox
|
brownˇ fox
|
||||||
jumps over
|
jumps over
|
||||||
the lazy"})
|
the lazy"},
|
||||||
.await;
|
["d", "shift-g"],
|
||||||
cx.assert(indoc! {"
|
)
|
||||||
|
.await;
|
||||||
|
cx.assert_neovim_compatible(
|
||||||
|
indoc! {"
|
||||||
The quick
|
The quick
|
||||||
brownˇ fox
|
brownˇ fox
|
||||||
jumps over
|
jumps over
|
||||||
the lazy"})
|
the lazy"},
|
||||||
.await;
|
["d", "shift-g"],
|
||||||
cx.assert_exempted(
|
)
|
||||||
|
.await;
|
||||||
|
cx.assert_neovim_compatible(
|
||||||
indoc! {"
|
indoc! {"
|
||||||
The quick
|
The quick
|
||||||
brown fox
|
brown fox
|
||||||
jumps over
|
jumps over
|
||||||
the lˇazy"},
|
the lˇazy"},
|
||||||
ExemptionFeatures::OperatorAbortsOnFailedMotion,
|
["d", "shift-g"],
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
cx.assert_exempted(
|
cx.assert_neovim_compatible(
|
||||||
indoc! {"
|
indoc! {"
|
||||||
The quick
|
The quick
|
||||||
brown fox
|
brown fox
|
||||||
jumps over
|
jumps over
|
||||||
ˇ"},
|
ˇ"},
|
||||||
ExemptionFeatures::OperatorAbortsOnFailedMotion,
|
["d", "shift-g"],
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
@ -318,34 +322,32 @@ mod test {
|
||||||
let mut cx = NeovimBackedTestContext::new(cx)
|
let mut cx = NeovimBackedTestContext::new(cx)
|
||||||
.await
|
.await
|
||||||
.binding(["d", "g", "g"]);
|
.binding(["d", "g", "g"]);
|
||||||
cx.assert(indoc! {"
|
cx.assert_neovim_compatible(indoc! {"
|
||||||
The quick
|
The quick
|
||||||
brownˇ fox
|
brownˇ fox
|
||||||
jumps over
|
jumps over
|
||||||
the lazy"})
|
the lazy"}, ["d", "g", "g"])
|
||||||
.await;
|
.await;
|
||||||
cx.assert(indoc! {"
|
cx.assert_neovim_compatible(indoc! {"
|
||||||
The quick
|
The quick
|
||||||
brown fox
|
brown fox
|
||||||
jumps over
|
jumps over
|
||||||
the lˇazy"})
|
the lˇazy"}, ["d", "g", "g"])
|
||||||
.await;
|
.await;
|
||||||
cx.assert_exempted(
|
cx.assert_neovim_compatible(
|
||||||
indoc! {"
|
indoc! {"
|
||||||
The qˇuick
|
The qˇuick
|
||||||
brown fox
|
brown fox
|
||||||
jumps over
|
jumps over
|
||||||
the lazy"},
|
the lazy"},["d", "g", "g"]
|
||||||
ExemptionFeatures::OperatorAbortsOnFailedMotion,
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
cx.assert_exempted(
|
cx.assert_neovim_compatible(
|
||||||
indoc! {"
|
indoc! {"
|
||||||
ˇ
|
ˇ
|
||||||
brown fox
|
brown fox
|
||||||
jumps over
|
jumps over
|
||||||
the lazy"},
|
the lazy"},["d", "g", "g"]
|
||||||
ExemptionFeatures::OperatorAbortsOnFailedMotion,
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,7 @@ use util::test::{generate_marked_text, marked_text_offsets};
|
||||||
use super::{neovim_connection::NeovimConnection, NeovimBackedBindingTestContext, VimTestContext};
|
use super::{neovim_connection::NeovimConnection, NeovimBackedBindingTestContext, VimTestContext};
|
||||||
use crate::state::Mode;
|
use crate::state::Mode;
|
||||||
|
|
||||||
pub const SUPPORTED_FEATURES: &[ExemptionFeatures] = &[
|
pub const SUPPORTED_FEATURES: &[ExemptionFeatures] = &[ExemptionFeatures::DeletionOnEmptyLine];
|
||||||
ExemptionFeatures::DeletionOnEmptyLine,
|
|
||||||
ExemptionFeatures::OperatorAbortsOnFailedMotion,
|
|
||||||
];
|
|
||||||
|
|
||||||
/// Enum representing features we have tests for but which don't work, yet. Used
|
/// Enum representing features we have tests for but which don't work, yet. Used
|
||||||
/// to add exemptions and automatically
|
/// to add exemptions and automatically
|
||||||
|
@ -25,8 +22,6 @@ pub enum ExemptionFeatures {
|
||||||
// MOTIONS
|
// MOTIONS
|
||||||
// Deletions on empty lines miss some newlines
|
// Deletions on empty lines miss some newlines
|
||||||
DeletionOnEmptyLine,
|
DeletionOnEmptyLine,
|
||||||
// When a motion fails, it should should not apply linewise operations
|
|
||||||
OperatorAbortsOnFailedMotion,
|
|
||||||
// When an operator completes at the end of the file, an extra newline is left
|
// When an operator completes at the end of the file, an extra newline is left
|
||||||
OperatorLastNewlineRemains,
|
OperatorLastNewlineRemains,
|
||||||
// Deleting a word on an empty line doesn't remove the newline
|
// Deleting a word on an empty line doesn't remove the newline
|
||||||
|
@ -389,6 +384,9 @@ impl<'a> DerefMut for NeovimBackedTestContext<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// a common mistake in tests is to call set_shared_state when
|
||||||
|
// you mean asswert_shared_state. This notices that and lets
|
||||||
|
// you know.
|
||||||
impl<'a> Drop for NeovimBackedTestContext<'a> {
|
impl<'a> Drop for NeovimBackedTestContext<'a> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
if self.is_dirty {
|
if self.is_dirty {
|
||||||
|
|
Loading…
Reference in a new issue