Skip to content

Commit

Permalink
test: cover edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
jpedroh committed May 2, 2024
1 parent c9cbfd8 commit b7f2fe1
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions parsing_handlers/src/java/tweak_import_declarations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,37 @@ pub fn tweak_import_declarations(root: CSTNode<'_>) -> CSTNode<'_> {
}
}
}

#[cfg(test)]
mod tests {
use model::{
cst_node::{NonTerminal, Terminal},
CSTNode,
};

#[test]
fn if_the_root_is_not_a_program_we_just_return_it() {
let root = CSTNode::Terminal(Terminal {
kind: "terminal",
value: "not_a_program",
..Default::default()
});

assert_eq!(super::tweak_import_declarations(root.clone()), root);
}

#[test]
fn if_somehow_the_root_is_a_terminal_node_we_just_return_it() {
let root = CSTNode::NonTerminal(NonTerminal {
kind: "program",
children: vec![CSTNode::Terminal(Terminal {
kind: "terminal",
value: "not_an_import_declaration",
..Default::default()
})],
..Default::default()
});

assert_eq!(super::tweak_import_declarations(root.clone()), root);
}
}

0 comments on commit b7f2fe1

Please sign in to comment.