use super::*;

fn parse(x: &[u8]) -> Ast<PreExpansion> {
    do_parse(x).unwrap()
}

fn parse_test(l: Ast<PreExpansion>, r: Ast<PreExpansion>) {
    if l != r {
        let mut left = Vec::new();
        l.cdisplay(&mut left).unwrap();
        let mut right = Vec::new();
        r.cdisplay(&mut right).unwrap();
        let left = String::from_utf8_lossy(&left);
        let right = String::from_utf8_lossy(&right);
        panic!("parse equality error\nleft: {left}\nright: {right}")
    }
}

#[test]
fn command_interp() {
    parse_test(
        parse(br#""$(echo echo)""#),
        pipes([cmd([str([cmdp(pipes([cmd([
            estr(b"echo"),
            estr(b"echo"),
        ])]))])])]),
    )
}
