1#include "testing.h"
2#include "flang/Evaluate/type.h"
3#include <cstdio>
4
5template <int KIND> void testKind() {
6 using Type =
7 Fortran::evaluate::Type<Fortran::common::TypeCategory::Logical, KIND>;
8 TEST(Fortran::evaluate::IsSpecificIntrinsicType<Type>);
9 TEST(Type::category == Fortran::common::TypeCategory::Logical);
10 TEST(Type::kind == KIND);
11 using Value = Fortran::evaluate::Scalar<Type>;
12 MATCH(8 * KIND, Value::bits);
13 TEST(!Value{}.IsTrue());
14 TEST(!Value{false}.IsTrue());
15 TEST(Value{true}.IsTrue());
16 TEST(Value{false}.NOT().IsTrue());
17 TEST(!Value{true}.NOT().IsTrue());
18 TEST(!Value{false}.AND(Value{false}).IsTrue());
19 TEST(!Value{false}.AND(Value{true}).IsTrue());
20 TEST(!Value{true}.AND(Value{false}).IsTrue());
21 TEST(Value{true}.AND(Value{true}).IsTrue());
22 TEST(!Value{false}.OR(Value{false}).IsTrue());
23 TEST(Value{false}.OR(Value{true}).IsTrue());
24 TEST(Value{true}.OR(Value{false}).IsTrue());
25 TEST(Value{true}.OR(Value{true}).IsTrue());
26 TEST(Value{false}.EQV(Value{false}).IsTrue());
27 TEST(!Value{false}.EQV(Value{true}).IsTrue());
28 TEST(!Value{true}.EQV(Value{false}).IsTrue());
29 TEST(Value{true}.EQV(Value{true}).IsTrue());
30 TEST(!Value{false}.NEQV(Value{false}).IsTrue());
31 TEST(Value{false}.NEQV(Value{true}).IsTrue());
32 TEST(Value{true}.NEQV(Value{false}).IsTrue());
33 TEST(!Value{true}.NEQV(Value{true}).IsTrue());
34}
35
36int main() {
37 testKind<1>();
38 testKind<2>();
39 testKind<4>();
40 testKind<8>();
41 return testing::Complete();
42}
43

source code of flang/unittests/Evaluate/logical.cpp