Enable CI for Junit tests (#7436)

This PR enables CI for java tests by adding --java-bindings to ci.yml.
It also replaces the unreliable finalize method and instead uses AutoCloseable and explicit close method to clean up dynamic memory allocated by java native interface.
The PR fixes compile errors for SolverTest.java and runtime errors for Solver.defineFun.
This commit is contained in:
mudathirmahgoub
2021-11-03 16:32:10 -05:00
committed by GitHub
parent b8504ef92e
commit 690a392656
57 changed files with 1281 additions and 1202 deletions

View File

@@ -23,43 +23,45 @@ public class Statistics
{
public static void main(String[] args)
{
Solver solver = getSolver();
// Get the statistics from the `Solver` and iterate over them. The
// `Statistics` class implements the `Iterable<Pair<String, Stat>>` interface.
io.github.cvc5.api.Statistics stats = solver.getStatistics();
// short version
System.out.println("Short version:");
System.out.println(stats);
System.out.println("-------------------------------------------------------");
System.out.println("Long version:");
// long version
for (Pair<String, Stat> pair : stats)
try (Solver solver = new Solver())
{
Stat stat = pair.second;
if (stat.isInt())
// Get the statistics from the `Solver` and iterate over them. The
// `Statistics` class implements the `Iterable<Pair<String, Stat>>` interface.
io.github.cvc5.api.Statistics stats = solver.getStatistics();
// short version
System.out.println("Short version:");
System.out.println(stats);
System.out.println("-------------------------------------------------------");
System.out.println("Long version:");
// long version
for (Pair<String, Stat> pair : stats)
{
System.out.println(pair.first + " = " + stat.getInt());
}
else if (stat.isDouble())
{
System.out.println(pair.first + " = " + stat.getDouble());
}
else if (stat.isString())
{
System.out.println(pair.first + " = " + stat.getString());
}
else if (stat.isHistogram())
{
System.out.println("-------------------------------------------------------");
System.out.println(pair.first + " : Map");
for (Map.Entry<String, Long> entry : stat.getHistogram().entrySet())
Stat stat = pair.second;
if (stat.isInt())
{
System.out.println(entry.getKey() + " = " + entry.getValue());
System.out.println(pair.first + " = " + stat.getInt());
}
else if (stat.isDouble())
{
System.out.println(pair.first + " = " + stat.getDouble());
}
else if (stat.isString())
{
System.out.println(pair.first + " = " + stat.getString());
}
else if (stat.isHistogram())
{
System.out.println("-------------------------------------------------------");
System.out.println(pair.first + " : Map");
for (Map.Entry<String, Long> entry : stat.getHistogram().entrySet())
{
System.out.println(entry.getKey() + " = " + entry.getValue());
}
System.out.println("-------------------------------------------------------");
}
System.out.println("-------------------------------------------------------");
}
}
}