Skip to content

Commit 5b65f5c

Browse files
committed
Java: Change test implementation to avoid failing CFG dead end consistency test.
1 parent 8c1de59 commit 5b65f5c

File tree

4 files changed

+49
-59
lines changed

4 files changed

+49
-59
lines changed

java/ql/test/utils/model-generator/typebasedflow/p/Stream.java

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,154 +11,152 @@ public Iterator<T> iterator() {
1111
}
1212

1313
public boolean allMatch(Predicate<? super T> predicate) {
14-
throw null;
14+
return false;
1515
}
1616

1717
public <R> R collect(Supplier<R> supplier, BiConsumer<R, ? super T> accumulator, BiConsumer<R, R> combiner) {
18-
throw null;
18+
return null;
1919
}
2020

2121
// Collector is not a functional interface, so this is not supported
2222
public <R, A> R collect(Collector<? super T, A, R> collector) {
23-
throw null;
23+
return null;
2424
}
2525

2626
public static <T> Stream<T> concat(Stream<? extends T> a, Stream<? extends T> b) {
27-
throw null;
27+
return null;
2828
}
2929

3030
public Stream<T> distinct() {
31-
throw null;
31+
return null;
3232
}
3333

3434
public static <T> Stream<T> empty() {
35-
throw null;
35+
return null;
3636
}
3737

3838
public Stream<T> filter(Predicate<? super T> predicate) {
39-
throw null;
39+
return null;
4040
}
4141

4242
public Optional<T> findAny() {
43-
throw null;
43+
return null;
4444
}
4545

4646
public Optional<T> findFirst() {
47-
throw null;
47+
return null;
4848
}
4949

5050
// public <R> Stream<R> flatMap(Function<? super T, ? extends Stream<? extends
5151
// R>> mapper) {
52-
// throw null;
52+
// return null;
5353
// }
5454

5555
public DoubleStream flatMapToDouble(Function<? super T, ? extends DoubleStream> mapper) {
56-
throw null;
56+
return null;
5757
}
5858

5959
public IntStream flatMapToInt(Function<? super T, ? extends IntStream> mapper) {
60-
throw null;
60+
return null;
6161
}
6262

6363
public LongStream flatMapToLong(Function<? super T, ? extends LongStream> mapper) {
64-
throw null;
64+
return null;
6565
}
6666

6767
public void forEach(Consumer<? super T> action) {
68-
throw null;
6968
}
7069

7170
public void forEachOrdered(Consumer<? super T> action) {
72-
throw null;
7371
}
7472

7573
public static <T> Stream<T> generate(Supplier<T> s) {
76-
throw null;
74+
return null;
7775
}
7876

7977
// Model generator adds a couple of extra models, which can't be
8078
// dismissed based on the type information.
8179
public static <T> Stream<T> iterate(T seed, UnaryOperator<T> f) {
82-
throw null;
80+
return null;
8381
}
8482

8583
public Stream<T> limit(long maxSize) {
86-
throw null;
84+
return null;
8785
}
8886

8987
public <R> Stream<R> map(Function<? super T, ? extends R> mapper) {
90-
throw null;
88+
return null;
9189
}
9290

9391
public DoubleStream mapToDouble(ToDoubleFunction<? super T> mapper) {
94-
throw null;
92+
return null;
9593
}
9694

9795
public IntStream mapToInt(ToIntFunction<? super T> mapper) {
98-
throw null;
96+
return null;
9997
}
10098

10199
public LongStream mapToLong(ToLongFunction<? super T> mapper) {
102-
throw null;
100+
return null;
103101
}
104102

105103
public Optional<T> max(Comparator<? super T> comparator) {
106-
throw null;
104+
return null;
107105
}
108106

109107
public Optional<T> min(Comparator<? super T> comparator) {
110-
throw null;
108+
return null;
111109
}
112110

113111
public boolean noneMatch(Predicate<? super T> predicate) {
114-
throw null;
112+
return false;
115113
}
116114

117115
// Issue with model generator. ... is not supported.
118116
// public static <T> Stream<T> of(T... t) {
119-
// throw null;
117+
// return null;
120118
// }
121119

122120
public static <T> Stream<T> of(T t) {
123-
throw null;
121+
return null;
124122
}
125123

126124
public Stream<T> peek(Consumer<? super T> action) {
127-
throw null;
125+
return null;
128126
}
129127

130128
// Model generator yields a couple of extra results as models are generated for
131129
// writing to the stream.
132130
public Optional<T> reduce(BinaryOperator<T> accumulator) {
133-
throw null;
131+
return null;
134132
}
135133

136134
// Model generator yields a couple of extra results as models are generated for
137135
// writing to the stream.
138136
public T reduce(T identity, BinaryOperator<T> accumulator) {
139-
throw null;
137+
return null;
140138
}
141139

142140
public <U> U reduce(U identity, BiFunction<U, ? super T, U> accumulator, BinaryOperator<U> combiner) {
143-
throw null;
141+
return null;
144142
}
145143

146144
public Stream<T> skip(long n) {
147-
throw null;
145+
return null;
148146
}
149147

150148
public Stream<T> sorted() {
151-
throw null;
149+
return null;
152150
}
153151

154152
public Stream<T> sorted(Comparator<? super T> comparator) {
155-
throw null;
153+
return null;
156154
}
157155

158156
// Models can never be generated correctly based on the type information
159157
// as it involves downcasting.
160158
public Object[] toArray() {
161-
throw null;
159+
return null;
162160
}
163161

164162
// Issue with model generator - no models are generated.

java/ql/test/utils/model-generator/typebasedflow/p/TypeBasedCollection.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,16 @@
66
public class TypeBasedCollection<T> extends ArrayList<T> {
77

88
public void addT(T x) {
9-
throw null;
109
}
1110

1211
public void addManyT(List<T> xs) {
13-
throw null;
1412
}
1513

1614
public T firstT() {
17-
throw null;
15+
return null;
1816
}
1917

2018
public List<T> getManyT() {
21-
throw null;
19+
return null;
2220
}
2321
}

java/ql/test/utils/model-generator/typebasedflow/p/TypeBasedComplex.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,54 +6,52 @@
66
public class TypeBasedComplex<T> {
77

88
public void addMany(List<T> xs) {
9-
throw null;
109
}
1110

1211
public List<T> getMany() {
13-
throw null;
12+
return null;
1413
}
1514

1615
public Integer apply(Function<T, Integer> f) {
17-
throw null;
16+
return null;
1817
}
1918

2019
public <T1, T2> T2 apply2(T1 x, Function<T1, T2> f) {
21-
throw null;
20+
return null;
2221
}
2322

2423
public TypeBasedComplex<T> flatMap(Function<T, List<T>> f) {
25-
throw null;
24+
return null;
2625
}
2726

2827
public <S> TypeBasedComplex<S> flatMap2(Function<T, List<S>> f) {
29-
throw null;
28+
return null;
3029
}
3130

3231
public <S> S map(Function<T, S> f) {
33-
throw null;
32+
return null;
3433
}
3534

3635
public <S> TypeBasedComplex<S> mapComplex(Function<T, S> f) {
37-
throw null;
36+
return null;
3837
}
3938

4039
public TypeBasedComplex<T> returnComplex(Function<T, TypeBasedComplex<T>> f) {
41-
throw null;
40+
return null;
4241
}
4342

4443
public void set(Integer x, Function<Integer, T> f) {
45-
throw null;
4644
}
4745

4846
public Integer applyMyFunction(MyFunction<T, Integer, T> f, Integer x) {
49-
throw null;
47+
return null;
5048
}
5149

5250
public <S1, S2> S2 applyMyFunctionGeneric(MyFunction<T, S1, S2> f, S1 x) {
53-
throw null;
51+
return null;
5452
}
5553

5654
public <S1, S2, S3> S3 applyMyFunctionGeneric(MyFunction<S1, S2, S3> f, S1 x, S2 y) {
57-
throw null;
55+
return null;
5856
}
5957
}

java/ql/test/utils/model-generator/typebasedflow/p/TypeBasedSimple.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,30 @@
22

33
public class TypeBasedSimple<T> {
44
public TypeBasedSimple(T t) {
5-
throw null;
65
}
76

87
public T get() {
9-
throw null;
8+
return null;
109
}
1110

1211
public T get(Object o) {
1312
return null;
1413
}
1514

1615
public T id(T x) {
17-
throw null;
16+
return null;
1817
}
1918

2019
public <S> S id2(S x) {
21-
throw null;
20+
return null;
2221
}
2322

2423
public void set(T x) {
25-
throw null;
2624
}
2725

2826
public void set(int x, T y) {
29-
throw null;
3027
}
3128

3229
public <S> void set2(S x) { // No summary as S is unrelated to T
33-
throw null;
3430
}
3531
}

0 commit comments

Comments
 (0)