cvc4-1.4
theory_test_utils.h
Go to the documentation of this file.
1/********************* */
17#include "cvc4_public.h"
18
19#ifndef __CVC4__THEORY__THEORY_TEST_UTILS_H
20#define __CVC4__THEORY__THEORY_TEST_UTILS_H
21
22#include "util/cvc4_assert.h"
23#include "expr/node.h"
24#include "theory/output_channel.h"
25#include "theory/interrupted.h"
26
27#include <vector>
28#include <utility>
29#include <iostream>
30
31namespace CVC4 {
32
33namespace theory {
34
47
48}/* CVC4::theory namespace */
49
50inline std::ostream& operator<<(std::ostream& out, theory::OutputChannelCallType type) {
51 switch(type) {
52 case theory::CONFLICT: return out << "CONFLICT";
53 case theory::PROPAGATE: return out << "PROPAGATE";
54 case theory::PROPAGATE_AS_DECISION: return out << "PROPAGATE_AS_DECISION";
55 case theory::AUG_LEMMA: return out << "AUG_LEMMA";
56 case theory::LEMMA: return out << "LEMMA";
57 case theory::EXPLANATION: return out << "EXPLANATION";
58 default: return out << "UNDEFINED-OutputChannelCallType!" << int(type);
59 }
60}
61
62namespace theory {
63
64class TestOutputChannel : public theory::OutputChannel {
65public:
66 std::vector< std::pair<enum OutputChannelCallType, Node> > d_callHistory;
67
69
71
72 void safePoint() throw(Interrupted, AssertionException) {}
73
75 throw(AssertionException) {
76 push(CONFLICT, n);
77 }
78
80 throw(AssertionException) {
81 push(PROPAGATE, n);
82 return true;
83 }
84
86 throw(AssertionException) {
87 push(PROPAGATE_AS_DECISION, n);
88 }
89
90 LemmaStatus lemma(TNode n, bool removable, bool preprocess) throw(AssertionException) {
91 push(LEMMA, n);
92 return LemmaStatus(Node::null(), 0);
93 }
94
95 void requirePhase(TNode, bool) throw(Interrupted, AssertionException) {
96 }
97
98 bool flipDecision() throw(Interrupted, AssertionException) {
99 return true;
100 }
101
102 void setIncomplete() throw(AssertionException) {}
103
104 void handleUserAttribute( const char* attr, theory::Theory* t ){}
105
106 void clear() {
107 d_callHistory.clear();
108 }
109
110 LemmaStatus splitLemma(TNode n, bool removable = false) throw(TypeCheckingExceptionPrivate, AssertionException){
111 push(LEMMA, n);
112 return LemmaStatus(Node::null(), 0);
113 }
114
116 Node tmp = (d_callHistory[i]).second;
117 return tmp;
118 }
119
121 return (d_callHistory[i]).first;
122 }
123
124 unsigned getNumCalls() {
125 return d_callHistory.size();
126 }
127
128 void printIth(std::ostream& os, int i){
129 os << "[TestOutputChannel " << i;
130 os << " " << getIthCallType(i);
131 os << " " << getIthNode(i) << "]";
132 }
133
134private:
135
136 void push(OutputChannelCallType call, TNode n) {
137 d_callHistory.push_back(std::make_pair(call, n));
138 }
139
140};/* class TestOutputChannel */
141
142}/* CVC4::theory namespace */
143}/* CVC4 namespace */
144
145#endif /* __CVC4__THEORY__THEORY_TEST_UTILS_H */
std::vector< std::pair< enum OutputChannelCallType, Node > > d_callHistory
void handleUserAttribute(const char *attr, theory::Theory *t)
OutputChannelCallType getIthCallType(int i)
LemmaStatus splitLemma(TNode n, bool removable=false)
LemmaStatus lemma(TNode n, bool removable, bool preprocess)
void printIth(std::ostream &os, int i)
Macros that should be defined everywhere during the building of the libraries and driver binary,...
OutputChannelCallType
Very basic OutputChannel for testing simple Theory Behaviour.
Definition expr.h:106
std::ostream & operator<<(std::ostream &out, const TypeCheckingException &e)