Test cases of resolved issues (#2614)

Summary:
Release Notes: None

Went through optimized functions issues looking for ones that have already been resolved and not closed. These were the only ones I found that didn't have a corresponding PR adding a test case linked from the issue.
Pull Request resolved: https://github.com/facebook/prepack/pull/2614

Differential Revision: D10516188

Pulled By: cblappert

fbshipit-source-id: aaf23d3aa857cc495b804fb1e05c2cb4955fd85f
This commit is contained in:
Chris Blappert 2018-10-23 14:34:48 -07:00 committed by Facebook Github Bot
parent 683bb2a280
commit 217868ba09
2 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,16 @@
(function() {
function f(x) {
this.x = 5 + x;
var self = this;
this.doSomething = function(y) {
return self.x + y;
};
}
if (global.__optimize) __optimize(f);
global.inspect = function() {
var obj = new f(10);
return obj.doSomething(20);
};
})();

View File

@ -0,0 +1,26 @@
var foo;
(function() {
function f() {
let x = 23;
function g() {
x = x + 1;
// x doesn't leak here
}
function h(gg) {
function hh() {
x = x + 1;
}
gg(hh); // leaks x
}
global.__optimize && __optimize(g);
global.__optimize && __optimize(h);
return [g, h];
}
global.__optimize && __optimize(f);
foo = f;
})();
global.inspect = function() {
let [g, h] = foo();
return h(g);
};