Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
backend_tests.cpp File Reference
#include <sysio/vm/backend.hpp>
#include <catch2/catch.hpp>
#include "utils.hpp"
Include dependency graph for backend_tests.cpp:

Go to the source code of this file.

Functions

 BACKEND_TEST_CASE ("Tests that the arguments of top level calls are validated", "[call_typecheck]")
 

Variables

wasm_allocator wa
 

Function Documentation

◆ BACKEND_TEST_CASE()

BACKEND_TEST_CASE ( "Tests that the arguments of top level calls are validated" ,
"" [call_typecheck] )

Definition at line 9 of file backend_tests.cpp.

10 {
11 /*
12 * (module
13 * (func (export "f0"))
14 * (func (export "f1") (param i32))
15 * )
16 */
17 std::vector<uint8_t> code = { 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x02, 0x60,
18 0x00, 0x00, 0x60, 0x01, 0x7f, 0x00, 0x03, 0x03, 0x02, 0x00, 0x01, 0x07,
19 0x0b, 0x02, 0x02, 0x66, 0x30, 0x00, 0x00, 0x02, 0x66, 0x31, 0x00, 0x01,
20 0x0a, 0x07, 0x02, 0x02, 0x00, 0x0b, 0x02, 0x00, 0x0b
21 };
22
24 backend_t bkend(code, &wa);
25
26 CHECK_THROWS_AS(bkend.call("env", "f0", 0), std::exception); // too many arguments
27 CHECK_THROWS_AS(bkend.call("env", "f1"), std::exception); // too few arguments
28 CHECK_THROWS_AS(bkend.call("env", "f1", UINT64_C(0)), std::exception); // wrong type of argument
29 CHECK_THROWS_AS(bkend.call("env", "f1", UINT32_C(0), UINT32_C(0)), std::exception); // too many arguments
30}
wasm_allocator wa
Definition main.cpp:10
bool call(host_t *host, uint32_t func_index, Args... args)
Definition backend.hpp:148
backend_t bkend(hello_wasm, ehm, &wa)
#define CHECK_THROWS_AS(expr, exceptionType)
Definition catch.hpp:203
#define UINT32_C(val)
Definition stdint.h:283
#define UINT64_C(val)
Definition stdint.h:284
Here is the call graph for this function:

Variable Documentation

◆ wa

wasm_allocator wa
extern

Definition at line 10 of file main.cpp.