From 85eda83398023296cda5795981b11f4a46b4b9c4 Mon Sep 17 00:00:00 2001 From: raleng Date: Fri, 26 Aug 2022 11:42:41 +0200 Subject: [PATCH] Enable and add multi-line string formatting tests --- crates/compiler/fmt/tests/test_fmt.rs | 139 +++++++++++++++++++------- 1 file changed, 103 insertions(+), 36 deletions(-) diff --git a/crates/compiler/fmt/tests/test_fmt.rs b/crates/compiler/fmt/tests/test_fmt.rs index dc8ca43b13..de33858d82 100644 --- a/crates/compiler/fmt/tests/test_fmt.rs +++ b/crates/compiler/fmt/tests/test_fmt.rs @@ -1098,47 +1098,114 @@ mod test_fmt { )); } - // #[test] - // fn empty_block_string() { - // expr_formats_same(indoc!( - // r#" - // """""" - // "# - // )); - // } + #[test] + fn empty_block_string() { + expr_formats_same(indoc!( + r#" + """ + """ + "# + )); + } - // #[test] - // fn basic_block_string() { - // expr_formats_same(indoc!( - // r#" - // """blah""" - // "# - // )); - // } + #[test] + fn oneline_empty_block_string() { + expr_formats_to( + indoc!( + r#" + """""" + "# + ), + indoc!( + r#" + """ + """ + "# + ), + ); + } - // #[test] - // fn newlines_block_string() { - // expr_formats_same(indoc!( - // r#" - // """blah - // spam - // foo""" - // "# - // )); - // } + #[test] + fn basic_block_string() { + expr_formats_to( + indoc!( + r#" + """griffin""" + "# + ), + indoc!( + r#" + "griffin" + "# + ), + ); + } - // #[test] - // fn quotes_block_string() { - // expr_formats_same(indoc!( - // r#" - // """ + #[test] + fn multiline_basic_block_string() { + expr_formats_to( + indoc!( + r#" + """griffin + harpy""" + "# + ), + indoc!( + r#" + """ + griffin + harpy + """ + "# + ), + ); + } - // "" \""" ""\" + #[test] + fn newlines_block_string() { + expr_formats_to( + indoc!( + r#" + """griffin + harpy + phoenix""" + "# + ), + indoc!( + r#" + """ + griffin + harpy + phoenix + """ + "# + ), + ); + } - // """ - // "# - // )); - // } + #[test] + fn quotes_block_string_single_segment() { + expr_formats_same(indoc!( + r#" + """ + "griffin" + """ + "# + )); + } + + #[test] + fn quotes_block_string() { + expr_formats_same(indoc!( + r#" + """ + + "" \""" ""\" + + """ + "# + )); + } #[test] fn zero() {