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

Go to the source code of this file.

Functions

 BACKEND_TEST_CASE ("Testing wasm <int_literals_0_wasm>", "[int_literals_0_wasm_tests]")
 

Variables

wasm_allocator wa
 

Function Documentation

◆ BACKEND_TEST_CASE()

BACKEND_TEST_CASE ( "Testing wasm <int_literals_0_wasm>" ,
"" [int_literals_0_wasm_tests] )

Definition at line 18 of file int_literals_tests.cpp.

18 {
20 auto code = read_wasm( std::string(wasm_directory) + "int_literals.0.wasm");
21 backend_t bkend( code, &wa );
22
23 CHECK(bkend.call_with_return("env", "i32.test")->to_ui32() == UINT32_C(195940365));
24 CHECK(bkend.call_with_return("env", "i32.umax")->to_ui32() == UINT32_C(4294967295));
25 CHECK(bkend.call_with_return("env", "i32.smax")->to_ui32() == UINT32_C(2147483647));
26 CHECK(bkend.call_with_return("env", "i32.neg_smax")->to_ui32() == UINT32_C(2147483649));
27 CHECK(bkend.call_with_return("env", "i32.smin")->to_ui32() == UINT32_C(2147483648));
28 CHECK(bkend.call_with_return("env", "i32.alt_smin")->to_ui32() == UINT32_C(2147483648));
29 CHECK(bkend.call_with_return("env", "i32.inc_smin")->to_ui32() == UINT32_C(2147483649));
30 CHECK(bkend.call_with_return("env", "i32.neg_zero")->to_ui32() == UINT32_C(0));
31 CHECK(bkend.call_with_return("env", "i32.not_octal")->to_ui32() == UINT32_C(10));
32 CHECK(bkend.call_with_return("env", "i32.unsigned_decimal")->to_ui32() == UINT32_C(4294967295));
33 CHECK(bkend.call_with_return("env", "i32.plus_sign")->to_ui32() == UINT32_C(42));
34 CHECK(bkend.call_with_return("env", "i64.test")->to_ui64() == UINT32_C(913028331277281902));
35 CHECK(bkend.call_with_return("env", "i64.umax")->to_ui64() == UINT32_C(18446744073709551615));
36 CHECK(bkend.call_with_return("env", "i64.smax")->to_ui64() == UINT32_C(9223372036854775807));
37 CHECK(bkend.call_with_return("env", "i64.neg_smax")->to_ui64() == UINT32_C(9223372036854775809));
38 CHECK(bkend.call_with_return("env", "i64.smin")->to_ui64() == UINT32_C(9223372036854775808));
39 CHECK(bkend.call_with_return("env", "i64.alt_smin")->to_ui64() == UINT32_C(9223372036854775808));
40 CHECK(bkend.call_with_return("env", "i64.inc_smin")->to_ui64() == UINT32_C(9223372036854775809));
41 CHECK(bkend.call_with_return("env", "i64.neg_zero")->to_ui64() == UINT32_C(0));
42 CHECK(bkend.call_with_return("env", "i64.not_octal")->to_ui64() == UINT32_C(10));
43 CHECK(bkend.call_with_return("env", "i64.unsigned_decimal")->to_ui64() == UINT32_C(18446744073709551615));
44 CHECK(bkend.call_with_return("env", "i64.plus_sign")->to_ui64() == UINT32_C(42));
45 CHECK(bkend.call_with_return("env", "i32-dec-sep1")->to_ui32() == UINT32_C(1000000));
46 CHECK(bkend.call_with_return("env", "i32-dec-sep2")->to_ui32() == UINT32_C(1000));
47 CHECK(bkend.call_with_return("env", "i32-hex-sep1")->to_ui32() == UINT32_C(168755353));
48 CHECK(bkend.call_with_return("env", "i32-hex-sep2")->to_ui32() == UINT32_C(109071));
49 CHECK(bkend.call_with_return("env", "i64-dec-sep1")->to_ui64() == UINT32_C(1000000));
50 CHECK(bkend.call_with_return("env", "i64-dec-sep2")->to_ui64() == UINT32_C(1000));
51 CHECK(bkend.call_with_return("env", "i64-hex-sep1")->to_ui64() == UINT32_C(3078696982321561));
52 CHECK(bkend.call_with_return("env", "i64-hex-sep2")->to_ui64() == UINT32_C(109071));
53}
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
Here is the call graph for this function:

Variable Documentation

◆ wa

wasm_allocator wa
extern

Definition at line 10 of file main.cpp.