From c2172847b2a55d0204e541ab5521bc15aa7e971b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Daron?= Date: Tue, 30 Jul 2024 23:03:22 +0200 Subject: [PATCH] adding tests --- .../tests/test/commands/variable_expansion.rs | 55 ++++++++++++++++++- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/helix-term/tests/test/commands/variable_expansion.rs b/helix-term/tests/test/commands/variable_expansion.rs index 1d644cb6c..61580d7e4 100644 --- a/helix-term/tests/test/commands/variable_expansion.rs +++ b/helix-term/tests/test/commands/variable_expansion.rs @@ -1,5 +1,5 @@ use super::*; - +use std::borrow::Cow; #[tokio::test(flavor = "multi_thread")] async fn test_variable_expansion() -> anyhow::Result<()> { { @@ -19,8 +19,6 @@ async fn test_variable_expansion() -> anyhow::Result<()> { .await?; let mut app = AppBuilder::new().build()?; - let mut app = AppBuilder::new().build()?; - test_key_sequence( &mut app, Some(":echo %{basename}"), @@ -128,6 +126,57 @@ async fn test_variable_expansion() -> anyhow::Result<()> { false, ) .await?; + + let mut app = AppBuilder::new().build()?; + + test_key_sequence( + &mut app, + Some(":echo %sh{echo %{filename}}"), + Some(&|app| { + assert_eq!( + app.editor.get_status().unwrap().0, + helix_view::document::SCRATCH_BUFFER_NAME + ); + }), + false, + ) + .await?; + let mut app = AppBuilder::new().build()?; + + test_key_sequence( + &mut app, + Some(":echo %sh{echo %{filename} %{linenumber}}"), + Some(&|app| { + assert_eq!( + app.editor.get_status().unwrap().0, + &Cow::from(format!( + "{} {}", + helix_view::document::SCRATCH_BUFFER_NAME, + 1 + )) + ); + }), + false, + ) + .await?; + let mut app = AppBuilder::new().build()?; + + test_key_sequence( + &mut app, + Some(":echo %sh{echo %{filename} %sh{echo %{filename}}}"), + Some(&|app| { + assert_eq!( + app.editor.get_status().unwrap().0, + &Cow::from(format!( + "{} {}", + helix_view::document::SCRATCH_BUFFER_NAME, + helix_view::document::SCRATCH_BUFFER_NAME + )) + ); + }), + false, + ) + .await?; } Ok(())