mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-29 00:21:34 +00:00
test(interface-types) Add test cases for errors.
This commit is contained in:
@ -23,11 +23,17 @@ macro_rules! lowering_lifting {
|
|||||||
)?))
|
)?))
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(_) => {
|
Some(wrong_value) => {
|
||||||
return Err(concat!(
|
return Err(format!(
|
||||||
"Instruction `",
|
concat!(
|
||||||
$instruction_name,
|
"Instruction `",
|
||||||
"` expects a `i32` value on the stack."
|
$instruction_name,
|
||||||
|
"` expects a `",
|
||||||
|
stringify!($from_variant),
|
||||||
|
"` value on the stack, got `{:?}`.",
|
||||||
|
),
|
||||||
|
wrong_value
|
||||||
|
|
||||||
)
|
)
|
||||||
.to_string())
|
.to_string())
|
||||||
},
|
},
|
||||||
@ -92,6 +98,22 @@ mod tests {
|
|||||||
stack: [InterfaceValue::S8(42)],
|
stack: [InterfaceValue::S8(42)],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
test_executable_instruction!(
|
||||||
|
test_type_mismatch =
|
||||||
|
instructions: [Instruction::ArgumentGet { index: 0}, Instruction::I32ToS8],
|
||||||
|
invocation_inputs: [InterfaceValue::I64(42)],
|
||||||
|
instance: Instance::new(),
|
||||||
|
error: "Instruction `i32-to-s8` expects a `I32` value on the stack, got `I64(42)`."
|
||||||
|
);
|
||||||
|
|
||||||
|
test_executable_instruction!(
|
||||||
|
test_no_value_on_the_stack =
|
||||||
|
instructions: [Instruction::I32ToS8],
|
||||||
|
invocation_inputs: [InterfaceValue::I32(42)],
|
||||||
|
instance: Instance::new(),
|
||||||
|
error: "Instruction `i32-to-s8` needs one value on the stack."
|
||||||
|
);
|
||||||
|
|
||||||
test_executable_instruction!(
|
test_executable_instruction!(
|
||||||
test_i32_to_u8 =
|
test_i32_to_u8 =
|
||||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I32ToU8],
|
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I32ToU8],
|
||||||
|
Reference in New Issue
Block a user