Skip to content

Commit 1fd89fa

Browse files
committed
Removed junit asserts from the code.
1 parent ec0f927 commit 1fd89fa

File tree

11 files changed

+106
-143
lines changed

11 files changed

+106
-143
lines changed

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,8 @@ You can find out more about LiquidJava in the following resources:
2828

2929
## Setup the project
3030
1. Clone the repository;
31-
<<<<<<< HEAD
3231
2. Open Eclipse and do `Ìmport...\ Existing Maven Project` selecting the current folder and waiting for the build process to finish (bottom right update bar)
3332
3. Select the current folder, right click it and select `Run as...\Maven install...`
34-
=======
35-
2. Open Eclipse and do `Ìmport...\ Existing Maven Project` selecting the project folder `liquidjava` and waiting for the build process to finish (bottom right update bar)
36-
3. Select the `liquidjava-umbrella` folder, right click it and select `Run as...\Maven install...`
37-
>>>>>>> 8f871c3c15eaf408a01354a867e71466d45115be
3833
4. If inside the `liquidjava-verifier` build path there is not a `target/generated-sources/antr4`: Select `liquidjava-verifier`, on right-click, go to `Build Path\Link Source...` and browse for `liquidjava-verifier\target\generated-sources\antlr4` and select `Finish`
3934

4035
## Run verification

liquidjava-api/pom.xml

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,52 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
24
<modelVersion>4.0.0</modelVersion>
3-
5+
46
<parent>
57
<groupId>liquidjava</groupId>
68
<artifactId>liquidjava-umbrella</artifactId>
79
<version>1.0</version>
810
</parent>
9-
11+
1012
<groupId>liquidjava-api</groupId>
1113
<artifactId>liquidjava-api</artifactId>
12-
<version>0.0.1-SNAPSHOT</version>
14+
<version>0.0.1-SNAPSHOT</version>
1315
<name>liquidjava-api</name>
1416
<packaging>jar</packaging>
1517

1618
<build>
17-
<pluginManagement>
18-
<plugins>
19-
<plugin>
20-
<groupId>fr.inria.gforge.spoon</groupId>
21-
<artifactId>spoon-maven-plugin</artifactId>
22-
<version>3.3</version>
23-
<executions>
24-
<execution>
25-
<phase>generate-sources</phase>
26-
<goals><goal>generate</goal></goals>
27-
</execution>
28-
</executions>
29-
</plugin>
30-
<plugin>
31-
<groupId>org.apache.maven.plugins</groupId>
32-
<artifactId>maven-compiler-plugin</artifactId>
33-
<version>3.8.1</version>
34-
<configuration>
35-
<source>1.8</source>
36-
<target>1.8</target>
37-
</configuration>
38-
</plugin>
39-
</plugins>
40-
</pluginManagement>
19+
<pluginManagement>
20+
<plugins>
21+
<plugin>
22+
<groupId>fr.inria.gforge.spoon</groupId>
23+
<artifactId>spoon-maven-plugin</artifactId>
24+
<version>3.3</version>
25+
<executions>
26+
<execution>
27+
<phase>generate-sources</phase>
28+
<goals>
29+
<goal>generate</goal>
30+
</goals>
31+
</execution>
32+
</executions>
33+
</plugin>
34+
<plugin>
35+
<groupId>org.apache.maven.plugins</groupId>
36+
<artifactId>maven-compiler-plugin</artifactId>
37+
<version>3.8.1</version>
38+
<configuration>
39+
<source>1.8</source>
40+
<target>1.8</target>
41+
</configuration>
42+
</plugin>
43+
</plugins>
44+
</pluginManagement>
4145
</build>
42-
43-
<properties>
46+
47+
<properties>
4448
<javaVersion>1.8</javaVersion>
4549
<maven.compiler.source>1.8</maven.compiler.source>
4650
<maven.compiler.target>1.8</maven.compiler.target>
4751
</properties>
48-
49-
<dependencies>
50-
<dependency>
51-
<groupId>junit</groupId>
52-
<artifactId>junit</artifactId>
53-
<version>4.13.1</version>
54-
<scope>test</scope>
55-
</dependency>
56-
</dependencies>
5752
</project>

liquidjava-example/pom.xml

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,6 @@
2626
<target>20</target>
2727
</configuration>
2828
</plugin>
29-
<plugin>
30-
<groupId>org.apache.maven.plugins</groupId>
31-
<artifactId>maven-surefire-plugin</artifactId>
32-
<version>${pVersion.surefire}</version>
33-
<configuration>
34-
<!-- the following is required to have the same execution semantics
35-
as eclipse (hence all tests passing) -->
36-
<useSystemClassLoader>false</useSystemClassLoader>
37-
<forkCount>1</forkCount>
38-
<argLine>-Dgumtree.match.gt.minh=1</argLine>
39-
<!-- we put the tests in src/main/java so that it's easier to navigate and
40-
understand on Github (recall that's an example code project, not a production
41-
app or library ) -->
42-
<testSourceDirectory>${basedir}/test/main/java/</testSourceDirectory>
43-
<testClassesDirectory>${project.build.directory}/classes/</testClassesDirectory>
44-
</configuration>
45-
</plugin>
4629
</plugins>
4730
</build>
4831

