#[cfg(test)]
mod inst_tests {
use crate::core::{function::*, instruction::*, llvm_string::*, llvm_type::*, llvm_value::*};
#[test]
fn alloca_inst_display_test() {
let i32_type = LLVMType::new_int(32);
let alloca_inst = Instruction::new(
InstKind::ALLOCA(i32_type.clone(), Some((i32_type, 4)), Some(4), None),
Some(LLVMValue::new_register(LLVMString::from("1"))),
);
assert_eq!(
"%1 = alloca i32, i32 4, align 4",
format!("{}", alloca_inst).as_str()
);
}
#[test]
fn call_inst_display_test() {
let void_type = LLVMType::new_void();
let call_inst = Instruction::new(
InstKind::CALL(
None,
None,
Ok(ReturnType::new(void_type, None)),
LLVMString::from("llvm.donothing"),
ParameterSet::new(Vec::new()),
),
None,
);
assert!(!call_inst.is_terminator());
assert_eq!(
"call void @llvm.donothing()",
format!("{}", call_inst).as_str()
);
}
}