spread-obj-spread-order.js (1818B)
1 // This file was procedurally generated from the following sources: 2 // - src/spread/obj-spread-order.case 3 // - src/spread/default/array.template 4 /*--- 5 description: Spread operation follows [[OwnPropertyKeys]] order (Array initializer) 6 esid: sec-runtime-semantics-arrayaccumulation 7 features: [Symbol, object-spread] 8 flags: [generated] 9 includes: [compareArray.js] 10 info: | 11 SpreadElement : ...AssignmentExpression 12 13 1. Let spreadRef be the result of evaluating AssignmentExpression. 14 2. Let spreadObj be ? GetValue(spreadRef). 15 3. Let iterator be ? GetIterator(spreadObj). 16 4. Repeat 17 a. Let next be ? IteratorStep(iterator). 18 b. If next is false, return nextIndex. 19 c. Let nextValue be ? IteratorValue(next). 20 d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), 21 nextValue). 22 e. Assert: status is true. 23 f. Let nextIndex be nextIndex + 1. 24 25 Pending Runtime Semantics: PropertyDefinitionEvaluation 26 27 PropertyDefinition:...AssignmentExpression 28 29 1. Let exprValue be the result of evaluating AssignmentExpression. 30 2. Let fromValue be GetValue(exprValue). 31 3. ReturnIfAbrupt(fromValue). 32 4. Let excludedNames be a new empty List. 33 5. Return CopyDataProperties(object, fromValue, excludedNames). 34 35 ---*/ 36 var calls = []; 37 var o = { get z() { calls.push('z') }, get a() { calls.push('a') } }; 38 Object.defineProperty(o, 1, { get: () => { calls.push(1) }, enumerable: true }); 39 Object.defineProperty(o, Symbol('foo'), { get: () => { calls.push("Symbol(foo)") }, enumerable: true }); 40 41 42 var callCount = 0; 43 44 (function(obj) { 45 assert.compareArray(calls, [1, 'z', 'a', "Symbol(foo)"]); 46 assert.sameValue(Object.keys(obj).length, 3); 47 callCount += 1; 48 }.apply(null, [{...o}])); 49 50 assert.sameValue(callCount, 1); 51 52 reportCompare(0, 0);