summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2022-01-17 02:46:04 -0500
committerJesse Luehrs <doy@tozt.net>2022-01-17 02:46:47 -0500
commit9a1bfdc13f69dbade1006517ed60f2eca756307a (patch)
treefa1f8e6b989da656830f0c83f2970bf19ddd58a9
parentb76bd65723a6318cdea378bd223fb14be1e335da (diff)
downloadnbsh-9a1bfdc13f69dbade1006517ed60f2eca756307a.tar.gz
nbsh-9a1bfdc13f69dbade1006517ed60f2eca756307a.zip
test subshell parsing
-rw-r--r--src/parse/test_ast.rs25
1 files 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]