Skip to content

Commit f8e79be

Browse files
mezpuszquickbeam123
authored andcommitted
Add minimal test with some syntax sugar
1 parent 7fcbfcf commit f8e79be

3 files changed

Lines changed: 52 additions & 1 deletion

File tree

Test/SyntaxSugar.hpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "Kernel/Inference.hpp"
2828
#include "Kernel/Clause.hpp"
2929
#include "Kernel/HOL/HOL.hpp"
30+
#include "Kernel/FormulaUnit.hpp"
3031
#include "Kernel/SortHelper.hpp"
3132
#include "Kernel/NumTraits.hpp"
3233
#include "Kernel/TypedTermList.hpp"
@@ -713,9 +714,20 @@ inline Clause* clause(Stack<Lit> ls, Inference inf) {
713714
inline Clause* clause(Stack<Lit> ls)
714715
{ return clause(ls, Inference(Kernel::NonspecificInference0(UnitInputType::ASSUMPTION, InferenceRule::INPUT))); }
715716

716-
inline Clause* clause(std::initializer_list<Lit> ls)
717+
inline Clause* clause(std::initializer_list<Lit> ls)
717718
{ return clause(Stack<Lit>(ls)); }
718719

720+
inline Stack<Clause*> clauses(std::initializer_list<std::initializer_list<Lit>> cls) {
721+
auto out = Stack<Clause*>();
722+
for (auto cl : cls) {
723+
out.push(clause(cl));
724+
}
725+
return out;
726+
}
727+
728+
inline FormulaUnit* formula(Lit lit)
729+
{ return new FormulaUnit(new AtomicFormula(lit), Inference(Kernel::NonspecificInference0(UnitInputType::ASSUMPTION, InferenceRule::INPUT))); }
730+
719731
inline void createTermAlgebra(SortSugar sort, std::initializer_list<FuncSugar> fs) {
720732
// avoid redeclaration
721733
if (env.signature->isTermAlgebraSort(sort.sugaredExpr())) {

UnitTests/tProperty.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* This file is part of the source code of the software program
3+
* Vampire. It is protected by applicable
4+
* copyright laws.
5+
*
6+
* This source code is distributed under the licence found here
7+
* https://vprover.github.io/license.html
8+
* and in the source directory
9+
*/
10+
11+
#include "Test/UnitTesting.hpp"
12+
#include "Test/SyntaxSugar.hpp"
13+
14+
#include "Shell/Property.hpp"
15+
16+
using namespace Shell;
17+
18+
/**
19+
* NECESSARY: We need to tell the tester which syntax sugar to import for creating terms & clauses.
20+
* See Test/SyntaxSugar.hpp for which kinds of syntax sugar are available
21+
*/
22+
#define MY_SYNTAX_SUGAR \
23+
DECL_DEFAULT_VARS \
24+
DECL_SORT(s) \
25+
DECL_FUNC(f, {s}, s) \
26+
DECL_CONST(c, s) \
27+
DECL_PRED(p, {s}) \
28+
29+
TEST_FUN(test01) {
30+
__ALLOW_UNUSED(MY_SYNTAX_SUGAR);
31+
32+
auto units = UnitList::empty();
33+
UnitList::push(clause({ f(c) == c, ~p(x) }), units);
34+
UnitList::push(formula(f(c) != c), units);
35+
36+
auto prop = Property::scan(units);
37+
ASS_EQ(prop->category(), Property::NEQ);
38+
}

cmake/sources.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ set(UNIT_TESTS
8282
UnitTests/tList.cpp
8383
UnitTests/tOption.cpp
8484
UnitTests/tOptionConstraints.cpp
85+
UnitTests/tProperty.cpp
8586
UnitTests/tQKbo.cpp
8687
UnitTests/tQuotientE.cpp
8788
UnitTests/tRebalance.cpp

0 commit comments

Comments
 (0)