Skip to content

Commit 6531db3

Browse files
committed
JS: Add test
1 parent b841cac commit 6531db3

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

javascript/ql/test/library-tests/CallGraphs/AnnotatedTest/Test.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ spuriousCallee
22
missingCallee
33
| constructor-field.ts:40:5:40:14 | f3.build() | constructor-field.ts:13:3:13:12 | build() {} | -1 |
44
| constructor-field.ts:71:1:71:11 | bf3.build() | constructor-field.ts:13:3:13:12 | build() {} | -1 |
5+
| returned-function.js:23:1:23:4 | r2() | returned-function.js:8:9:10:9 | functio ... } | -1 |
56
badAnnotation

javascript/ql/test/library-tests/CallGraphs/AnnotatedTest/Test.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ query predicate missingCallee(AnnotatedCall call, AnnotatedFunction target, int
6666

6767
query predicate badAnnotation(string name) {
6868
name = any(AnnotatedCall cl).getCallTargetName() and
69-
not name = any(AnnotatedFunction cl).getCalleeName()
69+
not name = any(AnnotatedFunction cl).getCalleeName() and
70+
name != "NONE"
7071
or
7172
not name = any(AnnotatedCall cl).getCallTargetName() and
7273
name = any(AnnotatedFunction cl).getCalleeName()
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import 'dummy';
2+
3+
/** name:curry1 */
4+
function curry1() {
5+
/** name:curry2 */
6+
function curry2(x) {
7+
/** name:curry3 */
8+
function curry3(y) {
9+
10+
}
11+
return curry3;
12+
}
13+
return curry2;
14+
};
15+
16+
/** calls:curry1 */
17+
let r1 = curry1();
18+
19+
/** calls:curry2 */
20+
let r2 = r1();
21+
22+
/** calls:curry3 */
23+
r2();
24+
25+
function callback(f) {
26+
// Call graph should not include callback invocations.
27+
/** calls:NONE */
28+
f();
29+
}
30+
31+
let w1 = callback(curry1);
32+
callback(() => {});

0 commit comments

Comments
 (0)