Add a regression test for #2090 (#2281)

Summary:
https://github.com/facebook/prepack/issues/2090 doesn't reproduce for me anymore so I'm adding a test.
Pull Request resolved: https://github.com/facebook/prepack/pull/2281

Differential Revision: D8893196

Pulled By: gaearon

fbshipit-source-id: c0d9748e5898ab8cffa0c6c23dd5db9dadfbf6cc
This commit is contained in:
Dan Abramov 2018-07-18 07:15:55 -07:00 committed by Facebook Github Bot
parent 6cdf42f9e1
commit 3bf79dd693

View File

@ -0,0 +1,35 @@
(function() {
function fn(arg) {
if (arg.foo) {
return "a";
}
if (arg.bar === 0) {
return "b";
}
return Object.assign(
{
qux: function() {
arg.qux();
},
},
arg.baz()
);
}
if (global.__optimize) {
__optimize(fn);
}
global.inspect = function() {
return JSON.stringify([
fn({ foo: 1 }),
fn({ bar: 0 }),
fn({ foo: 1, bar: 0 }),
fn({
baz: function() {
return { a: 42 };
},
}),
]);
};
})();