Skip to content

Commit

Permalink
added tests for check_if_eif_mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
mztikk committed Nov 5, 2024
1 parent c4f7e06 commit 1d339f6
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,4 +421,36 @@ mod test {
assert_eq!(result, test.1);
}
}

#[test]
fn test_if_eif_match() {
let instructions = vec![Instruction::IF, Instruction::EIF];
let result = Parser::check_if_eif_mismatch(&instructions);
assert!(result.is_none());
}

#[test]
fn test_nested_if_eif_match() {
let instructions = vec![Instruction::IF, Instruction::RND, Instruction::IF, Instruction::RND, Instruction::EIF, Instruction::EIF];
let result = Parser::check_if_eif_mismatch(&instructions);
assert!(result.is_none());
}

#[test]
fn test_if_eif_mismatch() {
let instructions = vec![Instruction::IF, Instruction::RND];
let result = Parser::check_if_eif_mismatch(&instructions);
assert!(result.is_some());
}

#[test]
fn test_nested_if_eif_mismatch() {
let instructions = vec![Instruction::IF, Instruction::IF, Instruction::RND];
let result = Parser::check_if_eif_mismatch(&instructions);
assert!(result.is_some());

let instructions = vec![Instruction::IF, Instruction::IF, Instruction::IF, Instruction::EIF, Instruction::RND, Instruction::EIF];
let result = Parser::check_if_eif_mismatch(&instructions);
assert!(result.is_some());
}
}

0 comments on commit 1d339f6

Please sign in to comment.