Skip to content

Commit

Permalink
deal with illegal arguments in test instruction explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-ferdinand committed Sep 29, 2023
1 parent 5dc7aae commit 19ae021
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion triton-vm/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ const fn all_instructions_without_args() -> [AnInstruction<BFieldElement>; Instr
Push(BFIELD_ZERO),
Divine,
Dup(ST0),
Swap(ST1),
Swap(ST0),
Nop,
Skiz,
Call(BFIELD_ZERO),
Expand Down Expand Up @@ -814,6 +814,7 @@ mod instruction_tests {
#[test]
fn instructions_act_on_op_stack_as_indicated() {
for test_instruction in all_instructions_without_args() {
let test_instruction = replace_illegal_arguments_in_instruction(test_instruction);
let (program, stack_size_before_test_instruction) =
construct_test_program_for_instruction(test_instruction);
let stack_size_after_test_instruction = terminal_op_stack_size_for_program(program);
Expand All @@ -827,6 +828,15 @@ mod instruction_tests {
}
}

fn replace_illegal_arguments_in_instruction(
instruction: AnInstruction<BFieldElement>,
) -> AnInstruction<BFieldElement> {
match instruction {
Swap(ST0) => Swap(ST1),
_ => instruction,
}
}

fn construct_test_program_for_instruction(
instruction: AnInstruction<BFieldElement>,
) -> (Program, usize) {
Expand Down

0 comments on commit 19ae021

Please sign in to comment.