prepack/test/serializer/pure-functions/ConditionalObjectPartialKey.js
Sebastian Markbage 2334d329d1 Special case conditionals for $DefineOwnProperty, $SetPartial, $GetPartial and $Delete (#2329)
Summary:
Follow up to #2219

This also includes two relevant bonus fixes: 2aa1ad35a4 and e96ac8c0c1
Pull Request resolved: https://github.com/facebook/prepack/pull/2329

Differential Revision: D9033950

Pulled By: sebmarkbage

fbshipit-source-id: b28b608b7449f0bbd7781c7d6aab5717d638d904
2018-07-27 13:56:01 -07:00

39 lines
734 B
JavaScript

let s = global.__abstract ? __abstract("string", "('foo')") : "foo";
function test(c) {
let read = false;
let read2 = false;
let write = false;
let write2 = false;
let knownObj = {
get foo() {
read = true;
return 1;
},
set foo(v) {
write = true;
},
};
let knownObj2 = {
get foo() {
read2 = true;
return 2;
},
set foo(v) {
write2 = true;
},
};
let conditionalObj = c ? knownObj : knownObj2;
conditionalObj[s] = 3;
let value = conditionalObj[s];
return "Value: " + value + " Touched: " + read + " " + read2 + "Written: " + write + " " + write2;
}
if (global.__optimize) {
__optimize(test);
}
inspect = function() {
return test(true);
};