use super::*; /// Comment and uncomment #[tokio::test(flavor = "multi_thread")] async fn test_injected_comment_tokens_simple() -> anyhow::Result<()> { // Uncomment inner injection 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?; // Comment inner injection 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?; // Block comment inner injection 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?; // Block uncomment inner injection 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(()) } /// Selections in different regions #[tokio::test(flavor = "multi_thread")] async fn test_injected_comment_tokens_multiple_selections() -> anyhow::Result<()> { // Comments two different injection layers with different comments test(( indoc! {r#"\

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

"#}, ":lang html c", indoc! {r#"\ "#}, )) .await?; // Uncomments two different injection layers with different comments test(( indoc! {r#"\ "#}, ":lang html c", indoc! {r#"\

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

"#}, )) .await?; // Works with multiple selections test(( indoc! {r#"\

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

"#}, ":lang html c", indoc! {r#"\ "#}, )) .await?; // Works with nested injection layers: html, js then css test(( indoc! {r#"\ "#}, ":lang html c", indoc! {r#"\

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

"#}, )) .await?; // Works with block comment toggle across different layers 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?; // Many selections on the same line 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?; // Many single-selections 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(()) }