14#define INCLUDE_INSIDE_JIT
18#define CHECK_TRUE(test) if(!(test)){ LOG_ERROR("%s", #test); return false; }
19#define CHECK_FALSE(test) CHECK_TRUE(!test)
20#define CHECK_ANY_THROW(test) try { test; LOG_ERROR("%s", #test); return false; } catch(...){ }
21#define CHECK_NO_THROW(test) try { test; } catch(...){ LOG_ERROR("%s", #test); return false; }
22#define CHECK_EQ(val1, val2) CHECK_TRUE((val1) == (val2))
24inline bool str_compare(
const std::string_view str1,
const std::string_view str2) {
25 if (str1.compare(str2) != 0) {
26 LOG_ERROR(
"'%s' != '%s'", str1.begin(), str2.begin());
32inline bool str_compare(
const std::wstring_view str1,
const std::wstring_view str2) {
33 if (str1.compare(str2) != 0) {
39#define CHECK_STREQ(val1, val2) CHECK_TRUE(str_compare(val1, val2))
41extern "C" int float_compare(
float val1,
float val2);
42extern "C" int double_compare(
double val1,
double val2);
44#pragma message WARNING("Проблема со встроенными функциями или аргументами (возвратом)!!!")
52#define CHECK_FLOAT_EQ(val1, val2) CHECK_TRUE(float_compare((val1), (val2)))
53#define CHECK_DOUBLE_EQ(val1, val2) CHECK_TRUE(double_compare((val1), (val2)))
56#define PLAСE_ASM_COMMENT(MSG) __asm__ volatile ( "; //SOURCE: " MSG)
59#define ASSERT_ANY_THROW(...) PLAСE_ASM_COMMENT(#__VA_ARGS__); CHECK_ANY_THROW(__VA_ARGS__)
60#define ASSERT_NO_THROW(...) PLAСE_ASM_COMMENT(#__VA_ARGS__); CHECK_NO_THROW(__VA_ARGS__)
61#define ASSERT_EQ(...) PLAСE_ASM_COMMENT(#__VA_ARGS__); CHECK_EQ(__VA_ARGS__)
62#define ASSERT_STREQ(...) PLAСE_ASM_COMMENT(#__VA_ARGS__); CHECK_STREQ(__VA_ARGS__)
64#pragma message WARNING("Не фурычит с аргументами!!!")
67#define ASSERT_FLOAT_EQ(arg1, arg2) PLAСE_ASM_COMMENT(#arg1 #arg2)
68#define ASSERT_DOUBLE_EQ(arg1, arg2) PLAСE_ASM_COMMENT(#arg1 #arg2)
74extern "C" bool include_h_i_function_test() {
76 LOG_DEBUG(
"Call function include_h_i_function_test!!\n");
80 ObjPtr obj = Obj::CreateEmpty();
83 ASSERT_STREQ(
"_", obj->toString().c_str());
84 ASSERT_ANY_THROW(
auto _ =
static_cast<bool> (*obj));
85 ASSERT_ANY_THROW(
auto _ =
static_cast<int8_t
> (*obj));
86 ASSERT_ANY_THROW(
auto _ =
static_cast<uint8_t
> (*obj));
87 ASSERT_ANY_THROW(
auto _ =
static_cast<int16_t
> (*obj));
88 ASSERT_ANY_THROW(
auto _ =
static_cast<uint16_t
> (*obj));
89 ASSERT_ANY_THROW(
auto _ =
static_cast<int32_t
> (*obj));
90 ASSERT_ANY_THROW(
auto _ =
static_cast<uint32_t
> (*obj));
91 ASSERT_ANY_THROW(
auto _ =
static_cast<int64_t
> (*obj));
92 ASSERT_ANY_THROW(
auto _ =
static_cast<uint64_t
> (*obj));
93 ASSERT_ANY_THROW(
auto _ =
static_cast<float> (*obj));
94 ASSERT_ANY_THROW(
auto _ =
static_cast<double> (*obj));
95 ASSERT_ANY_THROW(
auto _ =
static_cast<std::string
> (*obj));
96 ASSERT_ANY_THROW(
auto _ =
static_cast<std::wstring
> (*obj));
98 ASSERT_STREQ(
"_", val.
toString().c_str());
99 ASSERT_ANY_THROW(
auto _ =
static_cast<bool> (val));
100 ASSERT_ANY_THROW(
auto _ =
static_cast<int8_t
> (val));
101 ASSERT_ANY_THROW(
auto _ =
static_cast<uint8_t
> (val));
102 ASSERT_ANY_THROW(
auto _ =
static_cast<int16_t
> (val));
103 ASSERT_ANY_THROW(
auto _ =
static_cast<uint16_t
> (val));
104 ASSERT_ANY_THROW(
auto _ =
static_cast<int32_t
> (val));
105 ASSERT_ANY_THROW(
auto _ =
static_cast<uint32_t
> (val));
106 ASSERT_ANY_THROW(
auto _ =
static_cast<int64_t
> (val));
107 ASSERT_ANY_THROW(
auto _ =
static_cast<uint64_t
> (val));
108 ASSERT_ANY_THROW(
auto _ =
static_cast<float> (val));
109 ASSERT_ANY_THROW(
auto _ =
static_cast<double> (val));
110 ASSERT_ANY_THROW(
auto _ =
static_cast<std::string
> (val));
111 ASSERT_ANY_THROW(
auto _ =
static_cast<std::wstring
> (val));
117 ASSERT_EQ(
false,
static_cast<bool> (*obj));
118 ASSERT_EQ(0,
static_cast<int8_t
> (*obj));
119 ASSERT_EQ(0,
static_cast<uint8_t
> (*obj));
120 ASSERT_EQ(0,
static_cast<int16_t
> (*obj));
121 ASSERT_EQ(0,
static_cast<uint16_t
> (*obj));
122 ASSERT_EQ(0,
static_cast<int32_t
> (*obj));
123 ASSERT_EQ(0,
static_cast<uint32_t
> (*obj));
124 ASSERT_EQ(0,
static_cast<int64_t
> (*obj));
125 ASSERT_EQ(0,
static_cast<uint64_t
> (*obj));
126 ASSERT_STREQ(
"0",
static_cast<std::string
> (*obj).c_str());
127 ASSERT_STREQ(L
"0",
static_cast<std::wstring
> (*obj).c_str());
128 ASSERT_FLOAT_EQ(0,
static_cast<float> (*obj));
129 ASSERT_DOUBLE_EQ(0,
static_cast<double> (*obj));
131 ASSERT_EQ(
false,
static_cast<bool> (val));
132 ASSERT_EQ(0,
static_cast<int8_t
> (val));
133 ASSERT_EQ(0,
static_cast<uint8_t
> (val));
134 ASSERT_EQ(0,
static_cast<int16_t
> (val));
135 ASSERT_EQ(0,
static_cast<uint16_t
> (val));
136 ASSERT_EQ(0,
static_cast<int32_t
> (val));
137 ASSERT_EQ(0,
static_cast<uint32_t
> (val));
138 ASSERT_EQ(0,
static_cast<int64_t
> (val));
139 ASSERT_EQ(0,
static_cast<uint64_t
> (val));
140 ASSERT_STREQ(
"0",
static_cast<std::string
> (val).c_str());
141 ASSERT_STREQ(L
"0",
static_cast<std::wstring
> (val).c_str());
142 ASSERT_FLOAT_EQ(0,
static_cast<float> (val));
143 ASSERT_DOUBLE_EQ(0,
static_cast<double> (val));
158 CHECK_FLOAT_EQ(0,
static_cast<float> (*obj));
159 CHECK_DOUBLE_EQ(0,
static_cast<double> (*obj));
165 ASSERT_EQ(
true,
static_cast<bool> (*obj));
166 ASSERT_EQ(1,
static_cast<int8_t
> (*obj));
167 ASSERT_EQ(1,
static_cast<uint8_t
> (*obj));
168 ASSERT_EQ(1,
static_cast<int16_t
> (*obj));
169 ASSERT_EQ(1,
static_cast<uint16_t
> (*obj));
170 ASSERT_EQ(1,
static_cast<int32_t
> (*obj));
171 ASSERT_EQ(1,
static_cast<uint32_t
> (*obj));
172 ASSERT_EQ(1,
static_cast<int64_t
> (*obj));
173 ASSERT_EQ(1,
static_cast<uint64_t
> (*obj));
174 ASSERT_STREQ(
"1",
static_cast<std::string
> (*obj).c_str());
175 ASSERT_STREQ(L
"1",
static_cast<std::wstring
> (*obj).c_str());
176 ASSERT_DOUBLE_EQ(1, (
double)
static_cast<float> (*obj));
177 ASSERT_DOUBLE_EQ(1,
static_cast<double> (*obj));
179 ASSERT_EQ(
true,
static_cast<bool> (val));
180 ASSERT_EQ(1,
static_cast<int8_t
> (val));
181 ASSERT_EQ(1,
static_cast<uint8_t
> (val));
182 ASSERT_EQ(1,
static_cast<int16_t
> (val));
183 ASSERT_EQ(1,
static_cast<uint16_t
> (val));
184 ASSERT_EQ(1,
static_cast<int32_t
> (val));
185 ASSERT_EQ(1,
static_cast<uint32_t
> (val));
186 ASSERT_EQ(1,
static_cast<int64_t
> (val));
187 ASSERT_EQ(1,
static_cast<uint64_t
> (val));
188 ASSERT_STREQ(
"1",
static_cast<std::string
> (val).c_str());
189 ASSERT_STREQ(L
"1",
static_cast<std::wstring
> (val).c_str());
190 ASSERT_FLOAT_EQ(1,
static_cast<float> (val));
191 ASSERT_DOUBLE_EQ(1,
static_cast<double> (val));
193 if(!double_compare(0, 0)){
196 if(!double_compare(1, 1)){
199 if(!float_compare(0, 0)){
202 if(!float_compare(1, 1)){
218 ASSERT_EQ(
true,
static_cast<bool> (*obj));
219 ASSERT_ANY_THROW(
auto _ =
static_cast<int8_t
> (*obj));
220 ASSERT_ANY_THROW(
auto _ =
static_cast<uint8_t
> (*obj));
221 ASSERT_EQ(-200,
static_cast<int16_t
> (*obj));
222 ASSERT_ANY_THROW(
auto _ =
static_cast<uint16_t
> (*obj));
223 ASSERT_EQ(-200,
static_cast<int32_t
> (*obj));
224 ASSERT_ANY_THROW(
auto _ =
static_cast<uint32_t
> (*obj));
225 ASSERT_EQ(-200,
static_cast<int64_t
> (*obj));
226 ASSERT_ANY_THROW(
auto _ =
static_cast<uint64_t
> (*obj));
227 ASSERT_STREQ(
"-200",
static_cast<std::string
> (*obj).c_str());
228 ASSERT_STREQ(L
"-200",
static_cast<std::wstring
> (*obj).c_str());
229 ASSERT_FLOAT_EQ(-200,
static_cast<float> (*obj));
230 ASSERT_DOUBLE_EQ(-200,
static_cast<double> (*obj));
235 ASSERT_EQ(
true,
static_cast<bool> (*obj));
236 ASSERT_ANY_THROW(
auto _ =
static_cast<int8_t
> (*obj));
237 ASSERT_EQ(200,
static_cast<uint8_t
> (*obj));
238 ASSERT_EQ(200,
static_cast<int16_t
> (*obj));
239 ASSERT_EQ(200,
static_cast<uint16_t
> (*obj));
240 ASSERT_EQ(200,
static_cast<int32_t
> (*obj));
241 ASSERT_EQ(200,
static_cast<uint32_t
> (*obj));
242 ASSERT_EQ(200,
static_cast<int64_t
> (*obj));
243 ASSERT_EQ(200,
static_cast<uint64_t
> (*obj));
244 ASSERT_STREQ(
"200",
static_cast<std::string
> (*obj).c_str());
245 ASSERT_STREQ(L
"200",
static_cast<std::wstring
> (*obj).c_str());
246 ASSERT_FLOAT_EQ(200,
static_cast<float> (*obj));
247 ASSERT_DOUBLE_EQ(200,
static_cast<double> (*obj));
std::string toString(bool deep=true) const
#define LOG_RUNTIME(format,...)
std::shared_ptr< Obj > ObjPtr
std::string utf8_encode(const std::wstring wstr)