#![allow(clippy::unwrap_used)]
use crate::bash_parser::ast::*;
use crate::bash_parser::parser::*;
#[test]
fn test_parse_multiple_newlines() {
let input = "\n\n\necho hello\n\n\n";
let mut parser = BashParser::new(input).unwrap();
let ast = parser.parse().unwrap();
assert!(!ast.statements.is_empty());
}
#[test]
fn test_parse_semicolon_separated() {
let input = "echo a\necho b\necho c";
let mut parser = BashParser::new(input).unwrap();
let ast = parser.parse().unwrap();
assert_eq!(ast.statements.len(), 3);
}
#[test]
fn test_parse_if_elif_else() {
let input = r#"
if [ $x -eq 1 ]; then
echo one
elif [ $x -eq 2 ]; then
echo two
else
echo other
fi
"#;
let mut parser = BashParser::new(input).unwrap();
let ast = parser.parse().unwrap();
assert!(matches!(&ast.statements[0], BashStmt::If { .. }));
}