Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
local_get_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 <local_get_0_wasm>", "[local_get_0_wasm_tests]" ) {
20 auto code = read_wasm( std::string(wasm_directory) + "local_get.0.wasm");
21 backend_t bkend( code, &wa );
22
23 CHECK(bkend.call_with_return("env", "type-local-i32")->to_ui32() == UINT32_C(0));
24 CHECK(bkend.call_with_return("env", "type-local-i64")->to_ui64() == UINT32_C(0));
25 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "type-local-f32")->to_f32()) == UINT32_C(0));
26 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "type-local-f64")->to_f64()) == UINT64_C(0));
27 CHECK(bkend.call_with_return("env", "type-param-i32", UINT32_C(2))->to_ui32() == UINT32_C(2));
28 CHECK(bkend.call_with_return("env", "type-param-i64", UINT64_C(3))->to_ui64() == UINT32_C(3));
29 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "type-param-f32", bit_cast<float>(UINT32_C(1082969293)))->to_f32()) == UINT32_C(1082969293));
30 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "type-param-f64", bit_cast<double>(UINT64_C(4617878467915022336)))->to_f64()) == UINT64_C(4617878467915022336));
31 CHECK(bkend.call_with_return("env", "as-block-value", UINT32_C(6))->to_ui32() == UINT32_C(6));
32 CHECK(bkend.call_with_return("env", "as-loop-value", UINT32_C(7))->to_ui32() == UINT32_C(7));
33 CHECK(bkend.call_with_return("env", "as-br-value", UINT32_C(8))->to_ui32() == UINT32_C(8));
34 CHECK(bkend.call_with_return("env", "as-br_if-value", UINT32_C(9))->to_ui32() == UINT32_C(9));
35 CHECK(bkend.call_with_return("env", "as-br_if-value-cond", UINT32_C(10))->to_ui32() == UINT32_C(10));
36 CHECK(bkend.call_with_return("env", "as-br_table-value", UINT32_C(1))->to_ui32() == UINT32_C(2));
37 CHECK(bkend.call_with_return("env", "as-return-value", UINT32_C(0))->to_ui32() == UINT32_C(0));
38 CHECK(bkend.call_with_return("env", "as-if-then", UINT32_C(1))->to_ui32() == UINT32_C(1));
39 CHECK(bkend.call_with_return("env", "as-if-else", UINT32_C(0))->to_ui32() == UINT32_C(0));
40 CHECK(!bkend.call_with_return("env", "type-mixed", UINT64_C(1), bit_cast<float>(UINT32_C(1074580685)), bit_cast<double>(UINT64_C(4614613358185178726)), UINT32_C(4), UINT32_C(5)));
41 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "read", UINT64_C(1), bit_cast<float>(UINT32_C(1073741824)), bit_cast<double>(UINT64_C(4614613358185178726)), UINT32_C(4), UINT32_C(5))->to_f64()) == UINT64_C(4630094481904264806));
42}
43
44BACKEND_TEST_CASE( "Testing wasm <local_get_1_wasm>", "[local_get_1_wasm_tests]" ) {
46 auto code = read_wasm( std::string(wasm_directory) + "local_get.1.wasm");
47 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
48}
49
50BACKEND_TEST_CASE( "Testing wasm <local_get_10_wasm>", "[local_get_10_wasm_tests]" ) {
52 auto code = read_wasm( std::string(wasm_directory) + "local_get.10.wasm");
53 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
54}
55
56BACKEND_TEST_CASE( "Testing wasm <local_get_11_wasm>", "[local_get_11_wasm_tests]" ) {
58 auto code = read_wasm( std::string(wasm_directory) + "local_get.11.wasm");
59 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
60}
61
62BACKEND_TEST_CASE( "Testing wasm <local_get_12_wasm>", "[local_get_12_wasm_tests]" ) {
64 auto code = read_wasm( std::string(wasm_directory) + "local_get.12.wasm");
65 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
66}
67
68BACKEND_TEST_CASE( "Testing wasm <local_get_13_wasm>", "[local_get_13_wasm_tests]" ) {
70 auto code = read_wasm( std::string(wasm_directory) + "local_get.13.wasm");
71 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
72}
73
74BACKEND_TEST_CASE( "Testing wasm <local_get_14_wasm>", "[local_get_14_wasm_tests]" ) {
76 auto code = read_wasm( std::string(wasm_directory) + "local_get.14.wasm");
77 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
78}
79
80BACKEND_TEST_CASE( "Testing wasm <local_get_15_wasm>", "[local_get_15_wasm_tests]" ) {
82 auto code = read_wasm( std::string(wasm_directory) + "local_get.15.wasm");
83 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
84}
85
86BACKEND_TEST_CASE( "Testing wasm <local_get_16_wasm>", "[local_get_16_wasm_tests]" ) {
88 auto code = read_wasm( std::string(wasm_directory) + "local_get.16.wasm");
89 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
90}
91
92BACKEND_TEST_CASE( "Testing wasm <local_get_2_wasm>", "[local_get_2_wasm_tests]" ) {
94 auto code = read_wasm( std::string(wasm_directory) + "local_get.2.wasm");
95 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
96}
97
98BACKEND_TEST_CASE( "Testing wasm <local_get_3_wasm>", "[local_get_3_wasm_tests]" ) {
100 auto code = read_wasm( std::string(wasm_directory) + "local_get.3.wasm");
101 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
102}
103
104BACKEND_TEST_CASE( "Testing wasm <local_get_4_wasm>", "[local_get_4_wasm_tests]" ) {
106 auto code = read_wasm( std::string(wasm_directory) + "local_get.4.wasm");
107 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
108}
109
110BACKEND_TEST_CASE( "Testing wasm <local_get_5_wasm>", "[local_get_5_wasm_tests]" ) {
112 auto code = read_wasm( std::string(wasm_directory) + "local_get.5.wasm");
113 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
114}
115
116BACKEND_TEST_CASE( "Testing wasm <local_get_6_wasm>", "[local_get_6_wasm_tests]" ) {
118 auto code = read_wasm( std::string(wasm_directory) + "local_get.6.wasm");
119 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
120}
121
122BACKEND_TEST_CASE( "Testing wasm <local_get_7_wasm>", "[local_get_7_wasm_tests]" ) {
124 auto code = read_wasm( std::string(wasm_directory) + "local_get.7.wasm");
125 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
126}
127
128BACKEND_TEST_CASE( "Testing wasm <local_get_8_wasm>", "[local_get_8_wasm_tests]" ) {
130 auto code = read_wasm( std::string(wasm_directory) + "local_get.8.wasm");
131 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
132}
133
134BACKEND_TEST_CASE( "Testing wasm <local_get_9_wasm>", "[local_get_9_wasm_tests]" ) {
136 auto code = read_wasm( std::string(wasm_directory) + "local_get.9.wasm");
137 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
138}
139
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)
sysio::vm::backend< rhf_t > backend_t
#define CHECK_THROWS_AS(expr, exceptionType)
Definition catch.hpp:203
wasm_allocator wa
Definition main.cpp:10
std::vector< uint8_t > read_wasm(const std::string &fname)
Definition utils.hpp:30
#define UINT32_C(val)
Definition stdint.h:283
#define UINT64_C(val)
Definition stdint.h:284
#define BACKEND_TEST_CASE(name, tags)
Definition utils.hpp:59
T bit_cast(const U &u)
Definition utils.hpp:35