diff options
author | Morgan Deters <mdeters@gmail.com> | 2010-04-04 19:55:47 +0000 |
---|---|---|
committer | Morgan Deters <mdeters@gmail.com> | 2010-04-04 19:55:47 +0000 |
commit | 42c58baf0a2a96c1f3bd797d64834d02adfb9a59 (patch) | |
tree | a65529c9cd8399c8e78a4501eace01c150336942 /test/unit/context/context_white.h | |
parent | 73be7b6b5a9c98cc5a32dcfb3050b9656bf10243 (diff) |
* Node::isAtomic() now looks at an "atomic" attribute of arguments
instead of assuming it's atomic based on kind. Atomicity is
determined at node building time. Fixes bug #81. If this is
determined to make node building too slow, we can allocate another
attribute "AtomicHasBeenComputed" to lazily compute atomicity.
* TheoryImpl<> has gone away. Theory implementations now derive from
Theory directly and share a single RegisteredAttr attribute for term
registration (which shouldn't overlap: every term is "owned" by
exactly one Theory). Fixes bug #79.
* Additional atomicity tests in ExprBlack unit test.
* More appropriate whitebox testing for attribute ID assignment
(AttributeWhite unit test).
* Better (and more correct) assertion checking in NodeBuilderBlack.
* run-regression script now checks exit status against what's provided
in "% EXIT: " gesture in .cvc input files, and stderr against
"% EXPECT-ERROR: ". These can be used to support intended failures.
Fixes bug #84. Also add "% EXIT: " gestures to all .cvc regressions
in repository.
* Solved some "control reaches end of non-void function" warnings in
src/parser/bounded_token_buffer.cpp by replacing
"AlwaysAssert(false)" with "Unreachable()" (which is known
statically to never return normally).
* Regression tests now use the cvc4 binary under
builds/$(CURRENT_BUILD)/src/main instead of the one in bin/ which
may not be properly installed yet at that point of the build.
(Partially fixes bug #46.)
* -fvisibility=hidden is now included by configure.ac instead of each
Makefile.am, which will make it easier to support platforms
(e.g. cygwin) that do things a different way.
* TheoryUF code formatting. (re: my code review bug #64)
* CDMap<> is leaking memory again, pending a fix for bug #85 in the
context subsystem. (To avoid serious errors, can't free context
objects.)
* add ContextWhite unit test for bug #85 (though it's currently
"defanged," awaiting the bugfix)
* Minor documentation, other cleanup.
Diffstat (limited to 'test/unit/context/context_white.h')
-rw-r--r-- | test/unit/context/context_white.h | 186 |
1 files changed, 186 insertions, 0 deletions
diff --git a/test/unit/context/context_white.h b/test/unit/context/context_white.h new file mode 100644 index 000000000..3e0928baf --- /dev/null +++ b/test/unit/context/context_white.h @@ -0,0 +1,186 @@ +/********************* */ +/** context_white.h + ** Original author: mdeters + ** Major contributors: none + ** Minor contributors (to current version): none + ** This file is part of the CVC4 prototype. + ** Copyright (c) 2009, 2010 The Analysis of Computer Systems Group (ACSys) + ** Courant Institute of Mathematical Sciences + ** New York University + ** See the file COPYING in the top-level source directory for licensing + ** information. + ** + ** White box testing of CVC4::context::Context. + **/ + +#include <cxxtest/TestSuite.h> + +#include "context/context.h" +#include "context/cdo.h" +#include "util/Assert.h" + +using namespace std; +using namespace CVC4; +using namespace CVC4::context; + +class ContextWhite : public CxxTest::TestSuite { +private: + + Context* d_context; + +public: + + void setUp() { + d_context = new Context; + } + + void tearDown() { + delete d_context; + } + + void testContextSimple() { + Scope *s = d_context->getTopScope(); + + TS_ASSERT(s == d_context->getBottomScope()); + TS_ASSERT(d_context->getLevel() == 0); + TS_ASSERT(d_context->d_scopeList.size() == 1); + + TS_ASSERT(s->d_pContext == d_context); + TS_ASSERT(s->d_pCMM == d_context->d_pCMM); + TS_ASSERT(s->d_level == 0); + TS_ASSERT(s->d_pContextObjList == NULL); + + CDO<int> a(d_context); + + TS_ASSERT(s->d_pContext == d_context); + TS_ASSERT(s->d_pCMM == d_context->d_pCMM); + TS_ASSERT(s->d_level == 0); + TS_ASSERT(s->d_pContextObjList == &a); + + TS_ASSERT(a.d_pScope == s); + TS_ASSERT(a.d_pContextObjRestore == NULL); + TS_ASSERT(a.d_pContextObjNext == NULL); + TS_ASSERT(a.d_ppContextObjPrev == &s->d_pContextObjList); + + CDO<int> b(d_context); + + TS_ASSERT(s->d_pContext == d_context); + TS_ASSERT(s->d_pCMM == d_context->d_pCMM); + TS_ASSERT(s->d_level == 0); + TS_ASSERT(s->d_pContextObjList == &b); + + TS_ASSERT(a.d_pScope == s); + TS_ASSERT(a.d_pContextObjRestore == NULL); + TS_ASSERT(a.d_pContextObjNext == NULL); + TS_ASSERT(a.d_ppContextObjPrev == &b.d_pContextObjNext); + + TS_ASSERT(b.d_pScope == s); + TS_ASSERT(b.d_pContextObjRestore == NULL); + TS_ASSERT(b.d_pContextObjNext == &a); + TS_ASSERT(b.d_ppContextObjPrev == &s->d_pContextObjList); + + d_context->push(); + Scope* t = d_context->getTopScope(); + TS_ASSERT(s != t); + + TS_ASSERT(s == d_context->getBottomScope()); + TS_ASSERT(d_context->getLevel() == 1); + TS_ASSERT(d_context->d_scopeList.size() == 2); + + TS_ASSERT(s->d_pContext == d_context); + TS_ASSERT(s->d_pCMM == d_context->d_pCMM); + TS_ASSERT(s->d_level == 0); + TS_ASSERT(s->d_pContextObjList == &b); + + TS_ASSERT(t->d_pContext == d_context); + TS_ASSERT(t->d_pCMM == d_context->d_pCMM); + TS_ASSERT(t->d_level == 1); + TS_ASSERT(t->d_pContextObjList == NULL); + + TS_ASSERT(a.d_pScope == s); + TS_ASSERT(a.d_pContextObjRestore == NULL); + TS_ASSERT(a.d_pContextObjNext == NULL); + TS_ASSERT(a.d_ppContextObjPrev == &b.d_pContextObjNext); + + TS_ASSERT(b.d_pScope == s); + TS_ASSERT(b.d_pContextObjRestore == NULL); + TS_ASSERT(b.d_pContextObjNext == &a); + TS_ASSERT(b.d_ppContextObjPrev == &s->d_pContextObjList); + + a = 5; + + TS_ASSERT(t->d_pContext == d_context); + TS_ASSERT(t->d_pCMM == d_context->d_pCMM); + TS_ASSERT(t->d_level == 1); + TS_ASSERT(t->d_pContextObjList == &a); + + TS_ASSERT(a.d_pScope == t); + TS_ASSERT(a.d_pContextObjRestore != NULL); + TS_ASSERT(a.d_pContextObjNext == NULL); + TS_ASSERT(a.d_ppContextObjPrev == &t->d_pContextObjList); + + b = 3; + + TS_ASSERT(t->d_pContext == d_context); + TS_ASSERT(t->d_pCMM == d_context->d_pCMM); + TS_ASSERT(t->d_level == 1); + TS_ASSERT(t->d_pContextObjList == &b); + + TS_ASSERT(a.d_pScope == t); + TS_ASSERT(a.d_pContextObjRestore != NULL); + TS_ASSERT(a.d_pContextObjNext == NULL); + TS_ASSERT(a.d_ppContextObjPrev == &b.d_pContextObjNext); + + TS_ASSERT(b.d_pScope == t); + TS_ASSERT(b.d_pContextObjRestore != NULL); + TS_ASSERT(b.d_pContextObjNext == &a); + TS_ASSERT(b.d_ppContextObjPrev == &t->d_pContextObjList); + + d_context->push(); + Scope* u = d_context->getTopScope(); + TS_ASSERT(u != t); + TS_ASSERT(u != s); + + CDO<int> c(d_context); + c = 4; + + TS_ASSERT(c.d_pScope == u); + TS_ASSERT(c.d_pContextObjRestore != NULL); + TS_ASSERT(c.d_pContextObjNext == NULL); + TS_ASSERT(c.d_ppContextObjPrev == &u->d_pContextObjList); + + d_context->pop(); + + TS_ASSERT(t->d_pContext == d_context); + TS_ASSERT(t->d_pCMM == d_context->d_pCMM); + TS_ASSERT(t->d_level == 1); + TS_ASSERT(t->d_pContextObjList == &b); + + TS_ASSERT(a.d_pScope == t); + TS_ASSERT(a.d_pContextObjRestore != NULL); + TS_ASSERT(a.d_pContextObjNext == NULL); + TS_ASSERT(a.d_ppContextObjPrev == &b.d_pContextObjNext); + + TS_ASSERT(b.d_pScope == t); + TS_ASSERT(b.d_pContextObjRestore != NULL); + TS_ASSERT(b.d_pContextObjNext == &a); + //TS_ASSERT(b.d_ppContextObjPrev == &t->d_pContextObjList);// THIS ONE FAILS + + d_context->pop(); + + TS_ASSERT(s->d_pContext == d_context); + TS_ASSERT(s->d_pCMM == d_context->d_pCMM); + TS_ASSERT(s->d_level == 0); + //TS_ASSERT(s->d_pContextObjList == &b);// THIS ONE FAILS + + TS_ASSERT(a.d_pScope == s); + TS_ASSERT(a.d_pContextObjRestore == NULL); + TS_ASSERT(a.d_pContextObjNext == NULL); + TS_ASSERT(a.d_ppContextObjPrev == &b.d_pContextObjNext); + + TS_ASSERT(b.d_pScope == s); + TS_ASSERT(b.d_pContextObjRestore == NULL); + TS_ASSERT(b.d_pContextObjNext == &a); + TS_ASSERT(b.d_ppContextObjPrev == &s->d_pContextObjList); + } +}; |