GCC Code Coverage Report
Directory: . Exec Total Coverage
File: test/unit/util/datatype_black.cpp Lines: 353 353 100.0 %
Date: 2021-05-22 Branches: 1100 3106 35.4 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Aina Niemetz, Andrew Reynolds, Morgan Deters
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
 * Black box testing of cvc5::DType.
14
 */
15
16
#include <sstream>
17
18
#include "expr/dtype.h"
19
#include "expr/dtype_cons.h"
20
#include "expr/type_node.h"
21
#include "test_smt.h"
22
23
namespace cvc5 {
24
namespace test {
25
26
44
class TestUtilBlackDatatype : public TestSmt
27
{
28
 public:
29
22
  void SetUp() override
30
  {
31
22
    TestSmt::SetUp();
32
22
    Debug.on("datatypes");
33
22
    Debug.on("groundterms");
34
22
  }
35
};
36
37
20
TEST_F(TestUtilBlackDatatype, enumeration)
38
{
39
4
  DType colors("colors");
40
41
  std::shared_ptr<DTypeConstructor> yellow =
42
4
      std::make_shared<DTypeConstructor>("yellow");
43
  std::shared_ptr<DTypeConstructor> blue =
44
4
      std::make_shared<DTypeConstructor>("blue");
45
  std::shared_ptr<DTypeConstructor> green =
46
4
      std::make_shared<DTypeConstructor>("green");
47
  std::shared_ptr<DTypeConstructor> red =
48
4
      std::make_shared<DTypeConstructor>("red");
49
50
2
  colors.addConstructor(yellow);
51
2
  colors.addConstructor(blue);
52
2
  colors.addConstructor(green);
53
2
  colors.addConstructor(red);
54
55
2
  Debug("datatypes") << colors << std::endl;
56
4
  TypeNode colorsType = d_nodeManager->mkDatatypeType(colors);
57
2
  Debug("datatypes") << colorsType << std::endl;
58
59
4
  Node ctor = colorsType.getDType()[1].getConstructor();
60
4
  Node apply = d_nodeManager->mkNode(kind::APPLY_CONSTRUCTOR, ctor);
61
2
  Debug("datatypes") << apply << std::endl;
62
63
2
  ASSERT_FALSE(colorsType.getDType().isParametric());
64
2
  ASSERT_TRUE(colorsType.getDType().isFinite());
65
2
  ASSERT_EQ(colorsType.getDType().getCardinality().compare(4),
66
2
            Cardinality::EQUAL);
67
2
  ASSERT_EQ(ctor.getType().getCardinality().compare(1), Cardinality::EQUAL);
68
2
  ASSERT_TRUE(colorsType.getDType().isWellFounded());
69
4
  Debug("groundterms") << "ground term of " << colorsType.getDType().getName()
70
2
                       << std::endl
71
2
                       << "  is " << colorsType.mkGroundTerm() << std::endl;
72
2
  ASSERT_EQ(colorsType.mkGroundTerm().getType(), colorsType);
73
}
74
75
20
TEST_F(TestUtilBlackDatatype, nat)
76
{
77
4
  DType nat("nat");
78
79
  std::shared_ptr<DTypeConstructor> succ =
80
4
      std::make_shared<DTypeConstructor>("succ");
81
2
  succ->addArgSelf("pred");
82
2
  nat.addConstructor(succ);
83
84
  std::shared_ptr<DTypeConstructor> zero =
85
4
      std::make_shared<DTypeConstructor>("zero");
86
2
  nat.addConstructor(zero);
87
88
2
  Debug("datatypes") << nat << std::endl;
89
4
  TypeNode natType = d_nodeManager->mkDatatypeType(nat);
90
2
  Debug("datatypes") << natType << std::endl;
91
92
4
  Node ctor = natType.getDType()[1].getConstructor();
93
4
  Node apply = d_nodeManager->mkNode(kind::APPLY_CONSTRUCTOR, ctor);
94
2
  Debug("datatypes") << apply << std::endl;
95
96
2
  ASSERT_FALSE(natType.getDType().isParametric());
97
2
  ASSERT_FALSE(natType.getDType().isFinite());
98
2
  ASSERT_TRUE(natType.getDType().getCardinality().compare(Cardinality::INTEGERS)
99
2
              == Cardinality::EQUAL);
100
2
  ASSERT_TRUE(natType.getDType().isWellFounded());
101
4
  Debug("groundterms") << "ground term of " << natType.getDType().getName()
102
2
                       << std::endl
103
2
                       << "  is " << natType.mkGroundTerm() << std::endl;
104
2
  ASSERT_TRUE(natType.mkGroundTerm().getType() == natType);
105
}
106
107
20
TEST_F(TestUtilBlackDatatype, tree)
108
{
109
4
  DType tree("tree");
110
4
  TypeNode integerType = d_nodeManager->integerType();
111
112
  std::shared_ptr<DTypeConstructor> node =
113
4
      std::make_shared<DTypeConstructor>("node");
114
2
  node->addArgSelf("left");
115
2
  node->addArgSelf("right");
116
2
  tree.addConstructor(node);
117
118
  std::shared_ptr<DTypeConstructor> leaf =
119
4
      std::make_shared<DTypeConstructor>("leaf");
120
2
  leaf->addArg("leaf", integerType);
121
2
  tree.addConstructor(leaf);
122
123
2
  Debug("datatypes") << tree << std::endl;
124
4
  TypeNode treeType = d_nodeManager->mkDatatypeType(tree);
125
2
  Debug("datatypes") << treeType << std::endl;
126
127
2
  ASSERT_FALSE(treeType.getDType().isParametric());
128
2
  ASSERT_FALSE(treeType.getDType().isFinite());
129
2
  ASSERT_TRUE(
130
      treeType.getDType().getCardinality().compare(Cardinality::INTEGERS)
131
2
      == Cardinality::EQUAL);
132
2
  ASSERT_TRUE(treeType.getDType().isWellFounded());
133
4
  Debug("groundterms") << "ground term of " << treeType.getDType().getName()
134
2
                       << std::endl
135
2
                       << "  is " << treeType.mkGroundTerm() << std::endl;
136
2
  ASSERT_TRUE(treeType.mkGroundTerm().getType() == treeType);
137
}
138
139
20
TEST_F(TestUtilBlackDatatype, list_int)
140
{
141
4
  DType list("list");
142
4
  TypeNode integerType = d_nodeManager->integerType();
143
144
  std::shared_ptr<DTypeConstructor> cons =
145
4
      std::make_shared<DTypeConstructor>("cons");
146
2
  cons->addArg("car", integerType);
147
2
  cons->addArgSelf("cdr");
148
2
  list.addConstructor(cons);
149
150
  std::shared_ptr<DTypeConstructor> nil =
151
4
      std::make_shared<DTypeConstructor>("nil");
152
2
  list.addConstructor(nil);
153
154
2
  Debug("datatypes") << list << std::endl;
155
4
  TypeNode listType = d_nodeManager->mkDatatypeType(list);
156
2
  Debug("datatypes") << listType << std::endl;
157
158
2
  ASSERT_FALSE(listType.getDType().isParametric());
159
2
  ASSERT_FALSE(listType.getDType().isFinite());
160
2
  ASSERT_TRUE(
161
      listType.getDType().getCardinality().compare(Cardinality::INTEGERS)
162
2
      == Cardinality::EQUAL);
163
2
  ASSERT_TRUE(listType.getDType().isWellFounded());
164
4
  Debug("groundterms") << "ground term of " << listType.getDType().getName()
165
2
                       << std::endl
166
2
                       << "  is " << listType.mkGroundTerm() << std::endl;
167
2
  ASSERT_TRUE(listType.mkGroundTerm().getType() == listType);
168
}
169
170
20
TEST_F(TestUtilBlackDatatype, list_real)
171
{
172
4
  DType list("list");
173
4
  TypeNode realType = d_nodeManager->realType();
174
175
  std::shared_ptr<DTypeConstructor> cons =
176
4
      std::make_shared<DTypeConstructor>("cons");
177
2
  cons->addArg("car", realType);
178
2
  cons->addArgSelf("cdr");
179
2
  list.addConstructor(cons);
180
181
  std::shared_ptr<DTypeConstructor> nil =
182
4
      std::make_shared<DTypeConstructor>("nil");
183
2
  list.addConstructor(nil);
184
185
2
  Debug("datatypes") << list << std::endl;
186
4
  TypeNode listType = d_nodeManager->mkDatatypeType(list);
187
2
  Debug("datatypes") << listType << std::endl;
188
189
2
  ASSERT_FALSE(listType.getDType().isParametric());
190
2
  ASSERT_FALSE(listType.getDType().isFinite());
191
2
  ASSERT_TRUE(listType.getDType().getCardinality().compare(Cardinality::REALS)
192
2
              == Cardinality::EQUAL);
193
2
  ASSERT_TRUE(listType.getDType().isWellFounded());
194
4
  Debug("groundterms") << "ground term of " << listType.getDType().getName()
195
2
                       << std::endl
196
2
                       << "  is " << listType.mkGroundTerm() << std::endl;
197
2
  ASSERT_TRUE(listType.mkGroundTerm().getType() == listType);
198
}
199
200
20
TEST_F(TestUtilBlackDatatype, list_boolean)
201
{
202
4
  DType list("list");
203
4
  TypeNode booleanType = d_nodeManager->booleanType();
204
205
  std::shared_ptr<DTypeConstructor> cons =
206
4
      std::make_shared<DTypeConstructor>("cons");
207
2
  cons->addArg("car", booleanType);
208
2
  cons->addArgSelf("cdr");
209
2
  list.addConstructor(cons);
210
211
  std::shared_ptr<DTypeConstructor> nil =
212
4
      std::make_shared<DTypeConstructor>("nil");
213
2
  list.addConstructor(nil);
214
215
2
  Debug("datatypes") << list << std::endl;
216
4
  TypeNode listType = d_nodeManager->mkDatatypeType(list);
217
2
  Debug("datatypes") << listType << std::endl;
218
219
2
  ASSERT_FALSE(listType.getDType().isFinite());
220
2
  ASSERT_TRUE(
221
      listType.getDType().getCardinality().compare(Cardinality::INTEGERS)
222
2
      == Cardinality::EQUAL);
223
2
  ASSERT_TRUE(listType.getDType().isWellFounded());
224
4
  Debug("groundterms") << "ground term of " << listType.getDType().getName()
225
2
                       << std::endl
226
2
                       << "  is " << listType.mkGroundTerm() << std::endl;
227
2
  ASSERT_TRUE(listType.mkGroundTerm().getType() == listType);
228
}
229
230
20
TEST_F(TestUtilBlackDatatype, listIntUpdate)
231
{
232
4
  DType list("list");
233
4
  TypeNode integerType = d_nodeManager->integerType();
234
235
  std::shared_ptr<DTypeConstructor> cons =
236
4
      std::make_shared<DTypeConstructor>("cons");
237
2
  cons->addArg("car", integerType);
238
2
  cons->addArgSelf("cdr");
239
2
  list.addConstructor(cons);
240
241
  std::shared_ptr<DTypeConstructor> nil =
242
4
      std::make_shared<DTypeConstructor>("nil");
243
2
  list.addConstructor(nil);
244
245
4
  TypeNode listType = d_nodeManager->mkDatatypeType(list);
246
2
  const DType& ldt = listType.getDType();
247
4
  Node updater = ldt[0][0].getUpdater();
248
4
  Node gt = listType.mkGroundTerm();
249
4
  Node zero = d_nodeManager->mkConst(Rational(0));
250
4
  Node truen = d_nodeManager->mkConst(true);
251
  // construct an update term
252
4
  Node uterm = d_nodeManager->mkNode(kind::APPLY_UPDATER, updater, gt, zero);
253
  // construct a non well-formed update term
254
2
  ASSERT_THROW(d_nodeManager->mkNode(kind::APPLY_UPDATER, updater, gt, truen)
255
                   .getType(true),
256
2
               TypeCheckingExceptionPrivate);
257
}
258
259
20
TEST_F(TestUtilBlackDatatype, mutual_list_trees1)
260
{
261
  /* Create two mutual datatypes corresponding to this definition
262
   * block:
263
   *
264
   *   DATATYPE
265
   *     tree = node(left: tree, right: tree) | leaf(list),
266
   *     list = cons(car: tree, cdr: list) | nil
267
   *   END;
268
   */
269
4
  std::set<TypeNode> unresolvedTypes;
270
  TypeNode unresList =
271
4
      d_nodeManager->mkSort("list", NodeManager::SORT_FLAG_PLACEHOLDER);
272
2
  unresolvedTypes.insert(unresList);
273
  TypeNode unresTree =
274
4
      d_nodeManager->mkSort("tree", NodeManager::SORT_FLAG_PLACEHOLDER);
275
2
  unresolvedTypes.insert(unresTree);
276
277
4
  DType tree("tree");
278
  std::shared_ptr<DTypeConstructor> node =
279
4
      std::make_shared<DTypeConstructor>("node");
280
2
  node->addArgSelf("left");
281
2
  node->addArgSelf("right");
282
2
  tree.addConstructor(node);
283
284
  std::shared_ptr<DTypeConstructor> leaf =
285
4
      std::make_shared<DTypeConstructor>("leaf");
286
2
  leaf->addArg("leaf", unresList);
287
2
  tree.addConstructor(leaf);
288
289
2
  Debug("datatypes") << tree << std::endl;
290
291
4
  DType list("list");
292
  std::shared_ptr<DTypeConstructor> cons =
293
4
      std::make_shared<DTypeConstructor>("cons");
294
2
  cons->addArg("car", unresTree);
295
2
  cons->addArgSelf("cdr");
296
2
  list.addConstructor(cons);
297
298
  std::shared_ptr<DTypeConstructor> nil =
299
4
      std::make_shared<DTypeConstructor>("nil");
300
2
  list.addConstructor(nil);
301
302
2
  Debug("datatypes") << list << std::endl;
303
304
2
  ASSERT_FALSE(tree.isResolved());
305
2
  ASSERT_FALSE(list.isResolved());
306
307
4
  std::vector<DType> dts;
308
2
  dts.push_back(tree);
309
2
  dts.push_back(list);
310
  std::vector<TypeNode> dtts =
311
4
      d_nodeManager->mkMutualDatatypeTypes(dts, unresolvedTypes);
312
313
2
  ASSERT_TRUE(dtts[0].getDType().isResolved());
314
2
  ASSERT_TRUE(dtts[1].getDType().isResolved());
315
316
2
  ASSERT_FALSE(dtts[0].getDType().isFinite());
317
2
  ASSERT_TRUE(dtts[0].getDType().getCardinality().compare(Cardinality::INTEGERS)
318
2
              == Cardinality::EQUAL);
319
2
  ASSERT_TRUE(dtts[0].getDType().isWellFounded());
320
4
  Debug("groundterms") << "ground term of " << dtts[0].getDType().getName()
321
2
                       << std::endl
322
2
                       << "  is " << dtts[0].mkGroundTerm() << std::endl;
323
2
  ASSERT_TRUE(dtts[0].mkGroundTerm().getType() == dtts[0]);
324
325
2
  ASSERT_FALSE(dtts[1].getDType().isFinite());
326
2
  ASSERT_TRUE(dtts[1].getDType().getCardinality().compare(Cardinality::INTEGERS)
327
2
              == Cardinality::EQUAL);
328
2
  ASSERT_TRUE(dtts[1].getDType().isWellFounded());
329
4
  Debug("groundterms") << "ground term of " << dtts[1].getDType().getName()
330
2
                       << std::endl
331
2
                       << "  is " << dtts[1].mkGroundTerm() << std::endl;
332
2
  ASSERT_TRUE(dtts[1].mkGroundTerm().getType() == dtts[1]);
333
}
334
335
20
TEST_F(TestUtilBlackDatatype, mutual_list_trees2)
336
{
337
4
  std::set<TypeNode> unresolvedTypes;
338
  TypeNode unresList =
339
4
      d_nodeManager->mkSort("list", NodeManager::SORT_FLAG_PLACEHOLDER);
340
2
  unresolvedTypes.insert(unresList);
341
  TypeNode unresTree =
342
4
      d_nodeManager->mkSort("tree", NodeManager::SORT_FLAG_PLACEHOLDER);
343
2
  unresolvedTypes.insert(unresTree);
344
345
4
  DType tree("tree");
346
  std::shared_ptr<DTypeConstructor> node =
347
4
      std::make_shared<DTypeConstructor>("node");
348
2
  node->addArgSelf("left");
349
2
  node->addArgSelf("right");
350
2
  tree.addConstructor(node);
351
352
  std::shared_ptr<DTypeConstructor> leaf =
353
4
      std::make_shared<DTypeConstructor>("leaf");
354
2
  leaf->addArg("leaf", unresList);
355
2
  tree.addConstructor(leaf);
356
357
4
  DType list("list");
358
  std::shared_ptr<DTypeConstructor> cons =
359
4
      std::make_shared<DTypeConstructor>("cons");
360
2
  cons->addArg("car", unresTree);
361
2
  cons->addArgSelf("cdr");
362
2
  list.addConstructor(cons);
363
364
  std::shared_ptr<DTypeConstructor> nil =
365
4
      std::make_shared<DTypeConstructor>("nil");
366
2
  list.addConstructor(nil);
367
368
  // add another constructor to list datatype resulting in an
369
  // "otherNil-list"
370
  std::shared_ptr<DTypeConstructor> otherNil =
371
4
      std::make_shared<DTypeConstructor>("otherNil");
372
2
  list.addConstructor(otherNil);
373
374
4
  std::vector<DType> dts;
375
2
  dts.push_back(tree);
376
2
  dts.push_back(list);
377
  // remake the types
378
  std::vector<TypeNode> dtts2 =
379
4
      d_nodeManager->mkMutualDatatypeTypes(dts, unresolvedTypes);
380
381
2
  ASSERT_FALSE(dtts2[0].getDType().isFinite());
382
2
  ASSERT_TRUE(
383
      dtts2[0].getDType().getCardinality().compare(Cardinality::INTEGERS)
384
2
      == Cardinality::EQUAL);
385
2
  ASSERT_TRUE(dtts2[0].getDType().isWellFounded());
386
4
  Debug("groundterms") << "ground term of " << dtts2[0].getDType().getName()
387
2
                       << std::endl
388
2
                       << "  is " << dtts2[0].mkGroundTerm() << std::endl;
389
2
  ASSERT_TRUE(dtts2[0].mkGroundTerm().getType() == dtts2[0]);
390
391
2
  ASSERT_FALSE(dtts2[1].getDType().isParametric());
392
2
  ASSERT_FALSE(dtts2[1].getDType().isFinite());
393
2
  ASSERT_TRUE(
394
      dtts2[1].getDType().getCardinality().compare(Cardinality::INTEGERS)
395
2
      == Cardinality::EQUAL);
396
2
  ASSERT_TRUE(dtts2[1].getDType().isWellFounded());
397
4
  Debug("groundterms") << "ground term of " << dtts2[1].getDType().getName()
398
2
                       << std::endl
399
2
                       << "  is " << dtts2[1].mkGroundTerm() << std::endl;
400
2
  ASSERT_TRUE(dtts2[1].mkGroundTerm().getType() == dtts2[1]);
401
}
402
403
20
TEST_F(TestUtilBlackDatatype, not_so_well_founded)
404
{
405
4
  DType tree("tree");
406
407
  std::shared_ptr<DTypeConstructor> node =
408
4
      std::make_shared<DTypeConstructor>("node");
409
2
  node->addArgSelf("left");
410
2
  node->addArgSelf("right");
411
2
  tree.addConstructor(node);
412
413
2
  Debug("datatypes") << tree << std::endl;
414
4
  TypeNode treeType = d_nodeManager->mkDatatypeType(tree);
415
2
  Debug("datatypes") << treeType << std::endl;
416
417
2
  ASSERT_FALSE(treeType.getDType().isParametric());
418
2
  ASSERT_FALSE(treeType.getDType().isFinite());
419
2
  ASSERT_TRUE(
420
      treeType.getDType().getCardinality().compare(Cardinality::INTEGERS)
421
2
      == Cardinality::EQUAL);
422
2
  ASSERT_FALSE(treeType.getDType().isWellFounded());
423
2
  ASSERT_TRUE(treeType.mkGroundTerm().isNull());
424
2
  ASSERT_TRUE(treeType.getDType().mkGroundTerm(treeType).isNull());
425
}
426
427
20
TEST_F(TestUtilBlackDatatype, parametric_DType)
428
{
429
4
  std::vector<TypeNode> v;
430
4
  TypeNode t1, t2;
431
2
  v.push_back(t1 = d_nodeManager->mkSort("T1"));
432
2
  v.push_back(t2 = d_nodeManager->mkSort("T2"));
433
4
  DType pair("pair", v);
434
435
  std::shared_ptr<DTypeConstructor> mkpair =
436
4
      std::make_shared<DTypeConstructor>("mk-pair");
437
2
  mkpair->addArg("first", t1);
438
2
  mkpair->addArg("second", t2);
439
2
  pair.addConstructor(mkpair);
440
4
  TypeNode pairType = d_nodeManager->mkDatatypeType(pair);
441
442
2
  ASSERT_TRUE(pairType.getDType().isParametric());
443
2
  v.clear();
444
2
  v.push_back(d_nodeManager->integerType());
445
2
  v.push_back(d_nodeManager->integerType());
446
4
  TypeNode pairIntInt = pairType.getDType().getTypeNode(v);
447
2
  v.clear();
448
2
  v.push_back(d_nodeManager->realType());
449
2
  v.push_back(d_nodeManager->realType());
450
4
  TypeNode pairRealReal = pairType.getDType().getTypeNode(v);
451
2
  v.clear();
452
2
  v.push_back(d_nodeManager->realType());
453
2
  v.push_back(d_nodeManager->integerType());
454
4
  TypeNode pairRealInt = pairType.getDType().getTypeNode(v);
455
2
  v.clear();
456
2
  v.push_back(d_nodeManager->integerType());
457
2
  v.push_back(d_nodeManager->realType());
458
4
  TypeNode pairIntReal = pairType.getDType().getTypeNode(v);
459
460
2
  ASSERT_NE(pairIntInt, pairRealReal);
461
2
  ASSERT_NE(pairIntReal, pairRealReal);
462
2
  ASSERT_NE(pairRealInt, pairRealReal);
463
2
  ASSERT_NE(pairIntInt, pairIntReal);
464
2
  ASSERT_NE(pairIntInt, pairRealInt);
465
2
  ASSERT_NE(pairIntReal, pairRealInt);
466
467
2
  ASSERT_TRUE(pairRealReal.isComparableTo(pairRealReal));
468
2
  ASSERT_FALSE(pairIntReal.isComparableTo(pairRealReal));
469
2
  ASSERT_FALSE(pairRealInt.isComparableTo(pairRealReal));
470
2
  ASSERT_FALSE(pairIntInt.isComparableTo(pairRealReal));
471
2
  ASSERT_FALSE(pairRealReal.isComparableTo(pairRealInt));
472
2
  ASSERT_FALSE(pairIntReal.isComparableTo(pairRealInt));
473
2
  ASSERT_TRUE(pairRealInt.isComparableTo(pairRealInt));
474
2
  ASSERT_FALSE(pairIntInt.isComparableTo(pairRealInt));
475
2
  ASSERT_FALSE(pairRealReal.isComparableTo(pairIntReal));
476
2
  ASSERT_TRUE(pairIntReal.isComparableTo(pairIntReal));
477
2
  ASSERT_FALSE(pairRealInt.isComparableTo(pairIntReal));
478
2
  ASSERT_FALSE(pairIntInt.isComparableTo(pairIntReal));
479
2
  ASSERT_FALSE(pairRealReal.isComparableTo(pairIntInt));
480
2
  ASSERT_FALSE(pairIntReal.isComparableTo(pairIntInt));
481
2
  ASSERT_FALSE(pairRealInt.isComparableTo(pairIntInt));
482
2
  ASSERT_TRUE(pairIntInt.isComparableTo(pairIntInt));
483
484
2
  ASSERT_TRUE(pairRealReal.isSubtypeOf(pairRealReal));
485
2
  ASSERT_FALSE(pairIntReal.isSubtypeOf(pairRealReal));
486
2
  ASSERT_FALSE(pairRealInt.isSubtypeOf(pairRealReal));
487
2
  ASSERT_FALSE(pairIntInt.isSubtypeOf(pairRealReal));
488
2
  ASSERT_FALSE(pairRealReal.isSubtypeOf(pairRealInt));
489
2
  ASSERT_FALSE(pairIntReal.isSubtypeOf(pairRealInt));
490
2
  ASSERT_TRUE(pairRealInt.isSubtypeOf(pairRealInt));
491
2
  ASSERT_FALSE(pairIntInt.isSubtypeOf(pairRealInt));
492
2
  ASSERT_FALSE(pairRealReal.isSubtypeOf(pairIntReal));
493
2
  ASSERT_TRUE(pairIntReal.isSubtypeOf(pairIntReal));
494
2
  ASSERT_FALSE(pairRealInt.isSubtypeOf(pairIntReal));
495
2
  ASSERT_FALSE(pairIntInt.isSubtypeOf(pairIntReal));
496
2
  ASSERT_FALSE(pairRealReal.isSubtypeOf(pairIntInt));
497
2
  ASSERT_FALSE(pairIntReal.isSubtypeOf(pairIntInt));
498
2
  ASSERT_FALSE(pairRealInt.isSubtypeOf(pairIntInt));
499
2
  ASSERT_TRUE(pairIntInt.isSubtypeOf(pairIntInt));
500
501
2
  ASSERT_EQ(TypeNode::leastCommonTypeNode(pairRealReal, pairRealReal),
502
2
            pairRealReal);
503
2
  ASSERT_TRUE(
504
2
      TypeNode::leastCommonTypeNode(pairIntReal, pairRealReal).isNull());
505
2
  ASSERT_TRUE(
506
2
      TypeNode::leastCommonTypeNode(pairRealInt, pairRealReal).isNull());
507
2
  ASSERT_TRUE(TypeNode::leastCommonTypeNode(pairIntInt, pairRealReal).isNull());
508
2
  ASSERT_TRUE(
509
2
      TypeNode::leastCommonTypeNode(pairRealReal, pairRealInt).isNull());
510
2
  ASSERT_TRUE(TypeNode::leastCommonTypeNode(pairIntReal, pairRealInt).isNull());
511
2
  ASSERT_EQ(TypeNode::leastCommonTypeNode(pairRealInt, pairRealInt),
512
2
            pairRealInt);
513
2
  ASSERT_TRUE(TypeNode::leastCommonTypeNode(pairIntInt, pairRealInt).isNull());
514
2
  ASSERT_TRUE(
515
2
      TypeNode::leastCommonTypeNode(pairRealReal, pairIntReal).isNull());
516
2
  ASSERT_EQ(TypeNode::leastCommonTypeNode(pairIntReal, pairIntReal),
517
2
            pairIntReal);
518
2
  ASSERT_TRUE(TypeNode::leastCommonTypeNode(pairRealInt, pairIntReal).isNull());
519
2
  ASSERT_TRUE(TypeNode::leastCommonTypeNode(pairIntInt, pairIntReal).isNull());
520
2
  ASSERT_TRUE(TypeNode::leastCommonTypeNode(pairRealReal, pairIntInt).isNull());
521
2
  ASSERT_TRUE(TypeNode::leastCommonTypeNode(pairIntReal, pairIntInt).isNull());
522
2
  ASSERT_TRUE(TypeNode::leastCommonTypeNode(pairRealInt, pairIntInt).isNull());
523
2
  ASSERT_EQ(TypeNode::leastCommonTypeNode(pairIntInt, pairIntInt), pairIntInt);
524
}
525
}  // namespace test
526
166834
}  // namespace cvc5