Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
globals_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 <globals_0_wasm>", "[globals_0_wasm_tests]" ) {
20 auto code = read_wasm( std::string(wasm_directory) + "globals.0.wasm");
21 backend_t bkend( code, &wa );
22
23 CHECK(bkend.call_with_return("env", "get-a")->to_ui32() == UINT32_C(4294967294));
24 CHECK(bkend.call_with_return("env", "get-b")->to_ui64() == UINT32_C(18446744073709551611));
25 CHECK(bkend.call_with_return("env", "get-x")->to_ui32() == UINT32_C(4294967284));
26 CHECK(bkend.call_with_return("env", "get-y")->to_ui64() == UINT32_C(18446744073709551601));
27 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "get-1")->to_f32()) == UINT32_C(3225419776));
28 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "get-2")->to_f64()) == UINT64_C(13839561654909534208));
29 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "get-5")->to_f32()) == UINT32_C(3243245568));
30 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "get-6")->to_f64()) == UINT64_C(13847442954257432576));
31 CHECK(!bkend.call_with_return("env", "set-x", UINT32_C(6)));
32 CHECK(!bkend.call_with_return("env", "set-y", UINT64_C(7)));
33 CHECK(!bkend.call_with_return("env", "set-5", bit_cast<float>(UINT32_C(1090519040))));
34 CHECK(!bkend.call_with_return("env", "set-6", bit_cast<double>(UINT64_C(4621256167635550208))));
35 CHECK(bkend.call_with_return("env", "get-x")->to_ui32() == UINT32_C(6));
36 CHECK(bkend.call_with_return("env", "get-y")->to_ui64() == UINT32_C(7));
37 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "get-5")->to_f32()) == UINT32_C(1090519040));
38 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "get-6")->to_f64()) == UINT64_C(4621256167635550208));
39 CHECK(bkend.call_with_return("env", "as-select-first")->to_ui32() == UINT32_C(6));
40 CHECK(bkend.call_with_return("env", "as-select-mid")->to_ui32() == UINT32_C(2));
41 CHECK(bkend.call_with_return("env", "as-select-last")->to_ui32() == UINT32_C(2));
42 CHECK(bkend.call_with_return("env", "as-loop-first")->to_ui32() == UINT32_C(6));
43 CHECK(bkend.call_with_return("env", "as-loop-mid")->to_ui32() == UINT32_C(6));
44 CHECK(bkend.call_with_return("env", "as-loop-last")->to_ui32() == UINT32_C(6));
45 CHECK(bkend.call_with_return("env", "as-if-condition")->to_ui32() == UINT32_C(2));
46 CHECK(bkend.call_with_return("env", "as-if-then")->to_ui32() == UINT32_C(6));
47 CHECK(bkend.call_with_return("env", "as-if-else")->to_ui32() == UINT32_C(6));
48 CHECK(bkend.call_with_return("env", "as-br_if-first")->to_ui32() == UINT32_C(6));
49 CHECK(bkend.call_with_return("env", "as-br_if-last")->to_ui32() == UINT32_C(2));
50 CHECK(bkend.call_with_return("env", "as-br_table-first")->to_ui32() == UINT32_C(6));
51 CHECK(bkend.call_with_return("env", "as-br_table-last")->to_ui32() == UINT32_C(2));
52 CHECK(bkend.call_with_return("env", "as-call_indirect-first")->to_ui32() == UINT32_C(6));
53 CHECK(bkend.call_with_return("env", "as-call_indirect-mid")->to_ui32() == UINT32_C(2));
54 CHECK_THROWS_AS(bkend("env", "as-call_indirect-last"), std::exception);
55 CHECK(!bkend.call_with_return("env", "as-store-first"));
56 CHECK(!bkend.call_with_return("env", "as-store-last"));
57 CHECK(bkend.call_with_return("env", "as-load-operand")->to_ui32() == UINT32_C(1));
58 CHECK(bkend.call_with_return("env", "as-memory.grow-value")->to_ui32() == UINT32_C(1));
59 CHECK(bkend.call_with_return("env", "as-call-value")->to_ui32() == UINT32_C(6));
60 CHECK(bkend.call_with_return("env", "as-return-value")->to_ui32() == UINT32_C(6));
61 CHECK(!bkend.call_with_return("env", "as-drop-operand"));
62 CHECK(bkend.call_with_return("env", "as-br-value")->to_ui32() == UINT32_C(6));
63 CHECK(bkend.call_with_return("env", "as-local.set-value", UINT32_C(1))->to_ui32() == UINT32_C(6));
64 CHECK(bkend.call_with_return("env", "as-local.tee-value", UINT32_C(1))->to_ui32() == UINT32_C(6));
65 CHECK(bkend.call_with_return("env", "as-global.set-value")->to_ui32() == UINT32_C(6));
66 CHECK(bkend.call_with_return("env", "as-unary-operand")->to_ui32() == UINT32_C(0));
67 CHECK(bkend.call_with_return("env", "as-binary-operand")->to_ui32() == UINT32_C(36));
68 CHECK(bkend.call_with_return("env", "as-compare-operand")->to_ui32() == UINT32_C(1));
69}
70
71BACKEND_TEST_CASE( "Testing wasm <globals_1_wasm>", "[globals_1_wasm_tests]" ) {
73 auto code = read_wasm( std::string(wasm_directory) + "globals.1.wasm");
74 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
75}
76
77BACKEND_TEST_CASE( "Testing wasm <globals_10_wasm>", "[globals_10_wasm_tests]" ) {
79 auto code = read_wasm( std::string(wasm_directory) + "globals.10.wasm");
80 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
81}
82
83BACKEND_TEST_CASE( "Testing wasm <globals_11_wasm>", "[globals_11_wasm_tests]" ) {
85 auto code = read_wasm( std::string(wasm_directory) + "globals.11.wasm");
86 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
87}
88
89BACKEND_TEST_CASE( "Testing wasm <globals_12_wasm>", "[globals_12_wasm_tests]" ) {
91 auto code = read_wasm( std::string(wasm_directory) + "globals.12.wasm");
92 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
93}
94
95BACKEND_TEST_CASE( "Testing wasm <globals_13_wasm>", "[globals_13_wasm_tests]" ) {
97 auto code = read_wasm( std::string(wasm_directory) + "globals.13.wasm");
98 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
99}
100
101BACKEND_TEST_CASE( "Testing wasm <globals_15_wasm>", "[globals_15_wasm_tests]" ) {
103 auto code = read_wasm( std::string(wasm_directory) + "globals.15.wasm");
104 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
105}
106
107BACKEND_TEST_CASE( "Testing wasm <globals_16_wasm>", "[globals_16_wasm_tests]" ) {
109 auto code = read_wasm( std::string(wasm_directory) + "globals.16.wasm");
110 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
111}
112
113BACKEND_TEST_CASE( "Testing wasm <globals_17_wasm>", "[globals_17_wasm_tests]" ) {
115 auto code = read_wasm( std::string(wasm_directory) + "globals.17.wasm");
116 backend_t bkend( code, &wa );
117
118}
119
120BACKEND_TEST_CASE( "Testing wasm <globals_18_wasm>", "[globals_18_wasm_tests]" ) {
122 auto code = read_wasm( std::string(wasm_directory) + "globals.18.wasm");
123 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
124}
125
126BACKEND_TEST_CASE( "Testing wasm <globals_19_wasm>", "[globals_19_wasm_tests]" ) {
128 auto code = read_wasm( std::string(wasm_directory) + "globals.19.wasm");
129 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
130}
131
132BACKEND_TEST_CASE( "Testing wasm <globals_2_wasm>", "[globals_2_wasm_tests]" ) {
134 auto code = read_wasm( std::string(wasm_directory) + "globals.2.wasm");
135 backend_t bkend( code, &wa );
136
137}
138
139BACKEND_TEST_CASE( "Testing wasm <globals_20_wasm>", "[globals_20_wasm_tests]" ) {
141 auto code = read_wasm( std::string(wasm_directory) + "globals.20.wasm");
142 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
143}
144
145BACKEND_TEST_CASE( "Testing wasm <globals_21_wasm>", "[globals_21_wasm_tests]" ) {
147 auto code = read_wasm( std::string(wasm_directory) + "globals.21.wasm");
148 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
149}
150
151BACKEND_TEST_CASE( "Testing wasm <globals_22_wasm>", "[globals_22_wasm_tests]" ) {
153 auto code = read_wasm( std::string(wasm_directory) + "globals.22.wasm");
154 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
155}
156
157BACKEND_TEST_CASE( "Testing wasm <globals_23_wasm>", "[globals_23_wasm_tests]" ) {
159 auto code = read_wasm( std::string(wasm_directory) + "globals.23.wasm");
160 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
161}
162
163BACKEND_TEST_CASE( "Testing wasm <globals_24_wasm>", "[globals_24_wasm_tests]" ) {
165 auto code = read_wasm( std::string(wasm_directory) + "globals.24.wasm");
166 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
167}
168
169BACKEND_TEST_CASE( "Testing wasm <globals_25_wasm>", "[globals_25_wasm_tests]" ) {
171 auto code = read_wasm( std::string(wasm_directory) + "globals.25.wasm");
172 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
173}
174
175BACKEND_TEST_CASE( "Testing wasm <globals_26_wasm>", "[globals_26_wasm_tests]" ) {
177 auto code = read_wasm( std::string(wasm_directory) + "globals.26.wasm");
178 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
179}
180
181BACKEND_TEST_CASE( "Testing wasm <globals_27_wasm>", "[globals_27_wasm_tests]" ) {
183 auto code = read_wasm( std::string(wasm_directory) + "globals.27.wasm");
184 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
185}
186
187BACKEND_TEST_CASE( "Testing wasm <globals_28_wasm>", "[globals_28_wasm_tests]" ) {
189 auto code = read_wasm( std::string(wasm_directory) + "globals.28.wasm");
190 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
191}
192
193BACKEND_TEST_CASE( "Testing wasm <globals_29_wasm>", "[globals_29_wasm_tests]" ) {
195 auto code = read_wasm( std::string(wasm_directory) + "globals.29.wasm");
196 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
197}
198
199BACKEND_TEST_CASE( "Testing wasm <globals_3_wasm>", "[globals_3_wasm_tests]" ) {
201 auto code = read_wasm( std::string(wasm_directory) + "globals.3.wasm");
202 backend_t bkend( code, &wa );
203
204}
205
206BACKEND_TEST_CASE( "Testing wasm <globals_30_wasm>", "[globals_30_wasm_tests]" ) {
208 auto code = read_wasm( std::string(wasm_directory) + "globals.30.wasm");
209 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
210}
211
212BACKEND_TEST_CASE( "Testing wasm <globals_31_wasm>", "[globals_31_wasm_tests]" ) {
214 auto code = read_wasm( std::string(wasm_directory) + "globals.31.wasm");
215 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
216}
217
218BACKEND_TEST_CASE( "Testing wasm <globals_4_wasm>", "[globals_4_wasm_tests]" ) {
220 auto code = read_wasm( std::string(wasm_directory) + "globals.4.wasm");
221 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
222}
223
224BACKEND_TEST_CASE( "Testing wasm <globals_5_wasm>", "[globals_5_wasm_tests]" ) {
226 auto code = read_wasm( std::string(wasm_directory) + "globals.5.wasm");
227 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
228}
229
230BACKEND_TEST_CASE( "Testing wasm <globals_6_wasm>", "[globals_6_wasm_tests]" ) {
232 auto code = read_wasm( std::string(wasm_directory) + "globals.6.wasm");
233 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
234}
235
236BACKEND_TEST_CASE( "Testing wasm <globals_7_wasm>", "[globals_7_wasm_tests]" ) {
238 auto code = read_wasm( std::string(wasm_directory) + "globals.7.wasm");
239 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
240}
241
242BACKEND_TEST_CASE( "Testing wasm <globals_8_wasm>", "[globals_8_wasm_tests]" ) {
244 auto code = read_wasm( std::string(wasm_directory) + "globals.8.wasm");
245 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
246}
247
248BACKEND_TEST_CASE( "Testing wasm <globals_9_wasm>", "[globals_9_wasm_tests]" ) {
250 auto code = read_wasm( std::string(wasm_directory) + "globals.9.wasm");
251 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
252}
253
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
wasm_allocator wa
Definition main.cpp:10
backend_t bkend(hello_wasm, ehm, &wa)
sysio::vm::backend< rhf_t > backend_t
#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 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