mod error;
mod types;
mod machine;
mod instructions;
mod debug;
pub use error::MachineError;
pub use types::{AddressingMode, MachineWState};
pub use machine::MachineW;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_machine_creation() {
let machine = MachineW::new();
assert_eq!(machine.ak, 0);
assert_eq!(machine.l, 0);
assert_eq!(machine.is_running, false);
}
#[test]
fn test_addressing_mode_immediate() {
let addr_mode = AddressingMode::Immediate(42);
match addr_mode {
AddressingMode::Immediate(value) => assert_eq!(value, 42),
_ => panic!("Expected immediate addressing mode"),
}
}
#[test]
fn test_error_types() {
let error = MachineError::AddressOutOfBounds { address: 3000 };
assert!(error.to_string().contains("3000"));
assert!(error.to_string().contains("out of bounds"));
}
}