Add tests for interpolated multiline strings
@@ -1436,6 +1436,7 @@ Assume(#alwaysTrue -> #alwaysFalse, not ) true
#[test]
fn multiline_string_indent() {
+ // /!\ Trailing spaces on the first line are on purpose, don't remove ! /!\
assert_peq!(
r##"
m#"
@@ -1445,8 +1446,10 @@ Assume(#alwaysTrue -> #alwaysFalse, not ) true
text
"#m
"##,
- "\"this\n is an\n indented\ntext\"");
+ "\"this\n is an\n indented\ntext\""
+ );
+ // /!\ Trailing spaces on the first line are on purpose, don't remove ! /!\
assert_peq!(
r##"
m#"
@@ -1455,9 +1458,10 @@ Assume(#alwaysTrue -> #alwaysFalse, not ) true
indented
text"#m
"##,
- "\"this\n is an\n indented\ntext\"");
+ "\"this\n is an\n indented\ntext\""
+ );
- // /!\ Trailing spaces on the empty line are on purpose, don't remove ! /!\
+ // /!\ Trailing spaces on the middle line are on purpose, don't remove ! /!\
assert_peq!(
r##"
m#"
@@ -1466,7 +1470,8 @@ Assume(#alwaysTrue -> #alwaysFalse, not ) true
empty line indent
"#m
"##,
- "\"ignore\n\n empty line indent\"");
+ "\"ignore\n\n empty line indent\""
+ );
assert_peq!(
r##"
@@ -1476,8 +1481,8 @@ Assume(#alwaysTrue -> #alwaysFalse, not ) true
first line indent
"#m
"##,
- "\"\nignore\n first line indent\"");
-
+ "\"\nignore\n first line indent\""
+ );
}
#[test]
@@ -1506,6 +1511,46 @@ Assume(#alwaysTrue -> #alwaysFalse, not ) true
${"${m##"te"##m}xt"}
"#m
"###,
- "\"this\n is an\n indented\ntext\"");
+ "\"this\n is an\n indented\ntext\""
+ );
+
+ assert_peq!(
+ r##"
+ let x = "I\n need\n indent!" in
+ m#"
+ base
+ ${x}
+ ${x}
+ "#m
+ "##,
+ r#""base
+ I
+ need
+ indent!
+I
+ need
+ indent!""#
+ );
+
+ assert_peq!(
+ r##"
+ let x = "ignore\nmy\nindent" in
+ let y = "me\ntoo" in
+ m#"
+ strip
+ ${x} ${y}
+ ${"not\nme"}
+ "#m
+ "##,
+ r#""strip
+ strip
+ ignore
+my
+indent me
+too
+ not
+ me
+ ""#
+ );
}
}
