Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
local_get_tests.cpp File Reference
#include <algorithm>
#include <vector>
#include <iostream>
#include <iterator>
#include <cmath>
#include <cstdlib>
#include <catch2/catch.hpp>
#include <utils.hpp>
#include <wasm_config.hpp>
#include <sysio/vm/backend.hpp>
Include dependency graph for local_get_tests.cpp:

Go to the source code of this file.

Functions

 BACKEND_TEST_CASE ("Testing wasm <local_get_0_wasm>", "[local_get_0_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <local_get_1_wasm>", "[local_get_1_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <local_get_10_wasm>", "[local_get_10_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <local_get_11_wasm>", "[local_get_11_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <local_get_12_wasm>", "[local_get_12_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <local_get_13_wasm>", "[local_get_13_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <local_get_14_wasm>", "[local_get_14_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <local_get_15_wasm>", "[local_get_15_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <local_get_16_wasm>", "[local_get_16_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <local_get_2_wasm>", "[local_get_2_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <local_get_3_wasm>", "[local_get_3_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <local_get_4_wasm>", "[local_get_4_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <local_get_5_wasm>", "[local_get_5_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <local_get_6_wasm>", "[local_get_6_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <local_get_7_wasm>", "[local_get_7_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <local_get_8_wasm>", "[local_get_8_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <local_get_9_wasm>", "[local_get_9_wasm_tests]")
 

Variables

wasm_allocator wa
 

Function Documentation

◆ BACKEND_TEST_CASE() [1/17]

BACKEND_TEST_CASE ( "Testing wasm <local_get_0_wasm>" ,
"" [local_get_0_wasm_tests] )

Definition at line 18 of file local_get_tests.cpp.

18 {
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}
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)
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
T bit_cast(const U &u)
Definition utils.hpp:35
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [2/17]

BACKEND_TEST_CASE ( "Testing wasm <local_get_10_wasm>" ,
"" [local_get_10_wasm_tests] )

Definition at line 50 of file local_get_tests.cpp.

50 {
52 auto code = read_wasm( std::string(wasm_directory) + "local_get.10.wasm");
53 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
54}
sysio::vm::backend< rhf_t > backend_t
#define CHECK_THROWS_AS(expr, exceptionType)
Definition catch.hpp:203
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [3/17]

BACKEND_TEST_CASE ( "Testing wasm <local_get_11_wasm>" ,
"" [local_get_11_wasm_tests] )

Definition at line 56 of file local_get_tests.cpp.

56 {
58 auto code = read_wasm( std::string(wasm_directory) + "local_get.11.wasm");
59 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
60}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [4/17]

BACKEND_TEST_CASE ( "Testing wasm <local_get_12_wasm>" ,
"" [local_get_12_wasm_tests] )

Definition at line 62 of file local_get_tests.cpp.

62 {
64 auto code = read_wasm( std::string(wasm_directory) + "local_get.12.wasm");
65 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
66}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [5/17]

BACKEND_TEST_CASE ( "Testing wasm <local_get_13_wasm>" ,
"" [local_get_13_wasm_tests] )

Definition at line 68 of file local_get_tests.cpp.

68 {
70 auto code = read_wasm( std::string(wasm_directory) + "local_get.13.wasm");
71 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
72}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [6/17]

BACKEND_TEST_CASE ( "Testing wasm <local_get_14_wasm>" ,
"" [local_get_14_wasm_tests] )

Definition at line 74 of file local_get_tests.cpp.

74 {
76 auto code = read_wasm( std::string(wasm_directory) + "local_get.14.wasm");
77 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
78}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [7/17]

BACKEND_TEST_CASE ( "Testing wasm <local_get_15_wasm>" ,
"" [local_get_15_wasm_tests] )

Definition at line 80 of file local_get_tests.cpp.

80 {
82 auto code = read_wasm( std::string(wasm_directory) + "local_get.15.wasm");
83 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
84}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [8/17]

BACKEND_TEST_CASE ( "Testing wasm <local_get_16_wasm>" ,
"" [local_get_16_wasm_tests] )

Definition at line 86 of file local_get_tests.cpp.

86 {
88 auto code = read_wasm( std::string(wasm_directory) + "local_get.16.wasm");
89 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
90}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [9/17]

BACKEND_TEST_CASE ( "Testing wasm <local_get_1_wasm>" ,
"" [local_get_1_wasm_tests] )

Definition at line 44 of file local_get_tests.cpp.

44 {
46 auto code = read_wasm( std::string(wasm_directory) + "local_get.1.wasm");
47 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
48}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [10/17]

BACKEND_TEST_CASE ( "Testing wasm <local_get_2_wasm>" ,
"" [local_get_2_wasm_tests] )

Definition at line 92 of file local_get_tests.cpp.

92 {
94 auto code = read_wasm( std::string(wasm_directory) + "local_get.2.wasm");
95 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
96}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [11/17]

BACKEND_TEST_CASE ( "Testing wasm <local_get_3_wasm>" ,
"" [local_get_3_wasm_tests] )

Definition at line 98 of file local_get_tests.cpp.

98 {
100 auto code = read_wasm( std::string(wasm_directory) + "local_get.3.wasm");
101 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
102}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [12/17]

BACKEND_TEST_CASE ( "Testing wasm <local_get_4_wasm>" ,
"" [local_get_4_wasm_tests] )

Definition at line 104 of file local_get_tests.cpp.

104 {
106 auto code = read_wasm( std::string(wasm_directory) + "local_get.4.wasm");
107 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
108}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [13/17]

BACKEND_TEST_CASE ( "Testing wasm <local_get_5_wasm>" ,
"" [local_get_5_wasm_tests] )

Definition at line 110 of file local_get_tests.cpp.

110 {
112 auto code = read_wasm( std::string(wasm_directory) + "local_get.5.wasm");
113 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
114}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [14/17]

BACKEND_TEST_CASE ( "Testing wasm <local_get_6_wasm>" ,
"" [local_get_6_wasm_tests] )

Definition at line 116 of file local_get_tests.cpp.

116 {
118 auto code = read_wasm( std::string(wasm_directory) + "local_get.6.wasm");
119 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
120}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [15/17]

BACKEND_TEST_CASE ( "Testing wasm <local_get_7_wasm>" ,
"" [local_get_7_wasm_tests] )

Definition at line 122 of file local_get_tests.cpp.

122 {
124 auto code = read_wasm( std::string(wasm_directory) + "local_get.7.wasm");
125 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
126}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [16/17]

BACKEND_TEST_CASE ( "Testing wasm <local_get_8_wasm>" ,
"" [local_get_8_wasm_tests] )

Definition at line 128 of file local_get_tests.cpp.

128 {
130 auto code = read_wasm( std::string(wasm_directory) + "local_get.8.wasm");
131 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
132}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [17/17]

BACKEND_TEST_CASE ( "Testing wasm <local_get_9_wasm>" ,
"" [local_get_9_wasm_tests] )

Definition at line 134 of file local_get_tests.cpp.

134 {
136 auto code = read_wasm( std::string(wasm_directory) + "local_get.9.wasm");
137 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
138}
Here is the call graph for this function:

Variable Documentation

◆ wa

wasm_allocator wa
extern

Definition at line 10 of file main.cpp.