Java: Add test case for capturing type based summaries.

This commit is contained in:
Michael Nebel
2022-09-29 16:32:01 +02:00
parent 207191f987
commit f22e1db33f
5 changed files with 107 additions and 0 deletions

View File

@@ -199,6 +199,7 @@ class TypeBasedFlowTargetApi extends Specific::TargetApiSpecific {
TypeBasedFlowTargetApi() { Specific::isRelevantForTypeBasedFlowModels(this) }
/**
* TODO: Update with Java examples instead.
* Gets the string representation of all type based summaries for `this`
* inspired by the Theorems for Free approach.
*

View File

@@ -0,0 +1 @@
utils/model-generator/CaptureTypeBasedSummaryModels.ql

View File

@@ -0,0 +1,23 @@
package p;
import java.util.List;
import java.util.ArrayList;
public class TypeBasedCollection<T> extends ArrayList<T> {
public void addT(T x) {
throw null;
}
public void addManyT(List<T> xs) {
throw null;
}
public T firstT() {
throw null;
}
public List<T> getManyT() {
throw null;
}
}

View File

@@ -0,0 +1,47 @@
package p;
import java.util.List;
import java.util.function.Function;
public class TypeBasedComplex<T> {
public void addMany(List<T> xs) {
throw null;
}
public List<T> getMany() {
throw null;
}
public Integer apply(Function<T, Integer> f) {
throw null;
}
public <T1, T2> T2 apply2(T1 x, Function<T1, T2> f) {
throw null;
}
public TypeBasedComplex<T> flatMap(Function<T, List<T>> f) {
throw null;
}
public <S> TypeBasedComplex<S> flatMap2(Function<T, List<S>> f) {
throw null;
}
public <S> S map(Function<T, S> f) {
throw null;
}
public <S> TypeBasedComplex<S> mapComplex(Function<T, S> f) {
throw null;
}
public TypeBasedComplex<T> returnComplex(Function<T, TypeBasedComplex<T>> f) {
throw null;
}
public void set(Integer x, Function<Integer, T> f) {
throw null;
}
}

View File

@@ -0,0 +1,35 @@
package p;
public class TypeBasedSimple<T> {
public TypeBasedSimple(T t) {
throw null;
}
public T get() {
throw null;
}
public T get(Object o) {
return null;
}
public T id(T x) {
throw null;
}
public <S> S id2(S x) {
throw null;
}
public void set(T x) {
throw null;
}
public void set(int x, T y) {
throw null;
}
public <S> void set2(S x) { // No summary as S is unrelated to T
throw null;
}
}