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 cac6b4ae01
commit c617b1fa16

View File

@ -13,11 +13,11 @@ macro_rules! lowering_lifting {
.push(InterfaceValue::$to_variant(value.try_into().map_err(
|_| {
concat!(
"Failed to cast ",
"Failed to cast `",
stringify!($from_variant),
" to ",
"` to `",
stringify!($to_variant),
"."
"`."
).to_string()
},
)?))
@ -98,6 +98,14 @@ mod tests {
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_type_mismatch =
instructions: [Instruction::ArgumentGet { index: 0}, Instruction::I32ToS8],