diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-rest-getter.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..9a53bc062c --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +var f; +f = ({...x} = { get v() { count++; return 2; } }) => { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-rest-nested-obj.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..5310725ac7 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +var f; +f = ({a, b, ...{c, e}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) => { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-rest-obj-nested-rest.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..c498e46b91 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = ({a, b, ...{c, ...rest}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) => { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-rest-obj-own-property.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..85bb47d8aa --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest object contains just soruce object's own properties (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +var f; +f = ({ x, ...{y , z} } = o) => { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-rest-skip-non-enumerable.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..748c399a8c --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +var f; +f = ({...rest} = o) => { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-rest-val-obj.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..cb533a4cbc --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest object contains just unextracted data (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = ({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) => { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-rest-getter.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..fa313a74ac --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-rest-getter.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +var f; +f = ({...x}) => { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; +}; + +f({ get v() { count++; return 2; } }); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-rest-nested-obj.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..42771a7345 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +var f; +f = ({a, b, ...{c, e}}) => { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; +}; + +f({a: 1, b: 2, c: 3, d: 4, e: 5}); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-rest-obj-nested-rest.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..bb885d5399 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = ({a, b, ...{c, ...rest}}) => { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; +}; + +f({a: 1, b: 2, c: 3, d: 4, e: 5}); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-rest-obj-own-property.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..861211423f --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest object contains just soruce object's own properties (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +var f; +f = ({ x, ...{y , z} }) => { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; +}; + +f(o); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-rest-skip-non-enumerable.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..afba4548de --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest object doesn't contain non-enumerable properties (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +var f; +f = ({...rest}) => { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; +}; + +f(o); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-rest-val-obj.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..80b7d6dec9 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-rest-val-obj.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest object contains just unextracted data (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = ({a, b, ...rest}) => { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; +}; + +f({x: 1, y: 2, a: 5, b: 3}); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/assignment/dstr-obj-rest-descriptors.js b/test/language/expressions/assignment/dstr-obj-rest-descriptors.js new file mode 100644 index 0000000000..8dd277a194 --- /dev/null +++ b/test/language/expressions/assignment/dstr-obj-rest-descriptors.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-descriptors.case +// - src/dstr-assignment/default/assignment-expr.template +/*--- +description: Object created from rest deconstruction doesn't copy source object property descriptors. (AssignmentExpression) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ +var rest; +var obj = {}; +Object.defineProperty(obj, "a", { value: 3, configurable: false, enumerable: true }); +Object.defineProperty(obj, "b", { value: 4, writable: false, enumerable: true }); + +var result; +var vals = obj; + +result = {...rest} = vals; + +assert.sameValue(rest.a, 3); +assert.sameValue(rest.b, 4); + +verifyEnumerable(rest, "a"); +verifyWritable(rest, "a"); +verifyConfigurable(rest, "a"); + +verifyEnumerable(rest, "b"); +verifyWritable(rest, "b"); +verifyConfigurable(rest, "b"); + + +assert.sameValue(result, vals); diff --git a/test/language/expressions/assignment/dstr-obj-rest-empty-obj.js b/test/language/expressions/assignment/dstr-obj-rest-empty-obj.js new file mode 100644 index 0000000000..ad0f175300 --- /dev/null +++ b/test/language/expressions/assignment/dstr-obj-rest-empty-obj.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-empty-obj.case +// - src/dstr-assignment/default/assignment-expr.template +/*--- +description: RestBindingInitialization creates a new object even if lhs is an empty object (AssignmentExpression) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ +var rest; + + +var result; +var vals = {}; + +result = {...rest} = vals; + +assert.notSameValue(rest, undefined); +assert.notSameValue(rest, null); +assert.sameValue(typeof rest, "object"); + + +assert.sameValue(result, vals); diff --git a/test/language/expressions/assignment/dstr-obj-rest-getter-abrupt-get-error.js b/test/language/expressions/assignment/dstr-obj-rest-getter-abrupt-get-error.js new file mode 100644 index 0000000000..62c42b8f8d --- /dev/null +++ b/test/language/expressions/assignment/dstr-obj-rest-getter-abrupt-get-error.js @@ -0,0 +1,27 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-getter-abrupt-get-error.case +// - src/dstr-assignment/error/assignment-expr.template +/*--- +description: Rest deconstruction doesn't happen if getter return is abrupt (AssignmentExpression) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ +var x; +var count = 0; + +assert.throws(Test262Error, function() { + 0, {...x} = { get v() { count++; throw new Test262Error(); } }; +}); + +assert.sameValue(count, 1); + diff --git a/test/language/expressions/assignment/dstr-obj-rest-getter.js b/test/language/expressions/assignment/dstr-obj-rest-getter.js new file mode 100644 index 0000000000..d8b270b46f --- /dev/null +++ b/test/language/expressions/assignment/dstr-obj-rest-getter.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-getter.case +// - src/dstr-assignment/default/assignment-expr.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (AssignmentExpression) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ +var x; +var count = 0; + +var result; +var vals = { get v() { count++; return 2; } }; + +result = {...x} = vals; + +assert.sameValue(x.v, 2); +assert.sameValue(count, 1); + +verifyEnumerable(x, "v"); +verifyWritable(x, "v"); +verifyConfigurable(x, "v"); + + +assert.sameValue(result, vals); diff --git a/test/language/expressions/assignment/dstr-obj-rest-nested-obj-nested-rest.js b/test/language/expressions/assignment/dstr-obj-rest-nested-obj-nested-rest.js new file mode 100644 index 0000000000..f8f75ebd9a --- /dev/null +++ b/test/language/expressions/assignment/dstr-obj-rest-nested-obj-nested-rest.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-nested-obj-nested-rest.case +// - src/dstr-assignment/default/assignment-expr.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (AssignmentExpression) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ +var a, b, c, rest; + +var result; +var vals = {a: 1, b: 2, c: 3, d: 4, e: 5}; + +result = {a, b, ...{c, ...rest}} = vals; + +assert.sameValue(a, 1); +assert.sameValue(b, 2); +assert.sameValue(c, 3); + +assert.sameValue(rest.d, 4); +assert.sameValue(rest.e, 5); + +verifyEnumerable(rest, "d"); +verifyWritable(rest, "d"); +verifyConfigurable(rest, "d"); + +verifyEnumerable(rest, "e"); +verifyWritable(rest, "e"); +verifyConfigurable(rest, "e"); + + +assert.sameValue(result, vals); diff --git a/test/language/expressions/assignment/dstr-obj-rest-nested-obj.js b/test/language/expressions/assignment/dstr-obj-rest-nested-obj.js new file mode 100644 index 0000000000..0b3fd4d040 --- /dev/null +++ b/test/language/expressions/assignment/dstr-obj-rest-nested-obj.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-nested-obj.case +// - src/dstr-assignment/default/assignment-expr.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (AssignmentExpression) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ +var a, b, c, d, e; + +var result; +var vals = {a: 1, b: 2, c: 3, d: 4, e: 5}; + +result = {a, b, ...{c, e}} = vals; + +assert.sameValue(a, 1); +assert.sameValue(b, 2); +assert.sameValue(c, 3); +assert.sameValue(e, 5); +assert.sameValue(d, undefined); + + +assert.sameValue(result, vals); diff --git a/test/language/expressions/assignment/dstr-obj-rest-not-last-element-invalid.js b/test/language/expressions/assignment/dstr-obj-rest-not-last-element-invalid.js new file mode 100644 index 0000000000..91a927d3ae --- /dev/null +++ b/test/language/expressions/assignment/dstr-obj-rest-not-last-element-invalid.js @@ -0,0 +1,25 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-not-last-element-invalid.case +// - src/dstr-assignment/syntax/assignment-expr.template +/*--- +description: Object rest element needs to be the last AssignmenProperty in ObjectAssignmentPattern. (AssignmentExpression) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +negative: + phase: early + type: SyntaxError +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ +var rest, b; + +0, {...rest, b} = {} +; diff --git a/test/language/expressions/assignment/dstr-obj-rest-number.js b/test/language/expressions/assignment/dstr-obj-rest-number.js new file mode 100644 index 0000000000..b2c5aa9d02 --- /dev/null +++ b/test/language/expressions/assignment/dstr-obj-rest-number.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-number.case +// - src/dstr-assignment/default/assignment-expr.template +/*--- +description: RestBindingInitialization creates a new object even if lhs is a Number (AssignmentExpression) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ +var rest; + + +var result; +var vals = 51; + +result = {...rest} = vals; + +assert.notSameValue(rest, undefined); +assert.notSameValue(rest, null); +assert(rest instanceof Object); + + +assert.sameValue(result, vals); diff --git a/test/language/expressions/assignment/dstr-obj-rest-obj-own-property.js b/test/language/expressions/assignment/dstr-obj-rest-obj-own-property.js new file mode 100644 index 0000000000..58652c4749 --- /dev/null +++ b/test/language/expressions/assignment/dstr-obj-rest-obj-own-property.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-obj-own-property.case +// - src/dstr-assignment/default/assignment-expr.template +/*--- +description: Rest object contains just soruce object's own properties (AssignmentExpression) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var x, y, z; + +var result; +var vals = o; + +result = { x, ...{y , z} } = vals; + +assert.sameValue(x, 1); +assert.sameValue(y, undefined); +assert.sameValue(z, 3); + + +assert.sameValue(result, vals); diff --git a/test/language/expressions/assignment/dstr-obj-rest-put-const.js b/test/language/expressions/assignment/dstr-obj-rest-put-const.js new file mode 100644 index 0000000000..132032d03e --- /dev/null +++ b/test/language/expressions/assignment/dstr-obj-rest-put-const.js @@ -0,0 +1,24 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-put-const.case +// - src/dstr-assignment/error/assignment-expr.template +/*--- +description: The object rest deconstruction assignment target should obey `const` semantics. (AssignmentExpression) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [const, destructuring-binding] +flags: [generated] +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ +const rest = null; + +assert.throws(TypeError, function() { + 0, {...rest} = {} +; +}); diff --git a/test/language/expressions/assignment/dstr-obj-rest-skip-non-enumerable.js b/test/language/expressions/assignment/dstr-obj-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..535501b4a1 --- /dev/null +++ b/test/language/expressions/assignment/dstr-obj-rest-skip-non-enumerable.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-skip-non-enumerable.case +// - src/dstr-assignment/default/assignment-expr.template +/*--- +description: Rest object doesn't contain non-enumerable properties (AssignmentExpression) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ +var rest; +var obj = {a: 3, b: 4}; +Object.defineProperty(obj, "x", { value: 4, enumerable: false }); + +var result; +var vals = obj; + +result = {...rest} = vals; + +assert.sameValue(rest.a, 3); +assert.sameValue(rest.b, 4); +assert.sameValue(Object.getOwnPropertyDescriptor(rest, "x"), undefined); + +verifyEnumerable(rest, "a"); +verifyWritable(rest, "a"); +verifyConfigurable(rest, "a"); + +verifyEnumerable(rest, "b"); +verifyWritable(rest, "b"); +verifyConfigurable(rest, "b"); + + +assert.sameValue(result, vals); diff --git a/test/language/expressions/assignment/dstr-obj-rest-str-val.js b/test/language/expressions/assignment/dstr-obj-rest-str-val.js new file mode 100644 index 0000000000..a89f0658f6 --- /dev/null +++ b/test/language/expressions/assignment/dstr-obj-rest-str-val.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-str-val.case +// - src/dstr-assignment/default/assignment-expr.template +/*--- +description: RestBindingInitialization creats an object with indexes as property name (AssignmentExpression) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ +var rest; + + +var result; +var vals = "foo"; + +result = {...rest} = vals; + +assert.sameValue(rest["0"], "f"); +assert.sameValue(rest["1"], "o"); +assert.sameValue(rest["2"], "o"); +assert(rest instanceof Object); + + +assert.sameValue(result, vals); diff --git a/test/language/expressions/assignment/dstr-obj-rest-symbol-val.js b/test/language/expressions/assignment/dstr-obj-rest-symbol-val.js new file mode 100644 index 0000000000..f3a50754ab --- /dev/null +++ b/test/language/expressions/assignment/dstr-obj-rest-symbol-val.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-symbol-val.case +// - src/dstr-assignment/default/assignment-expr.template +/*--- +description: RestBindingInitialization creates a new object if lhs is a Symbol (AssignmentExpression) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ +var rest; + + +var result; +var vals = Symbol("foo"); + +result = {...rest} = vals; + +assert.notSameValue(rest, undefined); +assert.notSameValue(rest, null); +assert(rest instanceof Object); + + +assert.sameValue(result, vals); diff --git a/test/language/expressions/assignment/dstr-obj-rest-to-property-with-setter.js b/test/language/expressions/assignment/dstr-obj-rest-to-property-with-setter.js new file mode 100644 index 0000000000..1f30664bd3 --- /dev/null +++ b/test/language/expressions/assignment/dstr-obj-rest-to-property-with-setter.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-to-property-with-setter.case +// - src/dstr-assignment/default/assignment-expr.template +/*--- +description: When DestructuringAssignmentTarget is an object property setter, its value should be binded as rest object. (AssignmentExpression) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ +var settedValue; +var executedGetter = false; +var src = { + get y() { executedGetter = true; }, + set y(v) { + settedValue = v; + } +} +src.y = undefined; + +var result; +var vals = { x: 1, y: 2}; + +result = {...src.y} = vals; + +assert.sameValue(settedValue.x, 1); +assert.sameValue(settedValue.y, 2); +assert(!executedGetter, "The property should not be accessed"); + + +assert.sameValue(result, vals); diff --git a/test/language/expressions/assignment/dstr-obj-rest-to-property.js b/test/language/expressions/assignment/dstr-obj-rest-to-property.js new file mode 100644 index 0000000000..1788d589ec --- /dev/null +++ b/test/language/expressions/assignment/dstr-obj-rest-to-property.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-to-property.case +// - src/dstr-assignment/default/assignment-expr.template +/*--- +description: When DestructuringAssignmentTarget is an object property, its value should be binded as rest object. (AssignmentExpression) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ +var src = {}; + +var result; +var vals = { x: 1, y: 2}; + +result = {...src.y} = vals; + +assert.sameValue(src.y.x, 1); +assert.sameValue(src.y.y, 2); + +verifyEnumerable(src, "y"); +verifyWritable(src, "y"); +verifyConfigurable(src, "y"); + + +assert.sameValue(result, vals); diff --git a/test/language/expressions/assignment/dstr-obj-rest-val-null.js b/test/language/expressions/assignment/dstr-obj-rest-val-null.js new file mode 100644 index 0000000000..db5bf6046e --- /dev/null +++ b/test/language/expressions/assignment/dstr-obj-rest-val-null.js @@ -0,0 +1,24 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-val-null.case +// - src/dstr-assignment/error/assignment-expr.template +/*--- +description: TypeError is thrown when rhs is null because of 7.1.13 ToObject ( argument ) used by CopyDataProperties (AssignmentExpression) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ +var rest; + +assert.throws(TypeError, function() { + 0, {...rest} = null +; +}); diff --git a/test/language/expressions/assignment/dstr-obj-rest-val-undefined.js b/test/language/expressions/assignment/dstr-obj-rest-val-undefined.js new file mode 100644 index 0000000000..f7a4904831 --- /dev/null +++ b/test/language/expressions/assignment/dstr-obj-rest-val-undefined.js @@ -0,0 +1,24 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-val-undefined.case +// - src/dstr-assignment/error/assignment-expr.template +/*--- +description: TypeError is thrown when rhs is ```undefined``` because of 7.1.13 ToObject ( argument ) used by CopyDataProperties (AssignmentExpression) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ +var rest; + +assert.throws(TypeError, function() { + 0, {...rest} = undefined +; +}); diff --git a/test/language/expressions/assignment/dstr-obj-rest-valid-object.js b/test/language/expressions/assignment/dstr-obj-rest-valid-object.js new file mode 100644 index 0000000000..c2850b0cfc --- /dev/null +++ b/test/language/expressions/assignment/dstr-obj-rest-valid-object.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-valid-object.case +// - src/dstr-assignment/default/assignment-expr.template +/*--- +description: Rest object contains just unextracted data (AssignmentExpression) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ +var rest, a, b; + + +var result; +var vals = {x: 1, y: 2, a: 5, b: 3}; + +result = {a, b, ...rest} = vals; + +assert.sameValue(rest.x, 1); +assert.sameValue(rest.y, 2); +assert.sameValue(rest.a, undefined); +assert.sameValue(rest.b, undefined); + +verifyEnumerable(rest, "x"); +verifyWritable(rest, "x"); +verifyConfigurable(rest, "x"); + +verifyEnumerable(rest, "y"); +verifyWritable(rest, "y"); +verifyConfigurable(rest, "y"); + + +assert.sameValue(result, vals); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-rest-getter.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..04ae8cd435 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +var C = class { + *method({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-rest-nested-obj.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..2c6e850ed2 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +var C = class { + *method({a, b, ...{c, e}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-rest-obj-nested-rest.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..3cc4d3f5eb --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + *method({a, b, ...{c, ...rest}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-rest-obj-own-property.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..2b95e4c6e9 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Rest object contains just soruce object's own properties (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +var C = class { + *method({ x, ...{y , z} } = o) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..4be1a2a5b3 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +var C = class { + *method({...rest} = o) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-rest-val-obj.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..c897cabd23 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Rest object contains just unextracted data (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + *method({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-rest-getter.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..9957e8aa83 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-rest-getter.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +var C = class { + *method({...x}) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; + } +}; + +new C().method({ get v() { count++; return 2; } }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-rest-nested-obj.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..4f77207e0d --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +var C = class { + *method({a, b, ...{c, e}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; + } +}; + +new C().method({a: 1, b: 2, c: 3, d: 4, e: 5}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-rest-obj-nested-rest.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..a3256342e3 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + *method({a, b, ...{c, ...rest}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; + } +}; + +new C().method({a: 1, b: 2, c: 3, d: 4, e: 5}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-rest-obj-own-property.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..25fb833e34 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Rest object contains just soruce object's own properties (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +var C = class { + *method({ x, ...{y , z} }) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; + } +}; + +new C().method(o).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-rest-skip-non-enumerable.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..5884e4f80f --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Rest object doesn't contain non-enumerable properties (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +var C = class { + *method({...rest}) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; + } +}; + +new C().method(o).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-rest-val-obj.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..1885fa9336 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-rest-val-obj.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Rest object contains just unextracted data (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + *method({a, b, ...rest}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; + } +}; + +new C().method({x: 1, y: 2, a: 5, b: 3}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-getter.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..7e86b6a831 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +var C = class { + static *method({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-nested-obj.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..c84f67b6f4 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +var C = class { + static *method({a, b, ...{c, e}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-obj-nested-rest.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..7a2d95e338 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + static *method({a, b, ...{c, ...rest}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-obj-own-property.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..27d58ce4aa --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Rest object contains just soruce object's own properties (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +var C = class { + static *method({ x, ...{y , z} } = o) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..e909b8dbdc --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +var C = class { + static *method({...rest} = o) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-val-obj.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..7976abf4d8 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Rest object contains just unextracted data (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + static *method({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-rest-getter.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..6daadb963b --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-rest-getter.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +var C = class { + static *method({...x}) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; + } +}; + +C.method({ get v() { count++; return 2; } }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-rest-nested-obj.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..71b85cc644 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +var C = class { + static *method({a, b, ...{c, e}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; + } +}; + +C.method({a: 1, b: 2, c: 3, d: 4, e: 5}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-rest-obj-nested-rest.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..7190f9ca41 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + static *method({a, b, ...{c, ...rest}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; + } +}; + +C.method({a: 1, b: 2, c: 3, d: 4, e: 5}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-rest-obj-own-property.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..72391664a3 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Rest object contains just soruce object's own properties (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +var C = class { + static *method({ x, ...{y , z} }) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; + } +}; + +C.method(o).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-rest-skip-non-enumerable.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..1438d4fda0 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Rest object doesn't contain non-enumerable properties (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +var C = class { + static *method({...rest}) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; + } +}; + +C.method(o).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-rest-val-obj.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..41ff3fb90e --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-rest-val-obj.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Rest object contains just unextracted data (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + static *method({a, b, ...rest}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; + } +}; + +C.method({x: 1, y: 2, a: 5, b: 3}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-rest-getter.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..6d6c6402ab --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +var C = class { + method({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-rest-nested-obj.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..f86f87d244 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +var C = class { + method({a, b, ...{c, e}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-rest-obj-nested-rest.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..27036c6010 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + method({a, b, ...{c, ...rest}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-rest-obj-own-property.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..0d3d32f0aa --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Rest object contains just soruce object's own properties (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +var C = class { + method({ x, ...{y , z} } = o) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..f4afbe1678 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +var C = class { + method({...rest} = o) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-rest-val-obj.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..6ac34262cc --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Rest object contains just unextracted data (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + method({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-rest-getter.js b/test/language/expressions/class/dstr-meth-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..7434286f3c --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-rest-getter.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +var C = class { + method({...x}) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; + } +}; + +new C().method({ get v() { count++; return 2; } }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-rest-nested-obj.js b/test/language/expressions/class/dstr-meth-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..54eab9ccd3 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +var C = class { + method({a, b, ...{c, e}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; + } +}; + +new C().method({a: 1, b: 2, c: 3, d: 4, e: 5}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-rest-obj-nested-rest.js b/test/language/expressions/class/dstr-meth-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..c6b31883af --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + method({a, b, ...{c, ...rest}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; + } +}; + +new C().method({a: 1, b: 2, c: 3, d: 4, e: 5}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-rest-obj-own-property.js b/test/language/expressions/class/dstr-meth-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..ccbee2c5e3 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Rest object contains just soruce object's own properties (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +var C = class { + method({ x, ...{y , z} }) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; + } +}; + +new C().method(o); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-rest-skip-non-enumerable.js b/test/language/expressions/class/dstr-meth-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..a94647a03f --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Rest object doesn't contain non-enumerable properties (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +var C = class { + method({...rest}) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; + } +}; + +new C().method(o); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-rest-val-obj.js b/test/language/expressions/class/dstr-meth-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..ed96fd7759 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-rest-val-obj.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Rest object contains just unextracted data (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + method({a, b, ...rest}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; + } +}; + +new C().method({x: 1, y: 2, a: 5, b: 3}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-rest-getter.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..2708eceadd --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +var C = class { + static method({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-rest-nested-obj.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..0e498d0531 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +var C = class { + static method({a, b, ...{c, e}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-rest-obj-nested-rest.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..698377a34d --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + static method({a, b, ...{c, ...rest}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-rest-obj-own-property.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..60ebd7ba23 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Rest object contains just soruce object's own properties (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +var C = class { + static method({ x, ...{y , z} } = o) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..58d7513538 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +var C = class { + static method({...rest} = o) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-rest-val-obj.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..0e42c80fb5 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Rest object contains just unextracted data (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + static method({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-rest-getter.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..11d1a10cd1 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-rest-getter.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +var C = class { + static method({...x}) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; + } +}; + +C.method({ get v() { count++; return 2; } }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-rest-nested-obj.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..8a490143b2 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +var C = class { + static method({a, b, ...{c, e}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; + } +}; + +C.method({a: 1, b: 2, c: 3, d: 4, e: 5}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-rest-obj-nested-rest.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..68e7c80084 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + static method({a, b, ...{c, ...rest}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; + } +}; + +C.method({a: 1, b: 2, c: 3, d: 4, e: 5}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-rest-obj-own-property.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..c75394c447 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Rest object contains just soruce object's own properties (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +var C = class { + static method({ x, ...{y , z} }) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; + } +}; + +C.method(o); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-rest-skip-non-enumerable.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..511d564b12 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Rest object doesn't contain non-enumerable properties (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +var C = class { + static method({...rest}) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; + } +}; + +C.method(o); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-rest-val-obj.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..3fef914e86 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-rest-val-obj.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Rest object contains just unextracted data (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + static method({a, b, ...rest}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; + } +}; + +C.method({x: 1, y: 2, a: 5, b: 3}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-rest-getter.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..b2be1ab97e --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +var f; +f = function({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-rest-nested-obj.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..27e7c059c2 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +var f; +f = function({a, b, ...{c, e}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-rest-obj-nested-rest.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..dabfec8e63 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = function({a, b, ...{c, ...rest}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-rest-obj-own-property.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..28248dde62 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Rest object contains just soruce object's own properties (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +var f; +f = function({ x, ...{y , z} } = o) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-rest-skip-non-enumerable.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..3c73dc14a1 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +var f; +f = function({...rest} = o) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-rest-val-obj.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..cf8e4bc177 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Rest object contains just unextracted data (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = function({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-obj-ptrn-rest-getter.js b/test/language/expressions/function/dstr-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..0dc81a76a9 --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-rest-getter.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +var f; +f = function({...x}) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; +}; + +f({ get v() { count++; return 2; } }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-obj-ptrn-rest-nested-obj.js b/test/language/expressions/function/dstr-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..4af893c7cd --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +var f; +f = function({a, b, ...{c, e}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; +}; + +f({a: 1, b: 2, c: 3, d: 4, e: 5}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-obj-ptrn-rest-obj-nested-rest.js b/test/language/expressions/function/dstr-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..64618bf8dc --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = function({a, b, ...{c, ...rest}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; +}; + +f({a: 1, b: 2, c: 3, d: 4, e: 5}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-obj-ptrn-rest-obj-own-property.js b/test/language/expressions/function/dstr-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..02f25da760 --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Rest object contains just soruce object's own properties (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +var f; +f = function({ x, ...{y , z} }) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; +}; + +f(o); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-obj-ptrn-rest-skip-non-enumerable.js b/test/language/expressions/function/dstr-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..924073974a --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Rest object doesn't contain non-enumerable properties (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +var f; +f = function({...rest}) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; +}; + +f(o); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-obj-ptrn-rest-val-obj.js b/test/language/expressions/function/dstr-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..6c1bb53e51 --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-rest-val-obj.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Rest object contains just unextracted data (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = function({a, b, ...rest}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; +}; + +f({x: 1, y: 2, a: 5, b: 3}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-rest-getter.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..8b70a8cae4 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +var f; +f = function*({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-rest-nested-obj.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..ef96c0efe5 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +var f; +f = function*({a, b, ...{c, e}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-rest-obj-nested-rest.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..75553e26ca --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = function*({a, b, ...{c, ...rest}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-rest-obj-own-property.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..9d0060b2c0 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Rest object contains just soruce object's own properties (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +var f; +f = function*({ x, ...{y , z} } = o) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-rest-skip-non-enumerable.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..1e4b19b6f3 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +var f; +f = function*({...rest} = o) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-rest-val-obj.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..e05aa830d9 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Rest object contains just unextracted data (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = function*({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-rest-getter.js b/test/language/expressions/generators/dstr-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..03289aee38 --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-rest-getter.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +var f; +f = function*({...x}) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; +}; + +f({ get v() { count++; return 2; } }).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-rest-nested-obj.js b/test/language/expressions/generators/dstr-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..19e826e83c --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +var f; +f = function*({a, b, ...{c, e}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; +}; + +f({a: 1, b: 2, c: 3, d: 4, e: 5}).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-rest-obj-nested-rest.js b/test/language/expressions/generators/dstr-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..e90f20d099 --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = function*({a, b, ...{c, ...rest}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; +}; + +f({a: 1, b: 2, c: 3, d: 4, e: 5}).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-rest-obj-own-property.js b/test/language/expressions/generators/dstr-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..35a691d140 --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Rest object contains just soruce object's own properties (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +var f; +f = function*({ x, ...{y , z} }) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; +}; + +f(o).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-rest-skip-non-enumerable.js b/test/language/expressions/generators/dstr-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..fd293ce9a3 --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Rest object doesn't contain non-enumerable properties (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +var f; +f = function*({...rest}) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; +}; + +f(o).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-rest-val-obj.js b/test/language/expressions/generators/dstr-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..8005c8039b --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-rest-val-obj.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Rest object contains just unextracted data (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = function*({a, b, ...rest}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; +}; + +f({x: 1, y: 2, a: 5, b: 3}).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-rest-getter.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..742574e4ac --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +var obj = { + *method({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-rest-nested-obj.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..131b34ab35 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +var obj = { + *method({a, b, ...{c, e}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-rest-obj-nested-rest.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..eeafea25de --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var obj = { + *method({a, b, ...{c, ...rest}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-rest-obj-own-property.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..2307b82b6e --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Rest object contains just soruce object's own properties (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +var obj = { + *method({ x, ...{y , z} } = o) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..fa2721731b --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +var obj = { + *method({...rest} = o) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-rest-val-obj.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..079090dbbb --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Rest object contains just unextracted data (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var obj = { + *method({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-rest-getter.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..658b10be97 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-rest-getter.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +var obj = { + *method({...x}) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; + } +}; + +obj.method({ get v() { count++; return 2; } }).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-rest-nested-obj.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..23554c821b --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +var obj = { + *method({a, b, ...{c, e}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; + } +}; + +obj.method({a: 1, b: 2, c: 3, d: 4, e: 5}).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-rest-obj-nested-rest.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..56047880a7 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var obj = { + *method({a, b, ...{c, ...rest}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; + } +}; + +obj.method({a: 1, b: 2, c: 3, d: 4, e: 5}).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-rest-obj-own-property.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..64ab1563e4 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Rest object contains just soruce object's own properties (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +var obj = { + *method({ x, ...{y , z} }) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; + } +}; + +obj.method(o).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-rest-skip-non-enumerable.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..9f3c5ec9ab --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Rest object doesn't contain non-enumerable properties (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +var obj = { + *method({...rest}) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; + } +}; + +obj.method(o).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-rest-val-obj.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..441d78cd19 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-rest-val-obj.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Rest object contains just unextracted data (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var obj = { + *method({a, b, ...rest}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; + } +}; + +obj.method({x: 1, y: 2, a: 5, b: 3}).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-rest-getter.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..ff36f59aa8 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +var obj = { + method({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-rest-nested-obj.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..28efd59d50 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +var obj = { + method({a, b, ...{c, e}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-rest-obj-nested-rest.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..c40aa665ce --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var obj = { + method({a, b, ...{c, ...rest}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-rest-obj-own-property.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..63f10c9c16 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Rest object contains just soruce object's own properties (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +var obj = { + method({ x, ...{y , z} } = o) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..919fa26f7d --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +var obj = { + method({...rest} = o) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-rest-val-obj.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..8b93f4b5cd --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Rest object contains just unextracted data (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var obj = { + method({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-rest-getter.js b/test/language/expressions/object/dstr-meth-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..b2e3850e5f --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-rest-getter.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/meth.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +var obj = { + method({...x}) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; + } +}; + +obj.method({ get v() { count++; return 2; } }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-rest-nested-obj.js b/test/language/expressions/object/dstr-meth-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..c11317fc76 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/meth.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +var obj = { + method({a, b, ...{c, e}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; + } +}; + +obj.method({a: 1, b: 2, c: 3, d: 4, e: 5}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-rest-obj-nested-rest.js b/test/language/expressions/object/dstr-meth-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..1d42f3be2d --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/meth.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var obj = { + method({a, b, ...{c, ...rest}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; + } +}; + +obj.method({a: 1, b: 2, c: 3, d: 4, e: 5}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-rest-obj-own-property.js b/test/language/expressions/object/dstr-meth-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..64cd288b7a --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/meth.template +/*--- +description: Rest object contains just soruce object's own properties (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +var obj = { + method({ x, ...{y , z} }) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; + } +}; + +obj.method(o); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-rest-skip-non-enumerable.js b/test/language/expressions/object/dstr-meth-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..badc2b45ba --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/meth.template +/*--- +description: Rest object doesn't contain non-enumerable properties (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +var obj = { + method({...rest}) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; + } +}; + +obj.method(o); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-rest-val-obj.js b/test/language/expressions/object/dstr-meth-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..79bddb9982 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-rest-val-obj.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/meth.template +/*--- +description: Rest object contains just unextracted data (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var obj = { + method({a, b, ...rest}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; + } +}; + +obj.method({x: 1, y: 2, a: 5, b: 3}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-rest-getter.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..fd2674f6cb --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +class C { + *method({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-rest-nested-obj.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..ce6aa32ee4 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +class C { + *method({a, b, ...{c, e}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..fe49e5e307 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + *method({a, b, ...{c, ...rest}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-rest-obj-own-property.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..1eebc51701 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest object contains just soruce object's own properties (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +class C { + *method({ x, ...{y , z} } = o) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..6bcd358133 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +class C { + *method({...rest} = o) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-rest-val-obj.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..1c82a76cd3 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest object contains just unextracted data (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + *method({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-rest-getter.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..8c68a132da --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-rest-getter.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +class C { + *method({...x}) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; + } +}; + +new C().method({ get v() { count++; return 2; } }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-rest-nested-obj.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..8b3ff26221 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +class C { + *method({a, b, ...{c, e}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; + } +}; + +new C().method({a: 1, b: 2, c: 3, d: 4, e: 5}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..805f3a87ec --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + *method({a, b, ...{c, ...rest}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; + } +}; + +new C().method({a: 1, b: 2, c: 3, d: 4, e: 5}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-rest-obj-own-property.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..da44dcfd70 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest object contains just soruce object's own properties (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +class C { + *method({ x, ...{y , z} }) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; + } +}; + +new C().method(o).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..b2577e29f9 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest object doesn't contain non-enumerable properties (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +class C { + *method({...rest}) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; + } +}; + +new C().method(o).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-rest-val-obj.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..5bcdb10623 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-rest-val-obj.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest object contains just unextracted data (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + *method({a, b, ...rest}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; + } +}; + +new C().method({x: 1, y: 2, a: 5, b: 3}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-getter.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..b8bc9470b7 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +class C { + static *method({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-nested-obj.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..368c3be447 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +class C { + static *method({a, b, ...{c, e}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..8ad9c4af15 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + static *method({a, b, ...{c, ...rest}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-obj-own-property.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..1e08d9557b --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest object contains just soruce object's own properties (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +class C { + static *method({ x, ...{y , z} } = o) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..eb78bf371b --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +class C { + static *method({...rest} = o) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-val-obj.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..60310abf05 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest object contains just unextracted data (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + static *method({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-rest-getter.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..259bc65045 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-rest-getter.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +class C { + static *method({...x}) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; + } +}; + +C.method({ get v() { count++; return 2; } }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-rest-nested-obj.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..34fe198d2d --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +class C { + static *method({a, b, ...{c, e}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; + } +}; + +C.method({a: 1, b: 2, c: 3, d: 4, e: 5}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..36f9452037 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + static *method({a, b, ...{c, ...rest}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; + } +}; + +C.method({a: 1, b: 2, c: 3, d: 4, e: 5}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-rest-obj-own-property.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..c1a7cfde09 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest object contains just soruce object's own properties (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +class C { + static *method({ x, ...{y , z} }) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; + } +}; + +C.method(o).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..e00e39fc6e --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest object doesn't contain non-enumerable properties (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +class C { + static *method({...rest}) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; + } +}; + +C.method(o).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-rest-val-obj.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..abfc9b0cc4 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-rest-val-obj.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest object contains just unextracted data (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + static *method({a, b, ...rest}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; + } +}; + +C.method({x: 1, y: 2, a: 5, b: 3}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-rest-getter.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..7eb836e4da --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +class C { + method({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-rest-nested-obj.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..373cc926a0 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +class C { + method({a, b, ...{c, e}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..9870591a2a --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + method({a, b, ...{c, ...rest}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-rest-obj-own-property.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..678892e1e1 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest object contains just soruce object's own properties (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +class C { + method({ x, ...{y , z} } = o) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..5346fae5d9 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +class C { + method({...rest} = o) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-rest-val-obj.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..fb17c4c057 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest object contains just unextracted data (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + method({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-rest-getter.js b/test/language/statements/class/dstr-meth-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..c48666e231 --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-rest-getter.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +class C { + method({...x}) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; + } +}; + +new C().method({ get v() { count++; return 2; } }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-rest-nested-obj.js b/test/language/statements/class/dstr-meth-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..6df72e67c9 --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +class C { + method({a, b, ...{c, e}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; + } +}; + +new C().method({a: 1, b: 2, c: 3, d: 4, e: 5}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/class/dstr-meth-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..d4df883036 --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + method({a, b, ...{c, ...rest}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; + } +}; + +new C().method({a: 1, b: 2, c: 3, d: 4, e: 5}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-rest-obj-own-property.js b/test/language/statements/class/dstr-meth-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..789e2b3e9c --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest object contains just soruce object's own properties (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +class C { + method({ x, ...{y , z} }) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; + } +}; + +new C().method(o); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/class/dstr-meth-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..7ae8e75d29 --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest object doesn't contain non-enumerable properties (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +class C { + method({...rest}) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; + } +}; + +new C().method(o); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-rest-val-obj.js b/test/language/statements/class/dstr-meth-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..1e99b44b13 --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-rest-val-obj.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest object contains just unextracted data (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + method({a, b, ...rest}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; + } +}; + +new C().method({x: 1, y: 2, a: 5, b: 3}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-rest-getter.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..758c1bb34a --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +class C { + static method({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-rest-nested-obj.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..2fe4e482be --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +class C { + static method({a, b, ...{c, e}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..01f87367f5 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + static method({a, b, ...{c, ...rest}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-rest-obj-own-property.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..6a543ba403 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest object contains just soruce object's own properties (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +class C { + static method({ x, ...{y , z} } = o) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..ec4849fd7a --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +class C { + static method({...rest} = o) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-rest-val-obj.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..22dd70fd37 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest object contains just unextracted data (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + static method({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-rest-getter.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..42386408d8 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-rest-getter.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +class C { + static method({...x}) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; + } +}; + +C.method({ get v() { count++; return 2; } }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-rest-nested-obj.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..dc7cc2852c --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +class C { + static method({a, b, ...{c, e}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; + } +}; + +C.method({a: 1, b: 2, c: 3, d: 4, e: 5}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..46c38effc8 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + static method({a, b, ...{c, ...rest}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; + } +}; + +C.method({a: 1, b: 2, c: 3, d: 4, e: 5}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-rest-obj-own-property.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..6ec8d40a0d --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest object contains just soruce object's own properties (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +class C { + static method({ x, ...{y , z} }) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; + } +}; + +C.method(o); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..f69c7c43c6 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest object doesn't contain non-enumerable properties (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +class C { + static method({...rest}) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; + } +}; + +C.method(o); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-rest-val-obj.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..00dd2bcbc1 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-rest-val-obj.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest object contains just unextracted data (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + static method({a, b, ...rest}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; + } +}; + +C.method({x: 1, y: 2, a: 5, b: 3}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/const/dstr-obj-ptrn-rest-getter.js b/test/language/statements/const/dstr-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..e53000e345 --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-rest-getter.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context's LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env as the arguments. +---*/ +var count = 0; + +const {...x} = { get v() { count++; return 2; } }; + +assert.sameValue(x.v, 2); +assert.sameValue(count, 1); + +verifyEnumerable(x, "v"); +verifyWritable(x, "v"); +verifyConfigurable(x, "v"); + diff --git a/test/language/statements/const/dstr-obj-ptrn-rest-nested-obj.js b/test/language/statements/const/dstr-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..d407984af2 --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,28 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [destructuring-binding] +flags: [generated] +info: | + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context's LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env as the arguments. +---*/ +var obj = {a: 3, b: 4}; + +const {a, b, ...{c, e}} = {a: 1, b: 2, c: 3, d: 4, e: 5}; + +assert.sameValue(a, 1); +assert.sameValue(b, 2); +assert.sameValue(c, 3); +assert.sameValue(e, 5); + diff --git a/test/language/statements/const/dstr-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/const/dstr-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..561f7caf3c --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context's LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env as the arguments. +---*/ + +const {a, b, ...{c, ...rest}} = {a: 1, b: 2, c: 3, d: 4, e: 5}; + +assert.sameValue(a, 1); +assert.sameValue(b, 2); +assert.sameValue(c, 3); + +assert.sameValue(rest.d, 4); +assert.sameValue(rest.e, 5); + +verifyEnumerable(rest, "d"); +verifyWritable(rest, "d"); +verifyConfigurable(rest, "d"); + +verifyEnumerable(rest, "e"); +verifyWritable(rest, "e"); +verifyConfigurable(rest, "e"); + diff --git a/test/language/statements/const/dstr-obj-ptrn-rest-obj-own-property.js b/test/language/statements/const/dstr-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..e6716fff69 --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,29 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Rest object contains just soruce object's own properties (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context's LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env as the arguments. +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +const { x, ...{y , z} } = o; + +assert.sameValue(x, 1); +assert.sameValue(y, undefined); +assert.sameValue(z, 3); + diff --git a/test/language/statements/const/dstr-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/const/dstr-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..e89a2c00e1 --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context's LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env as the arguments. +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +const {...rest} = o; + +assert.sameValue(rest.a, 3); +assert.sameValue(rest.b, 4); +assert.sameValue(rest.x, undefined); + +verifyEnumerable(rest, "a"); +verifyWritable(rest, "a"); +verifyConfigurable(rest, "a"); + +verifyEnumerable(rest, "b"); +verifyWritable(rest, "b"); +verifyConfigurable(rest, "b"); + diff --git a/test/language/statements/const/dstr-obj-ptrn-rest-val-obj.js b/test/language/statements/const/dstr-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..e6ee096aa9 --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-rest-val-obj.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Rest object contains just unextracted data (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context's LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env as the arguments. +---*/ + +const {a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}; + +assert.sameValue(rest.x, 1); +assert.sameValue(rest.y, 2); +assert.sameValue(rest.a, undefined); +assert.sameValue(rest.b, undefined); + +verifyEnumerable(rest, "x"); +verifyWritable(rest, "x"); +verifyConfigurable(rest, "x"); + +verifyEnumerable(rest, "y"); +verifyWritable(rest, "y"); +verifyConfigurable(rest, "y"); + diff --git a/test/language/statements/for-in/dstr-obj-rest-not-last-element-invalid.js b/test/language/statements/for-in/dstr-obj-rest-not-last-element-invalid.js new file mode 100644 index 0000000000..bb25066136 --- /dev/null +++ b/test/language/statements/for-in/dstr-obj-rest-not-last-element-invalid.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-not-last-element-invalid.case +// - src/dstr-assignment/syntax/for-in.template +/*--- +description: Object rest element needs to be the last AssignmenProperty in ObjectAssignmentPattern. (For..in statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var rest, b; + +for ({...rest, b} in [{} +]) ; diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-rest-getter.js b/test/language/statements/for-of/dstr-const-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..04545462a6 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-rest-getter.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 3. Return ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 3. Let destructuring be IsDestructuring of lhs. + [...] + 5. Repeat + [...] + h. If destructuring is false, then + [...] + i. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var count = 0; + +var iterCount = 0; + +for (const {...x} of [{ get v() { count++; return 2; } }]) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-rest-nested-obj.js b/test/language/statements/for-of/dstr-const-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..d49377932a --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +info: | + IterationStatement : + for ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 3. Return ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 3. Let destructuring be IsDestructuring of lhs. + [...] + 5. Repeat + [...] + h. If destructuring is false, then + [...] + i. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var iterCount = 0; + +for (const {a, b, ...{c, e}} of [{a: 1, b: 2, c: 3, d: 4, e: 5}]) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/for-of/dstr-const-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..fd2bdf4f57 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 3. Return ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 3. Let destructuring be IsDestructuring of lhs. + [...] + 5. Repeat + [...] + h. If destructuring is false, then + [...] + i. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; + +for (const {a, b, ...{c, ...rest}} of [{a: 1, b: 2, c: 3, d: 4, e: 5}]) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-rest-obj-own-property.js b/test/language/statements/for-of/dstr-const-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..2f99501a2f --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Rest object contains just soruce object's own properties (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 3. Return ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 3. Let destructuring be IsDestructuring of lhs. + [...] + 5. Repeat + [...] + h. If destructuring is false, then + [...] + i. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var iterCount = 0; + +for (const { x, ...{y , z} } of [o]) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/for-of/dstr-const-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..f7800bd3e3 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Rest object doesn't contain non-enumerable properties (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 3. Return ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 3. Let destructuring be IsDestructuring of lhs. + [...] + 5. Repeat + [...] + h. If destructuring is false, then + [...] + i. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var iterCount = 0; + +for (const {...rest} of [o]) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-rest-val-obj.js b/test/language/statements/for-of/dstr-const-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..1d78fc2136 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-rest-val-obj.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Rest object contains just unextracted data (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 3. Return ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 3. Let destructuring be IsDestructuring of lhs. + [...] + 5. Repeat + [...] + h. If destructuring is false, then + [...] + i. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; + +for (const {a, b, ...rest} of [{x: 1, y: 2, a: 5, b: 3}]) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-rest-getter.js b/test/language/statements/for-of/dstr-let-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..981239c7e9 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-rest-getter.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 3. Return ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 3. Let destructuring be IsDestructuring of lhs. + [...] + 5. Repeat + [...] + h. If destructuring is false, then + [...] + i. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var count = 0; + +var iterCount = 0; + +for (let {...x} of [{ get v() { count++; return 2; } }]) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-rest-nested-obj.js b/test/language/statements/for-of/dstr-let-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..cea3bb198b --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +info: | + IterationStatement : + for ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 3. Return ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 3. Let destructuring be IsDestructuring of lhs. + [...] + 5. Repeat + [...] + h. If destructuring is false, then + [...] + i. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var iterCount = 0; + +for (let {a, b, ...{c, e}} of [{a: 1, b: 2, c: 3, d: 4, e: 5}]) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/for-of/dstr-let-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..fea88c0aca --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 3. Return ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 3. Let destructuring be IsDestructuring of lhs. + [...] + 5. Repeat + [...] + h. If destructuring is false, then + [...] + i. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; + +for (let {a, b, ...{c, ...rest}} of [{a: 1, b: 2, c: 3, d: 4, e: 5}]) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-rest-obj-own-property.js b/test/language/statements/for-of/dstr-let-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..da1c9dcfe0 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Rest object contains just soruce object's own properties (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 3. Return ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 3. Let destructuring be IsDestructuring of lhs. + [...] + 5. Repeat + [...] + h. If destructuring is false, then + [...] + i. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var iterCount = 0; + +for (let { x, ...{y , z} } of [o]) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/for-of/dstr-let-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..41ade66ae5 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Rest object doesn't contain non-enumerable properties (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 3. Return ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 3. Let destructuring be IsDestructuring of lhs. + [...] + 5. Repeat + [...] + h. If destructuring is false, then + [...] + i. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var iterCount = 0; + +for (let {...rest} of [o]) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-rest-val-obj.js b/test/language/statements/for-of/dstr-let-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..e4e8393886 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-rest-val-obj.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Rest object contains just unextracted data (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 3. Return ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 3. Let destructuring be IsDestructuring of lhs. + [...] + 5. Repeat + [...] + h. If destructuring is false, then + [...] + i. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; + +for (let {a, b, ...rest} of [{x: 1, y: 2, a: 5, b: 3}]) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-obj-rest-descriptors.js b/test/language/statements/for-of/dstr-obj-rest-descriptors.js new file mode 100644 index 0000000000..9277ceb6e5 --- /dev/null +++ b/test/language/statements/for-of/dstr-obj-rest-descriptors.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-descriptors.case +// - src/dstr-assignment/default/for-of.template +/*--- +description: Object created from rest deconstruction doesn't copy source object property descriptors. (For..of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var rest; +var obj = {}; +Object.defineProperty(obj, "a", { value: 3, configurable: false, enumerable: true }); +Object.defineProperty(obj, "b", { value: 4, writable: false, enumerable: true }); + +var counter = 0; + +for ({...rest} of [obj]) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + counter += 1; +} + +assert.sameValue(counter, 1); diff --git a/test/language/statements/for-of/dstr-obj-rest-empty-obj.js b/test/language/statements/for-of/dstr-obj-rest-empty-obj.js new file mode 100644 index 0000000000..82d68a66e8 --- /dev/null +++ b/test/language/statements/for-of/dstr-obj-rest-empty-obj.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-empty-obj.case +// - src/dstr-assignment/default/for-of.template +/*--- +description: RestBindingInitialization creates a new object even if lhs is an empty object (For..of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var rest; + + +var counter = 0; + +for ({...rest} of [{}]) { + assert.notSameValue(rest, undefined); + assert.notSameValue(rest, null); + assert.sameValue(typeof rest, "object"); + + counter += 1; +} + +assert.sameValue(counter, 1); diff --git a/test/language/statements/for-of/dstr-obj-rest-getter-abrupt-get-error.js b/test/language/statements/for-of/dstr-obj-rest-getter-abrupt-get-error.js new file mode 100644 index 0000000000..1490cc2187 --- /dev/null +++ b/test/language/statements/for-of/dstr-obj-rest-getter-abrupt-get-error.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-getter-abrupt-get-error.case +// - src/dstr-assignment/error/for-of.template +/*--- +description: Rest deconstruction doesn't happen if getter return is abrupt (For..of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var x; +var count = 0; + +var counter = 0; + +assert.throws(Test262Error, function() { + for ({...x} of [{ get v() { count++; throw new Test262Error(); } }]) { + counter += 1; + } + counter += 1; +}); + +assert.sameValue(counter, 0); + +assert.sameValue(count, 1); + diff --git a/test/language/statements/for-of/dstr-obj-rest-getter.js b/test/language/statements/for-of/dstr-obj-rest-getter.js new file mode 100644 index 0000000000..82d3bcd1f3 --- /dev/null +++ b/test/language/statements/for-of/dstr-obj-rest-getter.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-getter.case +// - src/dstr-assignment/default/for-of.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (For..of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var x; +var count = 0; + +var counter = 0; + +for ({...x} of [{ get v() { count++; return 2; } }]) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + counter += 1; +} + +assert.sameValue(counter, 1); diff --git a/test/language/statements/for-of/dstr-obj-rest-nested-obj-nested-rest.js b/test/language/statements/for-of/dstr-obj-rest-nested-obj-nested-rest.js new file mode 100644 index 0000000000..32be98f68f --- /dev/null +++ b/test/language/statements/for-of/dstr-obj-rest-nested-obj-nested-rest.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-nested-obj-nested-rest.case +// - src/dstr-assignment/default/for-of.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (For..of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var a, b, c, rest; + +var counter = 0; + +for ({a, b, ...{c, ...rest}} of [{a: 1, b: 2, c: 3, d: 4, e: 5}]) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + counter += 1; +} + +assert.sameValue(counter, 1); diff --git a/test/language/statements/for-of/dstr-obj-rest-nested-obj.js b/test/language/statements/for-of/dstr-obj-rest-nested-obj.js new file mode 100644 index 0000000000..6b81ad479b --- /dev/null +++ b/test/language/statements/for-of/dstr-obj-rest-nested-obj.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-nested-obj.case +// - src/dstr-assignment/default/for-of.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (For..of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var a, b, c, d, e; + +var counter = 0; + +for ({a, b, ...{c, e}} of [{a: 1, b: 2, c: 3, d: 4, e: 5}]) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + assert.sameValue(d, undefined); + + counter += 1; +} + +assert.sameValue(counter, 1); diff --git a/test/language/statements/for-of/dstr-obj-rest-not-last-element-invalid.js b/test/language/statements/for-of/dstr-obj-rest-not-last-element-invalid.js new file mode 100644 index 0000000000..bd9a2b9326 --- /dev/null +++ b/test/language/statements/for-of/dstr-obj-rest-not-last-element-invalid.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-not-last-element-invalid.case +// - src/dstr-assignment/syntax/for-of.template +/*--- +description: Object rest element needs to be the last AssignmenProperty in ObjectAssignmentPattern. (For..of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +negative: + phase: early + type: SyntaxError +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var rest, b; + +for ({...rest, b} of [{} +]) ; diff --git a/test/language/statements/for-of/dstr-obj-rest-number.js b/test/language/statements/for-of/dstr-obj-rest-number.js new file mode 100644 index 0000000000..2737e1a4be --- /dev/null +++ b/test/language/statements/for-of/dstr-obj-rest-number.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-number.case +// - src/dstr-assignment/default/for-of.template +/*--- +description: RestBindingInitialization creates a new object even if lhs is a Number (For..of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var rest; + + +var counter = 0; + +for ({...rest} of [51]) { + assert.notSameValue(rest, undefined); + assert.notSameValue(rest, null); + assert(rest instanceof Object); + + counter += 1; +} + +assert.sameValue(counter, 1); diff --git a/test/language/statements/for-of/dstr-obj-rest-obj-own-property.js b/test/language/statements/for-of/dstr-obj-rest-obj-own-property.js new file mode 100644 index 0000000000..6dc9e19001 --- /dev/null +++ b/test/language/statements/for-of/dstr-obj-rest-obj-own-property.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-obj-own-property.case +// - src/dstr-assignment/default/for-of.template +/*--- +description: Rest object contains just soruce object's own properties (For..of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var x, y, z; + +var counter = 0; + +for ({ x, ...{y , z} } of [o]) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + counter += 1; +} + +assert.sameValue(counter, 1); diff --git a/test/language/statements/for-of/dstr-obj-rest-put-const.js b/test/language/statements/for-of/dstr-obj-rest-put-const.js new file mode 100644 index 0000000000..77ff18c7b5 --- /dev/null +++ b/test/language/statements/for-of/dstr-obj-rest-put-const.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-put-const.case +// - src/dstr-assignment/error/for-of.template +/*--- +description: The object rest deconstruction assignment target should obey `const` semantics. (For..of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [const, destructuring-binding] +flags: [generated] +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +const rest = null; + +var counter = 0; + +assert.throws(TypeError, function() { + for ({...rest} of [{} +]) { + counter += 1; + } + counter += 1; +}); + +assert.sameValue(counter, 0); diff --git a/test/language/statements/for-of/dstr-obj-rest-skip-non-enumerable.js b/test/language/statements/for-of/dstr-obj-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..5d3b3e3347 --- /dev/null +++ b/test/language/statements/for-of/dstr-obj-rest-skip-non-enumerable.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-skip-non-enumerable.case +// - src/dstr-assignment/default/for-of.template +/*--- +description: Rest object doesn't contain non-enumerable properties (For..of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var rest; +var obj = {a: 3, b: 4}; +Object.defineProperty(obj, "x", { value: 4, enumerable: false }); + +var counter = 0; + +for ({...rest} of [obj]) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(Object.getOwnPropertyDescriptor(rest, "x"), undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + counter += 1; +} + +assert.sameValue(counter, 1); diff --git a/test/language/statements/for-of/dstr-obj-rest-str-val.js b/test/language/statements/for-of/dstr-obj-rest-str-val.js new file mode 100644 index 0000000000..55f0b4c9c6 --- /dev/null +++ b/test/language/statements/for-of/dstr-obj-rest-str-val.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-str-val.case +// - src/dstr-assignment/default/for-of.template +/*--- +description: RestBindingInitialization creats an object with indexes as property name (For..of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var rest; + + +var counter = 0; + +for ({...rest} of ["foo"]) { + assert.sameValue(rest["0"], "f"); + assert.sameValue(rest["1"], "o"); + assert.sameValue(rest["2"], "o"); + assert(rest instanceof Object); + + counter += 1; +} + +assert.sameValue(counter, 1); diff --git a/test/language/statements/for-of/dstr-obj-rest-symbol-val.js b/test/language/statements/for-of/dstr-obj-rest-symbol-val.js new file mode 100644 index 0000000000..51a994b998 --- /dev/null +++ b/test/language/statements/for-of/dstr-obj-rest-symbol-val.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-symbol-val.case +// - src/dstr-assignment/default/for-of.template +/*--- +description: RestBindingInitialization creates a new object if lhs is a Symbol (For..of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var rest; + + +var counter = 0; + +for ({...rest} of [Symbol("foo")]) { + assert.notSameValue(rest, undefined); + assert.notSameValue(rest, null); + assert(rest instanceof Object); + + counter += 1; +} + +assert.sameValue(counter, 1); diff --git a/test/language/statements/for-of/dstr-obj-rest-to-property-with-setter.js b/test/language/statements/for-of/dstr-obj-rest-to-property-with-setter.js new file mode 100644 index 0000000000..ea50631436 --- /dev/null +++ b/test/language/statements/for-of/dstr-obj-rest-to-property-with-setter.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-to-property-with-setter.case +// - src/dstr-assignment/default/for-of.template +/*--- +description: When DestructuringAssignmentTarget is an object property setter, its value should be binded as rest object. (For..of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var settedValue; +var executedGetter = false; +var src = { + get y() { executedGetter = true; }, + set y(v) { + settedValue = v; + } +} +src.y = undefined; + +var counter = 0; + +for ({...src.y} of [{ x: 1, y: 2}]) { + assert.sameValue(settedValue.x, 1); + assert.sameValue(settedValue.y, 2); + assert(!executedGetter, "The property should not be accessed"); + + counter += 1; +} + +assert.sameValue(counter, 1); diff --git a/test/language/statements/for-of/dstr-obj-rest-to-property.js b/test/language/statements/for-of/dstr-obj-rest-to-property.js new file mode 100644 index 0000000000..85fe869e89 --- /dev/null +++ b/test/language/statements/for-of/dstr-obj-rest-to-property.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-to-property.case +// - src/dstr-assignment/default/for-of.template +/*--- +description: When DestructuringAssignmentTarget is an object property, its value should be binded as rest object. (For..of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var src = {}; + +var counter = 0; + +for ({...src.y} of [{ x: 1, y: 2}]) { + assert.sameValue(src.y.x, 1); + assert.sameValue(src.y.y, 2); + + verifyEnumerable(src, "y"); + verifyWritable(src, "y"); + verifyConfigurable(src, "y"); + + counter += 1; +} + +assert.sameValue(counter, 1); diff --git a/test/language/statements/for-of/dstr-obj-rest-val-null.js b/test/language/statements/for-of/dstr-obj-rest-val-null.js new file mode 100644 index 0000000000..21ec1d7b4c --- /dev/null +++ b/test/language/statements/for-of/dstr-obj-rest-val-null.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-val-null.case +// - src/dstr-assignment/error/for-of.template +/*--- +description: TypeError is thrown when rhs is null because of 7.1.13 ToObject ( argument ) used by CopyDataProperties (For..of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var rest; + +var counter = 0; + +assert.throws(TypeError, function() { + for ({...rest} of [null +]) { + counter += 1; + } + counter += 1; +}); + +assert.sameValue(counter, 0); diff --git a/test/language/statements/for-of/dstr-obj-rest-val-undefined.js b/test/language/statements/for-of/dstr-obj-rest-val-undefined.js new file mode 100644 index 0000000000..1e518f34fd --- /dev/null +++ b/test/language/statements/for-of/dstr-obj-rest-val-undefined.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-val-undefined.case +// - src/dstr-assignment/error/for-of.template +/*--- +description: TypeError is thrown when rhs is ```undefined``` because of 7.1.13 ToObject ( argument ) used by CopyDataProperties (For..of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var rest; + +var counter = 0; + +assert.throws(TypeError, function() { + for ({...rest} of [undefined +]) { + counter += 1; + } + counter += 1; +}); + +assert.sameValue(counter, 0); diff --git a/test/language/statements/for-of/dstr-obj-rest-valid-object.js b/test/language/statements/for-of/dstr-obj-rest-valid-object.js new file mode 100644 index 0000000000..b0631cfd50 --- /dev/null +++ b/test/language/statements/for-of/dstr-obj-rest-valid-object.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-assignment/obj-rest-valid-object.case +// - src/dstr-assignment/default/for-of.template +/*--- +description: Rest object contains just unextracted data (For..of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », + AssignmentExpression, iterate). + 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, + keyResult, assignment, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. If destructuring is true and if lhsKind is assignment, then + a. Assert: lhs is a LeftHandSideExpression. + b. Let assignmentPattern be the parse of the source text corresponding to + lhs using AssignmentPattern as the goal symbol. + [...] +---*/ +var rest, a, b; + + +var counter = 0; + +for ({a, b, ...rest} of [{x: 1, y: 2, a: 5, b: 3}]) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + counter += 1; +} + +assert.sameValue(counter, 1); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-rest-getter.js b/test/language/statements/for-of/dstr-var-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..caf9b4cd18 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-rest-getter.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( var ForBinding of AssignmentExpression ) Statement + + [...] + 3. Return ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 3. Let destructuring be IsDestructuring of lhs. + [...] + 5. Repeat + [...] + h. If destructuring is false, then + [...] + i. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + 1. Assert: lhs is a ForBinding. + 2. Let status be the result of performing BindingInitialization + for lhs passing nextValue and undefined as the arguments. + [...] +---*/ +var count = 0; + +var iterCount = 0; + +for (var {...x} of [{ get v() { count++; return 2; } }]) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-rest-nested-obj.js b/test/language/statements/for-of/dstr-var-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..64b3fcaceb --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +info: | + IterationStatement : + for ( var ForBinding of AssignmentExpression ) Statement + + [...] + 3. Return ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 3. Let destructuring be IsDestructuring of lhs. + [...] + 5. Repeat + [...] + h. If destructuring is false, then + [...] + i. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + 1. Assert: lhs is a ForBinding. + 2. Let status be the result of performing BindingInitialization + for lhs passing nextValue and undefined as the arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var iterCount = 0; + +for (var {a, b, ...{c, e}} of [{a: 1, b: 2, c: 3, d: 4, e: 5}]) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/for-of/dstr-var-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..ab14b42f76 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( var ForBinding of AssignmentExpression ) Statement + + [...] + 3. Return ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 3. Let destructuring be IsDestructuring of lhs. + [...] + 5. Repeat + [...] + h. If destructuring is false, then + [...] + i. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + 1. Assert: lhs is a ForBinding. + 2. Let status be the result of performing BindingInitialization + for lhs passing nextValue and undefined as the arguments. + [...] +---*/ + +var iterCount = 0; + +for (var {a, b, ...{c, ...rest}} of [{a: 1, b: 2, c: 3, d: 4, e: 5}]) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-rest-obj-own-property.js b/test/language/statements/for-of/dstr-var-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..be11792933 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Rest object contains just soruce object's own properties (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( var ForBinding of AssignmentExpression ) Statement + + [...] + 3. Return ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 3. Let destructuring be IsDestructuring of lhs. + [...] + 5. Repeat + [...] + h. If destructuring is false, then + [...] + i. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + 1. Assert: lhs is a ForBinding. + 2. Let status be the result of performing BindingInitialization + for lhs passing nextValue and undefined as the arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var iterCount = 0; + +for (var { x, ...{y , z} } of [o]) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/for-of/dstr-var-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..646372547b --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Rest object doesn't contain non-enumerable properties (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( var ForBinding of AssignmentExpression ) Statement + + [...] + 3. Return ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 3. Let destructuring be IsDestructuring of lhs. + [...] + 5. Repeat + [...] + h. If destructuring is false, then + [...] + i. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + 1. Assert: lhs is a ForBinding. + 2. Let status be the result of performing BindingInitialization + for lhs passing nextValue and undefined as the arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var iterCount = 0; + +for (var {...rest} of [o]) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-rest-val-obj.js b/test/language/statements/for-of/dstr-var-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..decbfd2c14 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-rest-val-obj.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Rest object contains just unextracted data (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( var ForBinding of AssignmentExpression ) Statement + + [...] + 3. Return ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 3. Let destructuring be IsDestructuring of lhs. + [...] + 5. Repeat + [...] + h. If destructuring is false, then + [...] + i. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + 1. Assert: lhs is a ForBinding. + 2. Let status be the result of performing BindingInitialization + for lhs passing nextValue and undefined as the arguments. + [...] +---*/ + +var iterCount = 0; + +for (var {a, b, ...rest} of [{x: 1, y: 2, a: 5, b: 3}]) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-rest-getter.js b/test/language/statements/for/dstr-const-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..d9e53dfaf0 --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-rest-getter.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement + + [...] + 7. Let forDcl be the result of evaluating LexicalDeclaration. + [...] + + LexicalDeclaration : LetOrConst BindingList ; + + 1. Let next be the result of evaluating BindingList. + 2. ReturnIfAbrupt(next). + 3. Return NormalCompletion(empty). + + BindingList : BindingList , LexicalBinding + + 1. Let next be the result of evaluating BindingList. + 2. ReturnIfAbrupt(next). + 3. Return the result of evaluating LexicalBinding. + + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context’s LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env as the arguments. +---*/ +var count = 0; + +var iterCount = 0; + +for (const {...x} = { get v() { count++; return 2; } }; iterCount < 1; ) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-rest-nested-obj.js b/test/language/statements/for/dstr-const-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..4939b13f79 --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/for-const.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +info: | + IterationStatement : + for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement + + [...] + 7. Let forDcl be the result of evaluating LexicalDeclaration. + [...] + + LexicalDeclaration : LetOrConst BindingList ; + + 1. Let next be the result of evaluating BindingList. + 2. ReturnIfAbrupt(next). + 3. Return NormalCompletion(empty). + + BindingList : BindingList , LexicalBinding + + 1. Let next be the result of evaluating BindingList. + 2. ReturnIfAbrupt(next). + 3. Return the result of evaluating LexicalBinding. + + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context’s LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env as the arguments. +---*/ +var obj = {a: 3, b: 4}; + +var iterCount = 0; + +for (const {a, b, ...{c, e}} = {a: 1, b: 2, c: 3, d: 4, e: 5}; iterCount < 1; ) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/for/dstr-const-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..010d482446 --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/for-const.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement + + [...] + 7. Let forDcl be the result of evaluating LexicalDeclaration. + [...] + + LexicalDeclaration : LetOrConst BindingList ; + + 1. Let next be the result of evaluating BindingList. + 2. ReturnIfAbrupt(next). + 3. Return NormalCompletion(empty). + + BindingList : BindingList , LexicalBinding + + 1. Let next be the result of evaluating BindingList. + 2. ReturnIfAbrupt(next). + 3. Return the result of evaluating LexicalBinding. + + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context’s LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env as the arguments. +---*/ + +var iterCount = 0; + +for (const {a, b, ...{c, ...rest}} = {a: 1, b: 2, c: 3, d: 4, e: 5}; iterCount < 1; ) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-rest-obj-own-property.js b/test/language/statements/for/dstr-const-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..90c4fae5a2 --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Rest object contains just soruce object's own properties (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement + + [...] + 7. Let forDcl be the result of evaluating LexicalDeclaration. + [...] + + LexicalDeclaration : LetOrConst BindingList ; + + 1. Let next be the result of evaluating BindingList. + 2. ReturnIfAbrupt(next). + 3. Return NormalCompletion(empty). + + BindingList : BindingList , LexicalBinding + + 1. Let next be the result of evaluating BindingList. + 2. ReturnIfAbrupt(next). + 3. Return the result of evaluating LexicalBinding. + + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context’s LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env as the arguments. +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var iterCount = 0; + +for (const { x, ...{y , z} } = o; iterCount < 1; ) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/for/dstr-const-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..c0dbe7705e --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Rest object doesn't contain non-enumerable properties (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement + + [...] + 7. Let forDcl be the result of evaluating LexicalDeclaration. + [...] + + LexicalDeclaration : LetOrConst BindingList ; + + 1. Let next be the result of evaluating BindingList. + 2. ReturnIfAbrupt(next). + 3. Return NormalCompletion(empty). + + BindingList : BindingList , LexicalBinding + + 1. Let next be the result of evaluating BindingList. + 2. ReturnIfAbrupt(next). + 3. Return the result of evaluating LexicalBinding. + + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context’s LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env as the arguments. +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var iterCount = 0; + +for (const {...rest} = o; iterCount < 1; ) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-rest-val-obj.js b/test/language/statements/for/dstr-const-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..53f8c1d645 --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-rest-val-obj.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Rest object contains just unextracted data (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement + + [...] + 7. Let forDcl be the result of evaluating LexicalDeclaration. + [...] + + LexicalDeclaration : LetOrConst BindingList ; + + 1. Let next be the result of evaluating BindingList. + 2. ReturnIfAbrupt(next). + 3. Return NormalCompletion(empty). + + BindingList : BindingList , LexicalBinding + + 1. Let next be the result of evaluating BindingList. + 2. ReturnIfAbrupt(next). + 3. Return the result of evaluating LexicalBinding. + + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context’s LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env as the arguments. +---*/ + +var iterCount = 0; + +for (const {a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}; iterCount < 1; ) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-rest-getter.js b/test/language/statements/for/dstr-let-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..9abc9af7d6 --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-rest-getter.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement + + [...] + 7. Let forDcl be the result of evaluating LexicalDeclaration. + [...] + + LexicalDeclaration : LetOrConst BindingList ; + + 1. Let next be the result of evaluating BindingList. + 2. ReturnIfAbrupt(next). + 3. Return NormalCompletion(empty). + + BindingList : BindingList , LexicalBinding + + 1. Let next be the result of evaluating BindingList. + 2. ReturnIfAbrupt(next). + 3. Return the result of evaluating LexicalBinding. + + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context’s LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env as the arguments. +---*/ +var count = 0; + +var iterCount = 0; + +for (let {...x} = { get v() { count++; return 2; } }; iterCount < 1; ) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-rest-nested-obj.js b/test/language/statements/for/dstr-let-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..d4cf047575 --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/for-let.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +info: | + IterationStatement : + for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement + + [...] + 7. Let forDcl be the result of evaluating LexicalDeclaration. + [...] + + LexicalDeclaration : LetOrConst BindingList ; + + 1. Let next be the result of evaluating BindingList. + 2. ReturnIfAbrupt(next). + 3. Return NormalCompletion(empty). + + BindingList : BindingList , LexicalBinding + + 1. Let next be the result of evaluating BindingList. + 2. ReturnIfAbrupt(next). + 3. Return the result of evaluating LexicalBinding. + + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context’s LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env as the arguments. +---*/ +var obj = {a: 3, b: 4}; + +var iterCount = 0; + +for (let {a, b, ...{c, e}} = {a: 1, b: 2, c: 3, d: 4, e: 5}; iterCount < 1; ) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/for/dstr-let-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..67a645421f --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/for-let.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement + + [...] + 7. Let forDcl be the result of evaluating LexicalDeclaration. + [...] + + LexicalDeclaration : LetOrConst BindingList ; + + 1. Let next be the result of evaluating BindingList. + 2. ReturnIfAbrupt(next). + 3. Return NormalCompletion(empty). + + BindingList : BindingList , LexicalBinding + + 1. Let next be the result of evaluating BindingList. + 2. ReturnIfAbrupt(next). + 3. Return the result of evaluating LexicalBinding. + + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context’s LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env as the arguments. +---*/ + +var iterCount = 0; + +for (let {a, b, ...{c, ...rest}} = {a: 1, b: 2, c: 3, d: 4, e: 5}; iterCount < 1; ) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-rest-obj-own-property.js b/test/language/statements/for/dstr-let-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..ca1ccba4df --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Rest object contains just soruce object's own properties (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement + + [...] + 7. Let forDcl be the result of evaluating LexicalDeclaration. + [...] + + LexicalDeclaration : LetOrConst BindingList ; + + 1. Let next be the result of evaluating BindingList. + 2. ReturnIfAbrupt(next). + 3. Return NormalCompletion(empty). + + BindingList : BindingList , LexicalBinding + + 1. Let next be the result of evaluating BindingList. + 2. ReturnIfAbrupt(next). + 3. Return the result of evaluating LexicalBinding. + + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context’s LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env as the arguments. +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var iterCount = 0; + +for (let { x, ...{y , z} } = o; iterCount < 1; ) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/for/dstr-let-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..b1f13f4af8 --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Rest object doesn't contain non-enumerable properties (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement + + [...] + 7. Let forDcl be the result of evaluating LexicalDeclaration. + [...] + + LexicalDeclaration : LetOrConst BindingList ; + + 1. Let next be the result of evaluating BindingList. + 2. ReturnIfAbrupt(next). + 3. Return NormalCompletion(empty). + + BindingList : BindingList , LexicalBinding + + 1. Let next be the result of evaluating BindingList. + 2. ReturnIfAbrupt(next). + 3. Return the result of evaluating LexicalBinding. + + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context’s LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env as the arguments. +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var iterCount = 0; + +for (let {...rest} = o; iterCount < 1; ) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-rest-val-obj.js b/test/language/statements/for/dstr-let-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..26a6d34987 --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-rest-val-obj.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Rest object contains just unextracted data (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement + + [...] + 7. Let forDcl be the result of evaluating LexicalDeclaration. + [...] + + LexicalDeclaration : LetOrConst BindingList ; + + 1. Let next be the result of evaluating BindingList. + 2. ReturnIfAbrupt(next). + 3. Return NormalCompletion(empty). + + BindingList : BindingList , LexicalBinding + + 1. Let next be the result of evaluating BindingList. + 2. ReturnIfAbrupt(next). + 3. Return the result of evaluating LexicalBinding. + + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context’s LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env as the arguments. +---*/ + +var iterCount = 0; + +for (let {a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}; iterCount < 1; ) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-rest-getter.js b/test/language/statements/for/dstr-var-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..a116708584 --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-rest-getter.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement + + 1. Let varDcl be the result of evaluating VariableDeclarationList. + [...] + + 13.3.2.4 Runtime Semantics: Evaluation + + VariableDeclarationList : VariableDeclarationList , VariableDeclaration + + 1. Let next be the result of evaluating VariableDeclarationList. + 2. ReturnIfAbrupt(next). + 3. Return the result of evaluating VariableDeclaration. + + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for BindingPattern + passing rval and undefined as arguments. +---*/ +var count = 0; + +var iterCount = 0; + +for (var {...x} = { get v() { count++; return 2; } }; iterCount < 1; ) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-rest-nested-obj.js b/test/language/statements/for/dstr-var-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..4aa17de51c --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/for-var.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +info: | + IterationStatement : + for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement + + 1. Let varDcl be the result of evaluating VariableDeclarationList. + [...] + + 13.3.2.4 Runtime Semantics: Evaluation + + VariableDeclarationList : VariableDeclarationList , VariableDeclaration + + 1. Let next be the result of evaluating VariableDeclarationList. + 2. ReturnIfAbrupt(next). + 3. Return the result of evaluating VariableDeclaration. + + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for BindingPattern + passing rval and undefined as arguments. +---*/ +var obj = {a: 3, b: 4}; + +var iterCount = 0; + +for (var {a, b, ...{c, e}} = {a: 1, b: 2, c: 3, d: 4, e: 5}; iterCount < 1; ) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/for/dstr-var-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..7a6e442492 --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/for-var.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement + + 1. Let varDcl be the result of evaluating VariableDeclarationList. + [...] + + 13.3.2.4 Runtime Semantics: Evaluation + + VariableDeclarationList : VariableDeclarationList , VariableDeclaration + + 1. Let next be the result of evaluating VariableDeclarationList. + 2. ReturnIfAbrupt(next). + 3. Return the result of evaluating VariableDeclaration. + + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for BindingPattern + passing rval and undefined as arguments. +---*/ + +var iterCount = 0; + +for (var {a, b, ...{c, ...rest}} = {a: 1, b: 2, c: 3, d: 4, e: 5}; iterCount < 1; ) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-rest-obj-own-property.js b/test/language/statements/for/dstr-var-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..e34b8437eb --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Rest object contains just soruce object's own properties (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement + + 1. Let varDcl be the result of evaluating VariableDeclarationList. + [...] + + 13.3.2.4 Runtime Semantics: Evaluation + + VariableDeclarationList : VariableDeclarationList , VariableDeclaration + + 1. Let next be the result of evaluating VariableDeclarationList. + 2. ReturnIfAbrupt(next). + 3. Return the result of evaluating VariableDeclaration. + + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for BindingPattern + passing rval and undefined as arguments. +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var iterCount = 0; + +for (var { x, ...{y , z} } = o; iterCount < 1; ) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/for/dstr-var-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..f187ba4158 --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Rest object doesn't contain non-enumerable properties (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement + + 1. Let varDcl be the result of evaluating VariableDeclarationList. + [...] + + 13.3.2.4 Runtime Semantics: Evaluation + + VariableDeclarationList : VariableDeclarationList , VariableDeclaration + + 1. Let next be the result of evaluating VariableDeclarationList. + 2. ReturnIfAbrupt(next). + 3. Return the result of evaluating VariableDeclaration. + + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for BindingPattern + passing rval and undefined as arguments. +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var iterCount = 0; + +for (var {...rest} = o; iterCount < 1; ) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-rest-val-obj.js b/test/language/statements/for/dstr-var-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..65b74f2d2e --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-rest-val-obj.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Rest object contains just unextracted data (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + IterationStatement : + for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement + + 1. Let varDcl be the result of evaluating VariableDeclarationList. + [...] + + 13.3.2.4 Runtime Semantics: Evaluation + + VariableDeclarationList : VariableDeclarationList , VariableDeclaration + + 1. Let next be the result of evaluating VariableDeclarationList. + 2. ReturnIfAbrupt(next). + 3. Return the result of evaluating VariableDeclaration. + + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for BindingPattern + passing rval and undefined as arguments. +---*/ + +var iterCount = 0; + +for (var {a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}; iterCount < 1; ) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-rest-getter.js b/test/language/statements/function/dstr-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..64ef539825 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +function f({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-rest-nested-obj.js b/test/language/statements/function/dstr-dflt-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..4fef8c9796 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +function f({a, b, ...{c, e}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/function/dstr-dflt-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..5e608fb046 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +function f({a, b, ...{c, ...rest}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-rest-obj-own-property.js b/test/language/statements/function/dstr-dflt-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..ee8d0e316e --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest object contains just soruce object's own properties (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +function f({ x, ...{y , z} } = o) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/function/dstr-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..0f203e5bdd --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +function f({...rest} = o) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-rest-val-obj.js b/test/language/statements/function/dstr-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..30d635ca08 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest object contains just unextracted data (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +function f({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-obj-ptrn-rest-getter.js b/test/language/statements/function/dstr-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..75750caa5f --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-rest-getter.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +function f({...x}) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; +}; +f({ get v() { count++; return 2; } }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-obj-ptrn-rest-nested-obj.js b/test/language/statements/function/dstr-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..5eb4a4c31a --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +function f({a, b, ...{c, e}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; +}; +f({a: 1, b: 2, c: 3, d: 4, e: 5}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/function/dstr-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..d3898c1e14 --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +function f({a, b, ...{c, ...rest}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; +}; +f({a: 1, b: 2, c: 3, d: 4, e: 5}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-obj-ptrn-rest-obj-own-property.js b/test/language/statements/function/dstr-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..eba7a0e171 --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest object contains just soruce object's own properties (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +function f({ x, ...{y , z} }) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; +}; +f(o); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/function/dstr-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..edd7590a7c --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest object doesn't contain non-enumerable properties (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +function f({...rest}) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; +}; +f(o); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-obj-ptrn-rest-val-obj.js b/test/language/statements/function/dstr-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..2606e2955a --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-rest-val-obj.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest object contains just unextracted data (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +function f({a, b, ...rest}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; +}; +f({x: 1, y: 2, a: 5, b: 3}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-rest-getter.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..a518c1ccba --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +function* f({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-rest-nested-obj.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..74f9502d20 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +function* f({a, b, ...{c, e}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..d236580171 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +function* f({a, b, ...{c, ...rest}} = {a: 1, b: 2, c: 3, d: 4, e: 5}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-rest-obj-own-property.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..1d81fa0cf8 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Rest object contains just soruce object's own properties (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +function* f({ x, ...{y , z} } = o) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..8349e44b4d --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +function* f({...rest} = o) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-rest-val-obj.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..1ca04900fb --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Rest object contains just unextracted data (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +function* f({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-obj-ptrn-rest-getter.js b/test/language/statements/generators/dstr-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..53c1a539ff --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-rest-getter.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +function* f({...x}) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + callCount = callCount + 1; +}; +f({ get v() { count++; return 2; } }).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-obj-ptrn-rest-nested-obj.js b/test/language/statements/generators/dstr-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..31305ce34c --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var callCount = 0; +function* f({a, b, ...{c, e}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + callCount = callCount + 1; +}; +f({a: 1, b: 2, c: 3, d: 4, e: 5}).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/generators/dstr-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..ddc5e6d321 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +function* f({a, b, ...{c, ...rest}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + callCount = callCount + 1; +}; +f({a: 1, b: 2, c: 3, d: 4, e: 5}).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-obj-ptrn-rest-obj-own-property.js b/test/language/statements/generators/dstr-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..b4099d7913 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Rest object contains just soruce object's own properties (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var callCount = 0; +function* f({ x, ...{y , z} }) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + callCount = callCount + 1; +}; +f(o).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/generators/dstr-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..23edac9ce6 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Rest object doesn't contain non-enumerable properties (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +function* f({...rest}) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + callCount = callCount + 1; +}; +f(o).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-obj-ptrn-rest-val-obj.js b/test/language/statements/generators/dstr-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..289d9e2178 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-rest-val-obj.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Rest object contains just unextracted data (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +function* f({a, b, ...rest}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + callCount = callCount + 1; +}; +f({x: 1, y: 2, a: 5, b: 3}).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/let/dstr-obj-ptrn-rest-getter.js b/test/language/statements/let/dstr-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..f47cc4b8a2 --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-rest-getter.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context's LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env as the arguments. +---*/ +var count = 0; + +let {...x} = { get v() { count++; return 2; } }; + +assert.sameValue(x.v, 2); +assert.sameValue(count, 1); + +verifyEnumerable(x, "v"); +verifyWritable(x, "v"); +verifyConfigurable(x, "v"); + diff --git a/test/language/statements/let/dstr-obj-ptrn-rest-nested-obj.js b/test/language/statements/let/dstr-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..cdaa97c641 --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,28 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [destructuring-binding] +flags: [generated] +info: | + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context's LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env as the arguments. +---*/ +var obj = {a: 3, b: 4}; + +let {a, b, ...{c, e}} = {a: 1, b: 2, c: 3, d: 4, e: 5}; + +assert.sameValue(a, 1); +assert.sameValue(b, 2); +assert.sameValue(c, 3); +assert.sameValue(e, 5); + diff --git a/test/language/statements/let/dstr-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/let/dstr-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..f3f5993028 --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context's LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env as the arguments. +---*/ + +let {a, b, ...{c, ...rest}} = {a: 1, b: 2, c: 3, d: 4, e: 5}; + +assert.sameValue(a, 1); +assert.sameValue(b, 2); +assert.sameValue(c, 3); + +assert.sameValue(rest.d, 4); +assert.sameValue(rest.e, 5); + +verifyEnumerable(rest, "d"); +verifyWritable(rest, "d"); +verifyConfigurable(rest, "d"); + +verifyEnumerable(rest, "e"); +verifyWritable(rest, "e"); +verifyConfigurable(rest, "e"); + diff --git a/test/language/statements/let/dstr-obj-ptrn-rest-obj-own-property.js b/test/language/statements/let/dstr-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..935ba10870 --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,29 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Rest object contains just soruce object's own properties (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context's LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env as the arguments. +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +let { x, ...{y , z} } = o; + +assert.sameValue(x, 1); +assert.sameValue(y, undefined); +assert.sameValue(z, 3); + diff --git a/test/language/statements/let/dstr-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/let/dstr-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..2e40529977 --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context's LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env as the arguments. +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +let {...rest} = o; + +assert.sameValue(rest.a, 3); +assert.sameValue(rest.b, 4); +assert.sameValue(rest.x, undefined); + +verifyEnumerable(rest, "a"); +verifyWritable(rest, "a"); +verifyConfigurable(rest, "a"); + +verifyEnumerable(rest, "b"); +verifyWritable(rest, "b"); +verifyConfigurable(rest, "b"); + diff --git a/test/language/statements/let/dstr-obj-ptrn-rest-val-obj.js b/test/language/statements/let/dstr-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..1e83d04e43 --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-rest-val-obj.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Rest object contains just unextracted data (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context's LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env as the arguments. +---*/ + +let {a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}; + +assert.sameValue(rest.x, 1); +assert.sameValue(rest.y, 2); +assert.sameValue(rest.a, undefined); +assert.sameValue(rest.b, undefined); + +verifyEnumerable(rest, "x"); +verifyWritable(rest, "x"); +verifyConfigurable(rest, "x"); + +verifyEnumerable(rest, "y"); +verifyWritable(rest, "y"); +verifyConfigurable(rest, "y"); + diff --git a/test/language/statements/try/dstr-obj-ptrn-rest-getter.js b/test/language/statements/try/dstr-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..389128907c --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-rest-getter.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/try.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] +---*/ +var count = 0; + +var ranCatch = false; + +try { + throw { get v() { count++; return 2; } }; +} catch ({...x}) { + assert.sameValue(x.v, 2); + assert.sameValue(count, 1); + + verifyEnumerable(x, "v"); + verifyWritable(x, "v"); + verifyConfigurable(x, "v"); + + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-obj-ptrn-rest-nested-obj.js b/test/language/statements/try/dstr-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..7bb80e185c --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/try.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [destructuring-binding] +flags: [generated] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] +---*/ +var obj = {a: 3, b: 4}; + +var ranCatch = false; + +try { + throw {a: 1, b: 2, c: 3, d: 4, e: 5}; +} catch ({a, b, ...{c, e}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + assert.sameValue(e, 5); + + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/try/dstr-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..cd77b7877c --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/try.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] +---*/ + +var ranCatch = false; + +try { + throw {a: 1, b: 2, c: 3, d: 4, e: 5}; +} catch ({a, b, ...{c, ...rest}}) { + assert.sameValue(a, 1); + assert.sameValue(b, 2); + assert.sameValue(c, 3); + + assert.sameValue(rest.d, 4); + assert.sameValue(rest.e, 5); + + verifyEnumerable(rest, "d"); + verifyWritable(rest, "d"); + verifyConfigurable(rest, "d"); + + verifyEnumerable(rest, "e"); + verifyWritable(rest, "e"); + verifyConfigurable(rest, "e"); + + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-obj-ptrn-rest-obj-own-property.js b/test/language/statements/try/dstr-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..92de9235ce --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/try.template +/*--- +description: Rest object contains just soruce object's own properties (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var ranCatch = false; + +try { + throw o; +} catch ({ x, ...{y , z} }) { + assert.sameValue(x, 1); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/try/dstr-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..35658e2fdc --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/try.template +/*--- +description: Rest object doesn't contain non-enumerable properties (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var ranCatch = false; + +try { + throw o; +} catch ({...rest}) { + assert.sameValue(rest.a, 3); + assert.sameValue(rest.b, 4); + assert.sameValue(rest.x, undefined); + + verifyEnumerable(rest, "a"); + verifyWritable(rest, "a"); + verifyConfigurable(rest, "a"); + + verifyEnumerable(rest, "b"); + verifyWritable(rest, "b"); + verifyConfigurable(rest, "b"); + + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-obj-ptrn-rest-val-obj.js b/test/language/statements/try/dstr-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..4fd16e02cf --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-rest-val-obj.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/try.template +/*--- +description: Rest object contains just unextracted data (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] +---*/ + +var ranCatch = false; + +try { + throw {x: 1, y: 2, a: 5, b: 3}; +} catch ({a, b, ...rest}) { + assert.sameValue(rest.x, 1); + assert.sameValue(rest.y, 2); + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyEnumerable(rest, "x"); + verifyWritable(rest, "x"); + verifyConfigurable(rest, "x"); + + verifyEnumerable(rest, "y"); + verifyWritable(rest, "y"); + verifyConfigurable(rest, "y"); + + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/variable/dstr-obj-ptrn-rest-getter.js b/test/language/statements/variable/dstr-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..3b655b41a5 --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-rest-getter.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ +var count = 0; + +var {...x} = { get v() { count++; return 2; } }; + +assert.sameValue(x.v, 2); +assert.sameValue(count, 1); + +verifyEnumerable(x, "v"); +verifyWritable(x, "v"); +verifyConfigurable(x, "v"); + diff --git a/test/language/statements/variable/dstr-obj-ptrn-rest-nested-obj.js b/test/language/statements/variable/dstr-obj-ptrn-rest-nested-obj.js new file mode 100644 index 0000000000..2716949006 --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-rest-nested-obj.js @@ -0,0 +1,27 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-nested-obj.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment. (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ +var obj = {a: 3, b: 4}; + +var {a, b, ...{c, e}} = {a: 1, b: 2, c: 3, d: 4, e: 5}; + +assert.sameValue(a, 1); +assert.sameValue(b, 2); +assert.sameValue(c, 3); +assert.sameValue(e, 5); + diff --git a/test/language/statements/variable/dstr-obj-ptrn-rest-obj-nested-rest.js b/test/language/statements/variable/dstr-obj-ptrn-rest-obj-nested-rest.js new file mode 100644 index 0000000000..fe3654eb9c --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-rest-obj-nested-rest.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-nested-rest.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: When DestructuringAssignmentTarget is an object literal, it should be parsed parsed as a DestructuringAssignmentPattern and evaluated as a destructuring assignment and object rest desconstruction is allowed in that case. (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ + +var {a, b, ...{c, ...rest}} = {a: 1, b: 2, c: 3, d: 4, e: 5}; + +assert.sameValue(a, 1); +assert.sameValue(b, 2); +assert.sameValue(c, 3); + +assert.sameValue(rest.d, 4); +assert.sameValue(rest.e, 5); + +verifyEnumerable(rest, "d"); +verifyWritable(rest, "d"); +verifyConfigurable(rest, "d"); + +verifyEnumerable(rest, "e"); +verifyWritable(rest, "e"); +verifyConfigurable(rest, "e"); + diff --git a/test/language/statements/variable/dstr-obj-ptrn-rest-obj-own-property.js b/test/language/statements/variable/dstr-obj-ptrn-rest-obj-own-property.js new file mode 100644 index 0000000000..b0e678cd94 --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-rest-obj-own-property.js @@ -0,0 +1,28 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-obj-own-property.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Rest object contains just soruce object's own properties (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; + +var { x, ...{y , z} } = o; + +assert.sameValue(x, 1); +assert.sameValue(y, undefined); +assert.sameValue(z, 3); + diff --git a/test/language/statements/variable/dstr-obj-ptrn-rest-skip-non-enumerable.js b/test/language/statements/variable/dstr-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..0e75a3d229 --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var {...rest} = o; + +assert.sameValue(rest.a, 3); +assert.sameValue(rest.b, 4); +assert.sameValue(rest.x, undefined); + +verifyEnumerable(rest, "a"); +verifyWritable(rest, "a"); +verifyConfigurable(rest, "a"); + +verifyEnumerable(rest, "b"); +verifyWritable(rest, "b"); +verifyConfigurable(rest, "b"); + diff --git a/test/language/statements/variable/dstr-obj-ptrn-rest-val-obj.js b/test/language/statements/variable/dstr-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..77f49b131e --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-rest-val-obj.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Rest object contains just unextracted data (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ + +var {a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}; + +assert.sameValue(rest.x, 1); +assert.sameValue(rest.y, 2); +assert.sameValue(rest.a, undefined); +assert.sameValue(rest.b, undefined); + +verifyEnumerable(rest, "x"); +verifyWritable(rest, "x"); +verifyConfigurable(rest, "x"); + +verifyEnumerable(rest, "y"); +verifyWritable(rest, "y"); +verifyConfigurable(rest, "y"); +