pr 05
This commit is contained in:
parent
1a8ec25c07
commit
99f024eaa9
@ -263,6 +263,27 @@ mod tests {
|
||||
assert_eq!(res, Err(VerifierError::JumpToMidInstruction { pc: 6, target: 1 }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_verifier_jump_to_end_ok() {
|
||||
// Single-instruction function where JMP targets exactly func_len (end-exclusive)
|
||||
// Encoding: [JMP][u32 imm], with imm == total function length (6 bytes)
|
||||
let mut code = Vec::new();
|
||||
code.push(OpCode::Jmp as u8);
|
||||
code.push(0x00);
|
||||
code.extend_from_slice(&6u32.to_le_bytes());
|
||||
|
||||
let functions = vec![FunctionMeta {
|
||||
code_offset: 0,
|
||||
code_len: 6,
|
||||
return_slots: 0,
|
||||
..Default::default()
|
||||
}];
|
||||
|
||||
let res = Verifier::verify(&code, &functions).unwrap();
|
||||
// No stack usage; max stack remains 0
|
||||
assert_eq!(res[0], 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_verifier_truncation_opcode() {
|
||||
let code = vec![OpCode::PushI32 as u8]; // Truncated u16 opcode
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user