38 lines
1.1 KiB
Rust
38 lines
1.1 KiB
Rust
extern crate rustijvm;
|
|
|
|
use rustijvm::binread::BinReadable;
|
|
|
|
#[test]
|
|
fn task1_program1() {
|
|
let machine = rustijvm::machine::Machine::new_from_file("files/task1/program1.ijvm").unwrap();
|
|
|
|
assert_eq!(machine.block.len(), 7);
|
|
assert_eq!(machine.block[0], 0x10); // BIPUSH
|
|
assert_eq!(machine.block[2], 0x10); // BIPUSH
|
|
assert_eq!(machine.block[4], 0x60); // IADD
|
|
assert_eq!(machine.block[5], 0xFD); // OUT
|
|
}
|
|
|
|
#[test]
|
|
fn task1_program2() {
|
|
let machine = rustijvm::machine::Machine::new_from_file("files/task1/program2.ijvm").unwrap();
|
|
|
|
assert_eq!(machine.block.len(), 16);
|
|
assert_eq!(machine.block[0], 0x0);
|
|
assert_eq!(machine.block[1], 0x13);
|
|
assert_eq!(machine.block[4], 0x59);
|
|
assert_eq!(machine.block[5], 0x13);
|
|
assert_eq!(machine.block[8], 0x60);
|
|
assert_eq!(machine.block[9], 0x13);
|
|
assert_eq!(machine.block[12], 0x60);
|
|
assert_eq!(machine.block[13], 0xFD);
|
|
assert_eq!(machine.block[14], 0x0);
|
|
}
|
|
|
|
#[test]
|
|
fn task1_program_counter() {
|
|
let machine = rustijvm::machine::Machine::new_from_file("files/task1/program1.ijvm").unwrap();
|
|
|
|
assert_eq!(machine.get_program_counter(), 0);
|
|
}
|