MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / TEST

Function TEST

test/loader/typeTest.cpp:37–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37TEST(TypeTest, LoadFunctionType) {
38 std::vector<uint8_t> Vec;
39
40 Conf.setWASMStandard(WasmEdge::Standard::WASM_1);
41 WasmEdge::Loader::Loader LdrWASM1(Conf);
42
43 // 1. Test load function type.
44 //
45 // 1. Load invalid empty function type.
46 // 2. Load invalid types of function type.
47 // 3. Load void parameter and result function type.
48 // 4. Load non-void parameter function type.
49 // 5. Load non-void result function type.
50 // 6. Load function type with parameters and result.
51 // 7. Load invalid parameters with unexpected end.
52 // 8. Load invalid results with unexpected end.
53 // 9. Load invalid parameters with invalid value types.
54 // 10. Load invalid results with invalid value types.
55 // 11. Load invalid parameters with ExternRef without Ref-Types proposal.
56 // 12. Load invalid results with ExternRef without Ref-Types proposal.
57 // 13. Load invalid parameters with invalid value types without Ref-Types
58 // proposal.
59 // 14. Load invalid results with invalid value types without Ref-Types
60 // proposal.
61 // 15. Load invalid function type with multi-value returns without
62 // Multi-Value proposal.
63
64 Vec = {
65 0x01U, // Type section
66 0x01U, // Content size = 1
67 0x01U // Vector length = 1
68 };
69 EXPECT_FALSE(Ldr.parseModule(prefixedVec(Vec)));
70
71 Vec = {
72 0x01U, // Type section
73 0x04U, // Content size = 4
74 0x01U, // Vector length = 1
75 0xFFU, // Invalid function type header
76 0x00U, // Parameter length = 0
77 0x00U // Result length = 0
78 };
79 EXPECT_FALSE(Ldr.parseModule(prefixedVec(Vec)));
80
81 Vec = {
82 0x01U, // Type section
83 0x04U, // Content size = 4
84 0x01U, // Vector length = 1
85 0x60U, // Function type header
86 0x00U, // Parameter length = 0
87 0x00U // Result length = 0
88 };
89 EXPECT_TRUE(Ldr.parseModule(prefixedVec(Vec)));
90
91 Vec = {
92 0x01U, // Type section
93 0x08U, // Content size = 8
94 0x01U, // Vector length = 1

Callers

nothing calls this directly

Calls 3

setWASMStandardMethod · 0.80
parseModuleMethod · 0.80
prefixedVecFunction · 0.70

Tested by

no test coverage detected