@@ -64,11 +47,6 @@
6447
<artifactId>InMemoryJavaCompiler</artifactId>
6548
<version>${version.memcompiler}</version>
6649
</dependency>
67-
<dependency>
68-
<groupId>junit</groupId>
69-
<artifactId>junit</artifactId>
70-
<version>${version.junit}</version>
71-
</dependency>
7250
<dependency>
7351
<groupId>liquidjava-api</groupId>
7452
<artifactId>liquidjava-api</artifactId>

liquidjava-verifier/pom.xml

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,6 @@
3737
<compilerTargetPlatform>1.8</compilerTargetPlatform>
3838
</configuration>
3939
</plugin>
40-
<!-- <plugin>
41-
<groupId>org.apache.maven.plugins</groupId>
42-
<artifactId>maven-checkstyle-plugin</artifactId>
43-
<version>3.2.0</version>
44-
<configuration>
45-
<configLocation>checkstyle.xml</configLocation>
46-
</configuration>
47-
<executions>
48-
<execution>
49-
<id>validate</id>
50-
<phase>validate</phase>
51-
<goals>
52-
<goal>check</goal>
53-
</goals>
54-
</execution>
55-
</executions>
56-
<dependencies>
57-
<dependency>
58-
<groupId>com.puppycrawl.tools</groupId>
59-
<artifactId>checkstyle</artifactId>
60-
<version>10.3.4</version>
61-
</dependency>
62-
</dependencies>
63-
</plugin> -->
6440
<plugin>
6541
<groupId>org.apache.maven.plugins</groupId>
6642
<artifactId>maven-compiler-plugin</artifactId>
@@ -96,14 +72,14 @@
9672
<maven.compiler.source>1.8</maven.compiler.source>
9773
<maven.compiler.target>1.8</maven.compiler.target>
9874
<!-- versions -->
99-
<version.junit>4.13.1</version.junit>
75+
<version.junit>5.10.0</version.junit>
10076
<version.memcompiler>1.3.0</version.memcompiler>
10177
<version.spoon>10.4.2</version.spoon>
10278
<version.z3>4.8.17</version.z3>
10379
<version.liquidjava>1.0</version.liquidjava>
10480
<!-- plugin versions -->
10581
<pVersion.compiler>3.8.0</pVersion.compiler>
106-
<pVersion.surefire>2.22.1</pVersion.surefire>
82+
<pVersion.surefire>3.1.2</pVersion.surefire>
10783
</properties>
10884

10985
<repositories>
@@ -119,6 +95,28 @@
11995
</repository>
12096
</repositories>
12197
<dependencies>
98+
<!-- Only needed to run tests in a version of IntelliJ IDEA that bundles older versions -->
99+
<dependency>
100+
<groupId>org.junit.platform</groupId>
101+
<artifactId>junit-platform-launcher</artifactId>
102+
<scope>test</scope>
103+
</dependency>
104+
<dependency>
105+
<groupId>org.junit.jupiter</groupId>
106+
<artifactId>junit-jupiter-engine</artifactId>
107+
<scope>test</scope>
108+
</dependency>
109+
<dependency>
110+
<groupId>org.junit.vintage</groupId>
111+
<artifactId>junit-vintage-engine</artifactId>
112+
<scope>test</scope>
113+
</dependency>
114+
<dependency>
115+
<groupId>org.junit.jupiter</groupId>
116+
<artifactId>junit-jupiter-params</artifactId>
117+
<scope>test</scope>
118+
</dependency>
119+
122120
<dependency>
123121
<groupId>org.mdkt.compiler</groupId>
124122
<artifactId>InMemoryJavaCompiler</artifactId>
@@ -135,11 +133,7 @@
135133
<artifactId>z3-turnkey</artifactId>
136134
<version>${version.z3}</version>
137135
</dependency>
138-
<dependency>
139-
<groupId>junit</groupId>
140-
<artifactId>junit</artifactId>
141-
<version>${version.junit}</version>
142-
</dependency>
136+
143137
<dependency>
144138
<groupId>liquidjava-api</groupId>
145139
<artifactId>liquidjava-api</artifactId>
@@ -152,13 +146,22 @@
152146
<artifactId>antlr4</artifactId>
153147
<version>4.7.1</version>
154148
</dependency>
155-
156-
157149
<dependency>
158150
<groupId>org.antlr</groupId>
159151
<artifactId>antlr4-runtime</artifactId>
160152
<version>4.7.1</version>
161153
</dependency>
162154

163155
</dependencies>
156+
<dependencyManagement>
157+
<dependencies>
158+
<dependency>
159+
<groupId>org.junit</groupId>
160+
<artifactId>junit-bom</artifactId>
161+
<version>5.10.0</version>
162+
<type>pom</type>
163+
<scope>import</scope>
164+
</dependency>
165+
</dependencies>
166+
</dependencyManagement>
164167
</project>

