Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
float_memory_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 float_memory_tests.cpp:

Go to the source code of this file.

Functions

 BACKEND_TEST_CASE ("Testing wasm <float_memory_0_wasm>", "[float_memory_0_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <float_memory_1_wasm>", "[float_memory_1_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <float_memory_2_wasm>", "[float_memory_2_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <float_memory_3_wasm>", "[float_memory_3_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <float_memory_4_wasm>", "[float_memory_4_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <float_memory_5_wasm>", "[float_memory_5_wasm_tests]")
 

Variables

wasm_allocator wa
 

Function Documentation

◆ BACKEND_TEST_CASE() [1/6]

BACKEND_TEST_CASE ( "Testing wasm <float_memory_0_wasm>" ,
"" [float_memory_0_wasm_tests] )

Definition at line 18 of file float_memory_tests.cpp.

18 {
20 auto code = read_wasm( std::string(wasm_directory) + "float_memory.0.wasm");
21 backend_t bkend( code, &wa );
22
23 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(2141192192));
24 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(2141192192));
25bkend("env", "reset");
26 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(0));
27 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(0));
28bkend("env", "f32.store");
29 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(2141192192));
30 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(2141192192));
31bkend("env", "reset");
32 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(0));
33 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(0));
34bkend("env", "i32.store");
35 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(2141192192));
36 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(2141192192));
37}
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)
std::vector< uint8_t > read_wasm(const std::string &fname)
Definition utils.hpp:30
#define UINT32_C(val)
Definition stdint.h:283
T bit_cast(const U &u)
Definition utils.hpp:35
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [2/6]

BACKEND_TEST_CASE ( "Testing wasm <float_memory_1_wasm>" ,
"" [float_memory_1_wasm_tests] )

Definition at line 39 of file float_memory_tests.cpp.

39 {
41 auto code = read_wasm( std::string(wasm_directory) + "float_memory.1.wasm");
42 backend_t bkend( code, &wa );
43
44 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(9219994337134247936));
45 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(9219994337134247936));
46bkend("env", "reset");
47 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(0));
48 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(0));
49bkend("env", "f64.store");
50 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(9219994337134247936));
51 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(9219994337134247936));
52bkend("env", "reset");
53 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(0));
54 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(0));
55bkend("env", "i64.store");
56 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(9219994337134247936));
57 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(9219994337134247936));
58}
#define UINT64_C(val)
Definition stdint.h:284
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [3/6]

BACKEND_TEST_CASE ( "Testing wasm <float_memory_2_wasm>" ,
"" [float_memory_2_wasm_tests] )

Definition at line 60 of file float_memory_tests.cpp.

60 {
62 auto code = read_wasm( std::string(wasm_directory) + "float_memory.2.wasm");
63 backend_t bkend( code, &wa );
64
65 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(2141192192));
66 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(2141192192));
67bkend("env", "reset");
68 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(0));
69 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(0));
70bkend("env", "f32.store");
71 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(2141192192));
72 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(2141192192));
73bkend("env", "reset");
74 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(0));
75 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(0));
76bkend("env", "i32.store");
77 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(2141192192));
78 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(2141192192));
79}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [4/6]

BACKEND_TEST_CASE ( "Testing wasm <float_memory_3_wasm>" ,
"" [float_memory_3_wasm_tests] )

Definition at line 81 of file float_memory_tests.cpp.

81 {
83 auto code = read_wasm( std::string(wasm_directory) + "float_memory.3.wasm");
84 backend_t bkend( code, &wa );
85
86 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(9219994337134247936));
87 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(9219994337134247936));
88bkend("env", "reset");
89 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(0));
90 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(0));
91bkend("env", "f64.store");
92 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(9219994337134247936));
93 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(9219994337134247936));
94bkend("env", "reset");
95 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(0));
96 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(0));
97bkend("env", "i64.store");
98 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(9219994337134247936));
99 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(9219994337134247936));
100}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [5/6]

BACKEND_TEST_CASE ( "Testing wasm <float_memory_4_wasm>" ,
"" [float_memory_4_wasm_tests] )

Definition at line 102 of file float_memory_tests.cpp.

102 {
104 auto code = read_wasm( std::string(wasm_directory) + "float_memory.4.wasm");
105 backend_t bkend( code, &wa );
106
107 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(2144337921));
108 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(2144337921));
109bkend("env", "reset");
110 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(0));
111 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(0));
112bkend("env", "f32.store");
113 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(2144337921));
114 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(2144337921));
115bkend("env", "reset");
116 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(0));
117 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(0));
118bkend("env", "i32.store");
119 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(2144337921));
120 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(2144337921));
121}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [6/6]

BACKEND_TEST_CASE ( "Testing wasm <float_memory_5_wasm>" ,
"" [float_memory_5_wasm_tests] )

Definition at line 123 of file float_memory_tests.cpp.

123 {
125 auto code = read_wasm( std::string(wasm_directory) + "float_memory.5.wasm");
126 backend_t bkend( code, &wa );
127
128 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(9222246136947933185));
129 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(9222246136947933185));
130bkend("env", "reset");
131 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(0));
132 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(0));
133bkend("env", "f64.store");
134 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(9222246136947933185));
135 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(9222246136947933185));
136bkend("env", "reset");
137 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(0));
138 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(0));
139bkend("env", "i64.store");
140 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(9222246136947933185));
141 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(9222246136947933185));
142}
Here is the call graph for this function:

Variable Documentation

◆ wa

wasm_allocator wa
extern

Definition at line 10 of file main.cpp.