From 9a1bfdc13f69dbade1006517ed60f2eca756307a Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 17 Jan 2022 02:46:04 -0500 Subject: test subshell parsing --- src/parse/test_ast.rs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/parse/test_ast.rs b/src/parse/test_ast.rs index 5c89871..f762615 100644 --- a/src/parse/test_ast.rs +++ b/src/parse/test_ast.rs @@ -121,19 +121,19 @@ macro_rules! wpv { } macro_rules! wpb { - ($bareword:literal) => { + ($bareword:expr) => { WordPart::Bareword($bareword.to_string()) }; } macro_rules! wpd { - ($doublequoted:literal) => { + ($doublequoted:expr) => { WordPart::DoubleQuoted($doublequoted.to_string()) }; } macro_rules! wps { - ($singlequoted:literal) => { + ($singlequoted:expr) => { WordPart::SingleQuoted($singlequoted.to_string()) }; } @@ -201,6 +201,25 @@ fn test_basic() { p!((44, 60), e!(w!("builtin"), w!("echo"), w!("bar"))) ) ); + + // XXX this parse may change in the future + let exe = std::env::current_exe() + .unwrap() + .into_os_string() + .into_string() + .unwrap(); + parse_eq!( + "seq 1 5 | (while read line; echo \"line: $line\"; end)", + cs!(p!( + (0, 52), + e!(w!("seq"), w!("1"), w!("5")), + e!( + w!(wps!(exe)), + w!(wps!("-c")), + w!(wps!("while read line; echo \"line: $line\"; end")) + ) + )) + ); } #[test] -- cgit v1.2.3-54-g00ecf