use librasm::{RASM, RASMRuntimeError, SourceASM};
#[test]
fn assemble_and_emit_bytes_run_full_pipeline() {
let mut rasm = RASM::new(SourceASM::Slice(
"
_start:
mov rax, 7
ret
",
));
let output = rasm.assemble().unwrap();
assert_eq!(RASM::entry_offset(&output), Some(0));
assert_eq!(output.code.len(), 11);
let mut rasm = RASM::new(SourceASM::Slice(
"
_start:
ret
",
));
assert_eq!(rasm.emit_bytes().unwrap(), vec![0xC3]);
}
#[test]
fn jit_executor_reports_missing_entry_point() {
let mut rasm = RASM::new(SourceASM::Slice("ret"));
match rasm.jit_executor() {
Err(RASMRuntimeError::NoEntryPoint) => {}
Ok(_) => panic!("expected missing entry point, got JIT executor"),
Err(err) => panic!("expected missing entry point, got {err}"),
}
}