Skip to content

Commit c8ee8dc

Browse files
committed
Add test cases to verify correct call graph resolution with various JavaScript inheritance patterns
1 parent 0a9a791 commit c8ee8dc

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ spuriousCallee
22
missingCallee
33
| constructor-field.ts:40:5:40:14 | f3.build() | constructor-field.ts:13:3:13:12 | build() {} | -1 | calls |
44
| constructor-field.ts:71:1:71:11 | bf3.build() | constructor-field.ts:13:3:13:12 | build() {} | -1 | calls |
5+
| prototypes.js:96:5:96:15 | this.read() | prototypes.js:104:27:104:39 | function() {} | -1 | calls |
6+
| prototypes.js:96:5:96:15 | this.read() | prototypes.js:109:27:109:39 | function() {} | -1 | calls |
57
badAnnotation
68
accessorCall
79
| accessors.js:12:1:12:5 | obj.f | accessors.js:5:8:5:12 | () {} |

javascript/ql/test/library-tests/CallGraphs/AnnotatedTest/prototypes.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,21 @@ function barbar(bazExtented){
8989
}
9090

9191
barbar(new BazExtented());
92+
93+
class Base {
94+
constructor() {
95+
/** calls:Base.read calls:Derived1.read calls:Derived2.read */
96+
this.read();
97+
}
98+
/** name:Base.read */
99+
read() { }
100+
}
101+
102+
class Derived1 extends Base {}
103+
/** name:Derived1.read */
104+
Derived1.prototype.read = function() {};
105+
106+
class Derived2 {}
107+
Derived2.prototype = Object.create(Base.prototype);
108+
/** name:Derived2.read */
109+
Derived2.prototype.read = function() {};

0 commit comments

Comments
 (0)