Skip to content

Commit

Permalink
Merge pull request #15883 from RasmusWL/js-cg-tests
Browse files Browse the repository at this point in the history
JS: show test changes after #15823
  • Loading branch information
RasmusWL authored Mar 19, 2024
2 parents 5ab1047 + c82f5da commit d78efdb
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
21 changes: 21 additions & 0 deletions javascript/ql/test/ApiGraphs/classes/classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,24 @@ MyOtherStream.prototype.instanceProp = 1; /* def=moduleImport("classes").getMemb
MyOtherStream.classProp = 1; /* def=moduleImport("classes").getMember("exports").getMember("MyOtherStream").getMember("classProp") */

module.exports.MyOtherStream = MyOtherStream;


// function-style class without .prototype reference
function MyThirdStream() { /* use=moduleImport("classes").getMember("exports").getMember("MyThirdStream").getInstance() */
}
let instance = new MyThirdStream(); /* use=moduleImport("classes").getMember("exports").getMember("MyThirdStream").getInstance() */

module.exports.MyThirdStream = MyThirdStream;


// function-style class without .prototype reference (through global variable)
(function(f) {
foo.bar = function() { /* use=moduleImport("classes").getMember("exports").getMember("bar").getInstance() */
}
})(foo = foo || {});

(function(f) {
let x = new f.bar(); /* use=moduleImport("classes").getMember("exports").getMember("bar").getInstance() */
})(foo = foo || {});

module.exports.bar = foo.bar;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

27 changes: 27 additions & 0 deletions javascript/ql/test/library-tests/TypeTracking/implicit-receiver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'dummy';

let trackedProp = "implicit-receiver-prop"; // name: implicit-receiver-prop

function factory() {
let obj = unknown(); // name: implicit-receiver-obj
obj.foo = function() {
track(this); // track: implicit-receiver-obj
track(this.x); // track: implicit-receiver-obj track: implicit-receiver-prop
}
return obj;
}
let obj = factory();
obj.x = trackedProp;


function factory2() {
let obj2 = { // name: implicit-receiver-obj2
foo: function() {
track(this); // track: implicit-receiver-obj2
track(this.x); // track: implicit-receiver-obj2 track: implicit-receiver-prop
}
}
return obj2;
}
let obj2 = factory2()
obj2.x = trackedProp;

0 comments on commit d78efdb

Please sign in to comment.