Skip to content

Commit 5da4e3f

Browse files
Use tokenizer in SolverFormulaIOTest.checkThatAssertIsInLastLine to fix broken MathSAT tests
1 parent 42d394c commit 5da4e3f

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

src/org/sosy_lab/java_smt/test/SolverFormulaIOTest.java

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
package org.sosy_lab.java_smt.test;
1010

11-
import static com.google.common.collect.Iterables.filter;
1211
import static com.google.common.collect.Iterables.getLast;
1312
import static com.google.common.truth.Truth.assertThat;
1413
import static com.google.common.truth.Truth.assertWithMessage;
@@ -19,7 +18,6 @@
1918
import com.google.common.collect.Iterables;
2019
import com.google.common.collect.Multiset;
2120
import com.google.common.truth.TruthJUnit;
22-
import java.util.List;
2321
import java.util.function.Supplier;
2422
import org.junit.Test;
2523
import org.sosy_lab.java_smt.SolverContextFactory.Solvers;
@@ -29,6 +27,7 @@
2927
import org.sosy_lab.java_smt.api.FunctionDeclaration;
3028
import org.sosy_lab.java_smt.api.NumeralFormula.IntegerFormula;
3129
import org.sosy_lab.java_smt.api.SolverException;
30+
import org.sosy_lab.java_smt.basicimpl.Tokenizer;
3231

3332
@SuppressWarnings("checkstyle:linelength")
3433
public class SolverFormulaIOTest extends SolverBasedTest0.ParameterizedSolverBasedTest0 {
@@ -481,19 +480,11 @@ private void checkThatAssertIsInLastLine(String dump) {
481480
// Boolector will fail this anyway since bools are bitvecs for btor
482481
TruthJUnit.assume().that(solver).isNotEqualTo(Solvers.BOOLECTOR);
483482

484-
List<String> lines = Splitter.on('\n').splitToList(dump.trim());
485-
String lineUnderTest = getLast(lines);
486-
487-
if (solver == Solvers.OPENSMT) {
488-
// OpenSMT prints assertions over several lines, so lets find the last SMT-LIB command by
489-
// heuristic: the last line starting with a plain bracket.
490-
lineUnderTest = getLast(filter(lines, line -> line.startsWith("(")));
491-
}
492-
483+
String lastCommand = getLast(Tokenizer.tokenize(dump));
493484
assertWithMessage("last line(s) of <\n" + dump + ">")
494-
.that(lineUnderTest)
485+
.that(lastCommand)
495486
.startsWith("(assert ");
496-
assertWithMessage("last line(s) of <\n" + dump + ">").that(getLast(lines)).endsWith(")");
487+
assertWithMessage("last line(s) of <\n" + dump + ">").that(lastCommand).endsWith(")");
497488
}
498489

499490
@SuppressWarnings("CheckReturnValue")

0 commit comments

Comments
 (0)