Debian Codegraph @

test/api/python/smt2_compliance.py

raw
1 ###############################################################################
2 # Top contributors (to current version):
3 # Daniel Larraz
4 #
5 # This file is part of the cvc5 project.
6 #
7 # Copyright (c) 2009-2025 by the authors listed in the file AUTHORS
8 # in the top-level source directory and their institutional affiliations.
9 # All rights reserved. See the file COPYING in the top-level source
10 # directory for licensing information.
11 # #############################################################################
12 #
13 # A test of SMT-LIBv2 commands, checks for compliant output.
14 ##
15
16 import cvc5
17
18 def test_get_info(solver, key):
19 sm = cvc5.SymbolManager(solver.getTermManager())
20 parser = cvc5.InputParser(solver, sm)
21
22 input_str = f"(get-info {key})"
23 parser.setStringInput(cvc5.InputLanguage.SMT_LIB_2_6, input_str, "<internal>")
24
25 cmd = parser.nextCommand()
26 assert (not cmd.isNull())
27 print(f"{cmd}")
28
29 output_str = cmd.invoke(solver, sm)
30
31 cmd = parser.nextCommand()
32 assert cmd.isNull()
33 print(output_str)
34
35
36 tm = cvc5.TermManager()
37 solver = cvc5.Solver(tm)
38 solver.setOption("input-language", "smtlib2")
39 solver.setOption("output-language", "smtlib2")
40
41 test_get_info(solver, ":error-behavior")
42 test_get_info(solver, ":name")
43 test_get_info(solver, ":authors")
44 test_get_info(solver, ":version")
45 test_get_info(solver, ":status")
46 test_get_info(solver, ":reason-unknown")
47 test_get_info(solver, ":arbitrary-undefined-keyword")
48 test_get_info(solver, ":<=") # legal
49 test_get_info(solver, ":->") # legal
50 test_get_info(solver, ":all-statistics")