test262-automation e9a5a7f918 [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time) (#1620)
* [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time)
2018-07-03 15:59:58 -04:00

72 lines
1.4 KiB
JavaScript

function assert(x) {
if (!x)
throw "FAIL";
}
(function() {
var trace = [];
var foo = {
value: 5,
get bar() {
trace.push("get");
return this.value;
},
set bar(x) {
throw "Should not be reached";
},
set bar(x) {
trace.push("set2");
this.value = x + 10000;
return this.value;
}
}
assert(foo.value == 5);
assert(trace == "");
assert(foo.bar == 5);
assert(trace == "get");
foo.bar = 20;
assert(trace == "get,set2");
assert(foo.value == 10020);
assert(trace == "get,set2");
assert(foo.bar == 10020);
assert(trace == "get,set2,get");
})();
(function() {
var trace = [];
var foo = {
value: 5,
set bar(x) {
trace.push("set");
this.value = x;
return this.value;
},
get bar() {
throw "Should not be reached";
},
get bar() {
trace.push("get2");
this.value += 10000;
return this.value;
},
}
assert(foo.value == 5);
assert(trace == "");
assert(foo.bar == 10005);
assert(trace == "get2");
foo.bar = 20;
assert(trace == "get2,set");
assert(foo.value == 20);
assert(trace == "get2,set");
assert(foo.bar == 10020);
assert(trace == "get2,set,get2");
})();