test(interface-types) Test when lowering or lifting fails because of the value.

This commit is contained in:
Ivan Enderlin
2020-03-03 17:10:10 +01:00
parent 6576dfd64b
commit c157bdaf63

View File

@ -13,11 +13,11 @@ macro_rules! lowering_lifting {
.push(InterfaceValue::$to_variant(value.try_into().map_err( .push(InterfaceValue::$to_variant(value.try_into().map_err(
|_| { |_| {
concat!( concat!(
"Failed to cast ", "Failed to cast `",
stringify!($from_variant), stringify!($from_variant),
" to ", "` to `",
stringify!($to_variant), stringify!($to_variant),
"." "`."
).to_string() ).to_string()
}, },
)?)) )?))
@ -98,6 +98,14 @@ mod tests {
stack: [InterfaceValue::S8(42)], stack: [InterfaceValue::S8(42)],
); );
test_executable_instruction!(
test_convert_fails =
instructions: [Instruction::ArgumentGet { index: 0}, Instruction::I32ToS8],
invocation_inputs: [InterfaceValue::I32(128)],
instance: Instance::new(),
error: "Failed to cast `I32` to `S8`."
);
test_executable_instruction!( test_executable_instruction!(
test_type_mismatch = test_type_mismatch =
instructions: [Instruction::ArgumentGet { index: 0}, Instruction::I32ToS8], instructions: [Instruction::ArgumentGet { index: 0}, Instruction::I32ToS8],