use super::*; mod simple { use super::*; #[tokio::test(flavor = "multi_thread")] async fn uncomment_inner_injection() -> anyhow::Result<()> { test(( indoc! {r#"\

Comment toggle on this line should use the HTML comment token(s).

"#}, ":lang html c", indoc! {r#"\

Comment toggle on this line should use the HTML comment token(s).

"#}, )) .await?; Ok(()) } #[tokio::test(flavor = "multi_thread")] async fn comment_inner_injection() -> anyhow::Result<()> { test(( indoc! {r#"\

Comment toggle on this line should use the HTML comment token(s).

"#}, ":lang html c", indoc! {r#"\

Comment toggle on this line should use the HTML comment token(s).

"#}, )) .await?; Ok(()) } #[tokio::test(flavor = "multi_thread")] async fn block_comment_inner_injection() -> anyhow::Result<()> { test(( indoc! {r#"\

Comment toggle on this line should use the HTML comment token(s).

"#}, ":lang html C", indoc! {r#"\

Comment toggle on this line should use the HTML comment token(s).

"#}, )) .await?; Ok(()) } #[tokio::test(flavor = "multi_thread")] async fn block_uncomment_inner_injection() -> anyhow::Result<()> { test(( indoc! {r#"\

Comment toggle on this line should use the HTML comment token(s).

"#}, ":lang html C", indoc! {r#"\

Comment toggle on this line should use the HTML comment token(s).

"#}, )) .await?; Ok(()) } } mod injected_comment_tokens_continue_comment { use super::*; #[tokio::test(flavor = "multi_thread")] async fn adds_new_comment_on_newline() -> anyhow::Result<()> { test(( indoc! {r#"

Some text 1234

"#}, ":lang htmli", indoc! {r#"

Some text 1234

"#}, )) .await?; Ok(()) } #[tokio::test(flavor = "multi_thread")] async fn continues_comment() -> anyhow::Result<()> { test(( indoc! {r#"\

Some text 1234

"#}, ":lang htmli", indoc! {r#"\

Some text 1234

"#}, )) .await?; Ok(()) } } #[tokio::test(flavor = "multi_thread")] async fn test_injected_comment_tokens_continue_comment_d() -> anyhow::Result<()> { test(( indoc! {r#"\

Some text 1234

"#}, ":lang htmlO", indoc! {r#"\

Some text 1234

"#}, )) .await?; Ok(()) } mod multiple_selections_different_injection_layers { use super::*; #[tokio::test(flavor = "multi_thread")] async fn comments_two_different_injection_layers_with_different_comments() -> anyhow::Result<()> { test(( indoc! {r#"\

Comment toggle #[|on this line ]#should use the HTML comment token(s).

"#}, ":lang html c", indoc! {r#"\ "#}, )) .await?; Ok(()) } #[tokio::test(flavor = "multi_thread")] async fn uncomments_two_different_injection_layers_with_different_comments( ) -> anyhow::Result<()> { test(( indoc! {r#"\ "#}, ":lang html c", indoc! {r#"\

Comment toggle #[|on this line ]#should use the HTML comment token(s).

"#}, )) .await?; Ok(()) } #[tokio::test(flavor = "multi_thread")] async fn works_with_multiple_selections() -> anyhow::Result<()> { test(( indoc! {r#"\

Comment toggle #(|on this line )#should use the HTML comment token(s).

"#}, ":lang html c", indoc! {r#"\ "#}, )) .await?; Ok(()) } #[tokio::test(flavor = "multi_thread")] async fn works_with_nested_injection_layers_html_js_then_css() -> anyhow::Result<()> { test(( indoc! {r#"\ "#}, ":lang html c", indoc! {r#"\

Comment toggle #(|on this line)# should use the HTML comment token(s).

"#}, )) .await?; Ok(()) } #[tokio::test(flavor = "multi_thread")] async fn full_line_selection_commenting() -> anyhow::Result<()> { test(( indoc! {r#"\

Comment toggle on this line should use the HTML comment token(s).

"#}, ":lang html c", indoc! {r#"\

Comment toggle on this line should use the HTML comment token(s).

"#}, )) .await?; test(( indoc! {r#"\

Comment toggle on this line should use the HTML comment token(s).

"#}, ":lang html c", indoc! {r#"\

Comment toggle on this line should use the HTML comment token(s).

"#}, )) .await?; Ok(()) } #[tokio::test(flavor = "multi_thread")] async fn block_comment_toggle_across_different_layers() -> anyhow::Result<()> { test(( indoc! {r#"\

Comment toggle #(|on this line)# should use the HTML comment token(s).

"#}, ":lang html C", indoc! {r#"\

Comment toggle #(|)# should use the HTML comment token(s).

"#}, )) .await?; Ok(()) } #[tokio::test(flavor = "multi_thread")] async fn multiple_selections_same_line() -> anyhow::Result<()> { test(( indoc! {r#"\

C#[|o]#mment t#(|o)#ggle #(|o)#n this line sh#(|o)#uld use the HTML c#(|o)#mment t#(|o)#ken(s).

"#}, ":lang html C", indoc! {r#"\

C#[|]#mment t#(|)#ggle #(|)#n this line sh#(|)#uld use the HTML c#(|)#mment t#(|)#ken(s).

"#}, )) .await?; test(( indoc! {r#"\

C#[|]#mment t#(|)#ggle #(|)#n this line sh#(|)#uld use the HTML c#(|)#mment t#(|)#ken(s).

"#}, ":lang html C", indoc! {r#"\

C#[|o]#mment t#(|o)#ggle #(|o)#n this line sh#(|o)#uld use the HTML c#(|o)#mment t#(|o)#ken(s).

"#}, )) .await?; Ok(()) } #[tokio::test(flavor = "multi_thread")] async fn many_single_line_selections() -> anyhow::Result<()> { test(( indoc! {r#"\

C#[|o]#mment t#(|o)#ggle #(|o)#n this line sh#(|o)#uld use the HTML c#(|o)#mment t#(|o)#ken(s).

"#}, ":lang html C", indoc! {r#"\

C#[|]#mment t#(|)#ggle #(|)#n this line sh#(|)#uld use the HTML c#(|)#mment t#(|)#ken(s).

"#}, )) .await?; test(( indoc! {r#"\

C#[|]#mment t#(|)#ggle #(|)#n this line sh#(|)#uld use the HTML c#(|)#mment t#(|)#ken(s).

"#}, ":lang html C", indoc! {r#"\

C#[|o]#mment t#(|o)#ggle #(|o)#n this line sh#(|o)#uld use the HTML c#(|o)#mment t#(|o)#ken(s).

"#}, )) .await?; Ok(()) } } /// A selection that spans across several injections takes comment tokens /// from the injection with the bigger scope #[tokio::test(flavor = "multi_thread")] async fn test_injected_comment_tokens_selection_across_different_layers() -> anyhow::Result<()> { test(( indoc! {r#"\

Comment tog#[|gle on this line should use the HTML comment token(s).

"#}, ":lang html c", indoc! {r#"\ foo(); "#}, )) .await?; test(( indoc! {r#"\

Comment tog#[|gle on this line should use the HTML comment token(s).

"#}, ":lang html C", indoc! {r#"\

Comment tog#[|]#le on this line should use the javascript comment token(s). foo(); "#}, )) .await?; Ok(()) } #[tokio::test(flavor = "multi_thread")] async fn test_join_selections_comment() -> anyhow::Result<()> { test(( indoc! {"\ /// #[a|]#bc /// def "}, ":lang rustJ", indoc! {"\ /// #[a|]#bc def "}, )) .await?; // Only join if the comment token matches the previous line. test(( indoc! {"\ #[| // a // b /// c /// d e /// f // g]# "}, ":lang rustJ", indoc! {"\ #[| // a b /// c d e f // g]# "}, )) .await?; test(( "#[|\t// Join comments \t// with indent]#", ":lang goJ", "#[|\t// Join comments with indent]#", )) .await?; Ok(()) }