on master help sign in
make TestCase::From more generic
5b07ce7Skyler Hawthorne
helix-term/tests/test/auto_indent.rs+2−3
@@ -11,14 +11,13 @@ async fn auto_indent_c() -> anyhow::Result<()> {
11 helpers::test_syntax_conf(None),
11 helpers::test_syntax_conf(None),
12 // switches to append mode?
12 // switches to append mode?
13 (
13 (
14− helpers::platform_line("void foo() {#[|}]#").as_ref(),
14+ helpers::platform_line("void foo() {#[|}]#"),
15 "i<ret><esc>",
15 "i<ret><esc>",
16 helpers::platform_line(indoc! {"\
16 helpers::platform_line(indoc! {"\
17 void foo() {
17 void foo() {
18 #[|\n]#\
18 #[|\n]#\
19 }
19 }
20− "})
20+ "}),
21− .as_ref(),
22 ),
21 ),
23 )
22 )
24 .await?;
23 .await?;
helix-term/tests/test/helpers.rs+7−2
@@ -22,8 +22,13 @@ pub struct TestCase {
22 pub out_selection: Selection,
22 pub out_selection: Selection,
23}
23}
24
24
25−impl<S: Into<String>> From<(S, S, S)> for TestCase {
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+{
26− fn from((input, keys, output): (S, S, S)) -> Self {
31+ fn from((input, keys, output): (S, R, V)) -> Self {
27 let (in_text, in_selection) = test::print(&input.into());
32 let (in_text, in_selection) = test::print(&input.into());
28 let (out_text, out_selection) = test::print(&output.into());
33 let (out_text, out_selection) = test::print(&output.into());
29
34
helix-term/tests/test/movement.rs+10−18
@@ -395,7 +395,7 @@ async fn cursor_position_append_eof() -> anyhow::Result<()> {
395 test((
395 test((
396 "#[foo|]#",
396 "#[foo|]#",
397 "abar<esc>",
397 "abar<esc>",
398− helpers::platform_line("#[foobar|]#\n").as_ref(),
398+ helpers::platform_line("#[foobar|]#\n"),
399 ))
399 ))
400 .await?;
400 .await?;
401
401
@@ -403,7 +403,7 @@ async fn cursor_position_append_eof() -> anyhow::Result<()> {
403 test((
403 test((
404 "#[|foo]#",
404 "#[|foo]#",
405 "abar<esc>",
405 "abar<esc>",
406− helpers::platform_line("#[foobar|]#\n").as_ref(),
406+ helpers::platform_line("#[foobar|]#\n"),
407 ))
407 ))
408 .await?;
408 .await?;
409
409
@@ -425,16 +425,14 @@ async fn select_mode_tree_sitter_next_function_is_union_of_objects() -> anyhow::
425 fn inc(x: usize) -> usize { x + 1 }
425 fn inc(x: usize) -> usize { x + 1 }
426 /// Decrements
426 /// Decrements
427 fn dec(x: usize) -> usize { x - 1 }
427 fn dec(x: usize) -> usize { x - 1 }
428− "})
428+ "}),
429− .as_ref(),
430 "]fv]f",
429 "]fv]f",
431 helpers::platform_line(indoc! {"\
430 helpers::platform_line(indoc! {"\
432 /// Increments
431 /// Increments
433 #[fn inc(x: usize) -> usize { x + 1 }
432 #[fn inc(x: usize) -> usize { x + 1 }
434 /// Decrements
433 /// Decrements
435 fn dec(x: usize) -> usize { x - 1 }|]#
434 fn dec(x: usize) -> usize { x - 1 }|]#
436− "})
435+ "}),
437− .as_ref(),
438 ),
436 ),
439 )
437 )
440 .await?;
438 .await?;
@@ -457,16 +455,14 @@ async fn select_mode_tree_sitter_prev_function_unselects_object() -> anyhow::Res
457 #[fn inc(x: usize) -> usize { x + 1 }
455 #[fn inc(x: usize) -> usize { x + 1 }
458 /// Decrements
456 /// Decrements
459 fn dec(x: usize) -> usize { x - 1 }|]#
457 fn dec(x: usize) -> usize { x - 1 }|]#
460− "})
458+ "}),
461− .as_ref(),
462 "v[f",
459 "v[f",
463 helpers::platform_line(indoc! {"\
460 helpers::platform_line(indoc! {"\
464 /// Increments
461 /// Increments
465 #[fn inc(x: usize) -> usize { x + 1 }|]#
462 #[fn inc(x: usize) -> usize { x + 1 }|]#
466 /// Decrements
463 /// Decrements
467 fn dec(x: usize) -> usize { x - 1 }
464 fn dec(x: usize) -> usize { x - 1 }
468− "})
465+ "}),
469− .as_ref(),
470 ),
466 ),
471 )
467 )
472 .await?;
468 .await?;
@@ -492,8 +488,7 @@ async fn select_mode_tree_sitter_prev_function_goes_backwards_to_object() -> any
492 fn dec(x: usize) -> usize { x - 1 }
488 fn dec(x: usize) -> usize { x - 1 }
493 /// Identity
489 /// Identity
494 #[fn ident(x: usize) -> usize { x }|]#
490 #[fn ident(x: usize) -> usize { x }|]#
495− "})
491+ "}),
496− .as_ref(),
497 "v[f",
492 "v[f",
498 helpers::platform_line(indoc! {"\
493 helpers::platform_line(indoc! {"\
499 /// Increments
494 /// Increments
@@ -502,8 +497,7 @@ async fn select_mode_tree_sitter_prev_function_goes_backwards_to_object() -> any
502 #[|fn dec(x: usize) -> usize { x - 1 }
497 #[|fn dec(x: usize) -> usize { x - 1 }
503 /// Identity
498 /// Identity
504 ]#fn ident(x: usize) -> usize { x }
499 ]#fn ident(x: usize) -> usize { x }
505− "})
500+ "}),
506− .as_ref(),
507 ),
501 ),
508 )
502 )
509 .await?;
503 .await?;
@@ -523,8 +517,7 @@ async fn select_mode_tree_sitter_prev_function_goes_backwards_to_object() -> any
523 fn dec(x: usize) -> usize { x - 1 }
517 fn dec(x: usize) -> usize { x - 1 }
524 /// Identity
518 /// Identity
525 #[fn ident(x: usize) -> usize { x }|]#
519 #[fn ident(x: usize) -> usize { x }|]#
526− "})
520+ "}),
527− .as_ref(),
528 "v[f[f",
521 "v[f[f",
529 helpers::platform_line(indoc! {"\
522 helpers::platform_line(indoc! {"\
530 /// Increments
523 /// Increments
@@ -533,8 +526,7 @@ async fn select_mode_tree_sitter_prev_function_goes_backwards_to_object() -> any
533 fn dec(x: usize) -> usize { x - 1 }
526 fn dec(x: usize) -> usize { x - 1 }
534 /// Identity
527 /// Identity
535 ]#fn ident(x: usize) -> usize { x }
528 ]#fn ident(x: usize) -> usize { x }
536− "})
529+ "}),
537− .as_ref(),
538 ),
530 ),
539 )
531 )
540 .await?;
532 .await?;