mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-24 22:21:32 +00:00
test(runtime-core) Add tests for the Func
structure.
This commit is contained in:
@ -562,6 +562,44 @@ where
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
macro_rules! test_func_arity_n {
|
||||
($test_name:ident, $($x:ident),*) => {
|
||||
#[test]
|
||||
fn $test_name() {
|
||||
use crate::vm;
|
||||
|
||||
fn with_vmctx(_: &mut vm::Ctx, $($x: i32),*) -> i32 {
|
||||
vec![$($x),*].iter().sum()
|
||||
}
|
||||
|
||||
let _func = Func::new(with_vmctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_func_arity_0() {
|
||||
fn foo(_: &mut vm::Ctx) -> i32 {
|
||||
0
|
||||
}
|
||||
|
||||
let _ = Func::new(foo);
|
||||
}
|
||||
|
||||
test_func_arity_n!(test_func_arity_1, a);
|
||||
test_func_arity_n!(test_func_arity_2, a, b);
|
||||
test_func_arity_n!(test_func_arity_3, a, b, c);
|
||||
test_func_arity_n!(test_func_arity_4, a, b, c, d);
|
||||
test_func_arity_n!(test_func_arity_5, a, b, c, d, e);
|
||||
test_func_arity_n!(test_func_arity_6, a, b, c, d, e, f);
|
||||
test_func_arity_n!(test_func_arity_7, a, b, c, d, e, f, g);
|
||||
test_func_arity_n!(test_func_arity_8, a, b, c, d, e, f, g, h);
|
||||
test_func_arity_n!(test_func_arity_9, a, b, c, d, e, f, g, h, i);
|
||||
test_func_arity_n!(test_func_arity_10, a, b, c, d, e, f, g, h, i, j);
|
||||
test_func_arity_n!(test_func_arity_11, a, b, c, d, e, f, g, h, i, j, k);
|
||||
test_func_arity_n!(test_func_arity_12, a, b, c, d, e, f, g, h, i, j, k, l);
|
||||
|
||||
#[test]
|
||||
fn test_call() {
|
||||
fn foo(_ctx: &mut vm::Ctx, a: i32, b: i32) -> (i32, i32) {
|
||||
|
Reference in New Issue
Block a user