Implemented an abstraction for extracting flags from builtins

This commit is contained in:
2025-03-22 20:10:47 -04:00
parent b6a9bb880d
commit e3f3e3dcdc
18 changed files with 567 additions and 17 deletions

View File

@@ -1,3 +1,5 @@
use parse::{node_operation, NdRule, Node};
use super::super::*;
#[test]
@@ -196,3 +198,22 @@ fn parse_cursed() {
// 15,000 line snapshot file btw
insta::assert_debug_snapshot!(nodes)
}
#[test]
fn test_node_operation() {
let input = String::from("echo hello world; echo foo bar");
let mut check_nodes = vec![];
let mut tokens: Vec<Tk> = LexStream::new(input.into(), LexFlags::empty())
.map(|tk| tk.unwrap())
.collect();
let nodes = ParseStream::new(tokens)
.map(|nd| nd.unwrap());
for mut node in nodes {
node_operation(&mut node,
&|node: &Node| matches!(node.class, NdRule::Command {..}),
&mut |node: &mut Node| check_nodes.push(node.clone()),
);
}
insta::assert_debug_snapshot!(check_nodes)
}