From 93acb538121cab36712f40f26fa287df93817de5 Mon Sep 17 00:00:00 2001 From: Skyler Hawthorne Date: Tue, 16 Aug 2022 21:28:41 -0400 Subject: add node boundary movement --- helix-term/tests/test/commands/movement.rs | 199 +++++++++++++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 helix-term/tests/test/commands/movement.rs (limited to 'helix-term/tests/test/commands') diff --git a/helix-term/tests/test/commands/movement.rs b/helix-term/tests/test/commands/movement.rs new file mode 100644 index 00000000..03dc7ba9 --- /dev/null +++ b/helix-term/tests/test/commands/movement.rs @@ -0,0 +1,199 @@ +use super::*; + +#[tokio::test(flavor = "multi_thread")] +async fn test_move_parent_node_end() -> anyhow::Result<()> { + let tests = vec![ + // single cursor stays single cursor, first goes to end of current + // node, then parent + ( + helpers::platform_line(indoc! {r##" + fn foo() { + let result = if true { + "yes" + } else { + "no#["|]# + } + } + "##}), + "", + helpers::platform_line(indoc! {"\ + fn foo() { + let result = if true { + \"yes\" + } else { + \"no\"#[\n|]# + } + } + "}), + ), + ( + helpers::platform_line(indoc! {"\ + fn foo() { + let result = if true { + \"yes\" + } else { + \"no\"#[\n|]# + } + } + "}), + "", + helpers::platform_line(indoc! {"\ + fn foo() { + let result = if true { + \"yes\" + } else { + \"no\" + }#[\n|]# + } + "}), + ), + // select mode extends + ( + helpers::platform_line(indoc! {r##" + fn foo() { + let result = if true { + "yes" + } else { + #["no"|]# + } + } + "##}), + "v", + helpers::platform_line(indoc! {"\ + fn foo() { + let result = if true { + \"yes\" + } else { + #[\"no\" + }\n|]# + } + "}), + ), + ]; + + for test in tests { + test_with_config(AppBuilder::new().with_file("foo.rs", None), test).await?; + } + + Ok(()) +} + +#[tokio::test(flavor = "multi_thread")] +async fn test_move_parent_node_start() -> anyhow::Result<()> { + let tests = vec![ + // single cursor stays single cursor, first goes to end of current + // node, then parent + ( + helpers::platform_line(indoc! {r##" + fn foo() { + let result = if true { + "yes" + } else { + "no#["|]# + } + } + "##}), + "", + helpers::platform_line(indoc! {"\ + fn foo() { + let result = if true { + \"yes\" + } else { + #[\"|]#no\" + } + } + "}), + ), + ( + helpers::platform_line(indoc! {"\ + fn foo() { + let result = if true { + \"yes\" + } else { + \"no\"#[\n|]# + } + } + "}), + "", + helpers::platform_line(indoc! {"\ + fn foo() { + let result = if true { + \"yes\" + } else #[{|]# + \"no\" + } + } + "}), + ), + ( + helpers::platform_line(indoc! {"\ + fn foo() { + let result = if true { + \"yes\" + } else #[{|]# + \"no\" + } + } + "}), + "", + helpers::platform_line(indoc! {"\ + fn foo() { + let result = if true { + \"yes\" + } #[e|]#lse { + \"no\" + } + } + "}), + ), + // select mode extends + ( + helpers::platform_line(indoc! {r##" + fn foo() { + let result = if true { + "yes" + } else { + #["no"|]# + } + } + "##}), + "v", + helpers::platform_line(indoc! {"\ + fn foo() { + let result = if true { + \"yes\" + } else #[|{ + ]#\"no\" + } + } + "}), + ), + ( + helpers::platform_line(indoc! {r##" + fn foo() { + let result = if true { + "yes" + } else { + #["no"|]# + } + } + "##}), + "v", + helpers::platform_line(indoc! {"\ + fn foo() { + let result = if true { + \"yes\" + } #[|else { + ]#\"no\" + } + } + "}), + ), + ]; + + for test in tests { + test_with_config(AppBuilder::new().with_file("foo.rs", None), test).await?; + } + + Ok(()) +} -- cgit v1.2.3-70-g09d2