-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tests.cpp
123 lines (102 loc) · 2.45 KB
/
Tests.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include "Tests.hpp"
#include "Codegen.hpp"
// #include <efl/Core/Panic.hpp>
enum class MyEnum {
A = 1, BB, CCC, DDDD, EEEEE,
MEflEnumEnd(EEEEE)
};
enum FlagEnum : unsigned {
E1 = 1, E2 = 2, E3 = 4, E4 = 8,
MEflFlagEnd(E4)
};
enum class FlagEnumI : unsigned {
E1 = 1, E2 = 2, E3 = 4, E4 = 8
};
namespace efl {
namespace C {
MEflDeclareFlags(FlagEnumI, E4);
} // namespace C
} // namespace efl
struct ToApply {
private:
template <typename T>
ALWAYS_INLINE static C::ibyte ID(T&& t) NOEXCEPT {
std::cout << t << ' ';
return C::ibyte(0);
}
template <typename...TT>
ALWAYS_INLINE static CXX11Void Ignore(TT&&...) NOEXCEPT {
CXX11Return();
}
public:
template <typename...TT>
void operator()(TT&&...tt) CONST {
ToApply::Ignore(
ToApply::ID(HH::cxpr_forward<TT>(tt))...);
std::cout << std::endl;
}
};
namespace N {
MEflEnableEnumOperators();
void test_enums() {
/* Marked enums */ {
auto a = MyEnum::A;
auto b = MyEnum::BB;
$raw_assert((a | b) == MyEnum::CCC);
} /* Flagged enums */ {
auto e123 = (E1 | E2 | E3);
$raw_assert((e123 & ~E4) == e123);
}
}
} // namespace N
int scope_exit_test() {
goto __efl_skip; __efl_fail_unwrap: {
return ::efl::C::make_wrapper();
} __efl_skip: void(0);
return 1;
}
int main() {
#if CPPVER_LEAST(14)
MEflESAssert(!HasType<X>);
MEflESAssert(HasCallable<X>);
MEflESAssert(HasType<Y>);
MEflESAssert(!HasCallable<Y>);
#endif
MEflESAssert(C::is_nothrow_convertible<int, float>::value);
std::cout << std::boolalpha;
std::cout << "Is multithreaded: " << efl::is_multithreaded() << std::endl;
std::cout << "Tests:" << std::endl;
auto tup = C::make_tuple("Hello!", ' ', "I ", 4, 'M', " G", 0, 'D');
HH::apply(ToApply{}, tup);
volatile bool b = true;
if(!b) $unreachable;
auto box = C::Box<C::Str>::New();
box->append("Hello ");
auto bound = C::make_binding(box);
bound->append("there!");
std::cout << *box << std::endl;
#if CPPVER_LEAST(20)
using Lit = HH::LitC<"Hello">;
constexpr auto lit = C::Ls<"world!">;
print_lits(Lit{}, lit);
#endif
C::Option<int&> iro;
$raw_assert(iro.isEmpty());
int i = 0;
iro = i;
$raw_assert(iro);
MyBase B {};
C::Option<MyBase&> bro {B};
$raw_assert(bro.hasValue());
Meower M {};
bro = M;
bro->saySomething();
invoke_tests();
ref_tests();
strref_tests();
poly_tests();
assert(result_tests() == 0);
array_tests();
arrayref_tests();
return option_tests();
}