liquidjava-verifier/src/main/java/liquidjava/processor/refinement_checker/TypeChecker.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package liquidjava.processor.refinement_checker;
22

3-
import static org.junit.Assert.fail;
4-
53
import java.lang.annotation.Annotation;
64
import java.util.Arrays;
75
import java.util.List;
@@ -116,7 +114,7 @@ private void createStateSet(CtNewArray<String> e, int set, CtElement element) {
116114
Optional<GhostFunction> og = createStateGhost(set, element);
117115
if (!og.isPresent()) {
118116
System.out.println("Error in creation of GhostFunction");
119-
fail();
117+
assert false;
120118
}
121119
GhostFunction g = og.get();
122120
context.addGhostFunction(g);

liquidjava-verifier/src/main/java/liquidjava/processor/refinement_checker/general_checkers/MethodsFunctionsChecker.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package liquidjava.processor.refinement_checker.general_checkers;
22

3-
import static org.junit.Assert.assertFalse;
4-
53
import java.lang.annotation.Annotation;
64
import java.util.ArrayList;
75
import java.util.HashMap;
@@ -426,11 +424,9 @@ public void loadFunctionInfo(CtExecutable<?> method) {
426424
for (Variable v : lv)
427425
rtc.getContext().addVarToContext(v);
428426
} else {
429-
assertFalse(
430-
"Method should already be in context. Should not arrive this point in refinement" + " checker.",
431-
true);
432-
// getMethodRefinements(method); //should be irrelevant -should never need to
433-
// get here
427+
assert false;
428+
// Method should already be in context. Should not arrive this point in
429+
// refinement checker.
434430
}
435431
}
436432
}

liquidjava-verifier/src/main/java/liquidjava/processor/refinement_checker/object_checkers/AuxStateHandler.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package liquidjava.processor.refinement_checker.object_checkers;
22

3-
import static org.junit.Assert.assertFalse;
4-
import static org.junit.Assert.fail;
5-
63
import java.lang.annotation.Annotation;
74
import java.util.*;
85
import java.util.stream.Collectors;
@@ -62,7 +59,8 @@ public static void setDefaultState(RefinedFunction f, TypeChecker tc) {
6259
Predicate.createLit("0", Utils.INT));
6360
c = Predicate.createConjunction(c, p);
6461
} else {
65-
fail("Ghost Functions not implemented for other types than int -> implement in"
62+
// TODO: Implement other stuff
63+
throw new RuntimeException("Ghost Functions not implemented for other types than int -> implement in"
6664
+ " AuxStateHandler defaultState");
6765
}
6866
}
@@ -235,7 +233,8 @@ public static void constructorStateMetadata(String refKey, RefinedFunction f, Ma
235233
ctConstructorCall.putMetadata(refKey, c);
236234
// add maping to oc.get(0)-HERE
237235
} else if (oc.size() > 1) {
238-
assertFalse("Constructor can only have one to state, not multiple", true);
236+
// TODO: Proper Exception
237+
throw new RuntimeException("Constructor can only have one to state, not multiple.");
239238
}
240239
}
241240

liquidjava-verifier/src/main/java/liquidjava/rj_language/ast/BinaryExpression.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package liquidjava.rj_language.ast;
22

3-
import static org.junit.Assert.fail;
4-
53
import com.microsoft.z3.Expr;
64
import java.util.List;
75
import liquidjava.smt.TranslatorToZ3;
@@ -79,8 +77,7 @@ private Expr<?> evalBinaryOp(TranslatorToZ3 ctx, Expr<?> e1, Expr<?> e2) {
7977
case "%":
8078
return ctx.makeMod(e1, e2);
8179
default: // last case %
82-
fail("Reached unkown operation " + op);
83-
return null;
80+
throw new RuntimeException("Operation " + op + "not supported by z3");
8481
}
8582
}
8683

liquidjava-verifier/src/main/java/liquidjava/rj_language/ast/typing/TypeInfer.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package liquidjava.rj_language.ast.typing;
22

3-
import static org.junit.Assert.fail;
4-
53
import java.util.Optional;
4+
5+
import org.apache.commons.lang3.NotImplementedException;
6+
67
import liquidjava.processor.context.Context;
78
import liquidjava.processor.context.GhostFunction;
89
import liquidjava.rj_language.ast.AliasInvocation;
@@ -89,7 +90,8 @@ else if (e.isBooleanOperation()) { // >, >=, <, <=, ==, !=
8990
if (t1.get().equals(t2.get()))
9091
return t1;
9192
// TODO if the types are different ex: double, int
92-
fail("To implement in TypeInfer: Binary type, arithmetic with different arg types");
93+
throw new NotImplementedException(
94+
"To implement in TypeInfer: Binary type, arithmetic with different arg types");
9395
}
9496
return null;
9597
}

0 commit comments

Comments
 (0)