Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f22e1db

Browse files
committed
Java: Add test case for capturing type based summaries.
1 parent 207191f commit f22e1db

5 files changed

Lines changed: 107 additions & 0 deletions

File tree

java/ql/src/utils/model-generator/internal/CaptureTypeBasedSummaryModels.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ class TypeBasedFlowTargetApi extends Specific::TargetApiSpecific {
199199
TypeBasedFlowTargetApi() { Specific::isRelevantForTypeBasedFlowModels(this) }
200200

201201
/**
202+
* TODO: Update with Java examples instead.
202203
* Gets the string representation of all type based summaries for `this`
203204
* inspired by the Theorems for Free approach.
204205
*
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
utils/model-generator/CaptureTypeBasedSummaryModels.ql
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package p;
2+
3+
import java.util.List;
4+
import java.util.ArrayList;
5+
6+
public class TypeBasedCollection<T> extends ArrayList<T> {
7+
8+
public void addT(T x) {
9+
throw null;
10+
}
11+
12+
public void addManyT(List<T> xs) {
13+
throw null;
14+
}
15+
16+
public T firstT() {
17+
throw null;
18+
}
19+
20+
public List<T> getManyT() {
21+
throw null;
22+
}
23+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package p;
2+
3+
import java.util.List;
4+
import java.util.function.Function;
5+
6+
public class TypeBasedComplex<T> {
7+
8+
public void addMany(List<T> xs) {
9+
throw null;
10+
}
11+
12+
public List<T> getMany() {
13+
throw null;
14+
}
15+
16+
public Integer apply(Function<T, Integer> f) {
17+
throw null;
18+
}
19+
20+
public <T1, T2> T2 apply2(T1 x, Function<T1, T2> f) {
21+
throw null;
22+
}
23+
24+
public TypeBasedComplex<T> flatMap(Function<T, List<T>> f) {
25+
throw null;
26+
}
27+
28+
public <S> TypeBasedComplex<S> flatMap2(Function<T, List<S>> f) {
29+
throw null;
30+
}
31+
32+
public <S> S map(Function<T, S> f) {
33+
throw null;
34+
}
35+
36+
public <S> TypeBasedComplex<S> mapComplex(Function<T, S> f) {
37+
throw null;
38+
}
39+
40+
public TypeBasedComplex<T> returnComplex(Function<T, TypeBasedComplex<T>> f) {
41+
throw null;
42+
}
43+
44+
public void set(Integer x, Function<Integer, T> f) {
45+
throw null;
46+
}
47+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package p;
2+
3+
public class TypeBasedSimple<T> {
4+
public TypeBasedSimple(T t) {
5+
throw null;
6+
}
7+
8+
public T get() {
9+
throw null;
10+
}
11+
12+
public T get(Object o) {
13+
return null;
14+
}
15+
16+
public T id(T x) {
17+
throw null;
18+
}
19+
20+
public <S> S id2(S x) {
21+
throw null;
22+
}
23+
24+
public void set(T x) {
25+
throw null;
26+
}
27+
28+
public void set(int x, T y) {
29+
throw null;
30+
}
31+
32+
public <S> void set2(S x) { // No summary as S is unrelated to T
33+
throw null;
34+
}
35+
}

0 commit comments

Comments
 (0)