Skip to content

Commit

Permalink
refactor: simplify call stack test code
Browse files Browse the repository at this point in the history
  • Loading branch information
heypoom committed Oct 5, 2023
1 parent 401df5c commit b565eac
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions tests/call_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,18 @@
mod call_stack_tests {
extern crate opcodes_to_algorithms as O;

use O::{Machine, Execute, Load, Instruction as I};
use O::{Machine, Execute, Instruction as I};

#[test]
fn test_call_stack() {
let mut m = Machine::new();

let ptr_pusher = 1;
let ptr_start = 6;

m.mem.load_code(vec![
I::Call(ptr_start),

// [pusher]
I::Push(0xAA),
let mut m: Machine = vec![
I::Call(6),
I::Push(0xAA), // [pusher]
I::Push(0xBB),
I::Return,

// [start]
I::Call(ptr_pusher),
I::Call(ptr_pusher),
]);
I::Call(1), // [start]
I::Call(1),
].into();

m.run();
assert_eq!(m.mem.read_stack(4), [0xAA, 0xBB, 0xAA, 0xBB]);
Expand Down

0 comments on commit b565eac

Please sign in to comment.