From 7b84b6e05551239d93661bdeb811e72d16675364 Mon Sep 17 00:00:00 2001 From: Jonas Maier Date: Wed, 18 Mar 2026 11:48:17 +0100 Subject: test for multiline strings + custom multiline string delimiters --- src/parse/test.rs | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/parse/test.rs b/src/parse/test.rs index b3d9440..d221341 100644 --- a/src/parse/test.rs +++ b/src/parse/test.rs @@ -245,3 +245,58 @@ fn if_else() { fn simple_while() { parse_test!(parse(b"while cond { x }"), todo!()); } + +#[test] +fn multiline_string_1() { + parse_test!( + parse( + br#"echo """ +hello +world""""# + ), + pipes([cmd([estr(b"echo"), estr(b"hello\nworld")]),]) + ); +} + +#[test] +fn multiline_string_2() { + parse_test!( + parse( + br#"echo """ +line 1 +$var +line 3 +""""# + ), + pipes([cmd([estr(b"echo"), str([plain(b"line 1\n"),var(b"var"),plain(b"\nline 3\n")])]),]) + ); +} + +#[test] +fn multiline_string_3() { + parse_test!( + parse( + br#"echo ''' +line 1 +$var +line 3 +'''"# + ), + pipes([cmd([estr(b"echo"), estr(b"line 1\n$var\nline 3\n")]),]) + ); +} + +#[test] +fn multiline_string_4() { + parse_test!( + parse( + br#"echo foo""" +text +""" +more text +"""foo +"# + ), + pipes([cmd([estr(b"echo"), estr(b"text\n\"\"\"\nmore text\n")]),]) + ); +} -- cgit v1.2.3