From 9bcdac2d630e8680bd39e1aa6ab109f4f923fd2c Mon Sep 17 00:00:00 2001 From: Jan Ferdinand Sauer Date: Mon, 9 Oct 2023 16:47:36 +0200 Subject: [PATCH] test: print error of failing `assert_vector` --- triton-vm/src/error.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/triton-vm/src/error.rs b/triton-vm/src/error.rs index c0d8fc38..a9785d25 100644 --- a/triton-vm/src/error.rs +++ b/triton-vm/src/error.rs @@ -37,8 +37,8 @@ impl Display for InstructionError { let failing_index_lhs: usize = failing_position_lhs.into(); let failing_index_rhs = failing_index_lhs + DIGEST_LENGTH; write!(f, "Vector assertion failed: ")?; - write!(f, "op_stack[{failing_index_lhs}] = {lhs} != ")?; - write!(f, "{rhs} = op_stack[{failing_index_rhs}]. ")?; + write!(f, "op_stack[{failing_index_lhs}] == {lhs} != ")?; + write!(f, "{rhs} == op_stack[{failing_index_rhs}]. ")?; write!(f, "ip: {ip}, clk: {clk}") } InverseOfZero => write!(f, "0 does not have a multiplicative inverse"), @@ -97,6 +97,17 @@ mod tests { program.run([].into(), [].into()).unwrap(); } + #[test] + #[should_panic(expected = "op_stack[1] == 10 != 1 == op_stack[6]")] + fn print_unequal_vec_assert_error() { + let program = triton_program! { + push 4 push 3 push 2 push 1 push 0 + push 4 push 3 push 2 push 10 push 0 + assert_vector halt + }; + program.run([].into(), [].into()).unwrap(); + } + proptest! { #[test] fn assert_unequal_vec(