While working on API documentation for python, I noticed that isNull is not wrapped
by the python API. It is also not tested in the cpp API tests. This PR fixes both issues,
and also updates the python api tests accordingly.
bool Datatype::isNull() const
{
CVC5_API_TRY_CATCH_BEGIN;
- CVC5_API_CHECK_NOT_NULL;
//////// all checks before this line
return isNullHelper();
////////
bint isFinite() except +
bint isWellFounded() except +
bint hasNestedRecursion() except +
+ bint isNull() except +
string toString() except +
cppclass const_iterator:
const_iterator() except +
size_t getNumSelectors() except +
DatatypeSelector getSelector(const string& name) except +
Term getSelectorTerm(const string& name) except +
+ bint isNull() except +
string toString() except +
cppclass const_iterator:
const_iterator() except +
cdef cppclass DatatypeConstructorDecl:
void addSelector(const string& name, Sort sort) except +
void addSelectorSelf(const string& name) except +
+ bint isNull() except +
string toString() except +
bint isParametric() except +
string toString() except +
string getName() except +
+ bint isNull() except +
cdef cppclass DatatypeSelector:
Term getSelectorTerm() except +
Term getUpdaterTerm() except +
Sort getRangeSort() except +
+ bint isNull() except +
string toString() except +
""":return: whether this datatype has nested recursion (see :cpp:func:`Datatype::hasNestedRecursion() <cvc5::api::Datatype::hasNestedRecursion>`)."""
return self.cd.hasNestedRecursion()
+ def isNull(self):
+ return self.cd.isNull()
+
def __str__(self):
return self.cd.toString().decode()
term.cterm = self.cdc.getSelectorTerm(name.encode())
return term
+ def isNull(self):
+ return self.cdc.isNull()
+
def __str__(self):
return self.cdc.toString().decode()
def addSelectorSelf(self, str name):
self.cddc.addSelectorSelf(name.encode())
+ def isNull(self):
+ return self.cddc.isNull()
+
def __str__(self):
return self.cddc.toString().decode()
def getName(self):
return self.cdd.getName().decode()
+ def isNull(self):
+ return self.cdd.isNull()
+
def __str__(self):
return self.cdd.toString().decode()
sort.csort = self.cds.getRangeSort()
return sort
+ def isNull(self):
+ return self.cds.isNull()
+
def __str__(self):
return self.cds.toString().decode()
import pytest
import pycvc5
from pycvc5 import kinds
-from pycvc5 import Sort, Term, DatatypeDecl
+from pycvc5 import Sort, Term
+from pycvc5 import DatatypeDecl
+from pycvc5 import Datatype
+from pycvc5 import DatatypeConstructorDecl
+from pycvc5 import DatatypeConstructor
+from pycvc5 import DatatypeSelector
@pytest.fixture
consConstr.getConstructorTerm()
nilConstr.getConstructorTerm()
+def test_is_null(solver):
+ # creating empty (null) objects.
+ dtypeSpec = DatatypeDecl(solver)
+ cons = DatatypeConstructorDecl(solver)
+ d = Datatype(solver)
+ consConstr = DatatypeConstructor(solver)
+ sel = DatatypeSelector(solver)
+
+ # verifying that the objects are considered null.
+ assert dtypeSpec.isNull()
+ assert cons.isNull()
+ assert d.isNull()
+ assert consConstr.isNull()
+ assert sel.isNull()
+
+ # changing the objects to be non-null
+ dtypeSpec = solver.mkDatatypeDecl("list");
+ cons = solver.mkDatatypeConstructorDecl("cons");
+ cons.addSelector("head", solver.getIntegerSort());
+ dtypeSpec.addConstructor(cons);
+ listSort = solver.mkDatatypeSort(dtypeSpec)
+ d = listSort.getDatatype();
+ consConstr = d[0];
+ sel = consConstr[0];
+
+ # verifying that the new objects are non-null
+ assert not dtypeSpec.isNull()
+ assert not cons.isNull()
+ assert not d.isNull()
+ assert not consConstr.isNull()
+ assert not sel.isNull()
def test_mk_datatype_sorts(solver):
# Create two mutual datatypes corresponding to this definition
ASSERT_NO_THROW(nilConstr.getConstructorTerm());
}
+TEST_F(TestApiBlackDatatype, isNull)
+{
+ // creating empty (null) objects.
+ DatatypeDecl dtypeSpec;
+ DatatypeConstructorDecl cons;
+ Datatype d;
+ DatatypeConstructor consConstr;
+ DatatypeSelector sel;
+
+ // verifying that the objects are considered null.
+ ASSERT_TRUE(dtypeSpec.isNull());
+ ASSERT_TRUE(cons.isNull());
+ ASSERT_TRUE(d.isNull());
+ ASSERT_TRUE(consConstr.isNull());
+ ASSERT_TRUE(sel.isNull());
+
+ // changing the objects to be non-null
+ dtypeSpec = d_solver.mkDatatypeDecl("list");
+ cons = d_solver.mkDatatypeConstructorDecl("cons");
+ cons.addSelector("head", d_solver.getIntegerSort());
+ dtypeSpec.addConstructor(cons);
+ Sort listSort = d_solver.mkDatatypeSort(dtypeSpec);
+ d = listSort.getDatatype();
+ consConstr = d[0];
+ sel = consConstr[0];
+
+ // verifying that the new objects are non-null
+ ASSERT_FALSE(dtypeSpec.isNull());
+ ASSERT_FALSE(cons.isNull());
+ ASSERT_FALSE(d.isNull());
+ ASSERT_FALSE(consConstr.isNull());
+ ASSERT_FALSE(sel.isNull());
+}
+
TEST_F(TestApiBlackDatatype, mkDatatypeSorts)
{
/* Create two mutual datatypes corresponding to this definition