#![allow(clippy::unwrap_used)]
#![allow(clippy::expect_used)]
use super::*;
use crate::bash_parser::ast::*;
#[test]
fn test_purify_control_flow_span_preservation() {
let mut purifier = make_purifier();
let original_span = Span::new(99, 5, 120, 10);
let while_stmt = BashStmt::While {
condition: BashExpr::Literal("true".to_string()),
body: vec![],
span: original_span,
};
let result = purifier
.purify_control_flow(&while_stmt)
.expect("should succeed");
match result {
BashStmt::While { span, .. } => assert_eq!(span, original_span),
_ => panic!("Expected While"),
}
let until_stmt = BashStmt::Until {
condition: BashExpr::Literal("false".to_string()),
body: vec![],
span: original_span,
};
let result = purifier
.purify_control_flow(&until_stmt)
.expect("should succeed");
match result {
BashStmt::Until { span, .. } => assert_eq!(span, original_span),
_ => panic!("Expected Until"),
}
let case_stmt = BashStmt::Case {
word: BashExpr::Literal("x".to_string()),
arms: vec![],
span: original_span,
};
let result = purifier
.purify_control_flow(&case_stmt)
.expect("should succeed");
match result {
BashStmt::Case { span, .. } => assert_eq!(span, original_span),
_ => panic!("Expected Case"),
}
}