Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
unwind_tests.cpp
Go to the documentation of this file.
1// Generated by spec_test_generator. DO NOT MODIFY THIS FILE.
2
3#include <algorithm>
4#include <vector>
5#include <iostream>
6#include <iterator>
7#include <cmath>
8#include <cstdlib>
9#include <catch2/catch.hpp>
10#include <utils.hpp>
11#include <wasm_config.hpp>
12#include <sysio/vm/backend.hpp>
13
14using namespace sysio;
15using namespace sysio::vm;
16extern wasm_allocator wa;
17
18BACKEND_TEST_CASE( "Testing wasm <unwind_0_wasm>", "[unwind_0_wasm_tests]" ) {
20 auto code = read_wasm( std::string(wasm_directory) + "unwind.0.wasm");
21 backend_t bkend( code, &wa );
22
23 CHECK_THROWS_AS(bkend("env", "func-unwind-by-unreachable"), std::exception);
24 CHECK(!bkend.call_with_return("env", "func-unwind-by-br"));
25 CHECK(bkend.call_with_return("env", "func-unwind-by-br-value")->to_ui32() == UINT32_C(9));
26 CHECK(!bkend.call_with_return("env", "func-unwind-by-br_if"));
27 CHECK(bkend.call_with_return("env", "func-unwind-by-br_if-value")->to_ui32() == UINT32_C(9));
28 CHECK(!bkend.call_with_return("env", "func-unwind-by-br_table"));
29 CHECK(bkend.call_with_return("env", "func-unwind-by-br_table-value")->to_ui32() == UINT32_C(9));
30 CHECK(bkend.call_with_return("env", "func-unwind-by-return")->to_ui32() == UINT32_C(9));
31 CHECK_THROWS_AS(bkend("env", "block-unwind-by-unreachable"), std::exception);
32 CHECK(bkend.call_with_return("env", "block-unwind-by-br")->to_ui32() == UINT32_C(9));
33 CHECK(bkend.call_with_return("env", "block-unwind-by-br-value")->to_ui32() == UINT32_C(9));
34 CHECK(bkend.call_with_return("env", "block-unwind-by-br_if")->to_ui32() == UINT32_C(9));
35 CHECK(bkend.call_with_return("env", "block-unwind-by-br_if-value")->to_ui32() == UINT32_C(9));
36 CHECK(bkend.call_with_return("env", "block-unwind-by-br_table")->to_ui32() == UINT32_C(9));
37 CHECK(bkend.call_with_return("env", "block-unwind-by-br_table-value")->to_ui32() == UINT32_C(9));
38 CHECK(bkend.call_with_return("env", "block-unwind-by-return")->to_ui32() == UINT32_C(9));
39 CHECK_THROWS_AS(bkend("env", "block-nested-unwind-by-unreachable"), std::exception);
40 CHECK(bkend.call_with_return("env", "block-nested-unwind-by-br")->to_ui32() == UINT32_C(9));
41 CHECK(bkend.call_with_return("env", "block-nested-unwind-by-br-value")->to_ui32() == UINT32_C(9));
42 CHECK(bkend.call_with_return("env", "block-nested-unwind-by-br_if")->to_ui32() == UINT32_C(9));
43 CHECK(bkend.call_with_return("env", "block-nested-unwind-by-br_if-value")->to_ui32() == UINT32_C(9));
44 CHECK(bkend.call_with_return("env", "block-nested-unwind-by-br_table")->to_ui32() == UINT32_C(9));
45 CHECK(bkend.call_with_return("env", "block-nested-unwind-by-br_table-value")->to_ui32() == UINT32_C(9));
46 CHECK(bkend.call_with_return("env", "block-nested-unwind-by-return")->to_ui32() == UINT32_C(9));
47 CHECK_THROWS_AS(bkend("env", "unary-after-unreachable"), std::exception);
48 CHECK(bkend.call_with_return("env", "unary-after-br")->to_ui32() == UINT32_C(9));
49 CHECK(bkend.call_with_return("env", "unary-after-br_if")->to_ui32() == UINT32_C(9));
50 CHECK(bkend.call_with_return("env", "unary-after-br_table")->to_ui32() == UINT32_C(9));
51 CHECK(bkend.call_with_return("env", "unary-after-return")->to_ui32() == UINT32_C(9));
52 CHECK_THROWS_AS(bkend("env", "binary-after-unreachable"), std::exception);
53 CHECK(bkend.call_with_return("env", "binary-after-br")->to_ui32() == UINT32_C(9));
54 CHECK(bkend.call_with_return("env", "binary-after-br_if")->to_ui32() == UINT32_C(9));
55 CHECK(bkend.call_with_return("env", "binary-after-br_table")->to_ui32() == UINT32_C(9));
56 CHECK(bkend.call_with_return("env", "binary-after-return")->to_ui32() == UINT32_C(9));
57 CHECK_THROWS_AS(bkend("env", "select-after-unreachable"), std::exception);
58 CHECK(bkend.call_with_return("env", "select-after-br")->to_ui32() == UINT32_C(9));
59 CHECK(bkend.call_with_return("env", "select-after-br_if")->to_ui32() == UINT32_C(9));
60 CHECK(bkend.call_with_return("env", "select-after-br_table")->to_ui32() == UINT32_C(9));
61 CHECK(bkend.call_with_return("env", "select-after-return")->to_ui32() == UINT32_C(9));
62 CHECK_THROWS_AS(bkend("env", "block-value-after-unreachable"), std::exception);
63 CHECK(bkend.call_with_return("env", "block-value-after-br")->to_ui32() == UINT32_C(9));
64 CHECK(bkend.call_with_return("env", "block-value-after-br_if")->to_ui32() == UINT32_C(9));
65 CHECK(bkend.call_with_return("env", "block-value-after-br_table")->to_ui32() == UINT32_C(9));
66 CHECK(bkend.call_with_return("env", "block-value-after-return")->to_ui32() == UINT32_C(9));
67 CHECK_THROWS_AS(bkend("env", "loop-value-after-unreachable"), std::exception);
68 CHECK(bkend.call_with_return("env", "loop-value-after-br")->to_ui32() == UINT32_C(9));
69 CHECK(bkend.call_with_return("env", "loop-value-after-br_if")->to_ui32() == UINT32_C(9));
70 CHECK(bkend.call_with_return("env", "loop-value-after-br_table")->to_ui32() == UINT32_C(9));
71 CHECK(bkend.call_with_return("env", "loop-value-after-return")->to_ui32() == UINT32_C(9));
72}
73
auto call_with_return(host_t &host, const std::string_view &mod, const std::string_view &func, Args... args)
Definition backend.hpp:178
#define CHECK(cond)
Definition util.h:80
backend_t bkend(hello_wasm, ehm, &wa)
#define CHECK_THROWS_AS(expr, exceptionType)
Definition catch.hpp:203
std::vector< uint8_t > read_wasm(const std::string &fname)
Definition utils.hpp:30
#define UINT32_C(val)
Definition stdint.h:283
#define BACKEND_TEST_CASE(name, tags)
Definition utils.hpp:59
wasm_allocator wa
Definition main.cpp:10