Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration test helper improvements #6156

Merged
merged 7 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
make TestCase::From more generic
  • Loading branch information
dead10ck committed Mar 19, 2023
commit 8e07ddd8b61bbd0727012ae33c3d2555e972d08d
5 changes: 2 additions & 3 deletions helix-term/tests/test/auto_indent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ async fn auto_indent_c() -> anyhow::Result<()> {
helpers::test_syntax_conf(None),
// switches to append mode?
(
helpers::platform_line("void foo() {#[|}]#").as_ref(),
helpers::platform_line("void foo() {#[|}]#"),
"i<ret><esc>",
helpers::platform_line(indoc! {"\
void foo() {
#[|\n]#\
}
"})
.as_ref(),
"}),
),
)
.await?;
Expand Down
9 changes: 7 additions & 2 deletions helix-term/tests/test/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ pub struct TestCase {
pub out_selection: Selection,
}

impl<S: Into<String>> From<(S, S, S)> for TestCase {
fn from((input, keys, output): (S, S, S)) -> Self {
impl<S, R, V> From<(S, R, V)> for TestCase
where
S: Into<String>,
R: Into<String>,
V: Into<String>,
{
fn from((input, keys, output): (S, R, V)) -> Self {
let (in_text, in_selection) = test::print(&input.into());
let (out_text, out_selection) = test::print(&output.into());

Expand Down
28 changes: 10 additions & 18 deletions helix-term/tests/test/movement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,15 +395,15 @@ async fn cursor_position_append_eof() -> anyhow::Result<()> {
test((
"#[foo|]#",
"abar<esc>",
helpers::platform_line("#[foobar|]#\n").as_ref(),
helpers::platform_line("#[foobar|]#\n"),
))
.await?;

// Selection is backwards
test((
"#[|foo]#",
"abar<esc>",
helpers::platform_line("#[foobar|]#\n").as_ref(),
helpers::platform_line("#[foobar|]#\n"),
))
.await?;

Expand All @@ -425,16 +425,14 @@ async fn select_mode_tree_sitter_next_function_is_union_of_objects() -> anyhow::
fn inc(x: usize) -> usize { x + 1 }
/// Decrements
fn dec(x: usize) -> usize { x - 1 }
"})
.as_ref(),
"}),
"]fv]f",
helpers::platform_line(indoc! {"\
/// Increments
#[fn inc(x: usize) -> usize { x + 1 }
/// Decrements
fn dec(x: usize) -> usize { x - 1 }|]#
"})
.as_ref(),
"}),
),
)
.await?;
Expand All @@ -457,16 +455,14 @@ async fn select_mode_tree_sitter_prev_function_unselects_object() -> anyhow::Res
#[fn inc(x: usize) -> usize { x + 1 }
/// Decrements
fn dec(x: usize) -> usize { x - 1 }|]#
"})
.as_ref(),
"}),
"v[f",
helpers::platform_line(indoc! {"\
/// Increments
#[fn inc(x: usize) -> usize { x + 1 }|]#
/// Decrements
fn dec(x: usize) -> usize { x - 1 }
"})
.as_ref(),
"}),
),
)
.await?;
Expand All @@ -492,8 +488,7 @@ async fn select_mode_tree_sitter_prev_function_goes_backwards_to_object() -> any
fn dec(x: usize) -> usize { x - 1 }
/// Identity
#[fn ident(x: usize) -> usize { x }|]#
"})
.as_ref(),
"}),
"v[f",
helpers::platform_line(indoc! {"\
/// Increments
Expand All @@ -502,8 +497,7 @@ async fn select_mode_tree_sitter_prev_function_goes_backwards_to_object() -> any
#[|fn dec(x: usize) -> usize { x - 1 }
/// Identity
]#fn ident(x: usize) -> usize { x }
"})
.as_ref(),
"}),
),
)
.await?;
Expand All @@ -523,8 +517,7 @@ async fn select_mode_tree_sitter_prev_function_goes_backwards_to_object() -> any
fn dec(x: usize) -> usize { x - 1 }
/// Identity
#[fn ident(x: usize) -> usize { x }|]#
"})
.as_ref(),
"}),
"v[f[f",
helpers::platform_line(indoc! {"\
/// Increments
Expand All @@ -533,8 +526,7 @@ async fn select_mode_tree_sitter_prev_function_goes_backwards_to_object() -> any
fn dec(x: usize) -> usize { x - 1 }
/// Identity
]#fn ident(x: usize) -> usize { x }
"})
.as_ref(),
"}),
),
)
.await?;
Expand Down