diff --git a/test/language/expressions/array/spread-err-mult-err-obj-getter-throws.js b/test/language/expressions/array/spread-err-mult-err-obj-getter-throws.js new file mode 100644 index 0000000000..f75d429857 --- /dev/null +++ b/test/language/expressions/array/spread-err-mult-err-obj-getter-throws.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-err-obj-getter-throws.case +// - src/spread/Error/array.template +/*--- +description: Object Spread operator results in error when there is an getter that throws an exception (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +assert.throws(Test262Error, function() { + [{a: 1, ...{ get foo() { throw new Test262Error(); } }}]; +}); diff --git a/test/language/expressions/array/spread-err-mult-err-obj-unresolvable.js b/test/language/expressions/array/spread-err-mult-err-obj-unresolvable.js new file mode 100644 index 0000000000..765ba4b4e8 --- /dev/null +++ b/test/language/expressions/array/spread-err-mult-err-obj-unresolvable.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-err-obj-unresolvable.case +// - src/spread/error/array.template +/*--- +description: Object Spread operator results in error when using an unresolvable reference (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +assert.throws(ReferenceError, function() { + [{a: 0, ...unresolvableReference}]; +}); diff --git a/test/language/expressions/array/spread-err-sngl-err-obj-getter-throws.js b/test/language/expressions/array/spread-err-sngl-err-obj-getter-throws.js new file mode 100644 index 0000000000..6a648834cf --- /dev/null +++ b/test/language/expressions/array/spread-err-sngl-err-obj-getter-throws.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-obj-getter-throws.case +// - src/spread/error/array.template +/*--- +description: Object Spread operator results in error when there is an getter that throws an exception (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +assert.throws(Test262Error, function() { + [{...{ get foo() { throw new Test262Error(); } }}]; +}); diff --git a/test/language/expressions/array/spread-err-sngl-err-obj-unresolvable.js b/test/language/expressions/array/spread-err-sngl-err-obj-unresolvable.js new file mode 100644 index 0000000000..28171de37d --- /dev/null +++ b/test/language/expressions/array/spread-err-sngl-err-obj-unresolvable.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-obj-unresolvable.case +// - src/spread/error/array.template +/*--- +description: Object Spread operator results in error when using an unresolvable reference (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +assert.throws(ReferenceError, function() { + [{...unresolvableReference}]; +}); diff --git a/test/language/expressions/array/spread-mult-obj-base.js b/test/language/expressions/array/spread-mult-obj-base.js new file mode 100644 index 0000000000..87ed6babb5 --- /dev/null +++ b/test/language/expressions/array/spread-mult-obj-base.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-base.case +// - src/spread/default/array.template +/*--- +description: Object Spread operator following other arguments (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +includes: [propertyHelper.js] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(obj.c, 3); + assert.sameValue(obj.d, 4); + assert.sameValue(Object.keys(obj).length, 4); + + verifyEnumerable(obj, "c"); + verifyWritable(obj, "c"); + verifyConfigurable(obj, "c"); + + verifyEnumerable(obj, "d"); + verifyWritable(obj, "d"); + verifyConfigurable(obj, "d"); + + callCount += 1; +}.apply(null, [{a: 1, b: 2, ...{c: 3, d: 4}}])); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/array/spread-mult-obj-empty.js b/test/language/expressions/array/spread-mult-obj-empty.js new file mode 100644 index 0000000000..934cdc83ba --- /dev/null +++ b/test/language/expressions/array/spread-mult-obj-empty.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-empty.case +// - src/spread/default/array.template +/*--- +description: Object Spread operator following other arguments with empty object (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(Object.keys(obj).length, 2); + callCount += 1; +}.apply(null, [{a: 1, b: 2, ...{}}])); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/array/spread-mult-obj-ident.js b/test/language/expressions/array/spread-mult-obj-ident.js new file mode 100644 index 0000000000..0802f029d7 --- /dev/null +++ b/test/language/expressions/array/spread-mult-obj-ident.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-ident.case +// - src/spread/default/array.template +/*--- +description: Object Spread operator following other properties (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +includes: [propertyHelper.js] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = {c: 3, d: 4}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(obj.c, 3); + assert.sameValue(obj.d, 4); + assert.sameValue(Object.keys(obj).length, 4); + + verifyEnumerable(obj, "a"); + verifyWritable(obj, "a"); + verifyConfigurable(obj, "a"); + + verifyEnumerable(obj, "b"); + verifyWritable(obj, "b"); + verifyConfigurable(obj, "b"); + + verifyEnumerable(obj, "c"); + verifyWritable(obj, "c"); + verifyConfigurable(obj, "c"); + + verifyEnumerable(obj, "d"); + verifyWritable(obj, "d"); + verifyConfigurable(obj, "d"); + callCount += 1; +}.apply(null, [{a: 1, b: 2, ...o}])); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/array/spread-mult-obj-null-empty-undefined.js b/test/language/expressions/array/spread-mult-obj-null-empty-undefined.js new file mode 100644 index 0000000000..b43c6dd306 --- /dev/null +++ b/test/language/expressions/array/spread-mult-obj-null-empty-undefined.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-null-empty-undefined.case +// - src/spread/default/array.template +/*--- +description: Object Spread operator following other arguments with null, undefined and empty object (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +includes: [compareArray.js] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(obj.c, 3); + assert.sameValue(obj.d, 4); + assert(compareArray(Object.keys(obj), ["a", "b", "c", "d"])); + callCount += 1; +}.apply(null, [{a: 1, ...null, b: 2, ...undefined, c: 3, ...{}, ...{...{}}, d: 4}])); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/array/spread-mult-obj-null.js b/test/language/expressions/array/spread-mult-obj-null.js new file mode 100644 index 0000000000..380144d555 --- /dev/null +++ b/test/language/expressions/array/spread-mult-obj-null.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-null.case +// - src/spread/default/array.template +/*--- +description: Object Spread operator following other arguments with null value (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(Object.keys(obj).length, 2); + callCount += 1; +}.apply(null, [{a: 1, b: 2, ...null}])); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/array/spread-mult-obj-undefined.js b/test/language/expressions/array/spread-mult-obj-undefined.js new file mode 100644 index 0000000000..0503740bd6 --- /dev/null +++ b/test/language/expressions/array/spread-mult-obj-undefined.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-undefined.case +// - src/spread/default/array.template +/*--- +description: Object Spread operator following other arguments with undefined (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(Object.keys(obj).length, 2); + callCount += 1; +}.apply(null, [{a: 1, b: 2, ...undefined}])); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/array/spread-obj-getter-descriptor.js b/test/language/expressions/array/spread-obj-getter-descriptor.js new file mode 100644 index 0000000000..fd4b97b6c4 --- /dev/null +++ b/test/language/expressions/array/spread-obj-getter-descriptor.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-getter-descriptor.case +// - src/spread/default/array.template +/*--- +description: Spread operation with getter results in data property descriptor (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +includes: [propertyHelper.js] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = { + get a() { + return 42; + } +}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(Object.getOwnPropertyDescriptor(obj, "a").value, 42); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert.sameValue(Object.keys(obj).length, 3); + + verifyEnumerable(obj, "a"); + verifyWritable(obj, "a"); + verifyConfigurable(obj, "a"); + callCount += 1; +}.apply(null, [{...o, c: 4, d: 5}])); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/array/spread-obj-getter-init.js b/test/language/expressions/array/spread-obj-getter-init.js new file mode 100644 index 0000000000..6e35346864 --- /dev/null +++ b/test/language/expressions/array/spread-obj-getter-init.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-getter-init.case +// - src/spread/default/array.template +/*--- +description: Getter in object literal is not evaluated (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. +---*/ + +let o = {a: 2, b: 3}; +let executedGetter = false; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 2); + assert.sameValue(obj.b, 3); + assert.sameValue(executedGetter, false) + assert.sameValue(Object.keys(obj).length, 3); + callCount += 1; +}.apply(null, [{...o, get c() { executedGetter = true; }}])); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/array/spread-obj-manipulate-outter-obj-in-getter.js b/test/language/expressions/array/spread-obj-manipulate-outter-obj-in-getter.js new file mode 100644 index 0000000000..6d60bf08d3 --- /dev/null +++ b/test/language/expressions/array/spread-obj-manipulate-outter-obj-in-getter.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-manipulate-outter-obj-in-getter.case +// - src/spread/default/array.template +/*--- +description: Getter manipulates outter object before it's spread operation (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +var o = { a: 0, b: 1 }; +var cthulhu = { get x() { + delete o.a; + o.b = 42; + o.c = "ni"; +}}; + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.hasOwnProperty("a"), false); + assert.sameValue(obj.b, 42); + assert.sameValue(obj.c, "ni"); + assert(obj.hasOwnProperty("x")); + assert.sameValue(Object.keys(obj).length, 3); + callCount += 1; +}.apply(null, [{...cthulhu, ...o}])); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/array/spread-obj-mult-spread-getter.js b/test/language/expressions/array/spread-obj-mult-spread-getter.js new file mode 100644 index 0000000000..150075e543 --- /dev/null +++ b/test/language/expressions/array/spread-obj-mult-spread-getter.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-mult-spread-getter.case +// - src/spread/default/array.template +/*--- +description: Multiple Object Spread usage calls getter multiple times (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let getterCallCount = 0; +let o = { + get a() { + return ++getterCallCount; + } +}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 2); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert.sameValue(Object.keys(obj).length, 3); + callCount += 1; +}.apply(null, [{...o, c: 4, d: 5, a: 42, ...o}])); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/array/spread-obj-mult-spread.js b/test/language/expressions/array/spread-obj-mult-spread.js new file mode 100644 index 0000000000..197bc6fa36 --- /dev/null +++ b/test/language/expressions/array/spread-obj-mult-spread.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-mult-spread.case +// - src/spread/default/array.template +/*--- +description: Multiple Object Spread operation (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +let o = {a: 2, b: 3}; +let o2 = {c: 4, d: 5}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 2); + assert.sameValue(obj.b, 3); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert.sameValue(Object.keys(obj).length, 4); + callCount += 1; +}.apply(null, [{...o, ...o2}])); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/array/spread-obj-null.js b/test/language/expressions/array/spread-obj-null.js new file mode 100644 index 0000000000..acc60db0d0 --- /dev/null +++ b/test/language/expressions/array/spread-obj-null.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-null.case +// - src/spread/default/array.template +/*--- +description: Null Object Spread is ignored (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +(function(obj) { + assert.sameValue(Object.keys(obj).length, 0); + callCount += 1; +}.apply(null, [{...null}])); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/array/spread-obj-override-immutable.js b/test/language/expressions/array/spread-obj-override-immutable.js new file mode 100644 index 0000000000..ca47b8e2da --- /dev/null +++ b/test/language/expressions/array/spread-obj-override-immutable.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-override-immutable.case +// - src/spread/default/array.template +/*--- +description: Object Spread overriding immutable properties (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +includes: [propertyHelper.js] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. +---*/ + +let o = {b: 2}; +Object.defineProperty(o, "a", {value: 1, enumerable: true, writable: false, configurable: true}); + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 3) + assert.sameValue(obj.b, 2); + + verifyEnumerable(obj, "a"); + verifyWritable(obj, "a"); + verifyConfigurable(obj, "a"); + + verifyEnumerable(obj, "b"); + verifyWritable(obj, "b"); + verifyConfigurable(obj, "b"); + + callCount += 1; +}.apply(null, [{...o, a: 3}])); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/array/spread-obj-overrides-prev-properties.js b/test/language/expressions/array/spread-obj-overrides-prev-properties.js new file mode 100644 index 0000000000..87df02b346 --- /dev/null +++ b/test/language/expressions/array/spread-obj-overrides-prev-properties.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-overrides-prev-properties.case +// - src/spread/default/array.template +/*--- +description: Object Spread properties overrides previous definitions (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = {a: 2, b: 3}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 2); + assert.sameValue(obj.b, 3); + assert.sameValue(Object.keys(obj).length, 2); + assert.sameValue(o.a, 2); + assert.sameValue(o.b, 3); + callCount += 1; +}.apply(null, [{a: 1, b: 7, ...o}])); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/array/spread-obj-setter-redef.js b/test/language/expressions/array/spread-obj-setter-redef.js new file mode 100644 index 0000000000..7fadcad29a --- /dev/null +++ b/test/language/expressions/array/spread-obj-setter-redef.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-setter-redef.case +// - src/spread/default/array.template +/*--- +description: Setter are not executed when redefined in Object Spread (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. +---*/ +let executedSetter = false; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.c, 1); + assert.sameValue(executedSetter, false); + assert.sameValue(Object.keys(obj).length, 1); + callCount += 1; +}.apply(null, [{set c(v) { executedSetter = true; }, ...{c: 1}}])); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/array/spread-obj-skip-non-enumerable.js b/test/language/expressions/array/spread-obj-skip-non-enumerable.js new file mode 100644 index 0000000000..b2b21a3e64 --- /dev/null +++ b/test/language/expressions/array/spread-obj-skip-non-enumerable.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-skip-non-enumerable.case +// - src/spread/default/array.template +/*--- +description: Object Spread doesn't copy non-enumerable properties (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. +---*/ + +let o = {}; +Object.defineProperty(o, "b", {value: 3, enumerable: false}); + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.hasOwnProperty("b"), false) + assert.sameValue(Object.keys(obj).length, 0); + callCount += 1; +}.apply(null, [{...o}])); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/array/spread-obj-spread-order.js b/test/language/expressions/array/spread-obj-spread-order.js new file mode 100644 index 0000000000..eb873319b0 --- /dev/null +++ b/test/language/expressions/array/spread-obj-spread-order.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-spread-order.case +// - src/spread/default/array.template +/*--- +description: Spread operation follows [[OwnPropertyKeys]] order (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +includes: [compareArray.js] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +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 callCount = 0; + +(function(obj) { + assert(compareArray(calls, [1, 'z', 'a', "Symbol(foo)"])); + assert.sameValue(Object.keys(obj).length, 3); + callCount += 1; +}.apply(null, [{...o}])); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/array/spread-obj-symbol-property.js b/test/language/expressions/array/spread-obj-symbol-property.js new file mode 100644 index 0000000000..8a8cedcebe --- /dev/null +++ b/test/language/expressions/array/spread-obj-symbol-property.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-symbol-property.case +// - src/spread/default/array.template +/*--- +description: Spread operation where source object contains Symbol properties (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let symbol = Symbol('foo'); +let o = {}; +o[symbol] = 1; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj[symbol], 1); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert.sameValue(Object.keys(obj).length, 2); + callCount += 1; +}.apply(null, [{...o, c: 4, d: 5}])); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/array/spread-obj-undefined.js b/test/language/expressions/array/spread-obj-undefined.js new file mode 100644 index 0000000000..e77b0f28bb --- /dev/null +++ b/test/language/expressions/array/spread-obj-undefined.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-undefined.case +// - src/spread/default/array.template +/*--- +description: Undefined Object Spread is ignored (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +(function(obj) { + assert.sameValue(Object.keys(obj).length, 0); + callCount += 1; +}.apply(null, [{...undefined}])); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/array/spread-obj-with-overrides.js b/test/language/expressions/array/spread-obj-with-overrides.js new file mode 100644 index 0000000000..9b668c1877 --- /dev/null +++ b/test/language/expressions/array/spread-obj-with-overrides.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-with-overrides.case +// - src/spread/default/array.template +/*--- +description: Object Spread properties being overriden (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = {a: 2, b: 3, c: 4, e: undefined, f: null, g: false}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 7); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert(obj.hasOwnProperty("e")); + assert.sameValue(obj.f, null); + assert.sameValue(obj.g, false); + assert.sameValue(obj.h, -0); + assert.sameValue(obj.i.toString(), "Symbol(foo)"); + assert(Object.is(obj.j, o)); + assert.sameValue(Object.keys(obj).length, 10); + callCount += 1; +}.apply(null, [{...o, a: 1, b: 7, d: 5, h: -0, i: Symbol("foo"), j: o}])); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/array/spread-sngl-obj-base.js b/test/language/expressions/array/spread-sngl-obj-base.js new file mode 100644 index 0000000000..c52a2bdccd --- /dev/null +++ b/test/language/expressions/array/spread-sngl-obj-base.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-obj-base.case +// - src/spread/default/array.template +/*--- +description: Object Spread operator without other arguments (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +includes: [propertyHelper.js] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.c, 3); + assert.sameValue(obj.d, 4); + assert.sameValue(Object.keys(obj).length, 2); + + verifyEnumerable(obj, "c"); + verifyWritable(obj, "c"); + verifyConfigurable(obj, "c"); + + verifyEnumerable(obj, "d"); + verifyWritable(obj, "d"); + verifyConfigurable(obj, "d"); + callCount += 1; +}.apply(null, [{...{c: 3, d: 4}}])); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/array/spread-sngl-obj-empty.js b/test/language/expressions/array/spread-sngl-obj-empty.js new file mode 100644 index 0000000000..7f10f7fba6 --- /dev/null +++ b/test/language/expressions/array/spread-sngl-obj-empty.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-obj-empty.case +// - src/spread/default/array.template +/*--- +description: Object Spread operator on a single empty object (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +(function(obj) { + assert.sameValue(Object.keys(obj).length, 0); + callCount += 1; +}.apply(null, [{...{}}])); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/array/spread-sngl-obj-ident.js b/test/language/expressions/array/spread-sngl-obj-ident.js new file mode 100644 index 0000000000..95dfa3d529 --- /dev/null +++ b/test/language/expressions/array/spread-sngl-obj-ident.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-obj-ident.case +// - src/spread/default/array.template +/*--- +description: Object Spread operator without other arguments (Array initializer) +esid: sec-runtime-semantics-arrayaccumulation +es6id: 12.2.5.2 +flags: [generated] +includes: [propertyHelper.js] +info: | + SpreadElement : ...AssignmentExpression + + 1. Let spreadRef be the result of evaluating AssignmentExpression. + 2. Let spreadObj be ? GetValue(spreadRef). + 3. Let iterator be ? GetIterator(spreadObj). + 4. Repeat + a. Let next be ? IteratorStep(iterator). + b. If next is false, return nextIndex. + c. Let nextValue be ? IteratorValue(next). + d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), + nextValue). + e. Assert: status is true. + f. Let nextIndex be nextIndex + 1. + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = {c: 3, d: 4}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.c, 3); + assert.sameValue(obj.d, 4); + assert.sameValue(Object.keys(obj).length, 2); + + verifyEnumerable(obj, "c"); + verifyWritable(obj, "c"); + verifyConfigurable(obj, "c"); + + verifyEnumerable(obj, "d"); + verifyWritable(obj, "d"); + verifyConfigurable(obj, "d"); + callCount += 1; +}.apply(null, [{...o}])); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-err-mult-err-obj-getter-throws.js b/test/language/expressions/call/spread-err-mult-err-obj-getter-throws.js new file mode 100644 index 0000000000..774ec3a58b --- /dev/null +++ b/test/language/expressions/call/spread-err-mult-err-obj-getter-throws.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-err-obj-getter-throws.case +// - src/spread/Error/call-expr.template +/*--- +description: Object Spread operator results in error when there is an getter that throws an exception (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +assert.throws(Test262Error, function() { + (function() {}({a: 1, ...{ get foo() { throw new Test262Error(); } }})); +}); diff --git a/test/language/expressions/call/spread-err-mult-err-obj-unresolvable.js b/test/language/expressions/call/spread-err-mult-err-obj-unresolvable.js new file mode 100644 index 0000000000..68ad324e9c --- /dev/null +++ b/test/language/expressions/call/spread-err-mult-err-obj-unresolvable.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-err-obj-unresolvable.case +// - src/spread/error/call-expr.template +/*--- +description: Object Spread operator results in error when using an unresolvable reference (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +assert.throws(ReferenceError, function() { + (function() {}({a: 0, ...unresolvableReference})); +}); diff --git a/test/language/expressions/call/spread-err-sngl-err-obj-getter-throws.js b/test/language/expressions/call/spread-err-sngl-err-obj-getter-throws.js new file mode 100644 index 0000000000..b5a746063a --- /dev/null +++ b/test/language/expressions/call/spread-err-sngl-err-obj-getter-throws.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-obj-getter-throws.case +// - src/spread/error/call-expr.template +/*--- +description: Object Spread operator results in error when there is an getter that throws an exception (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +assert.throws(Test262Error, function() { + (function() {}({...{ get foo() { throw new Test262Error(); } }})); +}); diff --git a/test/language/expressions/call/spread-err-sngl-err-obj-unresolvable.js b/test/language/expressions/call/spread-err-sngl-err-obj-unresolvable.js new file mode 100644 index 0000000000..87b4cce0a0 --- /dev/null +++ b/test/language/expressions/call/spread-err-sngl-err-obj-unresolvable.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-obj-unresolvable.case +// - src/spread/error/call-expr.template +/*--- +description: Object Spread operator results in error when using an unresolvable reference (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +assert.throws(ReferenceError, function() { + (function() {}({...unresolvableReference})); +}); diff --git a/test/language/expressions/call/spread-mult-obj-base.js b/test/language/expressions/call/spread-mult-obj-base.js new file mode 100644 index 0000000000..b62eeca875 --- /dev/null +++ b/test/language/expressions/call/spread-mult-obj-base.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-base.case +// - src/spread/default/call-expr.template +/*--- +description: Object Spread operator following other arguments (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +includes: [propertyHelper.js] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(obj.c, 3); + assert.sameValue(obj.d, 4); + assert.sameValue(Object.keys(obj).length, 4); + + verifyEnumerable(obj, "c"); + verifyWritable(obj, "c"); + verifyConfigurable(obj, "c"); + + verifyEnumerable(obj, "d"); + verifyWritable(obj, "d"); + verifyConfigurable(obj, "d"); + + callCount += 1; +}({a: 1, b: 2, ...{c: 3, d: 4}})); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-mult-obj-empty.js b/test/language/expressions/call/spread-mult-obj-empty.js new file mode 100644 index 0000000000..f2318e12a9 --- /dev/null +++ b/test/language/expressions/call/spread-mult-obj-empty.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-empty.case +// - src/spread/default/call-expr.template +/*--- +description: Object Spread operator following other arguments with empty object (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(Object.keys(obj).length, 2); + callCount += 1; +}({a: 1, b: 2, ...{}})); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-mult-obj-ident.js b/test/language/expressions/call/spread-mult-obj-ident.js new file mode 100644 index 0000000000..5e3b30bef6 --- /dev/null +++ b/test/language/expressions/call/spread-mult-obj-ident.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-ident.case +// - src/spread/default/call-expr.template +/*--- +description: Object Spread operator following other properties (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +includes: [propertyHelper.js] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = {c: 3, d: 4}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(obj.c, 3); + assert.sameValue(obj.d, 4); + assert.sameValue(Object.keys(obj).length, 4); + + verifyEnumerable(obj, "a"); + verifyWritable(obj, "a"); + verifyConfigurable(obj, "a"); + + verifyEnumerable(obj, "b"); + verifyWritable(obj, "b"); + verifyConfigurable(obj, "b"); + + verifyEnumerable(obj, "c"); + verifyWritable(obj, "c"); + verifyConfigurable(obj, "c"); + + verifyEnumerable(obj, "d"); + verifyWritable(obj, "d"); + verifyConfigurable(obj, "d"); + callCount += 1; +}({a: 1, b: 2, ...o})); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-mult-obj-null-empty-undefined.js b/test/language/expressions/call/spread-mult-obj-null-empty-undefined.js new file mode 100644 index 0000000000..d54b4ecbdf --- /dev/null +++ b/test/language/expressions/call/spread-mult-obj-null-empty-undefined.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-null-empty-undefined.case +// - src/spread/default/call-expr.template +/*--- +description: Object Spread operator following other arguments with null, undefined and empty object (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +includes: [compareArray.js] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(obj.c, 3); + assert.sameValue(obj.d, 4); + assert(compareArray(Object.keys(obj), ["a", "b", "c", "d"])); + callCount += 1; +}({a: 1, ...null, b: 2, ...undefined, c: 3, ...{}, ...{...{}}, d: 4})); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-mult-obj-null.js b/test/language/expressions/call/spread-mult-obj-null.js new file mode 100644 index 0000000000..b51d799c7b --- /dev/null +++ b/test/language/expressions/call/spread-mult-obj-null.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-null.case +// - src/spread/default/call-expr.template +/*--- +description: Object Spread operator following other arguments with null value (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(Object.keys(obj).length, 2); + callCount += 1; +}({a: 1, b: 2, ...null})); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-mult-obj-undefined.js b/test/language/expressions/call/spread-mult-obj-undefined.js new file mode 100644 index 0000000000..f0b835fd50 --- /dev/null +++ b/test/language/expressions/call/spread-mult-obj-undefined.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-undefined.case +// - src/spread/default/call-expr.template +/*--- +description: Object Spread operator following other arguments with undefined (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(Object.keys(obj).length, 2); + callCount += 1; +}({a: 1, b: 2, ...undefined})); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-obj-getter-descriptor.js b/test/language/expressions/call/spread-obj-getter-descriptor.js new file mode 100644 index 0000000000..f5419982e3 --- /dev/null +++ b/test/language/expressions/call/spread-obj-getter-descriptor.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-getter-descriptor.case +// - src/spread/default/call-expr.template +/*--- +description: Spread operation with getter results in data property descriptor (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +includes: [propertyHelper.js] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = { + get a() { + return 42; + } +}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(Object.getOwnPropertyDescriptor(obj, "a").value, 42); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert.sameValue(Object.keys(obj).length, 3); + + verifyEnumerable(obj, "a"); + verifyWritable(obj, "a"); + verifyConfigurable(obj, "a"); + callCount += 1; +}({...o, c: 4, d: 5})); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-obj-getter-init.js b/test/language/expressions/call/spread-obj-getter-init.js new file mode 100644 index 0000000000..9c4941bafb --- /dev/null +++ b/test/language/expressions/call/spread-obj-getter-init.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-getter-init.case +// - src/spread/default/call-expr.template +/*--- +description: Getter in object literal is not evaluated (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] +---*/ + +let o = {a: 2, b: 3}; +let executedGetter = false; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 2); + assert.sameValue(obj.b, 3); + assert.sameValue(executedGetter, false) + assert.sameValue(Object.keys(obj).length, 3); + callCount += 1; +}({...o, get c() { executedGetter = true; }})); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-obj-manipulate-outter-obj-in-getter.js b/test/language/expressions/call/spread-obj-manipulate-outter-obj-in-getter.js new file mode 100644 index 0000000000..d16478264b --- /dev/null +++ b/test/language/expressions/call/spread-obj-manipulate-outter-obj-in-getter.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-manipulate-outter-obj-in-getter.case +// - src/spread/default/call-expr.template +/*--- +description: Getter manipulates outter object before it's spread operation (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +var o = { a: 0, b: 1 }; +var cthulhu = { get x() { + delete o.a; + o.b = 42; + o.c = "ni"; +}}; + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.hasOwnProperty("a"), false); + assert.sameValue(obj.b, 42); + assert.sameValue(obj.c, "ni"); + assert(obj.hasOwnProperty("x")); + assert.sameValue(Object.keys(obj).length, 3); + callCount += 1; +}({...cthulhu, ...o})); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-obj-mult-spread-getter.js b/test/language/expressions/call/spread-obj-mult-spread-getter.js new file mode 100644 index 0000000000..c41381978a --- /dev/null +++ b/test/language/expressions/call/spread-obj-mult-spread-getter.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-mult-spread-getter.case +// - src/spread/default/call-expr.template +/*--- +description: Multiple Object Spread usage calls getter multiple times (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let getterCallCount = 0; +let o = { + get a() { + return ++getterCallCount; + } +}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 2); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert.sameValue(Object.keys(obj).length, 3); + callCount += 1; +}({...o, c: 4, d: 5, a: 42, ...o})); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-obj-mult-spread.js b/test/language/expressions/call/spread-obj-mult-spread.js new file mode 100644 index 0000000000..e933c1b981 --- /dev/null +++ b/test/language/expressions/call/spread-obj-mult-spread.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-mult-spread.case +// - src/spread/default/call-expr.template +/*--- +description: Multiple Object Spread operation (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +let o = {a: 2, b: 3}; +let o2 = {c: 4, d: 5}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 2); + assert.sameValue(obj.b, 3); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert.sameValue(Object.keys(obj).length, 4); + callCount += 1; +}({...o, ...o2})); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-obj-null.js b/test/language/expressions/call/spread-obj-null.js new file mode 100644 index 0000000000..73e9d19140 --- /dev/null +++ b/test/language/expressions/call/spread-obj-null.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-null.case +// - src/spread/default/call-expr.template +/*--- +description: Null Object Spread is ignored (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +(function(obj) { + assert.sameValue(Object.keys(obj).length, 0); + callCount += 1; +}({...null})); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-obj-override-immutable.js b/test/language/expressions/call/spread-obj-override-immutable.js new file mode 100644 index 0000000000..51553ff041 --- /dev/null +++ b/test/language/expressions/call/spread-obj-override-immutable.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-override-immutable.case +// - src/spread/default/call-expr.template +/*--- +description: Object Spread overriding immutable properties (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +includes: [propertyHelper.js] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] +---*/ + +let o = {b: 2}; +Object.defineProperty(o, "a", {value: 1, enumerable: true, writable: false, configurable: true}); + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 3) + assert.sameValue(obj.b, 2); + + verifyEnumerable(obj, "a"); + verifyWritable(obj, "a"); + verifyConfigurable(obj, "a"); + + verifyEnumerable(obj, "b"); + verifyWritable(obj, "b"); + verifyConfigurable(obj, "b"); + + callCount += 1; +}({...o, a: 3})); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-obj-overrides-prev-properties.js b/test/language/expressions/call/spread-obj-overrides-prev-properties.js new file mode 100644 index 0000000000..eac8ab50f0 --- /dev/null +++ b/test/language/expressions/call/spread-obj-overrides-prev-properties.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-overrides-prev-properties.case +// - src/spread/default/call-expr.template +/*--- +description: Object Spread properties overrides previous definitions (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = {a: 2, b: 3}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 2); + assert.sameValue(obj.b, 3); + assert.sameValue(Object.keys(obj).length, 2); + assert.sameValue(o.a, 2); + assert.sameValue(o.b, 3); + callCount += 1; +}({a: 1, b: 7, ...o})); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-obj-setter-redef.js b/test/language/expressions/call/spread-obj-setter-redef.js new file mode 100644 index 0000000000..b14a129ef5 --- /dev/null +++ b/test/language/expressions/call/spread-obj-setter-redef.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-setter-redef.case +// - src/spread/default/call-expr.template +/*--- +description: Setter are not executed when redefined in Object Spread (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] +---*/ +let executedSetter = false; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.c, 1); + assert.sameValue(executedSetter, false); + assert.sameValue(Object.keys(obj).length, 1); + callCount += 1; +}({set c(v) { executedSetter = true; }, ...{c: 1}})); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-obj-skip-non-enumerable.js b/test/language/expressions/call/spread-obj-skip-non-enumerable.js new file mode 100644 index 0000000000..dafc8a5a27 --- /dev/null +++ b/test/language/expressions/call/spread-obj-skip-non-enumerable.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-skip-non-enumerable.case +// - src/spread/default/call-expr.template +/*--- +description: Object Spread doesn't copy non-enumerable properties (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] +---*/ + +let o = {}; +Object.defineProperty(o, "b", {value: 3, enumerable: false}); + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.hasOwnProperty("b"), false) + assert.sameValue(Object.keys(obj).length, 0); + callCount += 1; +}({...o})); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-obj-spread-order.js b/test/language/expressions/call/spread-obj-spread-order.js new file mode 100644 index 0000000000..f59c095261 --- /dev/null +++ b/test/language/expressions/call/spread-obj-spread-order.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-spread-order.case +// - src/spread/default/call-expr.template +/*--- +description: Spread operation follows [[OwnPropertyKeys]] order (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +includes: [compareArray.js] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +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 callCount = 0; + +(function(obj) { + assert(compareArray(calls, [1, 'z', 'a', "Symbol(foo)"])); + assert.sameValue(Object.keys(obj).length, 3); + callCount += 1; +}({...o})); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-obj-symbol-property.js b/test/language/expressions/call/spread-obj-symbol-property.js new file mode 100644 index 0000000000..9a26e67f60 --- /dev/null +++ b/test/language/expressions/call/spread-obj-symbol-property.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-symbol-property.case +// - src/spread/default/call-expr.template +/*--- +description: Spread operation where source object contains Symbol properties (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let symbol = Symbol('foo'); +let o = {}; +o[symbol] = 1; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj[symbol], 1); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert.sameValue(Object.keys(obj).length, 2); + callCount += 1; +}({...o, c: 4, d: 5})); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-obj-undefined.js b/test/language/expressions/call/spread-obj-undefined.js new file mode 100644 index 0000000000..cbd4ab4011 --- /dev/null +++ b/test/language/expressions/call/spread-obj-undefined.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-undefined.case +// - src/spread/default/call-expr.template +/*--- +description: Undefined Object Spread is ignored (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +(function(obj) { + assert.sameValue(Object.keys(obj).length, 0); + callCount += 1; +}({...undefined})); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-obj-with-overrides.js b/test/language/expressions/call/spread-obj-with-overrides.js new file mode 100644 index 0000000000..8666ca3118 --- /dev/null +++ b/test/language/expressions/call/spread-obj-with-overrides.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-with-overrides.case +// - src/spread/default/call-expr.template +/*--- +description: Object Spread properties being overriden (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = {a: 2, b: 3, c: 4, e: undefined, f: null, g: false}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 7); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert(obj.hasOwnProperty("e")); + assert.sameValue(obj.f, null); + assert.sameValue(obj.g, false); + assert.sameValue(obj.h, -0); + assert.sameValue(obj.i.toString(), "Symbol(foo)"); + assert(Object.is(obj.j, o)); + assert.sameValue(Object.keys(obj).length, 10); + callCount += 1; +}({...o, a: 1, b: 7, d: 5, h: -0, i: Symbol("foo"), j: o})); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-sngl-obj-base.js b/test/language/expressions/call/spread-sngl-obj-base.js new file mode 100644 index 0000000000..39b8e68092 --- /dev/null +++ b/test/language/expressions/call/spread-sngl-obj-base.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-obj-base.case +// - src/spread/default/call-expr.template +/*--- +description: Object Spread operator without other arguments (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +includes: [propertyHelper.js] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.c, 3); + assert.sameValue(obj.d, 4); + assert.sameValue(Object.keys(obj).length, 2); + + verifyEnumerable(obj, "c"); + verifyWritable(obj, "c"); + verifyConfigurable(obj, "c"); + + verifyEnumerable(obj, "d"); + verifyWritable(obj, "d"); + verifyConfigurable(obj, "d"); + callCount += 1; +}({...{c: 3, d: 4}})); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-sngl-obj-empty.js b/test/language/expressions/call/spread-sngl-obj-empty.js new file mode 100644 index 0000000000..15a17d8b70 --- /dev/null +++ b/test/language/expressions/call/spread-sngl-obj-empty.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-obj-empty.case +// - src/spread/default/call-expr.template +/*--- +description: Object Spread operator on a single empty object (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +(function(obj) { + assert.sameValue(Object.keys(obj).length, 0); + callCount += 1; +}({...{}})); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-sngl-obj-ident.js b/test/language/expressions/call/spread-sngl-obj-ident.js new file mode 100644 index 0000000000..d4d471d903 --- /dev/null +++ b/test/language/expressions/call/spread-sngl-obj-ident.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-obj-ident.case +// - src/spread/default/call-expr.template +/*--- +description: Object Spread operator without other arguments (CallExpression) +esid: sec-function-calls-runtime-semantics-evaluation +es6id: 12.3.4.1 +flags: [generated] +includes: [propertyHelper.js] +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = {c: 3, d: 4}; + + +var callCount = 0; + +(function(obj) { + assert.sameValue(obj.c, 3); + assert.sameValue(obj.d, 4); + assert.sameValue(Object.keys(obj).length, 2); + + verifyEnumerable(obj, "c"); + verifyWritable(obj, "c"); + verifyConfigurable(obj, "c"); + + verifyEnumerable(obj, "d"); + verifyWritable(obj, "d"); + verifyConfigurable(obj, "d"); + callCount += 1; +}({...o})); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-err-mult-err-obj-getter-throws.js b/test/language/expressions/new/spread-err-mult-err-obj-getter-throws.js new file mode 100644 index 0000000000..51d3087242 --- /dev/null +++ b/test/language/expressions/new/spread-err-mult-err-obj-getter-throws.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-err-obj-getter-throws.case +// - src/spread/Error/member-expr.template +/*--- +description: Object Spread operator results in error when there is an getter that throws an exception (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +assert.throws(Test262Error, function() { + new function() {}({a: 1, ...{ get foo() { throw new Test262Error(); } }}); +}); diff --git a/test/language/expressions/new/spread-err-mult-err-obj-unresolvable.js b/test/language/expressions/new/spread-err-mult-err-obj-unresolvable.js new file mode 100644 index 0000000000..6a6a52f89a --- /dev/null +++ b/test/language/expressions/new/spread-err-mult-err-obj-unresolvable.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-err-obj-unresolvable.case +// - src/spread/error/member-expr.template +/*--- +description: Object Spread operator results in error when using an unresolvable reference (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +assert.throws(ReferenceError, function() { + new function() {}({a: 0, ...unresolvableReference}); +}); diff --git a/test/language/expressions/new/spread-err-sngl-err-obj-getter-throws.js b/test/language/expressions/new/spread-err-sngl-err-obj-getter-throws.js new file mode 100644 index 0000000000..5e0050bfe2 --- /dev/null +++ b/test/language/expressions/new/spread-err-sngl-err-obj-getter-throws.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-obj-getter-throws.case +// - src/spread/error/member-expr.template +/*--- +description: Object Spread operator results in error when there is an getter that throws an exception (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +assert.throws(Test262Error, function() { + new function() {}({...{ get foo() { throw new Test262Error(); } }}); +}); diff --git a/test/language/expressions/new/spread-err-sngl-err-obj-unresolvable.js b/test/language/expressions/new/spread-err-sngl-err-obj-unresolvable.js new file mode 100644 index 0000000000..9fa533c2d1 --- /dev/null +++ b/test/language/expressions/new/spread-err-sngl-err-obj-unresolvable.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-obj-unresolvable.case +// - src/spread/error/member-expr.template +/*--- +description: Object Spread operator results in error when using an unresolvable reference (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +assert.throws(ReferenceError, function() { + new function() {}({...unresolvableReference}); +}); diff --git a/test/language/expressions/new/spread-mult-obj-base.js b/test/language/expressions/new/spread-mult-obj-base.js new file mode 100644 index 0000000000..05778b29f3 --- /dev/null +++ b/test/language/expressions/new/spread-mult-obj-base.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-base.case +// - src/spread/default/member-expr.template +/*--- +description: Object Spread operator following other arguments (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +includes: [propertyHelper.js] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +new function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(obj.c, 3); + assert.sameValue(obj.d, 4); + assert.sameValue(Object.keys(obj).length, 4); + + verifyEnumerable(obj, "c"); + verifyWritable(obj, "c"); + verifyConfigurable(obj, "c"); + + verifyEnumerable(obj, "d"); + verifyWritable(obj, "d"); + verifyConfigurable(obj, "d"); + + callCount += 1; +}({a: 1, b: 2, ...{c: 3, d: 4}}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-mult-obj-empty.js b/test/language/expressions/new/spread-mult-obj-empty.js new file mode 100644 index 0000000000..4ef1166f33 --- /dev/null +++ b/test/language/expressions/new/spread-mult-obj-empty.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-empty.case +// - src/spread/default/member-expr.template +/*--- +description: Object Spread operator following other arguments with empty object (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +new function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(Object.keys(obj).length, 2); + callCount += 1; +}({a: 1, b: 2, ...{}}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-mult-obj-ident.js b/test/language/expressions/new/spread-mult-obj-ident.js new file mode 100644 index 0000000000..af240b4d50 --- /dev/null +++ b/test/language/expressions/new/spread-mult-obj-ident.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-ident.case +// - src/spread/default/member-expr.template +/*--- +description: Object Spread operator following other properties (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +includes: [propertyHelper.js] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = {c: 3, d: 4}; + + +var callCount = 0; + +new function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(obj.c, 3); + assert.sameValue(obj.d, 4); + assert.sameValue(Object.keys(obj).length, 4); + + verifyEnumerable(obj, "a"); + verifyWritable(obj, "a"); + verifyConfigurable(obj, "a"); + + verifyEnumerable(obj, "b"); + verifyWritable(obj, "b"); + verifyConfigurable(obj, "b"); + + verifyEnumerable(obj, "c"); + verifyWritable(obj, "c"); + verifyConfigurable(obj, "c"); + + verifyEnumerable(obj, "d"); + verifyWritable(obj, "d"); + verifyConfigurable(obj, "d"); + callCount += 1; +}({a: 1, b: 2, ...o}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-mult-obj-null-empty-undefined.js b/test/language/expressions/new/spread-mult-obj-null-empty-undefined.js new file mode 100644 index 0000000000..7973599b31 --- /dev/null +++ b/test/language/expressions/new/spread-mult-obj-null-empty-undefined.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-null-empty-undefined.case +// - src/spread/default/member-expr.template +/*--- +description: Object Spread operator following other arguments with null, undefined and empty object (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +includes: [compareArray.js] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +new function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(obj.c, 3); + assert.sameValue(obj.d, 4); + assert(compareArray(Object.keys(obj), ["a", "b", "c", "d"])); + callCount += 1; +}({a: 1, ...null, b: 2, ...undefined, c: 3, ...{}, ...{...{}}, d: 4}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-mult-obj-null.js b/test/language/expressions/new/spread-mult-obj-null.js new file mode 100644 index 0000000000..65513d1704 --- /dev/null +++ b/test/language/expressions/new/spread-mult-obj-null.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-null.case +// - src/spread/default/member-expr.template +/*--- +description: Object Spread operator following other arguments with null value (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +new function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(Object.keys(obj).length, 2); + callCount += 1; +}({a: 1, b: 2, ...null}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-mult-obj-undefined.js b/test/language/expressions/new/spread-mult-obj-undefined.js new file mode 100644 index 0000000000..e0607b791c --- /dev/null +++ b/test/language/expressions/new/spread-mult-obj-undefined.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-undefined.case +// - src/spread/default/member-expr.template +/*--- +description: Object Spread operator following other arguments with undefined (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +new function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(Object.keys(obj).length, 2); + callCount += 1; +}({a: 1, b: 2, ...undefined}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-obj-getter-descriptor.js b/test/language/expressions/new/spread-obj-getter-descriptor.js new file mode 100644 index 0000000000..851fccd23e --- /dev/null +++ b/test/language/expressions/new/spread-obj-getter-descriptor.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-getter-descriptor.case +// - src/spread/default/member-expr.template +/*--- +description: Spread operation with getter results in data property descriptor (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +includes: [propertyHelper.js] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = { + get a() { + return 42; + } +}; + + +var callCount = 0; + +new function(obj) { + assert.sameValue(Object.getOwnPropertyDescriptor(obj, "a").value, 42); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert.sameValue(Object.keys(obj).length, 3); + + verifyEnumerable(obj, "a"); + verifyWritable(obj, "a"); + verifyConfigurable(obj, "a"); + callCount += 1; +}({...o, c: 4, d: 5}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-obj-getter-init.js b/test/language/expressions/new/spread-obj-getter-init.js new file mode 100644 index 0000000000..90e6c169be --- /dev/null +++ b/test/language/expressions/new/spread-obj-getter-init.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-getter-init.case +// - src/spread/default/member-expr.template +/*--- +description: Getter in object literal is not evaluated (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] +---*/ + +let o = {a: 2, b: 3}; +let executedGetter = false; + + +var callCount = 0; + +new function(obj) { + assert.sameValue(obj.a, 2); + assert.sameValue(obj.b, 3); + assert.sameValue(executedGetter, false) + assert.sameValue(Object.keys(obj).length, 3); + callCount += 1; +}({...o, get c() { executedGetter = true; }}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-obj-manipulate-outter-obj-in-getter.js b/test/language/expressions/new/spread-obj-manipulate-outter-obj-in-getter.js new file mode 100644 index 0000000000..f2f0c59c99 --- /dev/null +++ b/test/language/expressions/new/spread-obj-manipulate-outter-obj-in-getter.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-manipulate-outter-obj-in-getter.case +// - src/spread/default/member-expr.template +/*--- +description: Getter manipulates outter object before it's spread operation (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +var o = { a: 0, b: 1 }; +var cthulhu = { get x() { + delete o.a; + o.b = 42; + o.c = "ni"; +}}; + +var callCount = 0; + +new function(obj) { + assert.sameValue(obj.hasOwnProperty("a"), false); + assert.sameValue(obj.b, 42); + assert.sameValue(obj.c, "ni"); + assert(obj.hasOwnProperty("x")); + assert.sameValue(Object.keys(obj).length, 3); + callCount += 1; +}({...cthulhu, ...o}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-obj-mult-spread-getter.js b/test/language/expressions/new/spread-obj-mult-spread-getter.js new file mode 100644 index 0000000000..9b883d4fc3 --- /dev/null +++ b/test/language/expressions/new/spread-obj-mult-spread-getter.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-mult-spread-getter.case +// - src/spread/default/member-expr.template +/*--- +description: Multiple Object Spread usage calls getter multiple times (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let getterCallCount = 0; +let o = { + get a() { + return ++getterCallCount; + } +}; + + +var callCount = 0; + +new function(obj) { + assert.sameValue(obj.a, 2); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert.sameValue(Object.keys(obj).length, 3); + callCount += 1; +}({...o, c: 4, d: 5, a: 42, ...o}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-obj-mult-spread.js b/test/language/expressions/new/spread-obj-mult-spread.js new file mode 100644 index 0000000000..1db6e76e27 --- /dev/null +++ b/test/language/expressions/new/spread-obj-mult-spread.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-mult-spread.case +// - src/spread/default/member-expr.template +/*--- +description: Multiple Object Spread operation (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +let o = {a: 2, b: 3}; +let o2 = {c: 4, d: 5}; + + +var callCount = 0; + +new function(obj) { + assert.sameValue(obj.a, 2); + assert.sameValue(obj.b, 3); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert.sameValue(Object.keys(obj).length, 4); + callCount += 1; +}({...o, ...o2}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-obj-null.js b/test/language/expressions/new/spread-obj-null.js new file mode 100644 index 0000000000..56bb19d8ca --- /dev/null +++ b/test/language/expressions/new/spread-obj-null.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-null.case +// - src/spread/default/member-expr.template +/*--- +description: Null Object Spread is ignored (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +new function(obj) { + assert.sameValue(Object.keys(obj).length, 0); + callCount += 1; +}({...null}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-obj-override-immutable.js b/test/language/expressions/new/spread-obj-override-immutable.js new file mode 100644 index 0000000000..8499b07fcd --- /dev/null +++ b/test/language/expressions/new/spread-obj-override-immutable.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-override-immutable.case +// - src/spread/default/member-expr.template +/*--- +description: Object Spread overriding immutable properties (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +includes: [propertyHelper.js] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] +---*/ + +let o = {b: 2}; +Object.defineProperty(o, "a", {value: 1, enumerable: true, writable: false, configurable: true}); + + +var callCount = 0; + +new function(obj) { + assert.sameValue(obj.a, 3) + assert.sameValue(obj.b, 2); + + verifyEnumerable(obj, "a"); + verifyWritable(obj, "a"); + verifyConfigurable(obj, "a"); + + verifyEnumerable(obj, "b"); + verifyWritable(obj, "b"); + verifyConfigurable(obj, "b"); + + callCount += 1; +}({...o, a: 3}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-obj-overrides-prev-properties.js b/test/language/expressions/new/spread-obj-overrides-prev-properties.js new file mode 100644 index 0000000000..66db35815f --- /dev/null +++ b/test/language/expressions/new/spread-obj-overrides-prev-properties.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-overrides-prev-properties.case +// - src/spread/default/member-expr.template +/*--- +description: Object Spread properties overrides previous definitions (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = {a: 2, b: 3}; + + +var callCount = 0; + +new function(obj) { + assert.sameValue(obj.a, 2); + assert.sameValue(obj.b, 3); + assert.sameValue(Object.keys(obj).length, 2); + assert.sameValue(o.a, 2); + assert.sameValue(o.b, 3); + callCount += 1; +}({a: 1, b: 7, ...o}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-obj-setter-redef.js b/test/language/expressions/new/spread-obj-setter-redef.js new file mode 100644 index 0000000000..8fcc64fe41 --- /dev/null +++ b/test/language/expressions/new/spread-obj-setter-redef.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-setter-redef.case +// - src/spread/default/member-expr.template +/*--- +description: Setter are not executed when redefined in Object Spread (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] +---*/ +let executedSetter = false; + + +var callCount = 0; + +new function(obj) { + assert.sameValue(obj.c, 1); + assert.sameValue(executedSetter, false); + assert.sameValue(Object.keys(obj).length, 1); + callCount += 1; +}({set c(v) { executedSetter = true; }, ...{c: 1}}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-obj-skip-non-enumerable.js b/test/language/expressions/new/spread-obj-skip-non-enumerable.js new file mode 100644 index 0000000000..41df184690 --- /dev/null +++ b/test/language/expressions/new/spread-obj-skip-non-enumerable.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-skip-non-enumerable.case +// - src/spread/default/member-expr.template +/*--- +description: Object Spread doesn't copy non-enumerable properties (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] +---*/ + +let o = {}; +Object.defineProperty(o, "b", {value: 3, enumerable: false}); + + +var callCount = 0; + +new function(obj) { + assert.sameValue(obj.hasOwnProperty("b"), false) + assert.sameValue(Object.keys(obj).length, 0); + callCount += 1; +}({...o}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-obj-spread-order.js b/test/language/expressions/new/spread-obj-spread-order.js new file mode 100644 index 0000000000..5c00d7c285 --- /dev/null +++ b/test/language/expressions/new/spread-obj-spread-order.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-spread-order.case +// - src/spread/default/member-expr.template +/*--- +description: Spread operation follows [[OwnPropertyKeys]] order (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +includes: [compareArray.js] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +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 callCount = 0; + +new function(obj) { + assert(compareArray(calls, [1, 'z', 'a', "Symbol(foo)"])); + assert.sameValue(Object.keys(obj).length, 3); + callCount += 1; +}({...o}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-obj-symbol-property.js b/test/language/expressions/new/spread-obj-symbol-property.js new file mode 100644 index 0000000000..33f5868345 --- /dev/null +++ b/test/language/expressions/new/spread-obj-symbol-property.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-symbol-property.case +// - src/spread/default/member-expr.template +/*--- +description: Spread operation where source object contains Symbol properties (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let symbol = Symbol('foo'); +let o = {}; +o[symbol] = 1; + + +var callCount = 0; + +new function(obj) { + assert.sameValue(obj[symbol], 1); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert.sameValue(Object.keys(obj).length, 2); + callCount += 1; +}({...o, c: 4, d: 5}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-obj-undefined.js b/test/language/expressions/new/spread-obj-undefined.js new file mode 100644 index 0000000000..713310e689 --- /dev/null +++ b/test/language/expressions/new/spread-obj-undefined.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-undefined.case +// - src/spread/default/member-expr.template +/*--- +description: Undefined Object Spread is ignored (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +new function(obj) { + assert.sameValue(Object.keys(obj).length, 0); + callCount += 1; +}({...undefined}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-obj-with-overrides.js b/test/language/expressions/new/spread-obj-with-overrides.js new file mode 100644 index 0000000000..16674f9f33 --- /dev/null +++ b/test/language/expressions/new/spread-obj-with-overrides.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-with-overrides.case +// - src/spread/default/member-expr.template +/*--- +description: Object Spread properties being overriden (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = {a: 2, b: 3, c: 4, e: undefined, f: null, g: false}; + + +var callCount = 0; + +new function(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 7); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert(obj.hasOwnProperty("e")); + assert.sameValue(obj.f, null); + assert.sameValue(obj.g, false); + assert.sameValue(obj.h, -0); + assert.sameValue(obj.i.toString(), "Symbol(foo)"); + assert(Object.is(obj.j, o)); + assert.sameValue(Object.keys(obj).length, 10); + callCount += 1; +}({...o, a: 1, b: 7, d: 5, h: -0, i: Symbol("foo"), j: o}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-sngl-obj-base.js b/test/language/expressions/new/spread-sngl-obj-base.js new file mode 100644 index 0000000000..d03aa6e60d --- /dev/null +++ b/test/language/expressions/new/spread-sngl-obj-base.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-obj-base.case +// - src/spread/default/member-expr.template +/*--- +description: Object Spread operator without other arguments (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +includes: [propertyHelper.js] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +new function(obj) { + assert.sameValue(obj.c, 3); + assert.sameValue(obj.d, 4); + assert.sameValue(Object.keys(obj).length, 2); + + verifyEnumerable(obj, "c"); + verifyWritable(obj, "c"); + verifyConfigurable(obj, "c"); + + verifyEnumerable(obj, "d"); + verifyWritable(obj, "d"); + verifyConfigurable(obj, "d"); + callCount += 1; +}({...{c: 3, d: 4}}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-sngl-obj-empty.js b/test/language/expressions/new/spread-sngl-obj-empty.js new file mode 100644 index 0000000000..1dac2b4ad7 --- /dev/null +++ b/test/language/expressions/new/spread-sngl-obj-empty.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-obj-empty.case +// - src/spread/default/member-expr.template +/*--- +description: Object Spread operator on a single empty object (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +new function(obj) { + assert.sameValue(Object.keys(obj).length, 0); + callCount += 1; +}({...{}}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-sngl-obj-ident.js b/test/language/expressions/new/spread-sngl-obj-ident.js new file mode 100644 index 0000000000..f9594ceee6 --- /dev/null +++ b/test/language/expressions/new/spread-sngl-obj-ident.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-obj-ident.case +// - src/spread/default/member-expr.template +/*--- +description: Object Spread operator without other arguments (`new` operator) +esid: sec-new-operator-runtime-semantics-evaluation +es6id: 12.3.3.1 +flags: [generated] +includes: [propertyHelper.js] +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = {c: 3, d: 4}; + + +var callCount = 0; + +new function(obj) { + assert.sameValue(obj.c, 3); + assert.sameValue(obj.d, 4); + assert.sameValue(Object.keys(obj).length, 2); + + verifyEnumerable(obj, "c"); + verifyWritable(obj, "c"); + verifyConfigurable(obj, "c"); + + verifyEnumerable(obj, "d"); + verifyWritable(obj, "d"); + verifyConfigurable(obj, "d"); + callCount += 1; +}({...o}); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/call-spread-err-mult-err-obj-getter-throws.js b/test/language/expressions/super/call-spread-err-mult-err-obj-getter-throws.js new file mode 100644 index 0000000000..49666fbe2f --- /dev/null +++ b/test/language/expressions/super/call-spread-err-mult-err-obj-getter-throws.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-err-obj-getter-throws.case +// - src/spread/Error/super-call.template +/*--- +description: Object Spread operator results in error when there is an getter that throws an exception (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +class Test262ParentClass { + constructor() {} +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({a: 1, ...{ get foo() { throw new Test262Error(); } }}); + } +} + +assert.throws(Test262Error, function() { + new Test262ChildClass(); +}); diff --git a/test/language/expressions/super/call-spread-err-mult-err-obj-unresolvable.js b/test/language/expressions/super/call-spread-err-mult-err-obj-unresolvable.js new file mode 100644 index 0000000000..5625eb86cf --- /dev/null +++ b/test/language/expressions/super/call-spread-err-mult-err-obj-unresolvable.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-err-obj-unresolvable.case +// - src/spread/error/super-call.template +/*--- +description: Object Spread operator results in error when using an unresolvable reference (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +class Test262ParentClass { + constructor() {} +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({a: 0, ...unresolvableReference}); + } +} + +assert.throws(ReferenceError, function() { + new Test262ChildClass(); +}); diff --git a/test/language/expressions/super/call-spread-err-sngl-err-obj-getter-throws.js b/test/language/expressions/super/call-spread-err-sngl-err-obj-getter-throws.js new file mode 100644 index 0000000000..4c138c40d5 --- /dev/null +++ b/test/language/expressions/super/call-spread-err-sngl-err-obj-getter-throws.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-obj-getter-throws.case +// - src/spread/error/super-call.template +/*--- +description: Object Spread operator results in error when there is an getter that throws an exception (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +class Test262ParentClass { + constructor() {} +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({...{ get foo() { throw new Test262Error(); } }}); + } +} + +assert.throws(Test262Error, function() { + new Test262ChildClass(); +}); diff --git a/test/language/expressions/super/call-spread-err-sngl-err-obj-unresolvable.js b/test/language/expressions/super/call-spread-err-sngl-err-obj-unresolvable.js new file mode 100644 index 0000000000..72cf158c67 --- /dev/null +++ b/test/language/expressions/super/call-spread-err-sngl-err-obj-unresolvable.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-obj-unresolvable.case +// - src/spread/error/super-call.template +/*--- +description: Object Spread operator results in error when using an unresolvable reference (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +class Test262ParentClass { + constructor() {} +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({...unresolvableReference}); + } +} + +assert.throws(ReferenceError, function() { + new Test262ChildClass(); +}); diff --git a/test/language/expressions/super/call-spread-mult-obj-base.js b/test/language/expressions/super/call-spread-mult-obj-base.js new file mode 100644 index 0000000000..745e58c2fd --- /dev/null +++ b/test/language/expressions/super/call-spread-mult-obj-base.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-base.case +// - src/spread/default/super-call.template +/*--- +description: Object Spread operator following other arguments (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +includes: [propertyHelper.js] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +class Test262ParentClass { + constructor(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(obj.c, 3); + assert.sameValue(obj.d, 4); + assert.sameValue(Object.keys(obj).length, 4); + + verifyEnumerable(obj, "c"); + verifyWritable(obj, "c"); + verifyConfigurable(obj, "c"); + + verifyEnumerable(obj, "d"); + verifyWritable(obj, "d"); + verifyConfigurable(obj, "d"); + + callCount += 1; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({a: 1, b: 2, ...{c: 3, d: 4}}); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/call-spread-mult-obj-empty.js b/test/language/expressions/super/call-spread-mult-obj-empty.js new file mode 100644 index 0000000000..65464644e7 --- /dev/null +++ b/test/language/expressions/super/call-spread-mult-obj-empty.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-empty.case +// - src/spread/default/super-call.template +/*--- +description: Object Spread operator following other arguments with empty object (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +class Test262ParentClass { + constructor(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(Object.keys(obj).length, 2); + callCount += 1; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({a: 1, b: 2, ...{}}); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/call-spread-mult-obj-ident.js b/test/language/expressions/super/call-spread-mult-obj-ident.js new file mode 100644 index 0000000000..97d96d73e6 --- /dev/null +++ b/test/language/expressions/super/call-spread-mult-obj-ident.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-ident.case +// - src/spread/default/super-call.template +/*--- +description: Object Spread operator following other properties (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +includes: [propertyHelper.js] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = {c: 3, d: 4}; + + +var callCount = 0; + +class Test262ParentClass { + constructor(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(obj.c, 3); + assert.sameValue(obj.d, 4); + assert.sameValue(Object.keys(obj).length, 4); + + verifyEnumerable(obj, "a"); + verifyWritable(obj, "a"); + verifyConfigurable(obj, "a"); + + verifyEnumerable(obj, "b"); + verifyWritable(obj, "b"); + verifyConfigurable(obj, "b"); + + verifyEnumerable(obj, "c"); + verifyWritable(obj, "c"); + verifyConfigurable(obj, "c"); + + verifyEnumerable(obj, "d"); + verifyWritable(obj, "d"); + verifyConfigurable(obj, "d"); + callCount += 1; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({a: 1, b: 2, ...o}); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/call-spread-mult-obj-null-empty-undefined.js b/test/language/expressions/super/call-spread-mult-obj-null-empty-undefined.js new file mode 100644 index 0000000000..ce2fc69a5c --- /dev/null +++ b/test/language/expressions/super/call-spread-mult-obj-null-empty-undefined.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-null-empty-undefined.case +// - src/spread/default/super-call.template +/*--- +description: Object Spread operator following other arguments with null, undefined and empty object (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +includes: [compareArray.js] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +class Test262ParentClass { + constructor(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(obj.c, 3); + assert.sameValue(obj.d, 4); + assert(compareArray(Object.keys(obj), ["a", "b", "c", "d"])); + callCount += 1; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({a: 1, ...null, b: 2, ...undefined, c: 3, ...{}, ...{...{}}, d: 4}); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/call-spread-mult-obj-null.js b/test/language/expressions/super/call-spread-mult-obj-null.js new file mode 100644 index 0000000000..b0faabad26 --- /dev/null +++ b/test/language/expressions/super/call-spread-mult-obj-null.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-null.case +// - src/spread/default/super-call.template +/*--- +description: Object Spread operator following other arguments with null value (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +class Test262ParentClass { + constructor(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(Object.keys(obj).length, 2); + callCount += 1; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({a: 1, b: 2, ...null}); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/call-spread-mult-obj-undefined.js b/test/language/expressions/super/call-spread-mult-obj-undefined.js new file mode 100644 index 0000000000..9c94343c8c --- /dev/null +++ b/test/language/expressions/super/call-spread-mult-obj-undefined.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/spread/mult-obj-undefined.case +// - src/spread/default/super-call.template +/*--- +description: Object Spread operator following other arguments with undefined (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +class Test262ParentClass { + constructor(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 2); + assert.sameValue(Object.keys(obj).length, 2); + callCount += 1; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({a: 1, b: 2, ...undefined}); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/call-spread-obj-getter-descriptor.js b/test/language/expressions/super/call-spread-obj-getter-descriptor.js new file mode 100644 index 0000000000..75c356e7af --- /dev/null +++ b/test/language/expressions/super/call-spread-obj-getter-descriptor.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-getter-descriptor.case +// - src/spread/default/super-call.template +/*--- +description: Spread operation with getter results in data property descriptor (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +includes: [propertyHelper.js] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = { + get a() { + return 42; + } +}; + + +var callCount = 0; + +class Test262ParentClass { + constructor(obj) { + assert.sameValue(Object.getOwnPropertyDescriptor(obj, "a").value, 42); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert.sameValue(Object.keys(obj).length, 3); + + verifyEnumerable(obj, "a"); + verifyWritable(obj, "a"); + verifyConfigurable(obj, "a"); + callCount += 1; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({...o, c: 4, d: 5}); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/call-spread-obj-getter-init.js b/test/language/expressions/super/call-spread-obj-getter-init.js new file mode 100644 index 0000000000..a0caeec012 --- /dev/null +++ b/test/language/expressions/super/call-spread-obj-getter-init.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-getter-init.case +// - src/spread/default/super-call.template +/*--- +description: Getter in object literal is not evaluated (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] +---*/ + +let o = {a: 2, b: 3}; +let executedGetter = false; + + +var callCount = 0; + +class Test262ParentClass { + constructor(obj) { + assert.sameValue(obj.a, 2); + assert.sameValue(obj.b, 3); + assert.sameValue(executedGetter, false) + assert.sameValue(Object.keys(obj).length, 3); + callCount += 1; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({...o, get c() { executedGetter = true; }}); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/call-spread-obj-manipulate-outter-obj-in-getter.js b/test/language/expressions/super/call-spread-obj-manipulate-outter-obj-in-getter.js new file mode 100644 index 0000000000..d67c268b1e --- /dev/null +++ b/test/language/expressions/super/call-spread-obj-manipulate-outter-obj-in-getter.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-manipulate-outter-obj-in-getter.case +// - src/spread/default/super-call.template +/*--- +description: Getter manipulates outter object before it's spread operation (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +var o = { a: 0, b: 1 }; +var cthulhu = { get x() { + delete o.a; + o.b = 42; + o.c = "ni"; +}}; + +var callCount = 0; + +class Test262ParentClass { + constructor(obj) { + assert.sameValue(obj.hasOwnProperty("a"), false); + assert.sameValue(obj.b, 42); + assert.sameValue(obj.c, "ni"); + assert(obj.hasOwnProperty("x")); + assert.sameValue(Object.keys(obj).length, 3); + callCount += 1; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({...cthulhu, ...o}); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/call-spread-obj-mult-spread-getter.js b/test/language/expressions/super/call-spread-obj-mult-spread-getter.js new file mode 100644 index 0000000000..9e8fbe5132 --- /dev/null +++ b/test/language/expressions/super/call-spread-obj-mult-spread-getter.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-mult-spread-getter.case +// - src/spread/default/super-call.template +/*--- +description: Multiple Object Spread usage calls getter multiple times (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let getterCallCount = 0; +let o = { + get a() { + return ++getterCallCount; + } +}; + + +var callCount = 0; + +class Test262ParentClass { + constructor(obj) { + assert.sameValue(obj.a, 2); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert.sameValue(Object.keys(obj).length, 3); + callCount += 1; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({...o, c: 4, d: 5, a: 42, ...o}); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/call-spread-obj-mult-spread.js b/test/language/expressions/super/call-spread-obj-mult-spread.js new file mode 100644 index 0000000000..2bac42d56b --- /dev/null +++ b/test/language/expressions/super/call-spread-obj-mult-spread.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-mult-spread.case +// - src/spread/default/super-call.template +/*--- +description: Multiple Object Spread operation (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +let o = {a: 2, b: 3}; +let o2 = {c: 4, d: 5}; + + +var callCount = 0; + +class Test262ParentClass { + constructor(obj) { + assert.sameValue(obj.a, 2); + assert.sameValue(obj.b, 3); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert.sameValue(Object.keys(obj).length, 4); + callCount += 1; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({...o, ...o2}); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/call-spread-obj-null.js b/test/language/expressions/super/call-spread-obj-null.js new file mode 100644 index 0000000000..69e79d4b50 --- /dev/null +++ b/test/language/expressions/super/call-spread-obj-null.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-null.case +// - src/spread/default/super-call.template +/*--- +description: Null Object Spread is ignored (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +class Test262ParentClass { + constructor(obj) { + assert.sameValue(Object.keys(obj).length, 0); + callCount += 1; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({...null}); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/call-spread-obj-override-immutable.js b/test/language/expressions/super/call-spread-obj-override-immutable.js new file mode 100644 index 0000000000..da4ec6dcd7 --- /dev/null +++ b/test/language/expressions/super/call-spread-obj-override-immutable.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-override-immutable.case +// - src/spread/default/super-call.template +/*--- +description: Object Spread overriding immutable properties (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +includes: [propertyHelper.js] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] +---*/ + +let o = {b: 2}; +Object.defineProperty(o, "a", {value: 1, enumerable: true, writable: false, configurable: true}); + + +var callCount = 0; + +class Test262ParentClass { + constructor(obj) { + assert.sameValue(obj.a, 3) + assert.sameValue(obj.b, 2); + + verifyEnumerable(obj, "a"); + verifyWritable(obj, "a"); + verifyConfigurable(obj, "a"); + + verifyEnumerable(obj, "b"); + verifyWritable(obj, "b"); + verifyConfigurable(obj, "b"); + + callCount += 1; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({...o, a: 3}); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/call-spread-obj-overrides-prev-properties.js b/test/language/expressions/super/call-spread-obj-overrides-prev-properties.js new file mode 100644 index 0000000000..66383f82be --- /dev/null +++ b/test/language/expressions/super/call-spread-obj-overrides-prev-properties.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-overrides-prev-properties.case +// - src/spread/default/super-call.template +/*--- +description: Object Spread properties overrides previous definitions (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = {a: 2, b: 3}; + + +var callCount = 0; + +class Test262ParentClass { + constructor(obj) { + assert.sameValue(obj.a, 2); + assert.sameValue(obj.b, 3); + assert.sameValue(Object.keys(obj).length, 2); + assert.sameValue(o.a, 2); + assert.sameValue(o.b, 3); + callCount += 1; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({a: 1, b: 7, ...o}); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/call-spread-obj-setter-redef.js b/test/language/expressions/super/call-spread-obj-setter-redef.js new file mode 100644 index 0000000000..a5299f3e8a --- /dev/null +++ b/test/language/expressions/super/call-spread-obj-setter-redef.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-setter-redef.case +// - src/spread/default/super-call.template +/*--- +description: Setter are not executed when redefined in Object Spread (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] +---*/ +let executedSetter = false; + + +var callCount = 0; + +class Test262ParentClass { + constructor(obj) { + assert.sameValue(obj.c, 1); + assert.sameValue(executedSetter, false); + assert.sameValue(Object.keys(obj).length, 1); + callCount += 1; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({set c(v) { executedSetter = true; }, ...{c: 1}}); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/call-spread-obj-skip-non-enumerable.js b/test/language/expressions/super/call-spread-obj-skip-non-enumerable.js new file mode 100644 index 0000000000..fdc4e4ba4e --- /dev/null +++ b/test/language/expressions/super/call-spread-obj-skip-non-enumerable.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-skip-non-enumerable.case +// - src/spread/default/super-call.template +/*--- +description: Object Spread doesn't copy non-enumerable properties (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] +---*/ + +let o = {}; +Object.defineProperty(o, "b", {value: 3, enumerable: false}); + + +var callCount = 0; + +class Test262ParentClass { + constructor(obj) { + assert.sameValue(obj.hasOwnProperty("b"), false) + assert.sameValue(Object.keys(obj).length, 0); + callCount += 1; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({...o}); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/call-spread-obj-spread-order.js b/test/language/expressions/super/call-spread-obj-spread-order.js new file mode 100644 index 0000000000..311d3f9af3 --- /dev/null +++ b/test/language/expressions/super/call-spread-obj-spread-order.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-spread-order.case +// - src/spread/default/super-call.template +/*--- +description: Spread operation follows [[OwnPropertyKeys]] order (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +includes: [compareArray.js] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +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 callCount = 0; + +class Test262ParentClass { + constructor(obj) { + assert(compareArray(calls, [1, 'z', 'a', "Symbol(foo)"])); + assert.sameValue(Object.keys(obj).length, 3); + callCount += 1; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({...o}); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/call-spread-obj-symbol-property.js b/test/language/expressions/super/call-spread-obj-symbol-property.js new file mode 100644 index 0000000000..dd34984389 --- /dev/null +++ b/test/language/expressions/super/call-spread-obj-symbol-property.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-symbol-property.case +// - src/spread/default/super-call.template +/*--- +description: Spread operation where source object contains Symbol properties (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let symbol = Symbol('foo'); +let o = {}; +o[symbol] = 1; + + +var callCount = 0; + +class Test262ParentClass { + constructor(obj) { + assert.sameValue(obj[symbol], 1); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert.sameValue(Object.keys(obj).length, 2); + callCount += 1; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({...o, c: 4, d: 5}); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/call-spread-obj-undefined.js b/test/language/expressions/super/call-spread-obj-undefined.js new file mode 100644 index 0000000000..e36f01396c --- /dev/null +++ b/test/language/expressions/super/call-spread-obj-undefined.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-undefined.case +// - src/spread/default/super-call.template +/*--- +description: Undefined Object Spread is ignored (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +class Test262ParentClass { + constructor(obj) { + assert.sameValue(Object.keys(obj).length, 0); + callCount += 1; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({...undefined}); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/call-spread-obj-with-overrides.js b/test/language/expressions/super/call-spread-obj-with-overrides.js new file mode 100644 index 0000000000..81bb19f74c --- /dev/null +++ b/test/language/expressions/super/call-spread-obj-with-overrides.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/spread/obj-with-overrides.case +// - src/spread/default/super-call.template +/*--- +description: Object Spread properties being overriden (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = {a: 2, b: 3, c: 4, e: undefined, f: null, g: false}; + + +var callCount = 0; + +class Test262ParentClass { + constructor(obj) { + assert.sameValue(obj.a, 1); + assert.sameValue(obj.b, 7); + assert.sameValue(obj.c, 4); + assert.sameValue(obj.d, 5); + assert(obj.hasOwnProperty("e")); + assert.sameValue(obj.f, null); + assert.sameValue(obj.g, false); + assert.sameValue(obj.h, -0); + assert.sameValue(obj.i.toString(), "Symbol(foo)"); + assert(Object.is(obj.j, o)); + assert.sameValue(Object.keys(obj).length, 10); + callCount += 1; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({...o, a: 1, b: 7, d: 5, h: -0, i: Symbol("foo"), j: o}); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/call-spread-sngl-obj-base.js b/test/language/expressions/super/call-spread-sngl-obj-base.js new file mode 100644 index 0000000000..d83cf3594d --- /dev/null +++ b/test/language/expressions/super/call-spread-sngl-obj-base.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-obj-base.case +// - src/spread/default/super-call.template +/*--- +description: Object Spread operator without other arguments (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +includes: [propertyHelper.js] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +class Test262ParentClass { + constructor(obj) { + assert.sameValue(obj.c, 3); + assert.sameValue(obj.d, 4); + assert.sameValue(Object.keys(obj).length, 2); + + verifyEnumerable(obj, "c"); + verifyWritable(obj, "c"); + verifyConfigurable(obj, "c"); + + verifyEnumerable(obj, "d"); + verifyWritable(obj, "d"); + verifyConfigurable(obj, "d"); + callCount += 1; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({...{c: 3, d: 4}}); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/call-spread-sngl-obj-empty.js b/test/language/expressions/super/call-spread-sngl-obj-empty.js new file mode 100644 index 0000000000..6fd1a5237e --- /dev/null +++ b/test/language/expressions/super/call-spread-sngl-obj-empty.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-obj-empty.case +// - src/spread/default/super-call.template +/*--- +description: Object Spread operator on a single empty object (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ + +var callCount = 0; + +class Test262ParentClass { + constructor(obj) { + assert.sameValue(Object.keys(obj).length, 0); + callCount += 1; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({...{}}); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/call-spread-sngl-obj-ident.js b/test/language/expressions/super/call-spread-sngl-obj-ident.js new file mode 100644 index 0000000000..4271aa395b --- /dev/null +++ b/test/language/expressions/super/call-spread-sngl-obj-ident.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-obj-ident.case +// - src/spread/default/super-call.template +/*--- +description: Object Spread operator without other arguments (SuperCall) +esid: sec-super-keyword-runtime-semantics-evaluation +es6id: 12.3.5.1 +flags: [generated] +includes: [propertyHelper.js] +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + Pending Runtime Semantics: PropertyDefinitionEvaluation + + PropertyDefinition:...AssignmentExpression + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let fromValue be GetValue(exprValue). + 3. ReturnIfAbrupt(fromValue). + 4. Let excludedNames be a new empty List. + 5. Return CopyDataProperties(object, fromValue, excludedNames). + +---*/ +let o = {c: 3, d: 4}; + + +var callCount = 0; + +class Test262ParentClass { + constructor(obj) { + assert.sameValue(obj.c, 3); + assert.sameValue(obj.d, 4); + assert.sameValue(Object.keys(obj).length, 2); + + verifyEnumerable(obj, "c"); + verifyWritable(obj, "c"); + verifyConfigurable(obj, "c"); + + verifyEnumerable(obj, "d"); + verifyWritable(obj, "d"); + verifyConfigurable(obj, "d"); + callCount += 1; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super({...o}); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1);