diff options
author | Skyler Hawthorne | 2022-08-17 01:28:41 +0000 |
---|---|---|
committer | Michael Davis | 2023-08-01 14:41:42 +0000 |
commit | 93acb538121cab36712f40f26fa287df93817de5 (patch) | |
tree | b0ad0a3037d62750b4da6498a96b82758c25a18c /helix-term/tests | |
parent | 1d702ea191e9bf84566ea0008755d1ab53d19265 (diff) |
add node boundary movement
Diffstat (limited to 'helix-term/tests')
-rw-r--r-- | helix-term/tests/test/commands.rs | 1 | ||||
-rw-r--r-- | helix-term/tests/test/commands/movement.rs | 199 |
2 files changed, 200 insertions, 0 deletions
diff --git a/helix-term/tests/test/commands.rs b/helix-term/tests/test/commands.rs index b13c37bc..b3e13551 100644 --- a/helix-term/tests/test/commands.rs +++ b/helix-term/tests/test/commands.rs @@ -2,6 +2,7 @@ use helix_term::application::Application; use super::*; +mod movement; mod write; #[tokio::test(flavor = "multi_thread")] 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#["|]# + } + } + "##}), + "<A-e>", + 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|]# + } + } + "}), + "<A-e>", + 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<A-e><A-e>", + 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#["|]# + } + } + "##}), + "<A-b>", + 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|]# + } + } + "}), + "<A-b>", + 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\" + } + } + "}), + "<A-b>", + 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<A-b><A-b>", + 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<A-b><A-b><A-b>", + 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(()) +} |