Skip to content

Commit f986d07

Browse files
author
thk123
committed
Add tests for generic type erasure
Ensure that moving generic type information out of a comment doesn't cause type errors.
1 parent 24e7fef commit f986d07

11 files changed

+95
-0
lines changed

jbmc/regression/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ add_subdirectory(janalyzer-taint)
1111
add_subdirectory(jbmc-concurrency)
1212
add_subdirectory(jbmc-inheritance)
1313
add_subdirectory(jbmc-cover)
14+
add_subdirectory(generics)

jbmc/regression/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ DIRS = janalzyer-taint \
99
jbmc-strings \
1010
jdiff \
1111
string-smoke-tests \
12+
generics \
1213
# Empty last line
1314

1415
# Tests under goto-gcc cannot be run on Windows, so appveyor.yml unlinks
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
add_test_pl_tests(
2+
"$<TARGET_FILE:jbmc>"
3+
)
4+
5+
add_test_pl_profile(
6+
"jbmc-symex-driven-lazy-loading"
7+
"$<TARGET_FILE:jbmc> --symex-driven-lazy-loading"
8+
"-C;-X;symex-driven-lazy-loading-expected-failure;-s;symex-driven-loading"
9+
"CORE"
10+
)

jbmc/regression/generics/Makefile

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
default: tests.log
2+
3+
include ../../src/config.inc
4+
5+
test:
6+
@../$(CPROVER_DIR)/regression/test.pl -p -c ../../../src/jbmc/jbmc
7+
@../$(CPROVER_DIR)/regression/test.pl -p -c "../../../src/jbmc/jbmc --symex-driven-lazy-loading" -X symex-driven-lazy-loading-expected-failure -s symex-driven-loading
8+
9+
tests.log: ../$(CPROVER_DIR)/regression/test.pl
10+
@../$(CPROVER_DIR)/regression/test.pl -p -c ../../../src/jbmc/jbmc
11+
@../$(CPROVER_DIR)/regression/test.pl -p -c "../../../src/jbmc/jbmc --symex-driven-lazy-loading" -X symex-driven-lazy-loading-expected-failure -s symex-driven-loading
12+
13+
show:
14+
@for dir in *; do \
15+
if [ -d "$$dir" ]; then \
16+
vim -o "$$dir/*.java" "$$dir/*.out"; \
17+
fi; \
18+
done;
19+
20+
clean:
21+
find -name '*.out' -execdir $(RM) '{}' \;
22+
find -name '*.gb' -execdir $(RM) '{}' \;
23+
$(RM) tests.log
24+
25+
%.class: %.java ../../src/org.cprover.jar
26+
javac -g -cp ../../src/org.cprover.jar:. $<
27+
28+
nondet_java_files := $(shell find . -name "Nondet*.java")
29+
nondet_class_files := $(patsubst %.java, %.class, $(nondet_java_files))
30+
31+
.PHONY: nondet-class-files
32+
nondet-class-files: $(nondet_class_files)
33+
34+
.PHONY: clean-nondet-class-files
35+
clean-nondet-class-files:
36+
-rm $(nondet_class_files)
Binary file not shown.
406 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
class Gen<T> {
2+
public T t;
3+
}
4+
5+
class IWrapper {
6+
public int i;
7+
}
8+
9+
class BWrapper {
10+
public boolean b;
11+
}
12+
13+
class TestClass {
14+
static void testFunction() {
15+
Gen<IWrapper> a = new Gen<>();
16+
Gen b = a;
17+
assert(b == a);
18+
Gen<BWrapper> c;
19+
c = b;
20+
assert(c == b);
21+
// below assertion is incorrectly labelled as failure
22+
// assert(c.equals(a));
23+
}
24+
25+
static void testFunctionWithInput(Gen a, Gen<IWrapper> b, Gen<BWrapper> c) {
26+
if(a != null && b != null && c != null &&
27+
a.t != null && b.t != null && c.t != null)
28+
{
29+
b = a;
30+
assert(b == a);
31+
a = c;
32+
assert(a == c);
33+
}
34+
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
TestClass.class
3+
--function TestClass.testFunction
4+
EXIT=0
5+
SIGNAL=0
6+
VERIFICATION SUCCESSFUL
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
TestClass.class
3+
--function TestClass.testFunctionWithInput
4+
EXIT=0
5+
SIGNAL=0
6+
VERIFICATION SUCCESSFUL

0 commit comments

Comments
 (0)