Skip to content

Commit 81476cf

Browse files
committed
JS: Expand test case with call/return matching for backtracking
1 parent 3422fa3 commit 81476cf

3 files changed

Lines changed: 48 additions & 0 deletions

File tree

javascript/ql/test/library-tests/TypeTracking/ClassStyle.expected

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,20 @@ test_Connection
77
| tst.js:10:5:10:19 | this.connection |
88
| tst.js:15:10:15:49 | api.cha ... ction() |
99
| tst.js:18:7:18:21 | getConnection() |
10+
| tst.js:30:9:30:23 | getConnection() |
11+
| tst.js:39:7:39:21 | getConnection() |
12+
| tst.js:47:7:47:21 | getConnection() |
1013
test_DataCallback
1114
| tst.js:9:11:9:12 | cb |
1215
| tst.js:20:1:22:1 | functio ... ata);\\n} |
16+
| tst.js:29:26:29:27 | cb |
17+
| tst.js:32:17:32:26 | data => {} |
18+
| tst.js:37:10:37:19 | data => {} |
19+
| tst.js:39:32:39:45 | getDataCurry() |
20+
| tst.js:44:19:44:20 | cb |
21+
| tst.js:47:32:47:60 | identit ... llback) |
1322
test_DataValue
1423
| tst.js:20:18:20:21 | data |
1524
| tst.js:24:19:24:22 | data |
25+
| tst.js:32:17:32:20 | data |
26+
| tst.js:37:10:37:13 | data |

javascript/ql/test/library-tests/TypeTracking/PredicateStyle.expected

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,20 @@ connection
77
| type tracker with call steps | tst.js:10:5:10:19 | this.connection |
88
| type tracker without call steps | tst.js:15:10:15:49 | api.cha ... ction() |
99
| type tracker without call steps | tst.js:18:7:18:21 | getConnection() |
10+
| type tracker without call steps | tst.js:30:9:30:23 | getConnection() |
11+
| type tracker without call steps | tst.js:39:7:39:21 | getConnection() |
12+
| type tracker without call steps | tst.js:47:7:47:21 | getConnection() |
1013
dataCallback
1114
| tst.js:9:11:9:12 | cb |
1215
| tst.js:20:1:22:1 | functio ... ata);\\n} |
16+
| tst.js:29:26:29:27 | cb |
17+
| tst.js:32:17:32:26 | data => {} |
18+
| tst.js:37:10:37:19 | data => {} |
19+
| tst.js:39:32:39:45 | getDataCurry() |
20+
| tst.js:44:19:44:20 | cb |
21+
| tst.js:47:32:47:60 | identit ... llback) |
1322
dataValue
1423
| tst.js:20:18:20:21 | data |
1524
| tst.js:24:19:24:22 | data |
25+
| tst.js:32:17:32:20 | data |
26+
| tst.js:37:10:37:13 | data |

javascript/ql/test/library-tests/TypeTracking/tst.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,29 @@ function useData(data) {
2323

2424
function useData2(data) {
2525
}
26+
27+
28+
// Test tracking of callback into function
29+
function getDataIndirect(cb) {
30+
new C(getConnection()).getData(cb);
31+
}
32+
getDataIndirect(data => {});
33+
getDataIndirect(); // suppress precision gains from single-call special case
34+
35+
// Test tracking of callback out of function
36+
function getDataCurry() {
37+
return data => {};
38+
}
39+
new C(getConnection()).getData(getDataCurry());
40+
getDataCurry(); // suppress precision gains from single-call special case
41+
42+
43+
// Test call/return matching of callback tracking
44+
function identity(cb) {
45+
return cb;
46+
}
47+
new C(getConnection()).getData(identity(realGetDataCallback));
48+
identity(fakeGetDataCallback);
49+
50+
function realGetDataCallback(data) {} // not found due to missing summarization
51+
function fakeGetDataCallback(notData) {} // should not be found

0 commit comments

Comments
 (0)