mirror of
https://github.com/tc39/test262.git
synced 2025-05-03 22:40:28 +02:00
* [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)
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
function assert(a) {
|
|
if (!a)
|
|
throw new Error('Bad assertion');
|
|
}
|
|
|
|
// Check spread ordering without Proxy
|
|
(function () {
|
|
var calls = [];
|
|
var o = { get z() { calls.push('z') }, get a() { calls.push('a') } };
|
|
Object.defineProperty(o, 1, { get: () => { calls.push(1) }, enumerable: true });
|
|
Object.defineProperty(o, Symbol('foo'), { get: () => { calls.push('Symbol(foo)') }, enumerable: true });
|
|
|
|
var obj = {...o};
|
|
|
|
assert(calls[0] === 1);
|
|
assert(calls[1] === 'z');
|
|
assert(calls[2] === 'a');
|
|
assert(calls[3] === 'Symbol(foo)');
|
|
assert(Object.keys(obj).length === 3);
|
|
})();
|
|
|
|
// Check spread ordering with Proxy
|
|
(function () {
|
|
var calls = [];
|
|
var o = { z: 2, a: 3 };
|
|
var fooSymbol = Symbol('foo');
|
|
Object.defineProperty(o, 1, { value: 4, enumerable: true });
|
|
Object.defineProperty(o, fooSymbol, { value: 5, enumerable: true });
|
|
|
|
var p = new Proxy(o, {
|
|
get: function(target, property, receiver) {
|
|
calls.push(property);
|
|
return target[property];
|
|
}
|
|
});
|
|
|
|
var obj = {...p};
|
|
|
|
assert(calls[0] == 1);
|
|
assert(calls[1] == 'z');
|
|
assert(calls[2] == 'a');
|
|
assert(calls[3] === fooSymbol);
|
|
assert(Object.keys(obj).length === 3);
|
|
})();
|
|
|