Early ISA Unit tests
Some checks failed
per-push tests / test-frontend (push) Blocked by required conditions
per-push tests / timed-decomposer-parse (push) Blocked by required conditions
per-push tests / test-utility (push) Blocked by required conditions
per-push tests / test-backend (push) Blocked by required conditions
per-push tests / build (push) Has been cancelled

This commit provides some but not all unit tests for VM instructions.
All tests pass, and this commit includes modifications to logic to allow
for that.

Signed-off-by: Ava Affine <ava@sunnypup.io>
This commit is contained in:
Ava Apples Affine 2025-07-30 00:01:07 +00:00
parent 609e65a8db
commit 3bc256dab2
6 changed files with 544 additions and 156 deletions

View file

@ -258,23 +258,23 @@ mod tests {
assert_eq!(oe_bytes.unwrap(), vec![instr::TRAP.0, 0xf3]);
let two_operands =
TryInto::<Instruction>::try_into(&[instr::LOAD.0, 0xf3, 0xf4][..]);
TryInto::<Instruction>::try_into(&[instr::LINK.0, 0xf3, 0xf4][..]);
assert!(two_operands.is_ok());
let two_oper = two_operands.unwrap();
assert_eq!(two_oper.0, instr::LOAD);
assert_eq!(two_oper.0, instr::LINK);
assert_eq!(two_oper.1.len(), 2);
let two_bytes =
TryInto::<Vec<u8>>::try_into(two_oper.clone());
assert!(two_bytes.is_ok());
assert_eq!(two_bytes.unwrap(), vec![instr::LOAD.0, 0xf3, 0xf4]);
assert_eq!(two_bytes.unwrap(), vec![instr::LINK.0, 0xf3, 0xf4]);
assert_eq!(two_oper.1[0], Operand(Address::Oper1, 0));
assert_eq!(two_oper.1[1], Operand(Address::Oper2, 0));
}
#[test]
fn test_program_parse() {
let bytes1 = [instr::LOAD.0, 0xf3, 0xf4];
let out1 = vec![Instruction(instr::LOAD,
let bytes1 = [instr::LINK.0, 0xf3, 0xf4];
let out1 = vec![Instruction(instr::LINK,
vec![Operand(Address::Oper1, 0), Operand(Address::Oper2, 0)])];
let res1 =
TryInto::<Program>::try_into(&bytes1[..]);
@ -282,11 +282,11 @@ mod tests {
assert_eq!(res1.unwrap().0, out1);
let bytes2 = [
instr::LOAD.0, 0xf3, 0xf4,
instr::LINK.0, 0xf3, 0xf4,
instr::CLEAR.0, 0xf0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
];
let out2 = vec![
Instruction(instr::LOAD, vec![
Instruction(instr::LINK, vec![
Operand(Address::Oper1, 0),
Operand(Address::Oper2, 0)
]),