mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-22 17:36:19 +04:00
make TestCase::From more generic
This commit is contained in:
parent
8c5ec95ac0
commit
5b07ce76fc
@ -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?;
|
||||
|
@ -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());
|
||||
|
||||
|
@ -395,7 +395,7 @@ 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?;
|
||||
|
||||
@ -403,7 +403,7 @@ 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?;
|
||||
|
||||
@ -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?;
|
||||
@ -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?;
|
||||
@ -492,8 +488,7 @@ fn inc(x: usize) -> usize { x + 1 }
|
||||
fn dec(x: usize) -> usize { x - 1 }
|
||||
/// Identity
|
||||
#[fn ident(x: usize) -> usize { x }|]#
|
||||
"})
|
||||
.as_ref(),
|
||||
"}),
|
||||
"v[f",
|
||||
helpers::platform_line(indoc! {"\
|
||||
/// Increments
|
||||
@ -502,8 +497,7 @@ fn inc(x: usize) -> usize { x + 1 }
|
||||
#[|fn dec(x: usize) -> usize { x - 1 }
|
||||
/// Identity
|
||||
]#fn ident(x: usize) -> usize { x }
|
||||
"})
|
||||
.as_ref(),
|
||||
"}),
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
@ -523,8 +517,7 @@ fn inc(x: usize) -> usize { x + 1 }
|
||||
fn dec(x: usize) -> usize { x - 1 }
|
||||
/// Identity
|
||||
#[fn ident(x: usize) -> usize { x }|]#
|
||||
"})
|
||||
.as_ref(),
|
||||
"}),
|
||||
"v[f[f",
|
||||
helpers::platform_line(indoc! {"\
|
||||
/// Increments
|
||||
@ -533,8 +526,7 @@ fn dec(x: usize) -> usize { x - 1 }
|
||||
fn dec(x: usize) -> usize { x - 1 }
|
||||
/// Identity
|
||||
]#fn ident(x: usize) -> usize { x }
|
||||
"})
|
||||
.as_ref(),
|
||||
"}),
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
|
Loading…
Reference in New Issue
Block a user