on master help sign in
make TestCase::From more generic
commit5b07ce76fcf1fc3279860f079b32213689f9eb4e authorSkyler Hawthorne <skyler@dead10ck.com> dateSat 22 Oct 2022, 22:18 (4 years ago) parent8c5ec95
3 files changed+19−23
helix-term/tests/test/auto_indent.rs+2−3 helix-term/tests/test/helpers.rs+7−2 helix-term/tests/test/movement.rs+10−18
helix-term/tests/test/auto_indent.rs+2−3
@@ -11,14 +11,13 @@ async fn auto_indent_c() -> anyhow::Result<()> {
1111 helpers::test_syntax_conf(None),
1212 // switches to append mode?
1313 (
14− helpers::platform_line("void foo() {#[|}]#").as_ref(),
14+ helpers::platform_line("void foo() {#[|}]#"),
1515 "i<ret><esc>",
1616 helpers::platform_line(indoc! {"\
1717 void foo() {
1818 #[|\n]#\
1919 }
20− "})
21− .as_ref(),
20+ "}),
2221 ),
2322 )
2423 .await?;
helix-term/tests/test/helpers.rs+7−2
@@ -22,8 +22,13 @@ pub struct TestCase {
2222 pub out_selection: Selection,
2323}
2424
25−impl<S: Into<String>> From<(S, S, S)> for TestCase {
26− fn from((input, keys, output): (S, S, S)) -> Self {
25+impl<S, R, V> From<(S, R, V)> for TestCase
26+where
27+ S: Into<String>,
28+ R: Into<String>,
29+ V: Into<String>,
30+{
31+ fn from((input, keys, output): (S, R, V)) -> Self {
2732 let (in_text, in_selection) = test::print(&input.into());
2833 let (out_text, out_selection) = test::print(&output.into());
2934
helix-term/tests/test/movement.rs+10−18
@@ -395,7 +395,7 @@ async fn cursor_position_append_eof() -> anyhow::Result<()> {
395395 test((
396396 "#[foo|]#",
397397 "abar<esc>",
398− helpers::platform_line("#[foobar|]#\n").as_ref(),
398+ helpers::platform_line("#[foobar|]#\n"),
399399 ))
400400 .await?;
401401
@@ -403,7 +403,7 @@ async fn cursor_position_append_eof() -> anyhow::Result<()> {
403403 test((
404404 "#[|foo]#",
405405 "abar<esc>",
406− helpers::platform_line("#[foobar|]#\n").as_ref(),
406+ helpers::platform_line("#[foobar|]#\n"),
407407 ))
408408 .await?;
409409
@@ -425,16 +425,14 @@ async fn select_mode_tree_sitter_next_function_is_union_of_objects() -> anyhow::
425425 fn inc(x: usize) -> usize { x + 1 }
426426 /// Decrements
427427 fn dec(x: usize) -> usize { x - 1 }
428− "})
429− .as_ref(),
428+ "}),
430429 "]fv]f",
431430 helpers::platform_line(indoc! {"\
432431 /// Increments
433432 #[fn inc(x: usize) -> usize { x + 1 }
434433 /// Decrements
435434 fn dec(x: usize) -> usize { x - 1 }|]#
436− "})
437− .as_ref(),
435+ "}),
438436 ),
439437 )
440438 .await?;
@@ -457,16 +455,14 @@ async fn select_mode_tree_sitter_prev_function_unselects_object() -> anyhow::Res
457455 #[fn inc(x: usize) -> usize { x + 1 }
458456 /// Decrements
459457 fn dec(x: usize) -> usize { x - 1 }|]#
460− "})
461− .as_ref(),
458+ "}),
462459 "v[f",
463460 helpers::platform_line(indoc! {"\
464461 /// Increments
465462 #[fn inc(x: usize) -> usize { x + 1 }|]#
466463 /// Decrements
467464 fn dec(x: usize) -> usize { x - 1 }
468− "})
469− .as_ref(),
465+ "}),
470466 ),
471467 )
472468 .await?;
@@ -492,8 +488,7 @@ async fn select_mode_tree_sitter_prev_function_goes_backwards_to_object() -> any
492488 fn dec(x: usize) -> usize { x - 1 }
493489 /// Identity
494490 #[fn ident(x: usize) -> usize { x }|]#
495− "})
496− .as_ref(),
491+ "}),
497492 "v[f",
498493 helpers::platform_line(indoc! {"\
499494 /// Increments
@@ -502,8 +497,7 @@ async fn select_mode_tree_sitter_prev_function_goes_backwards_to_object() -> any
502497 #[|fn dec(x: usize) -> usize { x - 1 }
503498 /// Identity
504499 ]#fn ident(x: usize) -> usize { x }
505− "})
506− .as_ref(),
500+ "}),
507501 ),
508502 )
509503 .await?;
@@ -523,8 +517,7 @@ async fn select_mode_tree_sitter_prev_function_goes_backwards_to_object() -> any
523517 fn dec(x: usize) -> usize { x - 1 }
524518 /// Identity
525519 #[fn ident(x: usize) -> usize { x }|]#
526− "})
527− .as_ref(),
520+ "}),
528521 "v[f[f",
529522 helpers::platform_line(indoc! {"\
530523 /// Increments
@@ -533,8 +526,7 @@ async fn select_mode_tree_sitter_prev_function_goes_backwards_to_object() -> any
533526 fn dec(x: usize) -> usize { x - 1 }
534527 /// Identity
535528 ]#fn ident(x: usize) -> usize { x }
536− "})
537− .as_ref(),
529+ "}),
538530 ),
539531 )
540532 .await?;