-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathtst.js
More file actions
127 lines (102 loc) · 2.71 KB
/
tst.js
File metadata and controls
127 lines (102 loc) · 2.71 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import myapi from "@test/myapi";
import config from "@test/myconfig";
let api = new myapi();
class C {
constructor(conn) {
this.connection = conn;
}
getData(cb) {
this.connection.getData(cb);
}
}
function getConnection() {
return api.chain1().chain2().createConnection();
}
new C(getConnection()).getData(useData);
function useData(data) {
useData2(data);
}
function useData2(data) {
}
// Test tracking of callback into function
function getDataIndirect(cb) {
new C(getConnection()).getData(cb);
}
getDataIndirect(data => {});
getDataIndirect(); // suppress precision gains from single-call special case
// Test tracking of callback out of function
function getDataCurry() {
return data => {};
}
new C(getConnection()).getData(getDataCurry());
getDataCurry(); // suppress precision gains from single-call special case
// Test call/return matching of callback tracking
function identity(cb) {
return cb;
}
new C(getConnection()).getData(identity(realGetDataCallback));
identity(fakeGetDataCallback);
function realGetDataCallback(data) {} // not found due to missing summarization
function fakeGetDataCallback(notData) {} // should not be found
config.setConfigValue('connection', getConnection());
function getFromConfigFramework() {
let conn = config.getConfigValue('connection');
conn.getData(x => {});
}
function initConnection() {
MyApplication.namespace.connection = api.chain1().chain2().createConnection();
MyApplication.namespace.conflict = api.chain1().chain2().createConnection();
}
function useConnection() {
let conn = MyApplication.namespace.connection;
conn.getData(data => {
useData(data);
});
let conflict = MyApplication.namespace.conflict;
conflict.getData(data => {
useData(data);
});
}
export const exportedConnection = getConnection();
function outer(conn) {
function innerCapture() {
return conn;
}
function innerCall(x) {
return x;
}
innerCapture();
innerCall(conn);
innerCall(somethingElse());
function otherInner() {
innerCapture();
}
return class {
get() { return conn }
}
}
outer(getConnection());
new (outer(getConnection())).get();
new (outer(somethingElse())).get();
function shared(x) {
return (function() {
return x;
})();
}
shared(getConnection());
shared(somethingElse());
function getX(obj) {
return obj.x;
}
getX({ x: getConnection() });
getX({ x: somethingElse() });
function makeConnectionAsync(callback) {
callback(getConnection());
}
makeConnectionAsync(conn => {});
makeConnectionAsync(); // suppress single-call precision gains
function makeConnectionAsync2(callback) {
makeConnectionAsync(callback);
}
makeConnectionAsync2(conn => {});
makeConnectionAsync2(); // suppress single-call precision gains