-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into windowsSMTPathBug
- Loading branch information
Showing
19 changed files
with
477 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
key.core/src/test/java/de/uka/ilkd/key/nparser/AdtTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* This file is part of KeY - https://key-project.org | ||
* KeY is licensed under the GNU General Public License Version 2 | ||
* SPDX-License-Identifier: GPL-2.0-only */ | ||
package de.uka.ilkd.key.nparser; | ||
|
||
import java.io.File; | ||
import java.util.Collection; | ||
|
||
import de.uka.ilkd.key.control.KeYEnvironment; | ||
import de.uka.ilkd.key.logic.Name; | ||
import de.uka.ilkd.key.proof.io.ProblemLoaderException; | ||
import de.uka.ilkd.key.rule.Taclet; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* Tests for handling of abstract datatypes in KeY files. | ||
*/ | ||
public class AdtTests { | ||
private static final String EXPECTED_PRED_DEC_SUCC = """ | ||
pred_Dec_succ { | ||
\\find(pred(succ(pred_sv))) | ||
\\sameUpdateLevel\\replacewith(pred_sv)\s | ||
Choices: true}"""; | ||
private static final String EXPECTED_PRED_DECEQ_SUCC = """ | ||
pred_DecEQ_succ { | ||
\\assumes ([equals(pred_x,succ(pred_sv))]==>[])\s | ||
\\find(pred(pred_x)) | ||
\\sameUpdateLevel\\replacewith(pred_sv)\s | ||
Choices: true}"""; | ||
|
||
@Test | ||
public void destructorTest() throws ProblemLoaderException { | ||
var path = new File("../key.ui/examples/standard_key/adt/dt_nat.key"); | ||
var env = KeYEnvironment.load(path); | ||
var taclets = env.getInitConfig().activatedTaclets(); | ||
|
||
for (Taclet taclet : taclets) { | ||
if (taclet.name().toString().contains("_Dec")) | ||
System.out.println(taclet.name()); | ||
} | ||
|
||
var predDecsucc = get("pred_Dec_succ", taclets); | ||
var predDecEqSucc = get("pred_DecEQ_succ", taclets); | ||
|
||
Assertions.assertEquals(EXPECTED_PRED_DEC_SUCC, predDecsucc.toString()); | ||
Assertions.assertEquals(EXPECTED_PRED_DECEQ_SUCC, predDecEqSucc.toString()); | ||
|
||
} | ||
|
||
private Taclet get(String name, Collection<Taclet> taclets) { | ||
var n = new Name(name); | ||
var t = taclets.stream().filter(it -> n.equals(it.name())).findAny().orElse(null); | ||
Assertions.assertNotNull(t); | ||
return t; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
key.core/src/test/java/de/uka/ilkd/key/smt/newsmt2/TestSMTMod.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* This file is part of KeY - https://key-project.org | ||
* KeY is licensed under the GNU General Public License Version 2 | ||
* SPDX-License-Identifier: GPL-2.0-only */ | ||
package de.uka.ilkd.key.smt.newsmt2; | ||
|
||
import java.io.File; | ||
|
||
import de.uka.ilkd.key.control.DefaultUserInterfaceControl; | ||
import de.uka.ilkd.key.control.KeYEnvironment; | ||
import de.uka.ilkd.key.proof.Goal; | ||
import de.uka.ilkd.key.proof.Proof; | ||
import de.uka.ilkd.key.proof.io.ProblemLoaderException; | ||
import de.uka.ilkd.key.smt.SMTProblem; | ||
import de.uka.ilkd.key.smt.SMTSolverResult; | ||
import de.uka.ilkd.key.smt.SMTTestSettings; | ||
import de.uka.ilkd.key.smt.SolverLauncher; | ||
import de.uka.ilkd.key.smt.solvertypes.SolverType; | ||
import de.uka.ilkd.key.smt.solvertypes.SolverTypeImplementation; | ||
import de.uka.ilkd.key.smt.solvertypes.SolverTypes; | ||
|
||
import org.key_project.util.helper.FindResources; | ||
|
||
import org.junit.Test; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
/** | ||
* This class is for testing the translation of modulo from KeY to SMT | ||
* | ||
* @author Nils Buchholz, 2024 | ||
*/ | ||
public class TestSMTMod { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(TestSMTMod.class); | ||
|
||
private static final File testCaseDirectory = FindResources.getTestCasesDirectory(); | ||
|
||
private static final SolverType Z3_SOLVER = SolverTypes.getSolverTypes().stream() | ||
.filter(it -> it.getClass().equals(SolverTypeImplementation.class) | ||
&& it.getName().equals("Z3")) | ||
.findFirst().orElse(null); | ||
|
||
private static final SolverType CVC4_SOLVER = SolverTypes.getSolverTypes().stream() | ||
.filter(it -> it.getClass().equals(SolverTypeImplementation.class) | ||
&& it.getName().equals("CVC4")) | ||
.findFirst().orElse(null); | ||
|
||
/** | ||
* This tests if x mod y is non-negative and x mod y < |y| for y != 0 | ||
* thus satisfying the definition of euclidean modulo | ||
* Tests for Z3 and CVC4 | ||
* | ||
* @throws ProblemLoaderException Occured Exception during load of problem file | ||
*/ | ||
@Test | ||
public void testModSpec() throws ProblemLoaderException { | ||
KeYEnvironment<DefaultUserInterfaceControl> env = | ||
KeYEnvironment.load(new File(testCaseDirectory, "smt/modSpec.key")); | ||
try { | ||
Proof proof = env.getLoadedProof(); | ||
assertNotNull(proof); | ||
assertEquals(1, proof.openGoals().size()); | ||
Goal g = proof.openGoals().iterator().next(); | ||
SMTSolverResult result; | ||
if (Z3_SOLVER.isInstalled(true)) { | ||
result = checkGoal(g, Z3_SOLVER); | ||
assertSame(SMTSolverResult.ThreeValuedTruth.VALID, result.isValid()); | ||
} else { | ||
LOGGER.warn("Warning:Z3 solver not installed, tests skipped."); | ||
} | ||
if (CVC4_SOLVER.isInstalled(true)) { | ||
result = checkGoal(g, CVC4_SOLVER); | ||
assertSame(SMTSolverResult.ThreeValuedTruth.VALID, result.isValid()); | ||
} else { | ||
LOGGER.warn("Warning:CVC4 solver not installed, tests skipped."); | ||
} | ||
} finally { | ||
env.dispose(); | ||
} | ||
} | ||
|
||
private SMTSolverResult checkGoal(Goal g, SolverType solverType) { | ||
SolverLauncher launcher = new SolverLauncher(new SMTTestSettings()); | ||
SMTProblem problem = new SMTProblem(g); | ||
launcher.launch(problem, g.proof().getServices(), solverType); | ||
return problem.getFinalResult(); | ||
} | ||
} |
3 changes: 1 addition & 2 deletions
3
key.core/src/test/resources/de/uka/ilkd/key/speclang/njml/exceptional/TypeError.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
\functions { | ||
int y; | ||
int x; | ||
} | ||
|
||
\problem { | ||
((y>0) -> x % y >= 0 & x % y < y) & ((y<0) -> x%y >= 0 & x % y < -y) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.