1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Aina Niemetz, Andrew Reynolds |
4 |
|
* |
5 |
|
* This file is part of the cvc5 project. |
6 |
|
* |
7 |
|
* Copyright (c) 2009-2021 by the authors listed in the file AUTHORS |
8 |
|
* in the top-level source directory and their institutional affiliations. |
9 |
|
* All rights reserved. See the file COPYING in the top-level source |
10 |
|
* directory for licensing information. |
11 |
|
* **************************************************************************** |
12 |
|
* |
13 |
|
* White box testing of TypeNode. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include <iostream> |
17 |
|
#include <sstream> |
18 |
|
#include <string> |
19 |
|
|
20 |
|
#include "expr/node_manager.h" |
21 |
|
#include "expr/type_node.h" |
22 |
|
#include "smt/smt_engine.h" |
23 |
|
#include "test_node.h" |
24 |
|
#include "util/rational.h" |
25 |
|
|
26 |
|
namespace cvc5 { |
27 |
|
|
28 |
|
using namespace kind; |
29 |
|
using namespace context; |
30 |
|
|
31 |
|
namespace test { |
32 |
|
|
33 |
4 |
class TestNodeWhiteTypeNode : public TestNode |
34 |
|
{ |
35 |
|
protected: |
36 |
2 |
void SetUp() override |
37 |
|
{ |
38 |
2 |
TestNode::SetUp(); |
39 |
2 |
d_smt.reset(new SmtEngine(d_nodeManager.get())); |
40 |
2 |
} |
41 |
|
std::unique_ptr<SmtEngine> d_smt; |
42 |
|
}; |
43 |
|
|
44 |
10 |
TEST_F(TestNodeWhiteTypeNode, sub_types) |
45 |
|
{ |
46 |
4 |
TypeNode realType = d_nodeManager->realType(); |
47 |
4 |
TypeNode integerType = d_nodeManager->realType(); |
48 |
4 |
TypeNode booleanType = d_nodeManager->booleanType(); |
49 |
4 |
TypeNode arrayType = d_nodeManager->mkArrayType(realType, integerType); |
50 |
4 |
TypeNode bvType = d_nodeManager->mkBitVectorType(32); |
51 |
|
|
52 |
4 |
Node x = d_nodeManager->mkBoundVar("x", realType); |
53 |
4 |
Node xPos = d_nodeManager->mkNode(GT, x, d_nodeManager->mkConst(Rational(0))); |
54 |
4 |
TypeNode funtype = d_nodeManager->mkFunctionType(integerType, booleanType); |
55 |
4 |
Node lambda = d_nodeManager->mkVar("lambda", funtype); |
56 |
4 |
std::vector<Node> formals; |
57 |
2 |
formals.push_back(x); |
58 |
2 |
d_smt->defineFunction(lambda, formals, xPos); |
59 |
|
|
60 |
2 |
ASSERT_FALSE(realType.isComparableTo(booleanType)); |
61 |
2 |
ASSERT_TRUE(realType.isComparableTo(integerType)); |
62 |
2 |
ASSERT_TRUE(realType.isComparableTo(realType)); |
63 |
2 |
ASSERT_FALSE(realType.isComparableTo(arrayType)); |
64 |
2 |
ASSERT_FALSE(realType.isComparableTo(bvType)); |
65 |
|
|
66 |
2 |
ASSERT_FALSE(booleanType.isComparableTo(integerType)); |
67 |
2 |
ASSERT_FALSE(booleanType.isComparableTo(realType)); |
68 |
2 |
ASSERT_TRUE(booleanType.isComparableTo(booleanType)); |
69 |
2 |
ASSERT_FALSE(booleanType.isComparableTo(arrayType)); |
70 |
2 |
ASSERT_FALSE(booleanType.isComparableTo(bvType)); |
71 |
|
|
72 |
2 |
ASSERT_TRUE(integerType.isComparableTo(realType)); |
73 |
2 |
ASSERT_TRUE(integerType.isComparableTo(integerType)); |
74 |
2 |
ASSERT_FALSE(integerType.isComparableTo(booleanType)); |
75 |
2 |
ASSERT_FALSE(integerType.isComparableTo(arrayType)); |
76 |
2 |
ASSERT_FALSE(integerType.isComparableTo(bvType)); |
77 |
|
|
78 |
2 |
ASSERT_FALSE(arrayType.isComparableTo(booleanType)); |
79 |
2 |
ASSERT_FALSE(arrayType.isComparableTo(integerType)); |
80 |
2 |
ASSERT_FALSE(arrayType.isComparableTo(realType)); |
81 |
2 |
ASSERT_TRUE(arrayType.isComparableTo(arrayType)); |
82 |
2 |
ASSERT_FALSE(arrayType.isComparableTo(bvType)); |
83 |
|
|
84 |
2 |
ASSERT_FALSE(bvType.isComparableTo(booleanType)); |
85 |
2 |
ASSERT_FALSE(bvType.isComparableTo(integerType)); |
86 |
2 |
ASSERT_FALSE(bvType.isComparableTo(realType)); |
87 |
2 |
ASSERT_FALSE(bvType.isComparableTo(arrayType)); |
88 |
2 |
ASSERT_TRUE(bvType.isComparableTo(bvType)); |
89 |
|
|
90 |
2 |
ASSERT_TRUE(realType.getBaseType() == realType); |
91 |
2 |
ASSERT_TRUE(integerType.getBaseType() == realType); |
92 |
2 |
ASSERT_TRUE(booleanType.getBaseType() == booleanType); |
93 |
2 |
ASSERT_TRUE(arrayType.getBaseType() == arrayType); |
94 |
2 |
ASSERT_TRUE(bvType.getBaseType() == bvType); |
95 |
|
} |
96 |
|
} // namespace test |
97 |
14812 |
} // namespace cvc5 |