MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / TEST

Function TEST

crates/c-api/tests/func.cc:9–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7using empty_t = std::tuple<>;
8
9TEST(TypedFunc, Smoke) {
10 Engine engine;
11 Store store(engine);
12 Func thunk(
13 store, FuncType({}, {}),
14 [](auto caller, auto params, auto results) { return std::monostate(); });
15
16 EXPECT_FALSE((thunk.typed<int, int>(store)));
17 EXPECT_FALSE((thunk.typed<float, std::tuple<int32_t, uint32_t>>(store)));
18 EXPECT_FALSE((thunk.typed<float, empty_t>(store)));
19 EXPECT_TRUE((thunk.typed<empty_t, empty_t>(store)));
20
21 Func pi32(
22 store, FuncType({ValType::i32()}, {}),
23 [](auto caller, auto params, auto results) { return std::monostate(); });
24
25 EXPECT_FALSE((pi32.typed<float, empty_t>(store)));
26 EXPECT_TRUE((pi32.typed<std::tuple<int32_t>, empty_t>(store)));
27 EXPECT_TRUE((pi32.typed<int32_t, empty_t>(store)));
28 EXPECT_TRUE((pi32.typed<std::tuple<uint32_t>, empty_t>(store)));
29 EXPECT_TRUE((pi32.typed<uint32_t, empty_t>(store)));
30
31 Func rets(
32 store, FuncType({}, {ValType::f32(), ValType::f64()}),
33 [](auto caller, auto params, auto results) { return std::monostate(); });
34
35 EXPECT_FALSE((rets.typed<empty_t, std::tuple<int, int>>(store)));
36 EXPECT_FALSE((rets.typed<empty_t, empty_t>(store)));
37 EXPECT_TRUE((rets.typed<empty_t, std::tuple<float, double>>(store)));
38}
39
40TEST(TypedFunc, Call) {
41 Engine engine;

Callers

nothing calls this directly

Calls 15

i64Function · 0.85
v128Function · 0.85
assert_func_typeFunction · 0.85
FuncTypeClass · 0.50
ExternRefClass · 0.50
V128Class · 0.50
unwrapMethod · 0.45
callMethod · 0.45
i32Method · 0.45
f32Method · 0.45
i64Method · 0.45
gcMethod · 0.45

Tested by

no test coverage detected