summaryrefslogtreecommitdiff
path: root/test/api
diff options
context:
space:
mode:
authoryoni206 <yoni206@users.noreply.github.com>2021-05-17 11:00:41 -0700
committerGitHub <noreply@github.com>2021-05-17 11:00:41 -0700
commit91e41bcb666d25b19074537f3f2ee98281592616 (patch)
tree64482e9081232d76a2c810574ca6dcb8881e27f1 /test/api
parent01dd4f1aadcfc05f26f2ca00bd8afaa5c63ecb6c (diff)
Move and enhance python API grammar tests (#6538)
The existing test for python API grammar is moved to the right location, `yapf`ed, and changed according to the new style of python API tests. Additionally, minor changes are introduced in order to be an exact translation of https://github.com/cvc5/cvc5/blob/master/test/unit/api/grammar_black.cpp
Diffstat (limited to 'test/api')
-rw-r--r--test/api/python/CMakeLists.txt1
-rw-r--r--test/api/python/test_grammar.py130
2 files changed, 0 insertions, 131 deletions
diff --git a/test/api/python/CMakeLists.txt b/test/api/python/CMakeLists.txt
index 87ddbb5d6..7f05bf130 100644
--- a/test/api/python/CMakeLists.txt
+++ b/test/api/python/CMakeLists.txt
@@ -39,5 +39,4 @@ macro(cvc5_add_python_api_test name filename)
endmacro()
cvc5_add_python_api_test(pytest_datatype_api test_datatype_api.py)
-cvc5_add_python_api_test(pytest_grammar test_grammar.py)
cvc5_add_python_api_test(pytest_to_python_obj test_to_python_obj.py)
diff --git a/test/api/python/test_grammar.py b/test/api/python/test_grammar.py
deleted file mode 100644
index f83bee548..000000000
--- a/test/api/python/test_grammar.py
+++ /dev/null
@@ -1,130 +0,0 @@
-###############################################################################
-# Top contributors (to current version):
-# Yoni Zohar, Makai Mann, Mudathir Mohamed
-#
-# This file is part of the cvc5 project.
-#
-# Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
-# in the top-level source directory and their institutional affiliations.
-# All rights reserved. See the file COPYING in the top-level source
-# directory for licensing information.
-# #############################################################################
-#
-# Translated from test/unit/api/grammar_black.h
-##
-
-import pytest
-
-import pycvc5
-from pycvc5 import kinds
-
-def test_add_rule():
- solver = pycvc5.Solver()
- boolean = solver.getBooleanSort()
- integer = solver.getIntegerSort()
-
- nullTerm = pycvc5.Term(solver)
- start = solver.mkVar(boolean)
- nts = solver.mkVar(boolean)
-
- # expecting no error
- g = solver.mkSygusGrammar([], [start])
-
- g.addRule(start, solver.mkBoolean(False))
-
- # expecting errors
- with pytest.raises(Exception):
- g.addRule(nullTerm, solver.mkBoolean(false))
- with pytest.raises(Exception):
- g.addRule(start, nullTerm)
- with pytest.raises(Exception):
- g.addRule(nts, solver.mkBoolean(false))
- with pytest.raises(Exception):
- g.addRule(start, solver.mkInteger(0))
-
- # expecting no errors
- solver.synthFun("f", {}, boolean, g)
-
- # expecting an error
- with pytest.raises(Exception):
- g.addRule(start, solver.mkBoolean(false))
-
-def test_add_rules():
- solver = pycvc5.Solver()
- boolean = solver.getBooleanSort()
- integer = solver.getIntegerSort()
-
- nullTerm = pycvc5.Term(solver)
- start = solver.mkVar(boolean)
- nts = solver.mkVar(boolean)
-
- g = solver.mkSygusGrammar([], [start])
-
- g.addRules(start, {solver.mkBoolean(False)})
-
- #Expecting errors
- with pytest.raises(Exception):
- g.addRules(nullTerm, solver.mkBoolean(False))
- with pytest.raises(Exception):
- g.addRules(start, {nullTerm})
- with pytest.raises(Exception):
- g.addRules(nts, {solver.mkBoolean(False)})
- with pytest.raises(Exception):
- g.addRules(start, {solver.mkInteger(0)})
- #Expecting no errors
- solver.synthFun("f", {}, boolean, g)
-
- #Expecting an error
- with pytest.raises(Exception):
- g.addRules(start, solver.mkBoolean(False))
-
-def testAddAnyConstant():
- solver = pycvc5.Solver()
- boolean = solver.getBooleanSort()
-
- nullTerm = pycvc5.Term(solver)
- start = solver.mkVar(boolean)
- nts = solver.mkVar(boolean)
-
- g = solver.mkSygusGrammar({}, {start})
-
- g.addAnyConstant(start)
- g.addAnyConstant(start)
-
- with pytest.raises(Exception):
- g.addAnyConstant(nullTerm)
- with pytest.raises(Exception):
- g.addAnyConstant(nts)
-
- solver.synthFun("f", {}, boolean, g)
-
- with pytest.raises(Exception):
- g.addAnyConstant(start)
-
-
-def testAddAnyVariable():
- solver = pycvc5.Solver()
- boolean = solver.getBooleanSort()
-
- nullTerm = pycvc5.Term(solver)
- x = solver.mkVar(boolean)
- start = solver.mkVar(boolean)
- nts = solver.mkVar(boolean)
-
- g1 = solver.mkSygusGrammar({x}, {start})
- g2 = solver.mkSygusGrammar({}, {start})
-
- g1.addAnyVariable(start)
- g1.addAnyVariable(start)
- g2.addAnyVariable(start)
-
- with pytest.raises(Exception):
- g1.addAnyVariable(nullTerm)
- with pytest.raises(Exception):
- g1.addAnyVariable(nts)
-
- solver.synthFun("f", {}, boolean, g1)
-
- with pytest.raises(Exception):
- g1.addAnyVariable(start)
-
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback