-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathTest.java
More file actions
98 lines (91 loc) · 3.1 KB
/
Test.java
File metadata and controls
98 lines (91 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package generatedtest;
import java.util.Optional;
import java.util.stream.Stream;
// Test case generated by GenerateFlowTestCase.ql
public class Test {
Object getElement(Optional<Object> container) { return container.get(); }
Object getStreamElement(Stream<Object> container) { return null; /* Modelled in .ql file */ }
Optional<Object> newWithElement(Object element) { return Optional.of(element); }
Object source() { return null; }
void sink(Object o) { }
public void test() {
{
// "java.util;Optional;false;filter;;;Element of Argument[this];Element of ReturnValue;value;manual"
Optional<Object> out = null;
Optional<Object> in = newWithElement(source());
out = in.filter(null);
sink(getElement(out)); // $ hasValueFlow
}
{
// "java.util;Optional;false;get;;;Element of Argument[this];ReturnValue;value;manual"
Object out = null;
Optional<Object> in = newWithElement(source());
out = in.get();
sink(out); // $ hasValueFlow
}
{
// "java.util;Optional;false;of;;;Argument[0];Element of ReturnValue;value;manual"
Optional<Object> out = null;
Object in = (Object)source();
out = Optional.of(in);
sink(getElement(out)); // $ hasValueFlow
}
{
// "java.util;Optional;false;ofNullable;;;Argument[0];Element of ReturnValue;value;manual"
Optional<Object> out = null;
Object in = (Object)source();
out = Optional.ofNullable(in);
sink(getElement(out)); // $ hasValueFlow
}
{
// "java.util;Optional;false;or;;;Element of Argument[this];Element of ReturnValue;value;manual"
Optional<Object> out = null;
Optional<Object> in = newWithElement(source());
out = in.or(null);
sink(getElement(out)); // $ hasValueFlow
}
{
// "java.util;Optional;false;orElse;;;Argument[0];ReturnValue;value;manual"
Object out = null;
Object in = (Object)source();
Optional<Object> instance = null;
out = instance.orElse(in);
sink(out); // $ hasValueFlow
}
{
// "java.util;Optional;false;orElse;;;Element of Argument[this];ReturnValue;value;manual"
Object out = null;
Optional<Object> in = newWithElement(source());
out = in.orElse(null);
sink(out); // $ hasValueFlow
}
{
// "java.util;Optional;false;orElseGet;;;Element of Argument[this];ReturnValue;value;manual"
Object out = null;
Optional<Object> in = newWithElement(source());
out = in.orElseGet(null);
sink(out); // $ hasValueFlow
}
{
// "java.util;Optional;false;orElseThrow;;;Element of Argument[this];ReturnValue;value;manual"
Object out = null;
Optional<Object> in = newWithElement(source());
out = in.orElseThrow(null);
sink(out); // $ hasValueFlow
}
{
// "java.util;Optional;false;orElseThrow;;;Element of Argument[this];ReturnValue;value;manual"
Object out = null;
Optional<Object> in = newWithElement(source());
out = in.orElseThrow();
sink(out); // $ hasValueFlow
}
{
// "java.util;Optional;false;stream;;;Element of Argument[this];Element of ReturnValue;value;manual"
Stream<Object> out = null;
Optional<Object> in = newWithElement(source());
out = in.stream();
sink(getStreamElement(out)); // $ hasValueFlow
}
}
}