From 16e66ece0cd8bc8118e0f5a6816f3aaa54e0aa6d Mon Sep 17 00:00:00 2001 From: Caio Lima Date: Mon, 13 Mar 2017 14:21:26 +0000 Subject: [PATCH] Initial set for Object Spread feature (#890) --- src/spread/mult-err-obj-getter-throws.case | 23 +++++++++ src/spread/mult-err-obj-unresolvable.case | 23 +++++++++ src/spread/mult-obj-base.case | 39 +++++++++++++++ src/spread/mult-obj-empty.case | 27 ++++++++++ src/spread/mult-obj-ident.case | 49 +++++++++++++++++++ src/spread/mult-obj-null-empty-undefined.case | 30 ++++++++++++ src/spread/mult-obj-null.case | 27 ++++++++++ src/spread/mult-obj-undefined.case | 27 ++++++++++ src/spread/obj-getter-descriptor.case | 41 ++++++++++++++++ src/spread/obj-getter-init.case | 22 +++++++++ .../obj-manipulate-outter-obj-in-getter.case | 36 ++++++++++++++ src/spread/obj-mult-spread-getter.case | 36 ++++++++++++++ src/spread/obj-mult-spread.case | 34 +++++++++++++ src/spread/obj-null.case | 25 ++++++++++ src/spread/obj-override-immutable.case | 30 ++++++++++++ src/spread/obj-overrides-prev-properties.case | 32 ++++++++++++ src/spread/obj-setter-redef.case | 19 +++++++ src/spread/obj-skip-non-enumerable.case | 20 ++++++++ src/spread/obj-spread-order.case | 33 +++++++++++++ src/spread/obj-symbol-property.case | 34 +++++++++++++ src/spread/obj-undefined.case | 25 ++++++++++ src/spread/obj-with-overrides.case | 38 ++++++++++++++ src/spread/sngl-err-obj-getter-throws.case | 23 +++++++++ src/spread/sngl-err-obj-unresolvable.case | 23 +++++++++ src/spread/sngl-obj-base.case | 36 ++++++++++++++ src/spread/sngl-obj-empty.case | 25 ++++++++++ src/spread/sngl-obj-ident.case | 39 +++++++++++++++ 27 files changed, 816 insertions(+) create mode 100644 src/spread/mult-err-obj-getter-throws.case create mode 100644 src/spread/mult-err-obj-unresolvable.case create mode 100644 src/spread/mult-obj-base.case create mode 100644 src/spread/mult-obj-empty.case create mode 100644 src/spread/mult-obj-ident.case create mode 100644 src/spread/mult-obj-null-empty-undefined.case create mode 100644 src/spread/mult-obj-null.case create mode 100644 src/spread/mult-obj-undefined.case create mode 100644 src/spread/obj-getter-descriptor.case create mode 100644 src/spread/obj-getter-init.case create mode 100644 src/spread/obj-manipulate-outter-obj-in-getter.case create mode 100644 src/spread/obj-mult-spread-getter.case create mode 100644 src/spread/obj-mult-spread.case create mode 100644 src/spread/obj-null.case create mode 100644 src/spread/obj-override-immutable.case create mode 100644 src/spread/obj-overrides-prev-properties.case create mode 100644 src/spread/obj-setter-redef.case create mode 100644 src/spread/obj-skip-non-enumerable.case create mode 100644 src/spread/obj-spread-order.case create mode 100644 src/spread/obj-symbol-property.case create mode 100644 src/spread/obj-undefined.case create mode 100644 src/spread/obj-with-overrides.case create mode 100644 src/spread/sngl-err-obj-getter-throws.case create mode 100644 src/spread/sngl-err-obj-unresolvable.case create mode 100644 src/spread/sngl-obj-base.case create mode 100644 src/spread/sngl-obj-empty.case create mode 100644 src/spread/sngl-obj-ident.case diff --git a/src/spread/mult-err-obj-getter-throws.case b/src/spread/mult-err-obj-getter-throws.case new file mode 100644 index 0000000000..4c6e259e32 --- /dev/null +++ b/src/spread/mult-err-obj-getter-throws.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Object Spread operator results in error when there is an getter that throws an exception +template: Error +esid: pending +info: | + 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). + +---*/ + +//- error +Test262Error +//- args +{a: 1, ...{ get foo() { throw new Test262Error(); } }} diff --git a/src/spread/mult-err-obj-unresolvable.case b/src/spread/mult-err-obj-unresolvable.case new file mode 100644 index 0000000000..fce8cf0e94 --- /dev/null +++ b/src/spread/mult-err-obj-unresolvable.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Object Spread operator results in error when using an unresolvable reference +template: error +esid: pending +info: | + 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). + +---*/ + +//- error +ReferenceError +//- args +{a: 0, ...unresolvableReference} diff --git a/src/spread/mult-obj-base.case b/src/spread/mult-obj-base.case new file mode 100644 index 0000000000..46b07525dd --- /dev/null +++ b/src/spread/mult-obj-base.case @@ -0,0 +1,39 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Object Spread operator following other arguments +template: default +esid: pending +includes: [propertyHelper.js] +info: | + 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). + +---*/ + +//- args +{a: 1, b: 2, ...{c: 3, d: 4}} +//- params +obj +//- body +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"); + diff --git a/src/spread/mult-obj-empty.case b/src/spread/mult-obj-empty.case new file mode 100644 index 0000000000..9e3ae8f41b --- /dev/null +++ b/src/spread/mult-obj-empty.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Object Spread operator following other arguments with empty object +template: default +esid: pending +info: | + 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). + +---*/ + +//- args +{a: 1, b: 2, ...{}} +//- params +obj +//- body +assert.sameValue(obj.a, 1); +assert.sameValue(obj.b, 2); +assert.sameValue(Object.keys(obj).length, 2); diff --git a/src/spread/mult-obj-ident.case b/src/spread/mult-obj-ident.case new file mode 100644 index 0000000000..a5af7dbb5b --- /dev/null +++ b/src/spread/mult-obj-ident.case @@ -0,0 +1,49 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Object Spread operator following other properties +template: default +esid: pending +includes: [propertyHelper.js] +info: | + 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). + +---*/ + +//- setup +let o = {c: 3, d: 4}; + +//- args +{a: 1, b: 2, ...o} +//- params +obj +//- body +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"); diff --git a/src/spread/mult-obj-null-empty-undefined.case b/src/spread/mult-obj-null-empty-undefined.case new file mode 100644 index 0000000000..6af89493cc --- /dev/null +++ b/src/spread/mult-obj-null-empty-undefined.case @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Object Spread operator following other arguments with null, undefined and empty object +template: default +esid: pending +includes: [compareArray.js] +info: | + 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). + +---*/ + +//- args +{a: 1, ...null, b: 2, ...undefined, c: 3, ...{}, ...{...{}}, d: 4} +//- params +obj +//- body +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"])); diff --git a/src/spread/mult-obj-null.case b/src/spread/mult-obj-null.case new file mode 100644 index 0000000000..88917a6a04 --- /dev/null +++ b/src/spread/mult-obj-null.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Object Spread operator following other arguments with null value +template: default +esid: pending +info: | + 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). + +---*/ + +//- args +{a: 1, b: 2, ...null} +//- params +obj +//- body +assert.sameValue(obj.a, 1); +assert.sameValue(obj.b, 2); +assert.sameValue(Object.keys(obj).length, 2); diff --git a/src/spread/mult-obj-undefined.case b/src/spread/mult-obj-undefined.case new file mode 100644 index 0000000000..83be9ff650 --- /dev/null +++ b/src/spread/mult-obj-undefined.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Object Spread operator following other arguments with undefined +template: default +esid: pending +info: | + 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). + +---*/ + +//- args +{a: 1, b: 2, ...undefined} +//- params +obj +//- body +assert.sameValue(obj.a, 1); +assert.sameValue(obj.b, 2); +assert.sameValue(Object.keys(obj).length, 2); diff --git a/src/spread/obj-getter-descriptor.case b/src/spread/obj-getter-descriptor.case new file mode 100644 index 0000000000..83032faf13 --- /dev/null +++ b/src/spread/obj-getter-descriptor.case @@ -0,0 +1,41 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Spread operation with getter results in data property descriptor +template: default +esid: pending +includes: [propertyHelper.js] +info: | + 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). + +---*/ + +//- setup +let o = { + get a() { + return 42; + } +}; + +//- args +{...o, c: 4, d: 5} +//- params +obj +//- body + +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"); diff --git a/src/spread/obj-getter-init.case b/src/spread/obj-getter-init.case new file mode 100644 index 0000000000..57d8df172c --- /dev/null +++ b/src/spread/obj-getter-init.case @@ -0,0 +1,22 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Getter in object literal is not evaluated +template: default +esid: pending +---*/ + +//- setup + +let o = {a: 2, b: 3}; +let executedGetter = false; + +//- args +{...o, get c() { executedGetter = true; }} +//- params +obj +//- body +assert.sameValue(obj.a, 2); +assert.sameValue(obj.b, 3); +assert.sameValue(executedGetter, false) +assert.sameValue(Object.keys(obj).length, 3); diff --git a/src/spread/obj-manipulate-outter-obj-in-getter.case b/src/spread/obj-manipulate-outter-obj-in-getter.case new file mode 100644 index 0000000000..1411eda283 --- /dev/null +++ b/src/spread/obj-manipulate-outter-obj-in-getter.case @@ -0,0 +1,36 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Getter manipulates outter object before it's spread operation +template: default +esid: pending +info: | + 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). + +---*/ + +//- setup +var o = { a: 0, b: 1 }; +var cthulhu = { get x() { + delete o.a; + o.b = 42; + o.c = "ni"; +}}; +//- args +{...cthulhu, ...o} +//- params +obj +//- body +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); diff --git a/src/spread/obj-mult-spread-getter.case b/src/spread/obj-mult-spread-getter.case new file mode 100644 index 0000000000..5f50909dcc --- /dev/null +++ b/src/spread/obj-mult-spread-getter.case @@ -0,0 +1,36 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Multiple Object Spread usage calls getter multiple times +template: default +esid: pending +info: | + 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). + +---*/ + +//- setup +let getterCallCount = 0; +let o = { + get a() { + return ++getterCallCount; + } +}; + +//- args +{...o, c: 4, d: 5, a: 42, ...o} +//- params +obj +//- body +assert.sameValue(obj.a, 2); +assert.sameValue(obj.c, 4); +assert.sameValue(obj.d, 5); +assert.sameValue(Object.keys(obj).length, 3); diff --git a/src/spread/obj-mult-spread.case b/src/spread/obj-mult-spread.case new file mode 100644 index 0000000000..61cac2243a --- /dev/null +++ b/src/spread/obj-mult-spread.case @@ -0,0 +1,34 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Multiple Object Spread operation +template: default +esid: pending +info: | + 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). + +---*/ + +//- setup + +let o = {a: 2, b: 3}; +let o2 = {c: 4, d: 5}; + +//- args +{...o, ...o2} +//- params +obj +//- body +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); diff --git a/src/spread/obj-null.case b/src/spread/obj-null.case new file mode 100644 index 0000000000..6c9af0a626 --- /dev/null +++ b/src/spread/obj-null.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Null Object Spread is ignored +template: default +esid: pending +info: | + 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). + +---*/ + +//- args +{...null} +//- params +obj +//- body +assert.sameValue(Object.keys(obj).length, 0); diff --git a/src/spread/obj-override-immutable.case b/src/spread/obj-override-immutable.case new file mode 100644 index 0000000000..8e405c415d --- /dev/null +++ b/src/spread/obj-override-immutable.case @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Object Spread overriding immutable properties +template: default +esid: pending +includes: [propertyHelper.js] +---*/ + +//- setup + +let o = {b: 2}; +Object.defineProperty(o, "a", {value: 1, enumerable: true, writable: false, configurable: true}); + +//- args +{...o, a: 3} +//- params +obj +//- body +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"); + diff --git a/src/spread/obj-overrides-prev-properties.case b/src/spread/obj-overrides-prev-properties.case new file mode 100644 index 0000000000..1b95648b7b --- /dev/null +++ b/src/spread/obj-overrides-prev-properties.case @@ -0,0 +1,32 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Object Spread properties overrides previous definitions +template: default +esid: pending +info: | + 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). + +---*/ + +//- setup +let o = {a: 2, b: 3}; + +//- args +{a: 1, b: 7, ...o} +//- params +obj +//- body +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); diff --git a/src/spread/obj-setter-redef.case b/src/spread/obj-setter-redef.case new file mode 100644 index 0000000000..949503dd72 --- /dev/null +++ b/src/spread/obj-setter-redef.case @@ -0,0 +1,19 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Setter are not executed when redefined in Object Spread +template: default +esid: pending +---*/ + +//- setup +let executedSetter = false; + +//- args +{set c(v) { executedSetter = true; }, ...{c: 1}} +//- params +obj +//- body +assert.sameValue(obj.c, 1); +assert.sameValue(executedSetter, false); +assert.sameValue(Object.keys(obj).length, 1); diff --git a/src/spread/obj-skip-non-enumerable.case b/src/spread/obj-skip-non-enumerable.case new file mode 100644 index 0000000000..07b72b54e8 --- /dev/null +++ b/src/spread/obj-skip-non-enumerable.case @@ -0,0 +1,20 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Object Spread doesn't copy non-enumerable properties +template: default +esid: pending +---*/ + +//- setup + +let o = {}; +Object.defineProperty(o, "b", {value: 3, enumerable: false}); + +//- args +{...o} +//- params +obj +//- body +assert.sameValue(obj.hasOwnProperty("b"), false) +assert.sameValue(Object.keys(obj).length, 0); diff --git a/src/spread/obj-spread-order.case b/src/spread/obj-spread-order.case new file mode 100644 index 0000000000..21b86b949d --- /dev/null +++ b/src/spread/obj-spread-order.case @@ -0,0 +1,33 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Spread operation follows [[OwnPropertyKeys]] order +template: default +esid: pending +includes: [compareArray.js] +info: | + 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). + +---*/ + +//- setup +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 }); + +//- args +{...o} +//- params +obj +//- body +assert(compareArray(calls, [1, 'z', 'a', "Symbol(foo)"])); +assert.sameValue(Object.keys(obj).length, 3); diff --git a/src/spread/obj-symbol-property.case b/src/spread/obj-symbol-property.case new file mode 100644 index 0000000000..87a9869564 --- /dev/null +++ b/src/spread/obj-symbol-property.case @@ -0,0 +1,34 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Spread operation where source object contains Symbol properties +template: default +esid: pending +info: | + 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). + +---*/ + +//- setup +let symbol = Symbol('foo'); +let o = {}; +o[symbol] = 1; + +//- args +{...o, c: 4, d: 5} +//- params +obj +//- body + +assert.sameValue(obj[symbol], 1); +assert.sameValue(obj.c, 4); +assert.sameValue(obj.d, 5); +assert.sameValue(Object.keys(obj).length, 2); diff --git a/src/spread/obj-undefined.case b/src/spread/obj-undefined.case new file mode 100644 index 0000000000..09ac2293a8 --- /dev/null +++ b/src/spread/obj-undefined.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Undefined Object Spread is ignored +template: default +esid: pending +info: | + 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). + +---*/ + +//- args +{...undefined} +//- params +obj +//- body +assert.sameValue(Object.keys(obj).length, 0); diff --git a/src/spread/obj-with-overrides.case b/src/spread/obj-with-overrides.case new file mode 100644 index 0000000000..1e086f692d --- /dev/null +++ b/src/spread/obj-with-overrides.case @@ -0,0 +1,38 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Object Spread properties being overriden +template: default +esid: pending +info: | + 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). + +---*/ + +//- setup +let o = {a: 2, b: 3, c: 4, e: undefined, f: null, g: false}; + +//- args +{...o, a: 1, b: 7, d: 5, h: -0, i: Symbol("foo"), j: o} +//- params +obj +//- body +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); diff --git a/src/spread/sngl-err-obj-getter-throws.case b/src/spread/sngl-err-obj-getter-throws.case new file mode 100644 index 0000000000..4b929215d4 --- /dev/null +++ b/src/spread/sngl-err-obj-getter-throws.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Object Spread operator results in error when there is an getter that throws an exception +template: error +esid: pending +info: | + 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). + +---*/ + +//- error +Test262Error +//- args +{...{ get foo() { throw new Test262Error(); } }} diff --git a/src/spread/sngl-err-obj-unresolvable.case b/src/spread/sngl-err-obj-unresolvable.case new file mode 100644 index 0000000000..b6976d9989 --- /dev/null +++ b/src/spread/sngl-err-obj-unresolvable.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Object Spread operator results in error when using an unresolvable reference +template: error +esid: pending +info: | + 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). + +---*/ + +//- error +ReferenceError +//- args +{...unresolvableReference} diff --git a/src/spread/sngl-obj-base.case b/src/spread/sngl-obj-base.case new file mode 100644 index 0000000000..26aeb2faef --- /dev/null +++ b/src/spread/sngl-obj-base.case @@ -0,0 +1,36 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Object Spread operator without other arguments +template: default +esid: pending +includes: [propertyHelper.js] +info: | + 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). + +---*/ + +//- args +{...{c: 3, d: 4}} +//- params +obj +//- body +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"); diff --git a/src/spread/sngl-obj-empty.case b/src/spread/sngl-obj-empty.case new file mode 100644 index 0000000000..19afa8578f --- /dev/null +++ b/src/spread/sngl-obj-empty.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Object Spread operator on a single empty object +template: default +esid: pending +info: | + 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). + +---*/ + +//- args +{...{}} +//- params +obj +//- body +assert.sameValue(Object.keys(obj).length, 0); diff --git a/src/spread/sngl-obj-ident.case b/src/spread/sngl-obj-ident.case new file mode 100644 index 0000000000..b94d0ef16c --- /dev/null +++ b/src/spread/sngl-obj-ident.case @@ -0,0 +1,39 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Object Spread operator without other arguments +template: default +esid: pending +includes: [propertyHelper.js] +info: | + 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). + +---*/ + +//- setup +let o = {c: 3, d: 4}; + +//- args +{...o} +//- params +obj +//- body +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");