diff --git a/test/language/expressions/arrow-function/dstr-ary-init-iter-close.js b/test/language/expressions/arrow-function/dstr-ary-init-iter-close.js new file mode 100644 index 0000000000000000000000000000000000000000..4fad1f9feedd139ca1c37b2b5fec7a5b5a903d80 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-init-iter-close.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var f; +f = ([x]) => { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; +}; + +f(iter); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-init-iter-get-err.js b/test/language/expressions/arrow-function/dstr-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..11aaac1dc19f2ad80a3d58857117a763fd181b4c --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-init-iter-get-err.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Abrupt completion returned by GetIterator (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +var f = ([x]) => {}; + +assert.throws(Test262Error, function() { + f(iter); +}); diff --git a/test/language/expressions/arrow-function/dstr-ary-init-iter-no-close.js b/test/language/expressions/arrow-function/dstr-ary-init-iter-no-close.js new file mode 100644 index 0000000000000000000000000000000000000000..065e611c4ea42d03f20f5e1eb665063de4239a8a --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-init-iter-no-close.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var f; +f = ([x]) => { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; +}; + +f(iter); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-name-iter-val.js b/test/language/expressions/arrow-function/dstr-ary-name-iter-val.js index 62034aa679d57e55ed08a4e5ec334e6271d44943..f01b297f7080f304e7cf8df6b3dd962afb0d9ac1 100644 --- a/test/language/expressions/arrow-function/dstr-ary-name-iter-val.js +++ b/test/language/expressions/arrow-function/dstr-ary-name-iter-val.js @@ -3,7 +3,9 @@ // - src/dstr-binding/default/arrow-function.template /*--- description: SingleNameBinding with normal value iteration (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation es6id: 14.2.16 +features: [destructuring-binding] flags: [generated] info: | ArrowFunction : ArrowParameters => ConciseBody @@ -66,4 +68,4 @@ f = ([x, y, z]) => { }; f([1, 2, 3]); -assert.sameValue(callCount, 1); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-elem-init.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000000000000000000000000000000000..6d9bd714370592813fb3512bc4b1d78f60488e07 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = ([[x, y, z] = [4, 5, 6]]) => { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-elem-iter.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..6d6d29b5c7ff7401abe9a8d5db2c01c94df44faa --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = ([[x, y, z] = [4, 5, 6]]) => { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; +}; + +f([[7, 8, 9]]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-elision-init.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000000000000000000000000000000000..1fadce7fc720ebcd0c3d767667ef4fdb8fb45e20 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: BindingElement with array binding pattern and initializer is used (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var f; +f = ([[,] = g()]) => { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-elision-iter.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..c1eb3215868528028d635f5b377a1768acf6cece --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +var f; +f = ([[,] = g()]) => { + assert.sameValue(callCount, 0); + callCount = callCount + 1; +}; + +f([[]]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-empty-init.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000000000000000000000000000000000..e6eeb2c05897bef0eb40409b50e58b4ed326821f --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +var f; +f = ([[] = function() { initCount += 1; return iter; }()]) => { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-empty-iter.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..13c79c9a146653f3a12ac9869799b8d36ba082e7 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +var f; +f = ([[] = function() { initCount += 1; }()]) => { + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f([[23]]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-rest-init.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000000000000000000000000000000000..4aecd8163660b4bcda457dacdfdc4abf8c4a6359 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +var f; +f = ([[...x] = values]) => { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-rest-iter.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..71db866f54842dc182d210f86e02054c6f768bda --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +var f; +f = ([[...x] = function() { initCount += 1; }()]) => { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f([values]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..6c8a92444247fcf8d91e54ac49986d04483acd4f --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Nested array destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +var f = ([[x]]) => {}; + +assert.throws(TypeError, function() { + f([null]); +}); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-exhausted.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..cfe7aca42e9e702aa62ab9247ae608af4be38890 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Destructuring initializer with an exhausted iterator (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([x = 23]) => { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..39d37058cba65caf5b1bbeb8cf5ed55eba24cf0a --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding does assign name to arrow functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([arrow = () => {}]) => { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..89ce65095c165d0ce4c5f40a5f57f2b3e805a15e --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([cls = class {}, xCls = class X {}]) => { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..be98add9d420c1f7e2369b2baed28352a872e621 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([cover = (function () {}), xCover = (0, function() {})]) => { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..874c609fc027a21db4c1c11f08c9289a354b5c9a --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([fn = function () {}, xFn = function x() {}]) => { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..2fcfac3b30115d09f964dec84b11eb82ee72da31 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([gen = function* () {}, xGen = function* x() {}]) => { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-hole.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000000000000000000000000000000000..27cda2e77476bc5a2d72e1e2bac7a35effdce814 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Destructuring initializer with a "hole" (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([x = 23]) => { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; +}; + +f([,]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-skipped.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..db9a7fe904f9a169f22bedab4223a0c7c641d32c --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var f; +f = ([w = counter(), x = counter(), y = counter(), z = counter()]) => { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f([null, 0, false, '']); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..0b5c14d42804df7e1e0462d93e831533deea71dd --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Destructuring initializer returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +var f = ([x = (function() { throw new Test262Error(); })()]) => {}; + +assert.throws(Test262Error, function() { + f([undefined]); +}); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-undef.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..61728aa9c287273fe911face3c5d5df4df3504fd --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Destructuring initializer with an undefined value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([x = 23]) => { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; + +f([undefined]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..747c2f17e5058a2e4b4ee0e87e57315021e22627 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var f = ([ x = unresolvableReference ]) => {}; + +assert.throws(ReferenceError, function() { + f([]); +}); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-iter-complete.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000000000000000000000000000000000..ced24732c5431e19776745a90eee27bf60ae5d63 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding when value iteration completes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([x]) => { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-iter-done.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000000000000000000000000000000000..679d01c1a1479be548c86a3f875e10db570fb56b --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([_, x]) => { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..64a3cc875d67b525eb1778beccd77806181bde32 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +var f = ([x]) => {}; + +assert.throws(Test262Error, function() { + f(g); +}); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..8ab2e71299a7d1df30f173bb87d30d9a8dfc26d0 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +var f = ([x]) => {}; + +assert.throws(Test262Error, function() { + f(g); +}); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-iter-val.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..d2b420e8bc9edc7ceb6695154a87d684618c65e9 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([x, y, z]) => { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; + +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-obj-id-init.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..fe3a296a9c78a944615092995856c801dae62b79 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = ([{ x, y, z } = { x: 44, y: 55, z: 66 }]) => { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-obj-id.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..0d40e3a8aefed7cfdcaaea1ead8a778df598374c --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-obj-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = ([{ x, y, z } = { x: 44, y: 55, z: 66 }]) => { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; +}; + +f([{ x: 11, y: 22, z: 33 }]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-obj-prop-id-init.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..017fce6d6b1fb557508b122532018cea044f1f7c --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = ([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) => { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-obj-prop-id.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..205b5b5d1591a17ce89407534b77a3a970362dac --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = ([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) => { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; + +f([{ u: 777, w: 888, y: 999 }]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..4ec5596706244c5bd0834939a6ed26397bdaa5e3 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Nested object destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +var f = ([{ x }]) => {}; + +assert.throws(TypeError, function() { + f([null]); +}); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..e3c6becfd684c4711d0df6988d5617262dda704b --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Nested object destructuring with a value of `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +var f = ([{ x }]) => {}; + +assert.throws(TypeError, function() { + f([]); +}); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elision-exhausted.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..074291436c3f6e7149028f09f919439e91bf2d2e --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elision-exhausted.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Elision accepts exhausted iterator (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +var f; +f = ([,]) => { + + callCount = callCount + 1; +}; + +f(iter); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elision-step-err.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..f3eeca9e535225f4e5b19f8b7afe86a8c422ad10 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elision-step-err.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Elision advances iterator and forwards abrupt completions (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +var f = ([,]) => {}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-elision.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..980ad2f17ad0e7360a9a9d581dcec8421e6aa379 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-elision.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Elision advances iterator (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var f; +f = ([,]) => { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; + +f(g()); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-empty.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..404153e476fdb77f44484e485b44e168b2ed3ff3 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-empty.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var f; +f = ([]) => { + assert.sameValue(iterations, 0); + callCount = callCount + 1; +}; + +f(iter); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-ary-elem.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000000000000000000000000000000000..1ff14296c64f06811225ad246f0cf29455c60b48 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest element containing an array BindingElementList pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([...[x, y, z]]) => { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; +}; + +f([3, 4, 5]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-ary-elision.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..15c8837025cc825ef37d914ff80895464ef2c878 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest element containing an elision (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var f; +f = ([...[,]]) => { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; +}; + +f(g()); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-ary-empty.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..b596d3f50caeb295a603ea3f21b8426fa29807e4 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest element containing an "empty" array pattern (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var f; +f = ([...[]]) => { + assert.sameValue(iterations, 1); + callCount = callCount + 1; +}; + +f(iter); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-ary-rest.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..8f653030c15c688cc3742259d4e2bc4129fb1a1d --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest element containing a rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var f; +f = ([...[...x]]) => { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; +}; + +f(values); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..de5a6fa1f7bdc7e8b7d3dc0f324fc3e7b254a0f7 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Rest element following elision elements (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +var f = ([, ...x]) => {}; + +assert.throws(Test262Error, function() { + f(iter); +}); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-id-elision.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..082338c8746667cfda6f7f4ab9e9b431b14d1049 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-id-elision.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest element following elision elements (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +var f; +f = ([ , , ...x]) => { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; + +f(values); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-id-exhausted.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..f5d4b43d25feca1eacb3e4d52fc77e04deb513a1 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: RestElement applied to an exhausted iterator (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +var f; +f = ([, , ...x]) => { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; +}; + +f([1, 2]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..f84af531dde6e822a013ab001c9d120d1aa8137f --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +var f = ([...x]) => {}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..f374f82f582440200f36764cc0ebb0aa1c3274b8 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +var f = ([...x]) => {}; + +assert.throws(Test262Error, function() { + f(iter); +}); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-id.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-id.js new file mode 100644 index 0000000000000000000000000000000000000000..1e8d0313c7e73490bcd63a204b70c0e849366fb9 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-id.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Lone rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var f; +f = ([...x]) => { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; + +f(values); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-init-ary.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..bb142af3bd01e2ae5122b2e1b168605e8565a41c --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-init-ary.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Reset element (nested array pattern) does not support initializer (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = ([...[ x ] = []]) => { + + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-init-id.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000000000000000000000000000000000..0fcfd27a2e0d9d91076563f839c050097119bc7d --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-init-id.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Reset element (identifier) does not support initializer (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = ([...x = []]) => { + + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-init-obj.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..37ff29b22fb10064c6452bd53c7dacdcd37a5cb4 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-init-obj.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Reset element (nested object pattern) does not support initializer (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = ([...{ x } = []]) => { + + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-not-final-ary.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..2d24128c7ef308eed496904ddaa7c3515b827007 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = ([...[x], y]) => { + + callCount = callCount + 1; +}; + +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-not-final-id.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000000000000000000000000000000000..26e2e06ebddaff4b5276a3353705731f074bb234 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest element (identifier) may not be followed by any element (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = ([...x, y]) => { + + callCount = callCount + 1; +}; + +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-not-final-obj.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..7df64255b10d7bac78b80aab86b375501b1d35ea --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = ([...{ x }, y]) => { + + callCount = callCount + 1; +}; + +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-obj-id.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..4fb60c627a563e48e727a18d37c451e1e61edc76 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-obj-id.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = ([...{ length }]) => { + assert.sameValue(length, 3); + callCount = callCount + 1; +}; + +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-obj-prop-id.js b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..6c82a5fe1abd73cee7a8fc1b088640e0cce77b3f --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = ([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) => { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; +}; + +f([7, 8, 9]); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-obj-init-null.js b/test/language/expressions/arrow-function/dstr-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..30f219794a90464b5204b44dd775fd234e4559af --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-init-null.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var f = ({}) => {}; + +assert.throws(TypeError, function() { + f(null); +}); diff --git a/test/language/expressions/arrow-function/dstr-obj-init-undefined.js b/test/language/expressions/arrow-function/dstr-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..cba8e1a565b8bccbffa489dd12b6be4b822df0d4 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-init-undefined.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var f = ({}) => {}; + +assert.throws(TypeError, function() { + f(undefined); +}); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-empty.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..66c9ce442e52c3ad66f3327990d51af4bcbc9e04 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-empty.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: No property access occurs for an "empty" object binding pattern (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +var f; +f = ({}) => { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; +}; + +f(obj); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-id-get-value-err.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..cf6d8cc02107fddf168647931dca3187447ec10c --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-id-get-value-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +var f = ({ poisoned }) => {}; + +assert.throws(Test262Error, function() { + f(poisonedProperty); +}); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-id-init-fn-name-arrow.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..8232c3638205857b1428c693847c599a6d0488cf --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = ({ arrow = () => {} }) => { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; + +f({}); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-id-init-fn-name-class.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..b1f9de1cce8c526c48b6e6681f1963c63844f4c9 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = ({ cls = class {}, xCls = class X {} }) => { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; +}; + +f({}); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-id-init-fn-name-cover.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..4e1c6d8bc71e71f0794b8bb8c4586b009c099132 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = ({ cover = (function () {}), xCover = (0, function() {}) }) => { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; + +f({}); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-id-init-fn-name-fn.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..d481581069f1341854b06d8da8496fda13e471d0 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = ({ fn = function () {}, xFn = function x() {} }) => { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; + +f({}); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-id-init-fn-name-gen.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..bc3388608d27b01aea8a02b4d7a702c6ec3ee13e --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = ({ gen = function* () {}, xGen = function* x() {} }) => { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; + +f({}); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-id-init-skipped.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..09e95ac8db0cb40eeb9f1fed89f1f748e550c7b8 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-id-init-skipped.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var f; +f = ({ w = counter(), x = counter(), y = counter(), z = counter() }) => { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f({ w: null, x: 0, y: false, z: '' }); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-id-init-throws.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..f026b17cf3ad5dd06165927796cd2b35d533887a --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-id-init-throws.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +var f = ({ x = thrower() }) => {}; + +assert.throws(Test262Error, function() { + f({}); +}); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..a19a8e3e2decdc648b86997b57b7a3218bf60ba4 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var f = ({ x = unresolvableReference }) => {}; + +assert.throws(ReferenceError, function() { + f({}); +}); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-id-trailing-comma.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..57d4ba2fcb8f13f7134fe10268ebeee8fa57becd --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var f; +f = ({ x, }) => { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; + +f({ x: 23 }); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-list-err.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..040369a1c38633d51c7282798d5eaaa1ba5b2024 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-list-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +var f = ({ a, b = thrower(), c = ++initCount }) => {}; + +assert.throws(Test262Error, function() { + f({}); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-ary-init.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000000000000000000000000000000000..eab3214e257311ebbeb1c55f0d8aa1c7efe28042 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-ary-init.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = ({ w: [x, y, z] = [4, 5, 6] }) => { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f({}); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-ary-trailing-comma.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..db656b866d0c3c168a87e7503fc017026510bee8 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var f; +f = ({ x: [y], }) => { + assert.sameValue(y,45); + callCount = callCount + 1; +}; + +f({ x: [45] }); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..0daa622eb95900504834ae91db0f0bf29df440de --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var f = ({ w: [x, y, z] = [4, 5, 6] }) => {}; + +assert.throws(TypeError, function() { + f({ w: null }); +}); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-ary.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..dd06543964425c47cf1d8ee9c9b3dd250436870e --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-ary.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = ({ w: [x, y, z] = [4, 5, 6] }) => { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f({ w: [7, undefined, ] }); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-eval-err.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..ba85c840f868ec1e04a69542400d3ed5cef5732f --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-eval-err.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Evaluation of property name returns an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +var f = ({ [thrower()]: x }) => {}; + +assert.throws(Test262Error, function() { + f({}); +}); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..fd409ff36707726547dde569aba87163513b5cf8 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +var f = ({ poisoned: x = ++initEvalCount }) => {}; + +assert.throws(Test262Error, function() { + f(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-id-init-skipped.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..8092852f628a1c4f6ecacf82b6059588e2b02dd5 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var f; +f = ({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) => { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; + +f({ s: null, u: 0, w: false, y: '' }); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..4ba777caa92f49924633d4b9ff062e506daa97cc --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +var f = ({ x: y = thrower() }) => {}; + +assert.throws(Test262Error, function() { + f({}); +}); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..24b2fa3830062f342a2366ec8543ca40e409b92b --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var f = ({ x: y = unresolvableReference }) => {}; + +assert.throws(ReferenceError, function() { + f({}); +}); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-id-init.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..a4c9bbf7973be4716e0ee479bd8a18c1b49645c8 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-id-init.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Binding as specified via property name, identifier, and initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ({ x: y = 33 }) => { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; + +f({ }); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-id-trailing-comma.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..c08fbc90d1ddc35f9ffdd829924ad1d89c267b65 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var f; +f = ({ x: y, }) => { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; + +f({ x: 23 }); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-id.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..438d018feb95a9eb6f40b564dc89065897648f48 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-id.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Binding as specified via property name and identifier (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ({ x: y }) => { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; + +f({ x: 23 }); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-obj-init.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000000000000000000000000000000000..13f75848e39122946d0dc2fb730413f111a6b665 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-obj-init.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = ({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) => { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f({ w: undefined }); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..525cec17dc8e3542315bad237daa069160d6dd5b --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var f = ({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) => {}; + +assert.throws(TypeError, function() { + f({ w: null }); +}); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..6beab79801797d3c4627343aad433fa54d2e91db --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/arrow-function.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var f = ({ w: { x, y, z } = undefined }) => {}; + +assert.throws(TypeError, function() { + f({ }); +}); diff --git a/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-obj.js b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..7ce3a59f5f9161e5aa7653f1909c9c30d325d4a5 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-obj-ptrn-prop-obj.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = ({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) => { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f({ w: { x: undefined, z: 7 } }); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-init-iter-close.js b/test/language/expressions/class/dstr-gen-meth-ary-init-iter-close.js new file mode 100644 index 0000000000000000000000000000000000000000..9a7cc00e4ab1949032c60621dc7976581d5f1115 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-init-iter-close.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var C = class { + *method([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +new C().method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-init-iter-get-err.js b/test/language/expressions/class/dstr-gen-meth-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..a95f55b8d0c1dad608fb0dd37dbd17ea9ba994e0 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-init-iter-get-err.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-expr-gen-meth.template +/*--- +description: Abrupt completion returned by GetIterator (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +var C = class { + *method([x]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-init-iter-no-close.js b/test/language/expressions/class/dstr-gen-meth-ary-init-iter-no-close.js new file mode 100644 index 0000000000000000000000000000000000000000..4f061d966f9f59393fc506dfdb2037ad2b8638e4 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-init-iter-no-close.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var C = class { + *method([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-name-iter-val.js b/test/language/expressions/class/dstr-gen-meth-ary-name-iter-val.js index f84ae0daba1722edc8eefcdacd7971c8e871dc05..8a106acc39e555dbf97305305b78b6e3f63aabc9 100644 --- a/test/language/expressions/class/dstr-gen-meth-ary-name-iter-val.js +++ b/test/language/expressions/class/dstr-gen-meth-ary-name-iter-val.js @@ -3,7 +3,9 @@ // - src/dstr-binding/default/cls-expr-gen-meth.template /*--- description: SingleNameBinding with normal value iteration (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation es6id: 14.5.16 +features: [destructuring-binding] flags: [generated] info: | ClassExpression : class BindingIdentifieropt ClassTail @@ -91,4 +93,4 @@ var C = class { }; new C().method([1, 2, 3]).next(); -assert.sameValue(callCount, 1); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-ary-elem-init.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000000000000000000000000000000000..cb4e740544355b986b770f5ee4e55709fb5c22e2 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + *method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + 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-ary-ptrn-elem-ary-elem-iter.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..9f6c50afb9aa686ed2c10745914e330f656fe848 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + *method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +new C().method([[7, 8, 9]]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-ary-elision-init.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000000000000000000000000000000000..20c93847219b1df5daaa6c269d51fc678f400bb0 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var C = class { + *method([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + 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-ary-ptrn-elem-ary-elision-iter.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..6a0faaf0a6c34f8f365ae718d91b9fb1c47cd66e --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +var C = class { + *method([[,] = g()]) { + assert.sameValue(callCount, 0); + 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-ary-ptrn-elem-ary-empty-init.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000000000000000000000000000000000..7e7ddd4b3cb9036d33ac86384954535f1447229b --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +var C = class { + *method([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + 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-ary-ptrn-elem-ary-empty-iter.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..97912c789a0a2b28f6f2f10dbb7bbb15a8aa960b --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +var C = class { + *method([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([[23]]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-ary-rest-init.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000000000000000000000000000000000..5367bdd09ffd63921f255b791de104846ebc45fa --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +var C = class { + *method([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + 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-ary-ptrn-elem-ary-rest-iter.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..e6191a6ee3b4e72c51aebe4a8f68d9f620a6bb23 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +var C = class { + *method([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([values]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..b7f022e01ff8affca9992943c5eac17901329a14 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-expr-gen-meth.template +/*--- +description: Nested array destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +var C = class { + *method([[x]]) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method([null]); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-init-exhausted.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..35d7ad5e3769a61524dfbc69df65dcd6f5eb46f7 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Destructuring initializer with an exhausted iterator (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method([x = 23]) { + assert.sameValue(x, 23); + 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-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..c37dc2414a5bdbd96016f569cce6d8c0f76e1a56 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: SingleNameBinding does assign name to arrow functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + 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-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..dab8758c428887899ea937ba213a36caa224f3ba --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method([cls = class {}, xCls = class X {}]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + 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-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..3d7a39f0cda46c92212f54d99001634c108dc000 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + 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-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..67e0554ec5e0cc608a77cf2752ebf50e3929d673 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + 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-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..9e58e346676566477fe4cb96e337f1f93ea66f03 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + 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-ary-ptrn-elem-id-init-hole.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000000000000000000000000000000000..36dc3522fc6c41369913b4637726e7c2192b7463 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Destructuring initializer with a "hole" (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method([x = 23]) { + assert.sameValue(x, 23); + // another statement + 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-ary-ptrn-elem-id-init-skipped.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..4db99b3d04d8825b560e318eaca8a02b9ea4e5c6 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var C = class { + *method([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([null, 0, false, '']).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..5cb5a957cf5dfc22d7215586f30bc096630df857 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-expr-gen-meth.template +/*--- +description: Destructuring initializer returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +var C = class { + *method([x = (function() { throw new Test262Error(); })()]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method([undefined]); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-init-undef.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..3a45d0ab627acbe38c7db9323da070a68d5c77d6 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Destructuring initializer with an undefined value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method([undefined]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..ede1ab093bbfeb3210bdec75df57a9f783daad80 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var C = class { + *method([ x = unresolvableReference ]) {} +}; +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method([]); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-iter-complete.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000000000000000000000000000000000..8be02ddef1ab3af925bf0e0e378cfc93bd1bce76 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: SingleNameBinding when value iteration completes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method([x]) { + assert.sameValue(x, undefined); + 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-ary-ptrn-elem-id-iter-done.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000000000000000000000000000000000..aa7dc6e6610ccdab762add21e6f3ff46ea525325 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method([_, x]) { + assert.sameValue(x, undefined); + 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-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..cdbbdd4a22141eae2f8d389c430f707691f09359 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-expr-gen-meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +var C = class { + *method([x]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(g); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..4ce1fd3e7abc39bf8fc43ff6d66a32a10ae51396 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-expr-gen-meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +var C = class { + *method([x]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(g); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-iter-val.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..d23930ab0d7fd8c05b46c05de98f87451ec79ca0 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-obj-id-init.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..cad8bebd47d759dd0dd2b7a9d9035b267b6622e0 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + *method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + 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-ary-ptrn-elem-obj-id.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..bd5bee2db87060d4137fa80b1c4205ead6c68480 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-obj-id.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + *method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +new C().method([{ x: 11, y: 22, z: 33 }]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-obj-prop-id-init.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..fcd3e57de465d2f2d8e64ead772aab91a906bd32 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + 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-ary-ptrn-elem-obj-prop-id.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..58041f7408a2a5d1582c28643dc96471ea3223c1 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method([{ u: 777, w: 888, y: 999 }]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..0e7e3b3947cbb01df299bdc491d4afca77723939 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-expr-gen-meth.template +/*--- +description: Nested object destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +var C = class { + *method([{ x }]) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method([null]); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..3b3c0f9e48ae126bbb92f6c7708f2bd09c95a4f5 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-expr-gen-meth.template +/*--- +description: Nested object destructuring with a value of `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +var C = class { + *method([{ x }]) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method([]); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elision-exhausted.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..67e26599d721ff588f5912c51b9d41a45bd3203c --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elision-exhausted.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Elision accepts exhausted iterator (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +var C = class { + *method([,]) { + + callCount = callCount + 1; + } +}; + +new C().method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elision-step-err.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..16e10d3523725e81718048921d0b1b71b8ea29fc --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elision-step-err.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-expr-gen-meth.template +/*--- +description: Elision advances iterator and forwards abrupt completions (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +var C = class { + *method([,]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elision.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..c3d533fa9e52933f7fd29ce0b67e460b4f1d5cd6 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-elision.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Elision advances iterator (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var C = class { + *method([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +new C().method(g()).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-empty.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..e28521fd8288059edeea67d6a5077d22dd9e9df4 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-empty.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var C = class { + *method([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +new C().method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-ary-elem.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000000000000000000000000000000000..b7a2544819901cb5f1925e3671d7a64e2e83da8d --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,109 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Rest element containing an array BindingElementList pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +new C().method([3, 4, 5]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-ary-elision.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..4976a49bc61040117f5b8894a383954186a9b776 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,115 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Rest element containing an elision (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var C = class { + *method([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +new C().method(g()).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-ary-empty.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..31a7db2940a8b9e726dc106f97d5fde22a9ca7a6 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Rest element containing an "empty" array pattern (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var C = class { + *method([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +new C().method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-ary-rest.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..431371077c13ad0cb62b13f7465bea067d67955c --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Rest element containing a rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var C = class { + *method([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +new C().method(values).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..983792dfab13e1389ecde05d830d9fb9d02e3e6f --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-expr-gen-meth.template +/*--- +description: Rest element following elision elements (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +var C = class { + *method([, ...x]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-id-elision.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..3fdce775d099bccc9c0d551c0279c0fd6c6d0461 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-id-elision.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Rest element following elision elements (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +var C = class { + *method([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method(values).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-id-exhausted.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..feadaf99987b693b3823b73beaf70db9090f68ee --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: RestElement applied to an exhausted iterator (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +var C = class { + *method([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +new C().method([1, 2]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..17fce895aabeaf814a3b31d447283c0a41c9265b --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-expr-gen-meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +var C = class { + *method([...x]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..6762590a4424203098c76da39364dac530fb9faa --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-expr-gen-meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +var C = class { + *method([...x]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-id.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-id.js new file mode 100644 index 0000000000000000000000000000000000000000..618c9610f64fc25ff77e420e95d7aba7804c0dab --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-id.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Lone rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var C = class { + *method([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method(values).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-init-ary.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..587f427b5d2a3d01043f1206942402969b6d5b06 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-init-ary.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Reset element (nested array pattern) does not support initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + *method([...[ x ] = []]) { + + 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-ary-ptrn-rest-init-id.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000000000000000000000000000000000..64597cafaa6fc4910624073c86c3b54fe49bf75b --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-init-id.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Reset element (identifier) does not support initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + *method([...x = []]) { + + 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-ary-ptrn-rest-init-obj.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..c466ea95ebb436288d68d910f2fa3d9edd964ba1 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-init-obj.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Reset element (nested object pattern) does not support initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + *method([...{ x } = []]) { + + 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-ary-ptrn-rest-not-final-ary.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..faffc422d46856b9b32e20ef3e7f5277e48eb81d --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + *method([...[x], y]) { + + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-not-final-id.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000000000000000000000000000000000..0f972a095b74d9fbcbd2383803a8f7ccbc487fbc --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Rest element (identifier) may not be followed by any element (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + *method([...x, y]) { + + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-not-final-obj.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..5f37a9ed4b3de723582704bfc78e7f49f2fcd6e0 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + *method([...{ x }, y]) { + + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-obj-id.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..bd3efcd07b2491c22f2e55a4ca63ee0ab059f43c --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-obj-id.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + *method([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-obj-prop-id.js b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..df64b15a02a6dc22789913b34473e7272576190f --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + *method([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; + } +}; + +new C().method([7, 8, 9]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-init-null.js b/test/language/expressions/class/dstr-gen-meth-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..a651fa3854cafcd5aa91d7797519cd95b722008f --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-init-null.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-expr-gen-meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var C = class { + *method({}) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(null); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-init-undefined.js b/test/language/expressions/class/dstr-gen-meth-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..f1e742c1e436f76e8af6c8b8ab45fe291232d111 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-init-undefined.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-expr-gen-meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var C = class { + *method({}) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(undefined); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-empty.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..7e7637db4523bed31b144479dc7dcbcc6bc4e129 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-empty.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: No property access occurs for an "empty" object binding pattern (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +var C = class { + *method({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(obj).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-id-get-value-err.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..9e8146bcd65027c7c7d470f9cae174ff1dfb45d1 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-id-get-value-err.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-expr-gen-meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +var C = class { + *method({ poisoned }) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(poisonedProperty); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-id-init-fn-name-arrow.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..f14eef6ee498a53090526fd478162496e3657b77 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + *method({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + 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-id-init-fn-name-class.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..59e651c44abbd11b0f316bd7eb53d4467dc22bff --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + *method({ cls = class {}, xCls = class X {} }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + 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-id-init-fn-name-cover.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..4802bbf4508746b1a50f0ffe860c8417c9bed287 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + *method({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + 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-id-init-fn-name-fn.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..25697eec4a7fb282dd759dba16e4619e837d7adc --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + *method({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + 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-id-init-fn-name-gen.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..838d2629c30bfb2480533f8aca4d1038d6800d0f --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + *method({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + 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-id-init-skipped.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..212aebf55b28ade9e0cee5205e3f077bf0c79714 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-id-init-skipped.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var C = class { + *method({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method({ w: null, x: 0, y: false, z: '' }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-id-init-throws.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..dd7dbda6be098ae89739f13428653d3c34c9f275 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-id-init-throws.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-expr-gen-meth.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +var C = class { + *method({ x = thrower() }) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method({}); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..f276a9e02aad0a45e28ea56db39bbbc3c053aa2a --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var C = class { + *method({ x = unresolvableReference }) {} +}; +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method({}); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-id-trailing-comma.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..e565d89d48a680ed683d32ddd211ec43224357b8 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var C = class { + *method({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-list-err.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..8fc1d3615881e5d2dff0c88a01f3d109bced8808 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-list-err.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-expr-gen-meth.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +var C = class { + *method({ a, b = thrower(), c = ++initCount }) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method({}); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-ary-init.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000000000000000000000000000000000..b531eef57ada5e40bb6f06875058a68e80f15e4c --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-ary-init.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + *method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + 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-prop-ary-trailing-comma.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..bbb2a0869eca5afc9d042f9a0b02b35b58b95faa --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var C = class { + *method({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +new C().method({ x: [45] }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..d09604c377b1a776d95f6a31b6f4fabc01823684 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-expr-gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var C = class { + *method({ w: [x, y, z] = [4, 5, 6] }) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method({ w: null }); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-ary.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..1a6030169992f4f27f498f124f31de4eb162ac4c --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-ary.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + *method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method({ w: [7, undefined, ] }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-eval-err.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..b6bd4211db14b34de3595f7064251ae3583a182b --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-eval-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-expr-gen-meth.template +/*--- +description: Evaluation of property name returns an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +var C = class { + *method({ [thrower()]: x }) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method({}); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..2c592916ff17b95cb46e20055e367b247069ebb7 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-expr-gen-meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +var C = class { + *method({ poisoned: x = ++initEvalCount }) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-id-init-skipped.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..dbb0f992c84c16a37c2fa5811edfcda9de7f51b3 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,103 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var C = class { + *method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method({ s: null, u: 0, w: false, y: '' }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..6bccca464a7c004a2a28c4581b78e3b29bfe8894 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-expr-gen-meth.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +var C = class { + *method({ x: y = thrower() }) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method({}); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..7a3aeab6126999b5259dfc706d15095a84daa6d2 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var C = class { + *method({ x: y = unresolvableReference }) {} +}; +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method({}); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-id-init.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..81d7bf0c8d0f30f2feb8a71e923437facdbb81d2 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-id-init.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Binding as specified via property name, identifier, and initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + 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-prop-id-trailing-comma.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..0962d8b50cb48e570eec804df6c78f6d8c1a71a4 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var C = class { + *method({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-id.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..30db11009ea1299e30ef7c607f5e2a4c6617410e --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-id.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Binding as specified via property name and identifier (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-obj-init.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000000000000000000000000000000000..e7ce386ff710435e8714c8f3dae8f13265bde178 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-obj-init.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method({ w: undefined }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..f99fbf005711f4e8bcc7f00b652f08b9cbad8580 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-expr-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var C = class { + *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method({ w: null }); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..e125ea224751edccf04e50b805a387001ef9fa7f --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-expr-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var C = class { + *method({ w: { x, y, z } = undefined }) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method({ }); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-obj.js b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..73ed390f2463bb4e0d7d16c34096ea5a9a230cca --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-obj-ptrn-prop-obj.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-expr-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method({ w: { x: undefined, z: 7 } }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-init-iter-close.js b/test/language/expressions/class/dstr-gen-meth-static-ary-init-iter-close.js new file mode 100644 index 0000000000000000000000000000000000000000..7f2b326a7774ab2d98cebe085e7a05ddb340aea1 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-init-iter-close.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var C = class { + static *method([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +C.method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-init-iter-get-err.js b/test/language/expressions/class/dstr-gen-meth-static-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..dd6e9bef349baaa52584d8a9d1f66324ac4b7241 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-init-iter-get-err.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-expr-gen-meth-static.template +/*--- +description: Abrupt completion returned by GetIterator (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +var C = class { + static *method([x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-init-iter-no-close.js b/test/language/expressions/class/dstr-gen-meth-static-ary-init-iter-no-close.js new file mode 100644 index 0000000000000000000000000000000000000000..c0ca85a7800fee6f5134a630b59e730f054dccc8 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-init-iter-no-close.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var C = class { + static *method([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +C.method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-name-iter-val.js b/test/language/expressions/class/dstr-gen-meth-static-ary-name-iter-val.js index 41a3a79e89f2d6a1add7a4a78e0e6c22038e4194..256f3bd61366acb7f8c1779ec8d999751036b339 100644 --- a/test/language/expressions/class/dstr-gen-meth-static-ary-name-iter-val.js +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-name-iter-val.js @@ -3,7 +3,9 @@ // - src/dstr-binding/default/cls-expr-gen-meth-static.template /*--- description: SingleNameBinding with normal value iteration (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 @@ -91,4 +93,4 @@ var C = class { }; C.method([1, 2, 3]).next(); -assert.sameValue(callCount, 1); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-ary-elem-init.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000000000000000000000000000000000..1be8bd79e63828e9e157e66e36b86a3d7b12ff63 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static *method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + 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-ary-ptrn-elem-ary-elem-iter.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..81dfeb3b84c7e1deb7ce74558a3a44ba500de9e5 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static *method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +C.method([[7, 8, 9]]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-ary-elision-init.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000000000000000000000000000000000..6eb179be492f60d881d6a1a2c039595e88f49d3a --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var C = class { + static *method([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + 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-ary-ptrn-elem-ary-elision-iter.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..300c58bb0c6e9d9df9bd2ff17244a0a9626d9fe7 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +var C = class { + static *method([[,] = g()]) { + assert.sameValue(callCount, 0); + 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-ary-ptrn-elem-ary-empty-init.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000000000000000000000000000000000..2c3440ac96102f980fc98c0113dfbaf85c0b25f9 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +var C = class { + static *method([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + 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-ary-ptrn-elem-ary-empty-iter.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..7bfc2d192cc51a6d9d2aac5a10d70ad7eac245c4 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +var C = class { + static *method([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method([[23]]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-ary-rest-init.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000000000000000000000000000000000..c31866581ede4e3da4b3f031e66d89edd6fa2a84 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +var C = class { + static *method([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + 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-ary-ptrn-elem-ary-rest-iter.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..28c052dedc41e9dae0fa8c526623207f561ff35f --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +var C = class { + static *method([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method([values]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..025276bcfe25581868ecd8bcd2058ac5cd01c5e2 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-expr-gen-meth-static.template +/*--- +description: Nested array destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +var C = class { + static *method([[x]]) {} +}; + +assert.throws(TypeError, function() { + C.method([null]); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-exhausted.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..7fdc9e366cf1c068db3d02eb80c59638145e107e --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Destructuring initializer with an exhausted iterator (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method([x = 23]) { + assert.sameValue(x, 23); + 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-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..5c04d80d3732157eb92ddb131233368fbadddc67 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: SingleNameBinding does assign name to arrow functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + 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-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..79eda26772b2acfef90ab1d30ff0bbfd6f244344 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method([cls = class {}, xCls = class X {}]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + 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-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..a0cca224ec13691262fa1e5d2e9bc3eeb2b6399e --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + 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-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..f3b5ef18d18acb846b38f6056a1c4df7fb5aae2b --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + 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-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..7756951e3cd7a528e188c63fdbca7911add860f7 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + 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-ary-ptrn-elem-id-init-hole.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000000000000000000000000000000000..f970dae68919b1ca1584c00d7d9aec306cfc23e5 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Destructuring initializer with a "hole" (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method([x = 23]) { + assert.sameValue(x, 23); + // another statement + 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-ary-ptrn-elem-id-init-skipped.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..4e7e7b6a99ab36d75dbd96945a883120b8504618 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var C = class { + static *method([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method([null, 0, false, '']).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..007783bbc056a13fcb4daa4df00e6d020c094d2d --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-expr-gen-meth-static.template +/*--- +description: Destructuring initializer returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +var C = class { + static *method([x = (function() { throw new Test262Error(); })()]) {} +}; + +assert.throws(Test262Error, function() { + C.method([undefined]); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-undef.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..c637150815dbf52edbf0478eace79d5d19a15960 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Destructuring initializer with an undefined value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method([undefined]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..02e75ec61e7a08f1e71276874df6f58d7b9f3acd --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-gen-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var C = class { + static *method([ x = unresolvableReference ]) {} +}; + +assert.throws(ReferenceError, function() { + C.method([]); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-iter-complete.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000000000000000000000000000000000..8a79258da344ca1e7c207bf68bcfdd4db3a1c9c4 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: SingleNameBinding when value iteration completes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method([x]) { + assert.sameValue(x, undefined); + 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-ary-ptrn-elem-id-iter-done.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000000000000000000000000000000000..e9d46d397bc22be0c6b73fd6b2a3c746ee9484e3 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method([_, x]) { + assert.sameValue(x, undefined); + 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-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..264f339b780af435613fe5a6ed9e3f714a4ee317 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-expr-gen-meth-static.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +var C = class { + static *method([x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(g); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..f5bda44731ebb2aeb1c9e105dff1f526c29d3593 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-expr-gen-meth-static.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +var C = class { + static *method([x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(g); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-iter-val.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..e16c70658f89b1f6ffe5b9d1eeb9f1f27d14f992 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-obj-id-init.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..c8d21cfa7ecb521d3351c45ac418adfa540f0315 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static *method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + 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-ary-ptrn-elem-obj-id.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..abb881dc278da0993b570ae1dfd3a56667d9f47d --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-obj-id.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static *method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +C.method([{ x: 11, y: 22, z: 33 }]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-obj-prop-id-init.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..1291b884c0ce84f2f116a2f8b733ef101c17ceb8 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + 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-ary-ptrn-elem-obj-prop-id.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..d253638a1121e5ca89e745c1645b8f05c19cc5e5 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method([{ u: 777, w: 888, y: 999 }]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..cb29e7a3f39c2eff3349f9959506230aefddb2c6 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-expr-gen-meth-static.template +/*--- +description: Nested object destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +var C = class { + static *method([{ x }]) {} +}; + +assert.throws(TypeError, function() { + C.method([null]); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..be078269ed2ea21eec56fb4505a7bd460df42530 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-expr-gen-meth-static.template +/*--- +description: Nested object destructuring with a value of `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +var C = class { + static *method([{ x }]) {} +}; + +assert.throws(TypeError, function() { + C.method([]); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elision-exhausted.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..ffb8a4d5e144b7dd1006ff1fe98d049ff01dc73e --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elision-exhausted.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Elision accepts exhausted iterator (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +var C = class { + static *method([,]) { + + callCount = callCount + 1; + } +}; + +C.method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elision-step-err.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..a17525fa90aca93b1e744927a3701084457bfabb --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elision-step-err.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-expr-gen-meth-static.template +/*--- +description: Elision advances iterator and forwards abrupt completions (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +var C = class { + static *method([,]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elision.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..6cb62672aeb83bba2ee72527d6a75731be73d029 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-elision.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Elision advances iterator (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var C = class { + static *method([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +C.method(g()).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-empty.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..434f60a427916218d9de451b21279bc9e5deeb9f --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-empty.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var C = class { + static *method([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +C.method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-ary-elem.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000000000000000000000000000000000..de74966438d1d09b80683940fd6561391de3f1ed --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,109 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Rest element containing an array BindingElementList pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +C.method([3, 4, 5]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-ary-elision.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..2974bfca999c59d7a13b183fe91f64c30680dcc9 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,115 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Rest element containing an elision (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var C = class { + static *method([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +C.method(g()).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-ary-empty.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..d1d9d7f00670eaa543c8b24a171ce9841353f38e --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Rest element containing an "empty" array pattern (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var C = class { + static *method([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +C.method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-ary-rest.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..e68c06403f55bd9d83b19224888522140a73aad3 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Rest element containing a rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var C = class { + static *method([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +C.method(values).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..64eda4888f9b7a9c181b85a190b14758cbe24380 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-expr-gen-meth-static.template +/*--- +description: Rest element following elision elements (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +var C = class { + static *method([, ...x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-id-elision.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..c8e11b568ec20e8dded2c14000dcd84c42efcb3e --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-id-elision.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Rest element following elision elements (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +var C = class { + static *method([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method(values).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-id-exhausted.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..3eeed3980e96d28f64a2a754fffeb4dc6dba4062 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: RestElement applied to an exhausted iterator (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +var C = class { + static *method([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +C.method([1, 2]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..6193e33521525f54ccabc43ff11d38f19ad20091 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-expr-gen-meth-static.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +var C = class { + static *method([...x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..68af1e498712b763d9383089f7f6d5ff08b1ad2b --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-expr-gen-meth-static.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +var C = class { + static *method([...x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-id.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-id.js new file mode 100644 index 0000000000000000000000000000000000000000..c572e4e3af29b9b876e63cf0173efadf73c19f29 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-id.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Lone rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var C = class { + static *method([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method(values).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-init-ary.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..bf91de2a765665adff073bde427c08c2aec35180 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-init-ary.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Reset element (nested array pattern) does not support initializer (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + static *method([...[ x ] = []]) { + + 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-ary-ptrn-rest-init-id.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000000000000000000000000000000000..341b252d8966e02614fd7dfb912b9800dde833da --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-init-id.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Reset element (identifier) does not support initializer (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + static *method([...x = []]) { + + 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-ary-ptrn-rest-init-obj.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..fb0d0c28761210fb2e87310556750baa571c343f --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-init-obj.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Reset element (nested object pattern) does not support initializer (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + static *method([...{ x } = []]) { + + 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-ary-ptrn-rest-not-final-ary.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..8df96effec08a1d3c4068fb4d47458fd86c5142c --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + static *method([...[x], y]) { + + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-not-final-id.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000000000000000000000000000000000..8c3cf816abebd0b8e0e5498d7908e22329a61e13 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Rest element (identifier) may not be followed by any element (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + static *method([...x, y]) { + + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-not-final-obj.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..bef43f26397776b8b1a3172df71babc70b2bd987 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + static *method([...{ x }, y]) { + + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-obj-id.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..8f079828e3cdeecb81c87aac80681bf450d6d51a --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-obj-id.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + static *method([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-obj-prop-id.js b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..b56adb3024d2b131f9606323b0307a088c756e91 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + static *method([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; + } +}; + +C.method([7, 8, 9]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-init-null.js b/test/language/expressions/class/dstr-gen-meth-static-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..aa7b5c3c0089c112945b551337d1c50e9e9caa78 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-init-null.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-expr-gen-meth-static.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var C = class { + static *method({}) {} +}; + +assert.throws(TypeError, function() { + C.method(null); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-init-undefined.js b/test/language/expressions/class/dstr-gen-meth-static-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..8f1c79c3d0fa3b0917698cc4b420879015b10834 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-init-undefined.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-expr-gen-meth-static.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var C = class { + static *method({}) {} +}; + +assert.throws(TypeError, function() { + C.method(undefined); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-empty.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..f67434573ee39b399da9e0562be2d429a5ea0832 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-empty.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: No property access occurs for an "empty" object binding pattern (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +var C = class { + static *method({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +C.method(obj).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-id-get-value-err.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..c769b2df6f23ed23c96b2e098b819748b64c01c9 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-id-get-value-err.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-expr-gen-meth-static.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +var C = class { + static *method({ poisoned }) {} +}; + +assert.throws(Test262Error, function() { + C.method(poisonedProperty); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-id-init-fn-name-arrow.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..2b7e8223c55f231de4307d48d54a010fa08d3bf8 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + static *method({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + 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-id-init-fn-name-class.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..1ceb5c796f76742e4607d6e37ce6822d9055e9a4 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + static *method({ cls = class {}, xCls = class X {} }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + 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-id-init-fn-name-cover.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..8370a295556ed7dc5449990ee7e82103bfa83074 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + static *method({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + 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-id-init-fn-name-fn.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..ab48e68d58088b0d6545bf8bab799470183c5531 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + static *method({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + 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-id-init-fn-name-gen.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..27c2cba818c270e4508162c4bec78bd9b5623dfe --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + static *method({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + 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-id-init-skipped.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..289ed4377bcd1fb492de8733b26233dd18476f2e --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-id-init-skipped.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var C = class { + static *method({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method({ w: null, x: 0, y: false, z: '' }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-id-init-throws.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..404fc4e3ede4e64ab4d4909dd059d18988f60d11 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-id-init-throws.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-expr-gen-meth-static.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +var C = class { + static *method({ x = thrower() }) {} +}; + +assert.throws(Test262Error, function() { + C.method({}); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..c900579042605907c47853ce07d867598878bc67 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-gen-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var C = class { + static *method({ x = unresolvableReference }) {} +}; + +assert.throws(ReferenceError, function() { + C.method({}); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-id-trailing-comma.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..96dc2a0f8f5bdaf094f04d858dbbb50629739248 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var C = class { + static *method({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-list-err.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..06ab0fbfad6bba5c06543d5ef9ca802882e6fa99 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-list-err.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-expr-gen-meth-static.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +var C = class { + static *method({ a, b = thrower(), c = ++initCount }) {} +}; + +assert.throws(Test262Error, function() { + C.method({}); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-ary-init.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000000000000000000000000000000000..aa000f9b7f9eb762cd5ae9f989c9e50c39b904ae --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-ary-init.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + static *method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + 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-prop-ary-trailing-comma.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..24602298a5afbd6c5193808e91f7d855a25bf91e --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var C = class { + static *method({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +C.method({ x: [45] }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..45e5f68f102ede688c618765d248081a07e68d1e --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-expr-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var C = class { + static *method({ w: [x, y, z] = [4, 5, 6] }) {} +}; + +assert.throws(TypeError, function() { + C.method({ w: null }); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-ary.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..0d471012e8c0b9fd049abaa6dd1920fa9b7ca6eb --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-ary.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + static *method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method({ w: [7, undefined, ] }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-eval-err.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..dff93e39ad79dd1388fc6023a2d4cedd12ae9791 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-eval-err.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-expr-gen-meth-static.template +/*--- +description: Evaluation of property name returns an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +var C = class { + static *method({ [thrower()]: x }) {} +}; + +assert.throws(Test262Error, function() { + C.method({}); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..79a64e1497ff580c056f32f06e4e3baf2f4883ce --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-expr-gen-meth-static.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +var C = class { + static *method({ poisoned: x = ++initEvalCount }) {} +}; + +assert.throws(Test262Error, function() { + C.method(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-id-init-skipped.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..8f3e078e944e21adcac53a06d9188b67edaf2cb3 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,103 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var C = class { + static *method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method({ s: null, u: 0, w: false, y: '' }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..4a4f00744fc983bd187ea75eb308b50b27209ae8 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-expr-gen-meth-static.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +var C = class { + static *method({ x: y = thrower() }) {} +}; + +assert.throws(Test262Error, function() { + C.method({}); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..4483002f07cb8a7a5d13a0fe2bb8365f4c4cc9fb --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-gen-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var C = class { + static *method({ x: y = unresolvableReference }) {} +}; + +assert.throws(ReferenceError, function() { + C.method({}); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-id-init.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..327d127876f58b62b2e3bd7076745740fe42f891 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-id-init.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Binding as specified via property name, identifier, and initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + 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-prop-id-trailing-comma.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..fe6bd27c08435cd967d6738fd0bd0cabf686e747 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var C = class { + static *method({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-id.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..bfd4cbadf5cddf4bbd305faa39dfb0446c728d8d --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-id.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Binding as specified via property name and identifier (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-obj-init.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000000000000000000000000000000000..866c135b98ba8a35a8f581c1da037e8d7f405058 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-obj-init.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + static *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method({ w: undefined }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..25ae1b66fd6be87030bc77f8057ca95b587005af --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-expr-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var C = class { + static *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) {} +}; + +assert.throws(TypeError, function() { + C.method({ w: null }); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..87dca04e88e0689a1a08856386ee3ee6d53b8876 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-expr-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var C = class { + static *method({ w: { x, y, z } = undefined }) {} +}; + +assert.throws(TypeError, function() { + C.method({ }); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-obj.js b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..44908e53cfc2b71baa2ee604a041ee9951388746 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-obj-ptrn-prop-obj.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-expr-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + static *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method({ w: { x: undefined, z: 7 } }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-init-iter-close.js b/test/language/expressions/class/dstr-meth-ary-init-iter-close.js new file mode 100644 index 0000000000000000000000000000000000000000..4925659382487fb1b511a25fcf68b0f2905b7b0a --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-init-iter-close.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var C = class { + method([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +new C().method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-init-iter-get-err.js b/test/language/expressions/class/dstr-meth-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..3c5791140a116de1d51877c2a222fb18d1f7db1b --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-init-iter-get-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-expr-meth.template +/*--- +description: Abrupt completion returned by GetIterator (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +var C = class { + method([x]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); diff --git a/test/language/expressions/class/dstr-meth-ary-init-iter-no-close.js b/test/language/expressions/class/dstr-meth-ary-init-iter-no-close.js new file mode 100644 index 0000000000000000000000000000000000000000..7da50762d40eca2302ca736e7c723a7a9de649c6 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-init-iter-no-close.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var C = class { + method([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-name-iter-val.js b/test/language/expressions/class/dstr-meth-ary-name-iter-val.js index 6a23977c08b80f36178b153d90af8bd1ac37023f..67b1fc30e562bc612fba0d3f7df80a0b7acdb9b0 100644 --- a/test/language/expressions/class/dstr-meth-ary-name-iter-val.js +++ b/test/language/expressions/class/dstr-meth-ary-name-iter-val.js @@ -3,7 +3,9 @@ // - src/dstr-binding/default/cls-expr-meth.template /*--- description: SingleNameBinding with normal value iteration (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation es6id: 14.5.16 +features: [destructuring-binding] flags: [generated] info: | ClassExpression : class BindingIdentifieropt ClassTail @@ -88,4 +90,4 @@ var C = class { }; new C().method([1, 2, 3]); -assert.sameValue(callCount, 1); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-elem-init.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000000000000000000000000000000000..4fba2efce0a330af70661de2109d9fee379c105b --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-elem-iter.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..2407cdaacf7ca19db436bc72f1f9907dfbf1e070 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +new C().method([[7, 8, 9]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-elision-init.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000000000000000000000000000000000..6ee9339787d94d774b1031a4889159bcb1539c33 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var C = class { + method([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-elision-iter.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..d002ac93a7d0ac5bbfef9d73bc4465ed9f28fabc --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +var C = class { + method([[,] = g()]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([[]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-empty-init.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000000000000000000000000000000000..17876612341d609cd24573f13cb55fd3f7e0d418 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +var C = class { + method([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-empty-iter.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..fba3d01ddde5711b0d14bb19ec505348715c8bec --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +var C = class { + method([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([[23]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-rest-init.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000000000000000000000000000000000..a1cd7462d098e3598709419ef8e98f0995fbfbb9 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +var C = class { + method([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-rest-iter.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..9ea66ddac1af8ba70c8ed5bb6c2f234b142b0645 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +var C = class { + method([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([values]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..0c4ee83309d3561c56b5d10a4d8c0fccfddfec37 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-expr-meth.template +/*--- +description: Nested array destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +var C = class { + method([[x]]) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method([null]); +}); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-exhausted.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..582a016107b2bee88693b88a68509d0813c052e7 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Destructuring initializer with an exhausted iterator (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..8e658b3f59d059b21b679c7fbd39cf4075ae9b50 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: SingleNameBinding does assign name to arrow functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..ff41715850404e898e32dd645b578b3f9f96df9a --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method([cls = class {}, xCls = class X {}]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..a5e14b55e3f7c030592823b9fed525dfdd0c0528 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..738cc5d1672d02653f935198415429a07c5430cf --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..56a773909cb4ffc59100684df525175f4d093277 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-hole.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000000000000000000000000000000000..2283ab672fb113b8e82f8e06f0d3923f8f7de386 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Destructuring initializer with a "hole" (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method([x = 23]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +new C().method([,]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-skipped.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..fd9578c3f07a62e15743734e3dadfd3d10eda1e4 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var C = class { + method([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([null, 0, false, '']); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..8b101c7c213cc34abb1434bd0950a889a9047106 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-expr-meth.template +/*--- +description: Destructuring initializer returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +var C = class { + method([x = (function() { throw new Test262Error(); })()]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method([undefined]); +}); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-undef.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..258842d1bf5d56013e5c044d71273e40aebab298 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Destructuring initializer with an undefined value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method([undefined]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..a183e2046ff6a7a78502b090ef16d0b635d1a973 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var C = class { + method([ x = unresolvableReference ]) {} +}; + +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method([]); +}); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-iter-complete.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000000000000000000000000000000000..59c0c1c232653fb5acfdf259536bc04fb784da4e --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: SingleNameBinding when value iteration completes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method([x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-iter-done.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000000000000000000000000000000000..59354a23d323d4a7856621ec82ad56451daab571 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method([_, x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..008478e206b6d2c77e2bbe36a032440b773a9a34 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-expr-meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +var C = class { + method([x]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(g); +}); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..014a933edd455cae14a3d69f2503a717db64e645 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-expr-meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +var C = class { + method([x]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(g); +}); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-iter-val.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..974daec65e27bd16e6b2843f8bb8b0e719ec5bed --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-obj-id-init.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..6f10dc430211ff72eb9fe1300c8ed7290eebc9ca --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-obj-id.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..1a210ca2c013d451efa5010e4f31891723b1219f --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-obj-id.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +new C().method([{ x: 11, y: 22, z: 33 }]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-obj-prop-id-init.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..91a0707015283da9c25ac20262d886b823319610 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-obj-prop-id.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..7846ea244743335b21d6ae580ee99529a5c3196c --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method([{ u: 777, w: 888, y: 999 }]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..ae55411153b54343813b7a78d1ecbd6785400a7a --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-expr-meth.template +/*--- +description: Nested object destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +var C = class { + method([{ x }]) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method([null]); +}); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..b86b96601c0eaaf28c7d0ba7b9c49b4d6f17514d --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-expr-meth.template +/*--- +description: Nested object destructuring with a value of `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +var C = class { + method([{ x }]) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method([]); +}); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elision-exhausted.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..1d863918fa962a24ccd1e9079b62a87f6c3a72b9 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elision-exhausted.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Elision accepts exhausted iterator (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +var C = class { + method([,]) { + + callCount = callCount + 1; + } +}; + +new C().method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elision-step-err.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..72ef47ce72a96786e63562a7ec78ab3c5ce16efa --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elision-step-err.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-expr-meth.template +/*--- +description: Elision advances iterator and forwards abrupt completions (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +var C = class { + method([,]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-elision.js b/test/language/expressions/class/dstr-meth-ary-ptrn-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..56f4fc7fe734c13772955730ba34df0988b4a7e4 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-elision.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Elision advances iterator (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var C = class { + method([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +new C().method(g()); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-empty.js b/test/language/expressions/class/dstr-meth-ary-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..8a8ad09cc52b3bf29465241050de3d7b7951b3ac --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-empty.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var C = class { + method([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +new C().method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-rest-ary-elem.js b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000000000000000000000000000000000..6c4217875cf331c6b3b982aa0e309068674f9701 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,106 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Rest element containing an array BindingElementList pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +new C().method([3, 4, 5]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-rest-ary-elision.js b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..293b980d635b507fd23c86bddecb1c80edd3545b --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,112 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Rest element containing an elision (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var C = class { + method([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +new C().method(g()); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-rest-ary-empty.js b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..847ca26fb29d5d7b23817ff8d0ec3f90b2b37e47 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Rest element containing an "empty" array pattern (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var C = class { + method([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +new C().method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-rest-ary-rest.js b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..35c09938f4062b4af19d9007927cbedd01766c72 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Rest element containing a rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var C = class { + method([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +new C().method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..1edc0b8f255a300ac74f97ecf340367cf0ce100c --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-expr-meth.template +/*--- +description: Rest element following elision elements (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +var C = class { + method([, ...x]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-rest-id-elision.js b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..efe146df35d46977cae3b19aa2bafd940a94fa31 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-id-elision.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Rest element following elision elements (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +var C = class { + method([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-rest-id-exhausted.js b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..d9b1f17b10acee15962928b00ead8601ecb53ff3 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: RestElement applied to an exhausted iterator (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +var C = class { + method([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +new C().method([1, 2]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..d7359e92499c7dd9a17547c4307a605243bb3eac --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-expr-meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +var C = class { + method([...x]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..1805f511e370a75c7084920d38a19a0a5c9a6af4 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-expr-meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +var C = class { + method([...x]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-rest-id.js b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-id.js new file mode 100644 index 0000000000000000000000000000000000000000..9c55c247f05c238230a685579070a96bd7418eaa --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-id.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Lone rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var C = class { + method([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-rest-init-ary.js b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..54de5b38e47f64d0b4a293747d8e9b49356bf549 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-init-ary.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Reset element (nested array pattern) does not support initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + method([...[ x ] = []]) { + + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-rest-init-id.js b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000000000000000000000000000000000..64eb0078b19bc7a7f778cb94cd8dce4b704e2c8b --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-init-id.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Reset element (identifier) does not support initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + method([...x = []]) { + + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-rest-init-obj.js b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..2b9d683364e68a3e46ad2be46b10f6aec0e9550b --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-init-obj.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Reset element (nested object pattern) does not support initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + method([...{ x } = []]) { + + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-rest-not-final-ary.js b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..aea6c7fcbf19ae5170593d0ae3111e3f937bb47b --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + method([...[x], y]) { + + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-rest-not-final-id.js b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000000000000000000000000000000000..2d4b733535e778322ca9e146cc491e5e24e578ff --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Rest element (identifier) may not be followed by any element (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + method([...x, y]) { + + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-rest-not-final-obj.js b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..de80c94f87e485525014c6768e33b22a2e9030eb --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + method([...{ x }, y]) { + + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-rest-obj-id.js b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..db25d4e746a7b7f04f62f1668f8fec082dd40485 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-obj-id.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + method([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-ary-ptrn-rest-obj-prop-id.js b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..f75a94a129a014555c79bc8d6ad9feec7f4f5696 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + method([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; + } +}; + +new C().method([7, 8, 9]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-obj-init-null.js b/test/language/expressions/class/dstr-meth-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..6046e394360943e4fc0c67ea5202adac8b3a0589 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-init-null.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-expr-meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var C = class { + method({}) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(null); +}); diff --git a/test/language/expressions/class/dstr-meth-obj-init-undefined.js b/test/language/expressions/class/dstr-meth-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..546c5aed5905df049bdd2dec40de95928b640b6d --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-init-undefined.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-expr-meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var C = class { + method({}) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(undefined); +}); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-empty.js b/test/language/expressions/class/dstr-meth-obj-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..47d8d7d0387e7ae035f72736d11803f8ddff7e76 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-empty.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: No property access occurs for an "empty" object binding pattern (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +var C = class { + method({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(obj); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-id-get-value-err.js b/test/language/expressions/class/dstr-meth-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..4d444a51d18f1777ab1aeec8287bd1778df2b8b2 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-id-get-value-err.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-expr-meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +var C = class { + method({ poisoned }) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(poisonedProperty); +}); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-id-init-fn-name-arrow.js b/test/language/expressions/class/dstr-meth-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..731b8dbe4307e55f277010851987e8f6eb0a1862 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + method({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + 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-id-init-fn-name-class.js b/test/language/expressions/class/dstr-meth-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..ff41447995604b622fd384c440e84f0eebe90d08 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + method({ cls = class {}, xCls = class X {} }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + 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-id-init-fn-name-cover.js b/test/language/expressions/class/dstr-meth-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..b68cba0ce9edfe4a560d2742dd301b7c3b1e0041 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + method({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + 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-id-init-fn-name-fn.js b/test/language/expressions/class/dstr-meth-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..0112a3ad49ab17651a5fe53330b87f942198eec5 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + method({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + 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-id-init-fn-name-gen.js b/test/language/expressions/class/dstr-meth-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..d26cdc6a05179fe41f9081b0f44494b0205f282c --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + method({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + 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-id-init-skipped.js b/test/language/expressions/class/dstr-meth-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..e200021119c531a5adaa0ea1c2d00df85e250b0d --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-id-init-skipped.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var C = class { + method({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method({ w: null, x: 0, y: false, z: '' }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-id-init-throws.js b/test/language/expressions/class/dstr-meth-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..465a456d6924af9fd35ea904b7e72b619ba396d4 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-id-init-throws.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-expr-meth.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +var C = class { + method({ x = thrower() }) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method({}); +}); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/class/dstr-meth-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..c32d111e8d4a9cf33cd2e5d1c127e8b04cd9160d --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var C = class { + method({ x = unresolvableReference }) {} +}; + +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method({}); +}); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-id-trailing-comma.js b/test/language/expressions/class/dstr-meth-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..acb6b1ffec58ccaf157623020196e8ce535ebcf2 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var C = class { + method({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-list-err.js b/test/language/expressions/class/dstr-meth-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..d022f0cad798f248c30537f349e64c574837e0e9 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-list-err.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-expr-meth.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +var C = class { + method({ a, b = thrower(), c = ++initCount }) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method({}); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-prop-ary-init.js b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000000000000000000000000000000000..5ae7518bfd252207a7823d400363681aae33cc05 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-ary-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + 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-prop-ary-trailing-comma.js b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..cd0dd9cf4861cf8edbc4f2a85bd50f300b7b3b1e --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var C = class { + method({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +new C().method({ x: [45] }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..e486c08fefd9c7959d47d99e60900e45487df1c5 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-expr-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var C = class { + method({ w: [x, y, z] = [4, 5, 6] }) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method({ w: null }); +}); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-prop-ary.js b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..ec08b0d4c161c0433748709efdb624386dc04748 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-ary.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method({ w: [7, undefined, ] }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-prop-eval-err.js b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..6119e20eabd6ff3f444ec185014aa3d3c2a0f6bc --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-eval-err.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-expr-meth.template +/*--- +description: Evaluation of property name returns an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +var C = class { + method({ [thrower()]: x }) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method({}); +}); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..1f129259b2874744072ad1ae70f5b068812552a1 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-expr-meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +var C = class { + method({ poisoned: x = ++initEvalCount }) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-prop-id-init-skipped.js b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..04d1eafb3821559e378a4137239e7b9d7f4fe6cd --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var C = class { + method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method({ s: null, u: 0, w: false, y: '' }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..0d367594f9747b7e8752a2cf09fd79b626c452aa --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-expr-meth.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +var C = class { + method({ x: y = thrower() }) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method({}); +}); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..9a8404a6e1a08ff960cd83c659458eb8b07295ff --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var C = class { + method({ x: y = unresolvableReference }) {} +}; + +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method({}); +}); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-prop-id-init.js b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..a9e600bc54e9808beaac81a05f4951dc4d37f76b --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-id-init.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Binding as specified via property name, identifier, and initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + 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-prop-id-trailing-comma.js b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..808588dd81808fa3310f3b2cb01f2e5d00038dd2 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var C = class { + method({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-prop-id.js b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..25d7f737ff35d614f227e5d68b36a658342cc49d --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-id.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Binding as specified via property name and identifier (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-prop-obj-init.js b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000000000000000000000000000000000..e64f6654f8d9060dba97049621ab364653edc280 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-obj-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method({ w: undefined }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..92e065c5a0b32956729cffa99f7fe57e89ad9f5a --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-expr-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var C = class { + method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method({ w: null }); +}); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..c9f02876c0f18be14cb624b0ffc0d492355706ed --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-expr-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var C = class { + method({ w: { x, y, z } = undefined }) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method({ }); +}); diff --git a/test/language/expressions/class/dstr-meth-obj-ptrn-prop-obj.js b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..c24dba7394b0494098abb78db94cdc0331ddd8cd --- /dev/null +++ b/test/language/expressions/class/dstr-meth-obj-ptrn-prop-obj.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method({ w: { x: undefined, z: 7 } }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-init-iter-close.js b/test/language/expressions/class/dstr-meth-static-ary-init-iter-close.js new file mode 100644 index 0000000000000000000000000000000000000000..927e2dae88238cf9153e286610494944aa0e33f3 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-init-iter-close.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var C = class { + static method([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +C.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-init-iter-get-err.js b/test/language/expressions/class/dstr-meth-static-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..637351a686c0772996f37d1a168772a569e935b8 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-init-iter-get-err.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-expr-meth-static.template +/*--- +description: Abrupt completion returned by GetIterator (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +var C = class { + static method([x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); diff --git a/test/language/expressions/class/dstr-meth-static-ary-init-iter-no-close.js b/test/language/expressions/class/dstr-meth-static-ary-init-iter-no-close.js new file mode 100644 index 0000000000000000000000000000000000000000..3389786941f298706ea69eb145dc9b502fbf709b --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-init-iter-no-close.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var C = class { + static method([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +C.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-name-iter-val.js b/test/language/expressions/class/dstr-meth-static-ary-name-iter-val.js index fb37361ee64850f17bef06f54ca0216bba9de755..d32cd745d5de63e3fafc47ff389bcb0e59ae5516 100644 --- a/test/language/expressions/class/dstr-meth-static-ary-name-iter-val.js +++ b/test/language/expressions/class/dstr-meth-static-ary-name-iter-val.js @@ -3,7 +3,9 @@ // - src/dstr-binding/default/cls-expr-meth-static.template /*--- description: SingleNameBinding with normal value iteration (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 @@ -88,4 +90,4 @@ var C = class { }; C.method([1, 2, 3]); -assert.sameValue(callCount, 1); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-elem-init.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000000000000000000000000000000000..0294b165319185f2f0b752065691f5a6df7588ab --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-elem-iter.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..af9882a2b2d8a31bcaeaeddba16791a012f22246 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +C.method([[7, 8, 9]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-elision-init.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000000000000000000000000000000000..e930f59e106de816392c37a5e24a090910f62162 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var C = class { + static method([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-elision-iter.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..b479fe32634fa72f95b0ea3d6559797a5630c218 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +var C = class { + static method([[,] = g()]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +C.method([[]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-empty-init.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000000000000000000000000000000000..845f7e15f093c4c3dca366454e536698fab17fa0 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +var C = class { + static method([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-empty-iter.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..596f0c826557cdb64a9989bfa1abb0ec2893e44c --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +var C = class { + static method([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method([[23]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-rest-init.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000000000000000000000000000000000..0724bd236abee9e8cd9da4ea5ef89d0a65ba0ea5 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +var C = class { + static method([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-rest-iter.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..41c3d69b0cb743ca1629a4fb3b131efbac78c8d9 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +var C = class { + static method([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method([values]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..3979f3938647f6b2bc4ff3ca8be660aed4f2ddfb --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-expr-meth-static.template +/*--- +description: Nested array destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +var C = class { + static method([[x]]) {} +}; + +assert.throws(TypeError, function() { + C.method([null]); +}); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-exhausted.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..8b09db9d5422c3d93d9ec24efc70ac8d0994a393 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Destructuring initializer with an exhausted iterator (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..83b2683c1a997c87e50b2d149ae2c9c093f906b3 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: SingleNameBinding does assign name to arrow functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..c8015087ebf1a381b99b025db960f4d2ab5b3f85 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method([cls = class {}, xCls = class X {}]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..283affa69de71fcc420b1d10d1fa833075ab7936 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..e69b730884c91326612624698edec32a4c0c9728 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..34a1869883bb97124d349645f0251ccdd403a066 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-hole.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000000000000000000000000000000000..5ad5e1064680cb9e28bef06115973ecd06bb1b23 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Destructuring initializer with a "hole" (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method([x = 23]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +C.method([,]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-skipped.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..6c502184c0caae14091a48c9c88f061b3f1c0f40 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var C = class { + static method([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method([null, 0, false, '']); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..3fad2d385a7cb0f1c296329ff221b370135cf858 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-expr-meth-static.template +/*--- +description: Destructuring initializer returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +var C = class { + static method([x = (function() { throw new Test262Error(); })()]) {} +}; + +assert.throws(Test262Error, function() { + C.method([undefined]); +}); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-undef.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..1f75f14c0c24ed8fc74c94af328877f32b7befda --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Destructuring initializer with an undefined value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method([undefined]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..3af0841130e5c0c6def6958b832ec7609de37070 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var C = class { + static method([ x = unresolvableReference ]) {} +}; + +assert.throws(ReferenceError, function() { + C.method([]); +}); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-iter-complete.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000000000000000000000000000000000..372d7f536959268859bcb66227cc0fb38e624f69 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: SingleNameBinding when value iteration completes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method([x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-iter-done.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000000000000000000000000000000000..1a1c153d2f62e0bc6c9df612bed1641bbdc7b758 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method([_, x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..7b9d88f3fded8729bd2dba3447e1eb367f036c78 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-expr-meth-static.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +var C = class { + static method([x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(g); +}); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..727aa9b0402f597300e8811cee2decad04703fe2 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-expr-meth-static.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +var C = class { + static method([x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(g); +}); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-iter-val.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..b0491c5e8c97cad6cbf77172e01afbb9b2985f8e --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-obj-id-init.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..0a3a504ea767dab854e23d108b93e6fe443bc5ab --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-obj-id.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..8c275e643f2804abf383fe52daecb81baae4b997 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-obj-id.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +C.method([{ x: 11, y: 22, z: 33 }]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-obj-prop-id-init.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..cfaf5a946d8d2dbbb22c4f8fb5a86bc7740b4573 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-obj-prop-id.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..c4c6b6247d7f9a33d9e886e827912f7d582412e0 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method([{ u: 777, w: 888, y: 999 }]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..dc83039fe08eab52d8c7dd81213f5f673c87baaf --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-expr-meth-static.template +/*--- +description: Nested object destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +var C = class { + static method([{ x }]) {} +}; + +assert.throws(TypeError, function() { + C.method([null]); +}); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..eecbb264e193688250d2f48097a36a3dbf10d411 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-expr-meth-static.template +/*--- +description: Nested object destructuring with a value of `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +var C = class { + static method([{ x }]) {} +}; + +assert.throws(TypeError, function() { + C.method([]); +}); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elision-exhausted.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..b04d806c3bebfa7c0776185691bbc4a14a0afeab --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elision-exhausted.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Elision accepts exhausted iterator (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +var C = class { + static method([,]) { + + callCount = callCount + 1; + } +}; + +C.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elision-step-err.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..3e3d39d3923f460691f1dabc7f7e9c35e4c725c8 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elision-step-err.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-expr-meth-static.template +/*--- +description: Elision advances iterator and forwards abrupt completions (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +var C = class { + static method([,]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-elision.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..f9c5a0657f28b2ad469751e860a285101880b7dd --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-elision.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Elision advances iterator (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var C = class { + static method([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +C.method(g()); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-empty.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..8c7258eaff7db5679cb462c8a5c9efb2fc84617b --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-empty.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var C = class { + static method([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +C.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-ary-elem.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000000000000000000000000000000000..b31e4f4aed42f07cc28160d4cd80edbf14fcd876 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,106 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Rest element containing an array BindingElementList pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +C.method([3, 4, 5]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-ary-elision.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..f8e68cd6d29d9172bba2dd5fbe1941c96765ad11 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,112 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Rest element containing an elision (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var C = class { + static method([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +C.method(g()); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-ary-empty.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..2f686d003211862893ca2b2bfcd3fdb193457223 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Rest element containing an "empty" array pattern (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var C = class { + static method([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +C.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-ary-rest.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..2b9a827553419c1e3ce9e529e0014a1de691af17 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Rest element containing a rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var C = class { + static method([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +C.method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..42acdce0fa3f2f72b3b93c7745e64b92c2b89560 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-expr-meth-static.template +/*--- +description: Rest element following elision elements (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +var C = class { + static method([, ...x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-id-elision.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..a9ac4614ffdabe8206f6790dfa4bd50092ca0b6b --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-id-elision.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Rest element following elision elements (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +var C = class { + static method([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-id-exhausted.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..f9f25374f1adfcae83a2350396132fae0a5acabc --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: RestElement applied to an exhausted iterator (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +var C = class { + static method([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +C.method([1, 2]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..98793306f731e6c1d59e63b81dd654e2033c87b5 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-expr-meth-static.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +var C = class { + static method([...x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..385367f2d2add059837ee09b8c601582c76c1b60 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-expr-meth-static.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +var C = class { + static method([...x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-id.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-id.js new file mode 100644 index 0000000000000000000000000000000000000000..6355a4800bfc880e0ae808e0329526f56e6f6058 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-id.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Lone rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var C = class { + static method([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-init-ary.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..82262d71e85ff3c84b7cd3e240f0df53c7ddc34c --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-init-ary.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Reset element (nested array pattern) does not support initializer (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + static method([...[ x ] = []]) { + + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-init-id.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000000000000000000000000000000000..0377412b80cceee956cf72ceb315f59ef1ed40cd --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-init-id.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Reset element (identifier) does not support initializer (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + static method([...x = []]) { + + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-init-obj.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..d59ccef5a328c88debd6b52f9f3695e2d4889393 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-init-obj.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Reset element (nested object pattern) does not support initializer (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + static method([...{ x } = []]) { + + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-not-final-ary.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..1d25c1d4f0459f432111812c685213cf371a69b4 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + static method([...[x], y]) { + + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-not-final-id.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000000000000000000000000000000000..7210664acb653d9d11d0ac9af2c99ca8f4ab8a75 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Rest element (identifier) may not be followed by any element (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + static method([...x, y]) { + + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-not-final-obj.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..ef3407f4a0b9b9728bf5ff9da5bddb87cc972466 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + static method([...{ x }, y]) { + + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-obj-id.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..eeffb242ce9a0480a38e23408689f42177a8755f --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-obj-id.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + static method([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-obj-prop-id.js b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..9d319a248a277d6cdda1133803a171640091470e --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + static method([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; + } +}; + +C.method([7, 8, 9]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-obj-init-null.js b/test/language/expressions/class/dstr-meth-static-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..a1534f2682c6def6239a53bfe38411a6e65b5999 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-init-null.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-expr-meth-static.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var C = class { + static method({}) {} +}; + +assert.throws(TypeError, function() { + C.method(null); +}); diff --git a/test/language/expressions/class/dstr-meth-static-obj-init-undefined.js b/test/language/expressions/class/dstr-meth-static-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..af0973b6cbfc90114123836196491e8286a58a9f --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-init-undefined.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-expr-meth-static.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var C = class { + static method({}) {} +}; + +assert.throws(TypeError, function() { + C.method(undefined); +}); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-empty.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..7853ac6213e68c33b26cbf5ebc9f524042f0ba01 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-empty.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: No property access occurs for an "empty" object binding pattern (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +var C = class { + static method({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +C.method(obj); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-id-get-value-err.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..891b1382471e7bbd2e733e23f9ab42d61e0c0d8a --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-id-get-value-err.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-expr-meth-static.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +var C = class { + static method({ poisoned }) {} +}; + +assert.throws(Test262Error, function() { + C.method(poisonedProperty); +}); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-id-init-fn-name-arrow.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..aa3c6f1366f042d4bfdea19b17aafc469b707160 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + static method({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + 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-id-init-fn-name-class.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..3ecb8f44418a6f42cf93fe423077f70011e5fdb1 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + static method({ cls = class {}, xCls = class X {} }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + 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-id-init-fn-name-cover.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..6a863760500d4572a7919865ca8696bf89d92fd6 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + static method({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + 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-id-init-fn-name-fn.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..2e3ec0b2daac196a4c2667210d6a5273ed461682 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + static method({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + 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-id-init-fn-name-gen.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..3bfa6adb112be5e9576e821f9da8071ee58513a9 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + static method({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + 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-id-init-skipped.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..0e0dba6c8ec06a105c675191681c5f52beda7087 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-id-init-skipped.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var C = class { + static method({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method({ w: null, x: 0, y: false, z: '' }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-id-init-throws.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..53ce87d34d6c8c155b2c81aa9e3a80bc98863ed0 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-id-init-throws.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-expr-meth-static.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +var C = class { + static method({ x = thrower() }) {} +}; + +assert.throws(Test262Error, function() { + C.method({}); +}); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..26c7dc6d123535be28b56e1867c9e205b6c51aeb --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var C = class { + static method({ x = unresolvableReference }) {} +}; + +assert.throws(ReferenceError, function() { + C.method({}); +}); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-id-trailing-comma.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..ffdfde3b4de7f19c9dd66e4093365bc3b3b5e7c9 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var C = class { + static method({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-list-err.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..97edafc0314de2def2db5c9e41d41c902a3114ae --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-list-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-expr-meth-static.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +var C = class { + static method({ a, b = thrower(), c = ++initCount }) {} +}; + +assert.throws(Test262Error, function() { + C.method({}); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-ary-init.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000000000000000000000000000000000..222c537dd352ee38530ef127c943086921ac5671 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-ary-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + static method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + 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-prop-ary-trailing-comma.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..7e82ed1389d42cd9c0da5608a5f28a13efa4cba9 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var C = class { + static method({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +C.method({ x: [45] }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..950e61cc6e67d3a116d64ec5856d3e456309deb3 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-expr-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var C = class { + static method({ w: [x, y, z] = [4, 5, 6] }) {} +}; + +assert.throws(TypeError, function() { + C.method({ w: null }); +}); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-ary.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..28d2505dd37ca0b244b462b90bcf431d2835568b --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-ary.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + static method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method({ w: [7, undefined, ] }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-eval-err.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..9fde30cea749cec8c4ca7a66241001a2df6e5899 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-eval-err.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-expr-meth-static.template +/*--- +description: Evaluation of property name returns an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +var C = class { + static method({ [thrower()]: x }) {} +}; + +assert.throws(Test262Error, function() { + C.method({}); +}); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..9683155b1563e3d7aab9df0a74e756a56863a82a --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-expr-meth-static.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +var C = class { + static method({ poisoned: x = ++initEvalCount }) {} +}; + +assert.throws(Test262Error, function() { + C.method(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-id-init-skipped.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..282a0de247bbdde6ac274ba2a40c869c52f9a45b --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var C = class { + static method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method({ s: null, u: 0, w: false, y: '' }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..8ad0eff788d13428c1151cc024665b5696090200 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-expr-meth-static.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +var C = class { + static method({ x: y = thrower() }) {} +}; + +assert.throws(Test262Error, function() { + C.method({}); +}); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..e6a3b2166f4284f84f0370cccfa54e06a5494aac --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var C = class { + static method({ x: y = unresolvableReference }) {} +}; + +assert.throws(ReferenceError, function() { + C.method({}); +}); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-id-init.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..3a527fd6a242e6aa8985205a88298c81c9d0ea70 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-id-init.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Binding as specified via property name, identifier, and initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + 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-prop-id-trailing-comma.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..9e9295e5bcc528ba35e09ad67b9861b69c51a1c8 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var C = class { + static method({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-id.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..b3bc644d0b8cffc84cf15c39a3da417f3084f5f5 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-id.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Binding as specified via property name and identifier (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-obj-init.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000000000000000000000000000000000..70947f1de82a34af79b3fca2ac139afa894d566d --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-obj-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + static method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method({ w: undefined }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..202a4b3515b2be1a8c585b0ccfb9722f49801b30 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-expr-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var C = class { + static method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) {} +}; + +assert.throws(TypeError, function() { + C.method({ w: null }); +}); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..fac92c721e35e306afd16d18f507f16b1ab325f1 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-expr-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var C = class { + static method({ w: { x, y, z } = undefined }) {} +}; + +assert.throws(TypeError, function() { + C.method({ }); +}); diff --git a/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-obj.js b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..c760a74d194c1a39606e74ddd189edfb169a3b96 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-obj-ptrn-prop-obj.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-expr-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + static method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method({ w: { x: undefined, z: 7 } }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-init-iter-close.js b/test/language/expressions/function/dstr-ary-init-iter-close.js new file mode 100644 index 0000000000000000000000000000000000000000..86ec7962f294983f059a9a9199380c366badaea8 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-init-iter-close.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var f; +f = function([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; +}; + +f(iter); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-init-iter-get-err.js b/test/language/expressions/function/dstr-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..dc3691dcc5176a9506f7f3877e38761069e00098 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-init-iter-get-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/func-expr.template +/*--- +description: Abrupt completion returned by GetIterator (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +var f = function([x]) {}; + +assert.throws(Test262Error, function() { + f(iter); +}); diff --git a/test/language/expressions/function/dstr-ary-init-iter-no-close.js b/test/language/expressions/function/dstr-ary-init-iter-no-close.js new file mode 100644 index 0000000000000000000000000000000000000000..c9594dc9554c3cceffb19ef70a061d00d7ffb604 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-init-iter-no-close.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var f; +f = function([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; +}; + +f(iter); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-name-iter-val.js b/test/language/expressions/function/dstr-ary-name-iter-val.js index 06d35a57f9441c5c0006ee72a06fe816de7df392..601ef149ab8a574fa7cea88ac4e03a7ecf171130 100644 --- a/test/language/expressions/function/dstr-ary-name-iter-val.js +++ b/test/language/expressions/function/dstr-ary-name-iter-val.js @@ -3,7 +3,9 @@ // - src/dstr-binding/default/func-expr.template /*--- description: SingleNameBinding with normal value iteration (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation es6id: 14.1.20 +features: [destructuring-binding] flags: [generated] info: | FunctionExpression : function ( FormalParameters ) { FunctionBody } @@ -67,4 +69,4 @@ f = function([x, y, z]) { }; f([1, 2, 3]); -assert.sameValue(callCount, 1); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-ary-elem-init.js b/test/language/expressions/function/dstr-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000000000000000000000000000000000..ab69960420d009b493f6dbb012949aeaa1856409 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-ary-elem-iter.js b/test/language/expressions/function/dstr-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..6a6bd9ff3dfca62f7760ae4e4dc48f9af533bd2f --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; +}; + +f([[7, 8, 9]]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-ary-elision-init.js b/test/language/expressions/function/dstr-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000000000000000000000000000000000..9e536a928401e74fb6b1460a5312fb2adbb85195 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is used (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var f; +f = function([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-ary-elision-iter.js b/test/language/expressions/function/dstr-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..a2affccd7ec6fc9cf7979154340cf36b1ec5fdc0 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +var f; +f = function([[,] = g()]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; +}; + +f([[]]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-ary-empty-init.js b/test/language/expressions/function/dstr-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000000000000000000000000000000000..14c3b5078abb3d4db4cf4e2baa7184aeb517e776 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +var f; +f = function([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-ary-empty-iter.js b/test/language/expressions/function/dstr-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..5045a21a837e707aa0b1f6fa8d6d4db22ec4088d --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +var f; +f = function([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f([[23]]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-ary-rest-init.js b/test/language/expressions/function/dstr-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000000000000000000000000000000000..4dc818329f263e4f468374afa3f35686a8c18892 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +var f; +f = function([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-ary-rest-iter.js b/test/language/expressions/function/dstr-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..15075285761abd8453f4f0711160e8fbdbcbbd2d --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +var f; +f = function([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f([values]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/function/dstr-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..1b37b270ce22b9e089f28f3ae7a161901012532a --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/func-expr.template +/*--- +description: Nested array destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +var f = function([[x]]) {}; + +assert.throws(TypeError, function() { + f([null]); +}); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-exhausted.js b/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..3a73acaf75e580ef8fcdc6640c2078dfbd767a2a --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Destructuring initializer with an exhausted iterator (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..9c49e9fc46b0c96806d67c10c350378f596adecc --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: SingleNameBinding does assign name to arrow functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..306517b68e9f3edaf6145a6a3d5c8770b0bcde19 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function([cls = class {}, xCls = class X {}]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..1bcc103d8e26e7ceb47fda719f2d374a2ddbfd3d --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..cb1d27fc91436a18be990b73abc4b51ee4a493ac --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..bd6d3657db40ab114d95e538700b55f1147d456c --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-hole.js b/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000000000000000000000000000000000..9b6afdd8a2f0f129f58e5dbe3e5619cf82a902a7 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Destructuring initializer with a "hole" (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function([x = 23]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; +}; + +f([,]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-skipped.js b/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..072a6d097819b83ca82bcbdc1122eb3d0663175d --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var f; +f = function([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f([null, 0, false, '']); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..70c2c8f82b0251cbf97cd6db062baf535684c677 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/func-expr.template +/*--- +description: Destructuring initializer returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +var f = function([x = (function() { throw new Test262Error(); })()]) {}; + +assert.throws(Test262Error, function() { + f([undefined]); +}); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-undef.js b/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..80c0b61627b573768d6565a94251882fae2d0e05 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Destructuring initializer with an undefined value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; + +f([undefined]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..5d21ba9b19c3ec24affda7361cf8473320cddc60 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/func-expr.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var f = function([ x = unresolvableReference ]) {}; + +assert.throws(ReferenceError, function() { + f([]); +}); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-id-iter-complete.js b/test/language/expressions/function/dstr-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000000000000000000000000000000000..3d83d873e6dee795eed74baf3a370f2d29945a98 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: SingleNameBinding when value iteration completes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function([x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-id-iter-done.js b/test/language/expressions/function/dstr-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000000000000000000000000000000000..e8ff2b017556e3f3cb5b409e20cbda572ce4417e --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function([_, x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/function/dstr-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..550ff46c6e05a12f1d23bd1c65f2947499560cd7 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/func-expr.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +var f = function([x]) {}; + +assert.throws(Test262Error, function() { + f(g); +}); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/function/dstr-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..a97e316782dd69acb404c6057b42e10cda7b489e --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/func-expr.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +var f = function([x]) {}; + +assert.throws(Test262Error, function() { + f(g); +}); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-id-iter-val.js b/test/language/expressions/function/dstr-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..11826283214700890256226448d6b174f74ff711 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; + +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-obj-id-init.js b/test/language/expressions/function/dstr-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..e205673832317b1b01e9aeef998fffa4a73bc2c6 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-obj-id.js b/test/language/expressions/function/dstr-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..cdf2ae1d777cd3b98d8ffc29a751887f2b4cd179 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-obj-id.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; +}; + +f([{ x: 11, y: 22, z: 33 }]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-obj-prop-id-init.js b/test/language/expressions/function/dstr-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..ac4de7fc03e5849e1c1eb04a85568f482adf759b --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-obj-prop-id.js b/test/language/expressions/function/dstr-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..90c5cf2c099f973edb660872e3ad2940e6ead6db --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; + +f([{ u: 777, w: 888, y: 999 }]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/function/dstr-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..9a8f8685ed2a490a3981579bfa8102be949201d1 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/func-expr.template +/*--- +description: Nested object destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +var f = function([{ x }]) {}; + +assert.throws(TypeError, function() { + f([null]); +}); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/function/dstr-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..f3b5559a65a50b3d7d45a137d80ec9c5ca102fad --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/func-expr.template +/*--- +description: Nested object destructuring with a value of `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +var f = function([{ x }]) {}; + +assert.throws(TypeError, function() { + f([]); +}); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elision-exhausted.js b/test/language/expressions/function/dstr-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..289ebbc62aa4ebca1fa63553759b5cdf11192941 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elision-exhausted.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Elision accepts exhausted iterator (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +var f; +f = function([,]) { + + callCount = callCount + 1; +}; + +f(iter); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elision-step-err.js b/test/language/expressions/function/dstr-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..5ff03c127e865526abe73d10061f07299de2f7a6 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elision-step-err.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/func-expr.template +/*--- +description: Elision advances iterator and forwards abrupt completions (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +var f = function([,]) {}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-elision.js b/test/language/expressions/function/dstr-ary-ptrn-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..633956ebcea0bbc003d819e4fd0e0c15fc9d9c8a --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-elision.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Elision advances iterator (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var f; +f = function([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; + +f(g()); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-empty.js b/test/language/expressions/function/dstr-ary-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..6f9e8a4d8278ee85e8cd91d2c503a365a6d041eb --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-empty.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var f; +f = function([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; +}; + +f(iter); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-rest-ary-elem.js b/test/language/expressions/function/dstr-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000000000000000000000000000000000..85df564622ef82e160a425bbd4e0f7b3cf0414dd --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Rest element containing an array BindingElementList pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; +}; + +f([3, 4, 5]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-rest-ary-elision.js b/test/language/expressions/function/dstr-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..3016057bf8a41817f6e5e4db75d261656b8f8db6 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Rest element containing an elision (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var f; +f = function([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; +}; + +f(g()); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-rest-ary-empty.js b/test/language/expressions/function/dstr-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..0a8823fb7223df50829307c9a61dd8b73c0d98f6 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Rest element containing an "empty" array pattern (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var f; +f = function([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; +}; + +f(iter); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-rest-ary-rest.js b/test/language/expressions/function/dstr-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..4b23fd24f336eb11408dd127149d94db2c05a09d --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Rest element containing a rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var f; +f = function([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; +}; + +f(values); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/function/dstr-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..27bc3d6d1238e3e2fdd2c081e0f25e4ee8943638 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/func-expr.template +/*--- +description: Rest element following elision elements (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +var f = function([, ...x]) {}; + +assert.throws(Test262Error, function() { + f(iter); +}); diff --git a/test/language/expressions/function/dstr-ary-ptrn-rest-id-elision.js b/test/language/expressions/function/dstr-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..c449d0a840d372c38acb2a6d0e08df39fc48535e --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-rest-id-elision.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Rest element following elision elements (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +var f; +f = function([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; + +f(values); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-rest-id-exhausted.js b/test/language/expressions/function/dstr-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..9e89fa3454802cb21ad46807a0b842df86439832 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: RestElement applied to an exhausted iterator (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +var f; +f = function([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; +}; + +f([1, 2]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/function/dstr-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..ec32d32f17a411d2fad762d9524f4ac3a65076fe --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/func-expr.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +var f = function([...x]) {}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/function/dstr-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..fdc91721ca911499d27efae44f2664cfd49dc412 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/func-expr.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +var f = function([...x]) {}; + +assert.throws(Test262Error, function() { + f(iter); +}); diff --git a/test/language/expressions/function/dstr-ary-ptrn-rest-id.js b/test/language/expressions/function/dstr-ary-ptrn-rest-id.js new file mode 100644 index 0000000000000000000000000000000000000000..4a5b3f022294e22e4a63f89e5540bcd8602ec87f --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-rest-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Lone rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var f; +f = function([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; + +f(values); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-rest-init-ary.js b/test/language/expressions/function/dstr-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..ccb93a07dab10509002749fa34f9d49e6594b2ef --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-rest-init-ary.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Reset element (nested array pattern) does not support initializer (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = function([...[ x ] = []]) { + + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-rest-init-id.js b/test/language/expressions/function/dstr-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000000000000000000000000000000000..bbc5eaebc6e2ab0f90b654231f906039387911ff --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-rest-init-id.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Reset element (identifier) does not support initializer (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = function([...x = []]) { + + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-rest-init-obj.js b/test/language/expressions/function/dstr-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..f611f5a1a3134ff98fa171f25a1c44d2bf6eadaa --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-rest-init-obj.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Reset element (nested object pattern) does not support initializer (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = function([...{ x } = []]) { + + callCount = callCount + 1; +}; + +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-rest-not-final-ary.js b/test/language/expressions/function/dstr-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..46877109ec08ec69e03fec2ab24bb153bb0f957a --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = function([...[x], y]) { + + callCount = callCount + 1; +}; + +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-rest-not-final-id.js b/test/language/expressions/function/dstr-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000000000000000000000000000000000..698d5ae84d9428b8bbd462f691f8406aaf286ca2 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Rest element (identifier) may not be followed by any element (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = function([...x, y]) { + + callCount = callCount + 1; +}; + +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-rest-not-final-obj.js b/test/language/expressions/function/dstr-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..107c4cc33e0ff17019d1bffa10ac386625eb9773 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = function([...{ x }, y]) { + + callCount = callCount + 1; +}; + +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-rest-obj-id.js b/test/language/expressions/function/dstr-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..64fbcd0784b637a45e5a0547bc37f2017cd1a60a --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-rest-obj-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = function([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; +}; + +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-ary-ptrn-rest-obj-prop-id.js b/test/language/expressions/function/dstr-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..293166c407ba19f585041800fbabebf2f07f6927 --- /dev/null +++ b/test/language/expressions/function/dstr-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = function([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; +}; + +f([7, 8, 9]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-obj-init-null.js b/test/language/expressions/function/dstr-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..9350d05a57578912197cac7bca2abdf179c20ced --- /dev/null +++ b/test/language/expressions/function/dstr-obj-init-null.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/func-expr.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var f = function({}) {}; + +assert.throws(TypeError, function() { + f(null); +}); diff --git a/test/language/expressions/function/dstr-obj-init-undefined.js b/test/language/expressions/function/dstr-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..096e119f29dc9513b0c411a12b4039bf2362a374 --- /dev/null +++ b/test/language/expressions/function/dstr-obj-init-undefined.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/func-expr.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var f = function({}) {}; + +assert.throws(TypeError, function() { + f(undefined); +}); diff --git a/test/language/expressions/function/dstr-obj-ptrn-empty.js b/test/language/expressions/function/dstr-obj-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..55a3e2064905ab7315c2495fb1dbbfc8ec1bd356 --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-empty.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: No property access occurs for an "empty" object binding pattern (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +var f; +f = function({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; +}; + +f(obj); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-obj-ptrn-id-get-value-err.js b/test/language/expressions/function/dstr-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..c1a064b220a42022a413c727e73d1ab1f3ad4e28 --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-id-get-value-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/func-expr.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +var f = function({ poisoned }) {}; + +assert.throws(Test262Error, function() { + f(poisonedProperty); +}); diff --git a/test/language/expressions/function/dstr-obj-ptrn-id-init-fn-name-arrow.js b/test/language/expressions/function/dstr-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..d7472d785f0178f777881b6995f43086a6572d02 --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = function({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; + +f({}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-obj-ptrn-id-init-fn-name-class.js b/test/language/expressions/function/dstr-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..cc57e2481088a058887b298aadffd2c1ff25eb6c --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = function({ cls = class {}, xCls = class X {} }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; +}; + +f({}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-obj-ptrn-id-init-fn-name-cover.js b/test/language/expressions/function/dstr-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..ef1b87f7cac7217cbb5a3dc6c93be6ea3a95968b --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = function({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; + +f({}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-obj-ptrn-id-init-fn-name-fn.js b/test/language/expressions/function/dstr-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..40e0b5b6e4f348165857550237bd1430962c51b4 --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = function({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; + +f({}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-obj-ptrn-id-init-fn-name-gen.js b/test/language/expressions/function/dstr-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..d77ad633ede4c96891aad4ca2348371eb992f682 --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = function({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; + +f({}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-obj-ptrn-id-init-skipped.js b/test/language/expressions/function/dstr-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..268a5842d9fd25de0b37332ac117cf911f1486aa --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-id-init-skipped.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var f; +f = function({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f({ w: null, x: 0, y: false, z: '' }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-obj-ptrn-id-init-throws.js b/test/language/expressions/function/dstr-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..286f7d7b7c53994ed871479463baa1f88764c777 --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-id-init-throws.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/func-expr.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +var f = function({ x = thrower() }) {}; + +assert.throws(Test262Error, function() { + f({}); +}); diff --git a/test/language/expressions/function/dstr-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/function/dstr-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..d2cd8fcbbf90ce627bfb0e8526c63c20147440c2 --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/func-expr.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var f = function({ x = unresolvableReference }) {}; + +assert.throws(ReferenceError, function() { + f({}); +}); diff --git a/test/language/expressions/function/dstr-obj-ptrn-id-trailing-comma.js b/test/language/expressions/function/dstr-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..6694ae008475704a50104f349fbe22103bc38faa --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var f; +f = function({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; + +f({ x: 23 }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-obj-ptrn-list-err.js b/test/language/expressions/function/dstr-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..a40e0c31e2115c2fc07b671897fec6dcc874563d --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-list-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/func-expr.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +var f = function({ a, b = thrower(), c = ++initCount }) {}; + +assert.throws(Test262Error, function() { + f({}); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/function/dstr-obj-ptrn-prop-ary-init.js b/test/language/expressions/function/dstr-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000000000000000000000000000000000..f3bcb9d7998099644e8c9eeb9d95338ec8a705d3 --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-prop-ary-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = function({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f({}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-obj-ptrn-prop-ary-trailing-comma.js b/test/language/expressions/function/dstr-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..4aa66810903addfff6546e8c99efffef8c59356c --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var f; +f = function({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; +}; + +f({ x: [45] }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/function/dstr-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..90303311e00532767cb6e58d74dde53d0cd847b9 --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/func-expr.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var f = function({ w: [x, y, z] = [4, 5, 6] }) {}; + +assert.throws(TypeError, function() { + f({ w: null }); +}); diff --git a/test/language/expressions/function/dstr-obj-ptrn-prop-ary.js b/test/language/expressions/function/dstr-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..d7454214d62bb9dc3ae5504bdea6c3546e898e5e --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-prop-ary.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = function({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f({ w: [7, undefined, ] }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-obj-ptrn-prop-eval-err.js b/test/language/expressions/function/dstr-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..a00f5d1391e32be5df1da37cd42fb26c1094649a --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-prop-eval-err.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/func-expr.template +/*--- +description: Evaluation of property name returns an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +var f = function({ [thrower()]: x }) {}; + +assert.throws(Test262Error, function() { + f({}); +}); diff --git a/test/language/expressions/function/dstr-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/function/dstr-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..f2c2991dddd58e9b0b3270c736a37cde1ab80a5f --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/func-expr.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +var f = function({ poisoned: x = ++initEvalCount }) {}; + +assert.throws(Test262Error, function() { + f(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/function/dstr-obj-ptrn-prop-id-init-skipped.js b/test/language/expressions/function/dstr-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..71177f199b0359cbb5440b4b6860ba7470734ab3 --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var f; +f = function({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; + +f({ s: null, u: 0, w: false, y: '' }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/function/dstr-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..464bb2b4d122a13ccfce08000bbf5c18d35cc498 --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/func-expr.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +var f = function({ x: y = thrower() }) {}; + +assert.throws(Test262Error, function() { + f({}); +}); diff --git a/test/language/expressions/function/dstr-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/function/dstr-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..56c120c2840ee3a07285c19e49b2cbe1a48fbee5 --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/func-expr.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var f = function({ x: y = unresolvableReference }) {}; + +assert.throws(ReferenceError, function() { + f({}); +}); diff --git a/test/language/expressions/function/dstr-obj-ptrn-prop-id-init.js b/test/language/expressions/function/dstr-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..54ad485bfa3f30000ce6c759e89219870dfb4b91 --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-prop-id-init.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Binding as specified via property name, identifier, and initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; + +f({ }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-obj-ptrn-prop-id-trailing-comma.js b/test/language/expressions/function/dstr-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..af22dd63f5546393bb2bce1d95d4a55c429b196f --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var f; +f = function({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; + +f({ x: 23 }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-obj-ptrn-prop-id.js b/test/language/expressions/function/dstr-obj-ptrn-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..7655f3e421921950107a68511bc6b38293fd8b4f --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-prop-id.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Binding as specified via property name and identifier (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; + +f({ x: 23 }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-obj-ptrn-prop-obj-init.js b/test/language/expressions/function/dstr-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000000000000000000000000000000000..53cc7fa6eb3116317f19764f8b5ce9cc4a26816f --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-prop-obj-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = function({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f({ w: undefined }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/function/dstr-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..10223ec247ad462579811b5fcfce887b53e687df --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/func-expr.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var f = function({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) {}; + +assert.throws(TypeError, function() { + f({ w: null }); +}); diff --git a/test/language/expressions/function/dstr-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/function/dstr-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..c8915d6c2f3dea40c7d6e4eb860cbed999b4aed5 --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/func-expr.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var f = function({ w: { x, y, z } = undefined }) {}; + +assert.throws(TypeError, function() { + f({ }); +}); diff --git a/test/language/expressions/function/dstr-obj-ptrn-prop-obj.js b/test/language/expressions/function/dstr-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..40d9a1f57ff034023fc405844dcc2d6b6405ca4a --- /dev/null +++ b/test/language/expressions/function/dstr-obj-ptrn-prop-obj.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/func-expr.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = function({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f({ w: { x: undefined, z: 7 } }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-init-iter-close.js b/test/language/expressions/generators/dstr-ary-init-iter-close.js new file mode 100644 index 0000000000000000000000000000000000000000..48ab07296fc1fceeb749051938fface0831e2c1a --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-init-iter-close.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var f; +f = function*([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; +}; + +f(iter).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-init-iter-get-err.js b/test/language/expressions/generators/dstr-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..bde748ea3fd17b8ea19c7d47c19e1dd378176464 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-init-iter-get-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/gen-func-expr.template +/*--- +description: Abrupt completion returned by GetIterator (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +var f = function*([x]) {}; + +assert.throws(Test262Error, function() { + f(iter); +}); diff --git a/test/language/expressions/generators/dstr-ary-init-iter-no-close.js b/test/language/expressions/generators/dstr-ary-init-iter-no-close.js new file mode 100644 index 0000000000000000000000000000000000000000..4e7ff934a36260f67e02299256f55a98619a2602 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-init-iter-no-close.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var f; +f = function*([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; +}; + +f(iter).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-name-iter-val.js b/test/language/expressions/generators/dstr-ary-name-iter-val.js index 13fe38531b441fc8d02b5ad561b23c236d7fd90e..abf1968043f17cbcf36fc1869308604235943725 100644 --- a/test/language/expressions/generators/dstr-ary-name-iter-val.js +++ b/test/language/expressions/generators/dstr-ary-name-iter-val.js @@ -3,7 +3,9 @@ // - src/dstr-binding/default/gen-func-expr.template /*--- description: SingleNameBinding with normal value iteration (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 } @@ -67,4 +69,4 @@ f = function*([x, y, z]) { }; f([1, 2, 3]).next(); -assert.sameValue(callCount, 1); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-elem-init.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000000000000000000000000000000000..6ab9e851b18c228efae8c6eb96adf086aba9851f --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function*([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; +}; + +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-elem-iter.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..31dfd70046ac8f35aab47ae3544ccbf7a0368b91 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function*([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; +}; + +f([[7, 8, 9]]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-elision-init.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000000000000000000000000000000000..03bc8bf6c21f6ccb0413cbe4dfe7d16cfdd6583a --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is used (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var f; +f = function*([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; + +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-elision-iter.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..b632305d84e45e9ce6a0bc708cc6773770663157 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +var f; +f = function*([[,] = g()]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; +}; + +f([[]]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-empty-init.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000000000000000000000000000000000..89ac77a7e3d99fc472812c05237e357bba28d17b --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +var f; +f = function*([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; +}; + +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-empty-iter.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..e6592ec88142753f65ba477879e222344b648086 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +var f; +f = function*([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f([[23]]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-rest-init.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000000000000000000000000000000000..bf4b5648558cdbb8c68a11266065962afd9fe713 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +var f; +f = function*([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; + +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-rest-iter.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..7ed60bb0ee69e1b0322d82c1bbd723ae839e1053 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +var f; +f = function*([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f([values]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..10e2ffb2baa08b514a8f6e66e57a02ce92e4927a --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/gen-func-expr.template +/*--- +description: Nested array destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +var f = function*([[x]]) {}; + +assert.throws(TypeError, function() { + f([null]); +}); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-exhausted.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..183c09e1b2b85ffed65b4751b329ec2b3f143927 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Destructuring initializer with an exhausted iterator (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; + +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..0a8cbd1f2ab9bb100ac879c387e3294e5636f916 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: SingleNameBinding does assign name to arrow functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; + +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..47b0c4eb23817732551abf3d24eb8723bf98ce06 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*([cls = class {}, xCls = class X {}]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; +}; + +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..68c6b6cc801fe19f25017f2c50a2ec1af6eb085d --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; + +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..ed5baebb6b9e18a739504bc43429e44feab1b2cc --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; + +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..d80f9c87b4f717e3a881d08043379ef596312c46 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; + +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-hole.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000000000000000000000000000000000..7b010a94eca5b370c0249d29a301ca77475a7bb8 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Destructuring initializer with a "hole" (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*([x = 23]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; +}; + +f([,]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-skipped.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..39dc1cdb9baa9e691bed319c8f1b8ed5d929ee20 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var f; +f = function*([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f([null, 0, false, '']).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..89d6cb82b304398d4d0300f7f332b88892f217c1 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/gen-func-expr.template +/*--- +description: Destructuring initializer returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +var f = function*([x = (function() { throw new Test262Error(); })()]) {}; + +assert.throws(Test262Error, function() { + f([undefined]); +}); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-undef.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..0e9d19cdb5cf5c4001e706ec1ef1b03f704edd0f --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Destructuring initializer with an undefined value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; + +f([undefined]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..dc459a822e8b72e2efbafab9f100c75ff7aad2e3 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/gen-func-expr.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var f = function*([ x = unresolvableReference ]) {}; + +assert.throws(ReferenceError, function() { + f([]); +}); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-id-iter-complete.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000000000000000000000000000000000..3e0642f53b4b18d0053c6c12d9169959db840f52 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: SingleNameBinding when value iteration completes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*([x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; + +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-id-iter-done.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000000000000000000000000000000000..7a31978018270df63fea501640db0bcc4d4dba0f --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*([_, x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; + +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..c8c7261b2d24212a133980f2defa876af025eb41 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/gen-func-expr.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +var f = function*([x]) {}; + +assert.throws(Test262Error, function() { + f(g); +}); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..f6edd9648e7215b6b4a25998db8cc70dd968a77e --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/gen-func-expr.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +var f = function*([x]) {}; + +assert.throws(Test262Error, function() { + f(g); +}); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-id-iter-val.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..6213084b7d9deb740214b2cff561aacc08cf029e --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; + +f([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-obj-id-init.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..bd94ebb5c27c70f42388117081ade22acf5fc409 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function*([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; +}; + +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-obj-id.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..631bf5e0c4b985eba63c6c12e8e97901565dce95 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-obj-id.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function*([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; +}; + +f([{ x: 11, y: 22, z: 33 }]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-obj-prop-id-init.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..eae3628af4496913def191e34dcee3447648f870 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function*([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; + +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-obj-prop-id.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..c3ff53956a9860fb41695bf61518f2fad098cc1c --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function*([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; + +f([{ u: 777, w: 888, y: 999 }]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..b054901be7f42548c686b52f8f959c1807d466c1 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/gen-func-expr.template +/*--- +description: Nested object destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +var f = function*([{ x }]) {}; + +assert.throws(TypeError, function() { + f([null]); +}); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/generators/dstr-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..d64344d2c23307fa3d904ae230a58b80ff496788 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/gen-func-expr.template +/*--- +description: Nested object destructuring with a value of `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +var f = function*([{ x }]) {}; + +assert.throws(TypeError, function() { + f([]); +}); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elision-exhausted.js b/test/language/expressions/generators/dstr-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..fee364e7b82c7bcdf91343f3674448c05215f2d5 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elision-exhausted.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Elision accepts exhausted iterator (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +var f; +f = function*([,]) { + + callCount = callCount + 1; +}; + +f(iter).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elision-step-err.js b/test/language/expressions/generators/dstr-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..d4f621405f5807d769f7a5ed1a9c695c3014dea4 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elision-step-err.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/gen-func-expr.template +/*--- +description: Elision advances iterator and forwards abrupt completions (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +var f = function*([,]) {}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-elision.js b/test/language/expressions/generators/dstr-ary-ptrn-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..07276b70620b6be8476feb39f4967f38ccf4ed3b --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-elision.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Elision advances iterator (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var f; +f = function*([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; + +f(g()).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-empty.js b/test/language/expressions/generators/dstr-ary-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..69dde4d8d0ab62fd2fe362328acb49b151cd31d3 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-empty.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var f; +f = function*([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; +}; + +f(iter).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-rest-ary-elem.js b/test/language/expressions/generators/dstr-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000000000000000000000000000000000..603dce2cf2250e59c6729bfcdd2434b6e362b76f --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Rest element containing an array BindingElementList pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; +}; + +f([3, 4, 5]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-rest-ary-elision.js b/test/language/expressions/generators/dstr-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..d3332e5b71b6a987a4180be9a9767e7d1e0ee6cb --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Rest element containing an elision (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var f; +f = function*([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; +}; + +f(g()).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-rest-ary-empty.js b/test/language/expressions/generators/dstr-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..c4aec19f0b8e2e9db872b99746e4cd83d23050ef --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Rest element containing an "empty" array pattern (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var f; +f = function*([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; +}; + +f(iter).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-rest-ary-rest.js b/test/language/expressions/generators/dstr-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..066513a1a1bb0b133ce639d6239fbc8d2398c8e4 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Rest element containing a rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var f; +f = function*([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; +}; + +f(values).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/generators/dstr-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..e8a25f0dbd5a0cf320dbd22d45f0637cc6c3d4ed --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/gen-func-expr.template +/*--- +description: Rest element following elision elements (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +var f = function*([, ...x]) {}; + +assert.throws(Test262Error, function() { + f(iter); +}); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-rest-id-elision.js b/test/language/expressions/generators/dstr-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..ac6f1e2bb1e0dc9641686f8cbbba2e299570e0df --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-rest-id-elision.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Rest element following elision elements (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +var f; +f = function*([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; + +f(values).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-rest-id-exhausted.js b/test/language/expressions/generators/dstr-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..aebe8dd4959498b592c4f2a45e1fcbdeb5f59a2e --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: RestElement applied to an exhausted iterator (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +var f; +f = function*([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; +}; + +f([1, 2]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/generators/dstr-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..cd8949ae189150633a4be9a063b6146fb42b0414 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/gen-func-expr.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +var f = function*([...x]) {}; + +assert.throws(Test262Error, function() { + f(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/generators/dstr-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..480f6f877fcfe0f95bd5cad7ed46971fddb4f292 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/gen-func-expr.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +var f = function*([...x]) {}; + +assert.throws(Test262Error, function() { + f(iter); +}); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-rest-id.js b/test/language/expressions/generators/dstr-ary-ptrn-rest-id.js new file mode 100644 index 0000000000000000000000000000000000000000..882ed8f56a716dffc26f95dd632ac84f020a4317 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-rest-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Lone rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var f; +f = function*([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; + +f(values).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-rest-init-ary.js b/test/language/expressions/generators/dstr-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..e7e18fa57bc491d5d3d800ca2350811343dd7a41 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-rest-init-ary.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Reset element (nested array pattern) does not support initializer (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = function*([...[ x ] = []]) { + + callCount = callCount + 1; +}; + +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-rest-init-id.js b/test/language/expressions/generators/dstr-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000000000000000000000000000000000..e9862c19edef8f06606e78dca092d64d5af644a6 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-rest-init-id.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Reset element (identifier) does not support initializer (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = function*([...x = []]) { + + callCount = callCount + 1; +}; + +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-rest-init-obj.js b/test/language/expressions/generators/dstr-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..d1a7e12b5a5a462b3275c22672782362bd5a1645 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-rest-init-obj.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Reset element (nested object pattern) does not support initializer (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = function*([...{ x } = []]) { + + callCount = callCount + 1; +}; + +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-rest-not-final-ary.js b/test/language/expressions/generators/dstr-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..b639ce36170eaf6502e7ccc6ab12471b429158a4 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = function*([...[x], y]) { + + callCount = callCount + 1; +}; + +f([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-rest-not-final-id.js b/test/language/expressions/generators/dstr-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000000000000000000000000000000000..491f27ec8a6451f8a80f7d0c348800f32040ce0e --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Rest element (identifier) may not be followed by any element (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = function*([...x, y]) { + + callCount = callCount + 1; +}; + +f([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-rest-not-final-obj.js b/test/language/expressions/generators/dstr-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..be3207a344fa76d6e3a6b695adfc7d53c3ce89f7 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = function*([...{ x }, y]) { + + callCount = callCount + 1; +}; + +f([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-rest-obj-id.js b/test/language/expressions/generators/dstr-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..f2ba6b8fd30913ba51d43afe8d3b40fd6b3248d2 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-rest-obj-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = function*([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; +}; + +f([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-ary-ptrn-rest-obj-prop-id.js b/test/language/expressions/generators/dstr-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..823106b4bf13f0fbcdf7c5b9ca560e47a17b81e0 --- /dev/null +++ b/test/language/expressions/generators/dstr-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = function*([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; +}; + +f([7, 8, 9]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-obj-init-null.js b/test/language/expressions/generators/dstr-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..80c44cd450719b2253a92dc0f9df343dbbccd9cb --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-init-null.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/gen-func-expr.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var f = function*({}) {}; + +assert.throws(TypeError, function() { + f(null); +}); diff --git a/test/language/expressions/generators/dstr-obj-init-undefined.js b/test/language/expressions/generators/dstr-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..96416c4ad3dc30e28f3afefc72c94c45ad193b4e --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-init-undefined.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/gen-func-expr.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var f = function*({}) {}; + +assert.throws(TypeError, function() { + f(undefined); +}); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-empty.js b/test/language/expressions/generators/dstr-obj-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..ba67f957756ff6c044b9522e5a31a7284ed958fd --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-empty.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: No property access occurs for an "empty" object binding pattern (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +var f; +f = function*({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; +}; + +f(obj).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-id-get-value-err.js b/test/language/expressions/generators/dstr-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..e3d564c7f9a00ed30f5e9564de22c07609f47a8a --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-id-get-value-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/gen-func-expr.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +var f = function*({ poisoned }) {}; + +assert.throws(Test262Error, function() { + f(poisonedProperty); +}); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-id-init-fn-name-arrow.js b/test/language/expressions/generators/dstr-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..5ccfe777c3f07758847118157fcfd0f6d95c56b6 --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = function*({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; + +f({}).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-id-init-fn-name-class.js b/test/language/expressions/generators/dstr-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..7d4409663497d0b2770332e5065504c64375fdb6 --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = function*({ cls = class {}, xCls = class X {} }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; +}; + +f({}).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-id-init-fn-name-cover.js b/test/language/expressions/generators/dstr-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..e7396ec06a59565505bf6bba39ed030dcbb3cde1 --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = function*({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; + +f({}).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-id-init-fn-name-fn.js b/test/language/expressions/generators/dstr-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..802ae12a1d8f6f59f995183190b3b0d3a6cb9b18 --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = function*({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; + +f({}).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-id-init-fn-name-gen.js b/test/language/expressions/generators/dstr-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..07f43ae6bb778ff7f5fc2e47cb4342f556b81e32 --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = function*({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; + +f({}).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-id-init-skipped.js b/test/language/expressions/generators/dstr-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..5305377a6c8d0201a74134e0f01e6eecb816edff --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-id-init-skipped.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var f; +f = function*({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f({ w: null, x: 0, y: false, z: '' }).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-id-init-throws.js b/test/language/expressions/generators/dstr-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..c3519252dd3c6cf5751d289e80c6636657470c26 --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-id-init-throws.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/gen-func-expr.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +var f = function*({ x = thrower() }) {}; + +assert.throws(Test262Error, function() { + f({}); +}); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/generators/dstr-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..71b79fbd97c24cda317db893895be0a50e2fed1c --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/gen-func-expr.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var f = function*({ x = unresolvableReference }) {}; + +assert.throws(ReferenceError, function() { + f({}); +}); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-id-trailing-comma.js b/test/language/expressions/generators/dstr-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..5133d1bd8c44fc22cc13a25e74c93fa81dbdf6ec --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var f; +f = function*({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; + +f({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-list-err.js b/test/language/expressions/generators/dstr-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..c7750e13f84467ca53b38a887fc4b52324041d54 --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-list-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/gen-func-expr.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +var f = function*({ a, b = thrower(), c = ++initCount }) {}; + +assert.throws(Test262Error, function() { + f({}); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-prop-ary-init.js b/test/language/expressions/generators/dstr-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000000000000000000000000000000000..e11c7abad9ebd0ea6d23bf34984462b0b18c0531 --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-prop-ary-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = function*({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f({}).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-prop-ary-trailing-comma.js b/test/language/expressions/generators/dstr-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..ac53a5f136993a6c949cab120c69e437f497701f --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var f; +f = function*({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; +}; + +f({ x: [45] }).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/generators/dstr-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..8869ebe969046962dc73d6902e5183736f5ed5ac --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/gen-func-expr.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var f = function*({ w: [x, y, z] = [4, 5, 6] }) {}; + +assert.throws(TypeError, function() { + f({ w: null }); +}); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-prop-ary.js b/test/language/expressions/generators/dstr-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..1eb70547dc014a8a92aa9f984c01c6e7dec40476 --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-prop-ary.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = function*({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f({ w: [7, undefined, ] }).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-prop-eval-err.js b/test/language/expressions/generators/dstr-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..13ff987ec4993ecc5aee6547e8363f0c908d20bf --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-prop-eval-err.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/gen-func-expr.template +/*--- +description: Evaluation of property name returns an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +var f = function*({ [thrower()]: x }) {}; + +assert.throws(Test262Error, function() { + f({}); +}); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/generators/dstr-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..b2123cc0a835fbe3f4f74fb72d0559be71c337a7 --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/gen-func-expr.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +var f = function*({ poisoned: x = ++initEvalCount }) {}; + +assert.throws(Test262Error, function() { + f(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-prop-id-init-skipped.js b/test/language/expressions/generators/dstr-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..b2629d369ff39f623ad5f335d1262a584646f0c7 --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var f; +f = function*({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; + +f({ s: null, u: 0, w: false, y: '' }).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/generators/dstr-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..eef30e7cf9084681e30d672be04e631afcc63823 --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/gen-func-expr.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +var f = function*({ x: y = thrower() }) {}; + +assert.throws(Test262Error, function() { + f({}); +}); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/generators/dstr-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..4d4e741aa59bb2b3d7e4140805667b2169d86e4c --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/gen-func-expr.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var f = function*({ x: y = unresolvableReference }) {}; + +assert.throws(ReferenceError, function() { + f({}); +}); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-prop-id-init.js b/test/language/expressions/generators/dstr-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..2903ebac5537ef99bca83e921e589e2e6feafa71 --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-prop-id-init.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Binding as specified via property name, identifier, and initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; + +f({ }).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-prop-id-trailing-comma.js b/test/language/expressions/generators/dstr-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..83717fda1e2f6cffd2489ddb9f31cd0d4c791c74 --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var f; +f = function*({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; + +f({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-prop-id.js b/test/language/expressions/generators/dstr-obj-ptrn-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..5668f147c5a34081f8c9125a2031eed2180827b0 --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-prop-id.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Binding as specified via property name and identifier (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; + +f({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-prop-obj-init.js b/test/language/expressions/generators/dstr-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000000000000000000000000000000000..c1d855982de27987ed6f7ceb2f427608292b0f17 --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-prop-obj-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = function*({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f({ w: undefined }).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/generators/dstr-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..03a0be82a03280fa0d9cc2aa8749838b74685d5d --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/gen-func-expr.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var f = function*({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) {}; + +assert.throws(TypeError, function() { + f({ w: null }); +}); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/generators/dstr-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..b0b28529d683340254e99862a240877d27f93e15 --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/gen-func-expr.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var f = function*({ w: { x, y, z } = undefined }) {}; + +assert.throws(TypeError, function() { + f({ }); +}); diff --git a/test/language/expressions/generators/dstr-obj-ptrn-prop-obj.js b/test/language/expressions/generators/dstr-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..408aeb51a21fd9c21d093a947fa02e3f88c22240 --- /dev/null +++ b/test/language/expressions/generators/dstr-obj-ptrn-prop-obj.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/gen-func-expr.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = function*({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f({ w: { x: undefined, z: 7 } }).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-init-iter-close.js b/test/language/expressions/object/dstr-gen-meth-ary-init-iter-close.js new file mode 100644 index 0000000000000000000000000000000000000000..3771eabe5d29dbfeee52462bbcf71ed7dfbbcc4a --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-init-iter-close.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var obj = { + *method([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +obj.method(iter).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-init-iter-get-err.js b/test/language/expressions/object/dstr-gen-meth-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..6a5a76ba2f130c3ee835bcd2794281a2b846d40a --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-init-iter-get-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Abrupt completion returned by GetIterator (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +var obj = { + *method([x]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-init-iter-no-close.js b/test/language/expressions/object/dstr-gen-meth-ary-init-iter-no-close.js new file mode 100644 index 0000000000000000000000000000000000000000..07c0537d41b8158909b91d63d7f511c8878c91b9 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-init-iter-no-close.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var obj = { + *method([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +obj.method(iter).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-name-iter-val.js b/test/language/expressions/object/dstr-gen-meth-ary-name-iter-val.js index dcbcdcc8ca1f471ea52cce8d60932b8ffe3340e9..0ab271c911666e69bd89f2ee82ca07af15b26efa 100644 --- a/test/language/expressions/object/dstr-gen-meth-ary-name-iter-val.js +++ b/test/language/expressions/object/dstr-gen-meth-ary-name-iter-val.js @@ -3,7 +3,9 @@ // - src/dstr-binding/default/gen-meth.template /*--- description: SingleNameBinding with normal value iteration (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation es6id: 14.4.13 +features: [destructuring-binding] flags: [generated] info: | GeneratorMethod : @@ -73,4 +75,4 @@ var obj = { }; obj.method([1, 2, 3]).next(); -assert.sameValue(callCount, 1); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-ary-elem-init.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000000000000000000000000000000000..1ad16e9e69a25ad8bc4cf5e03ad84028c9849e71 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + *method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + 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-ary-ptrn-elem-ary-elem-iter.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..3b7aa060fb6a5981ea5d92ef41392163fd2c2fe9 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + *method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +obj.method([[7, 8, 9]]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-ary-elision-init.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000000000000000000000000000000000..25313e26bf49e4a3812c079bfc44de43e6b09779 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var obj = { + *method([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + 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-ary-ptrn-elem-ary-elision-iter.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..3a18c6f050210514e4fa761c2350bb3f397e71f2 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +var obj = { + *method([[,] = g()]) { + assert.sameValue(callCount, 0); + 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-ary-ptrn-elem-ary-empty-init.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000000000000000000000000000000000..1c43677cc24f6e6bc8daa2fe6fc09bc0286726e5 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +var obj = { + *method([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + 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-ary-ptrn-elem-ary-empty-iter.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..ece4c9d3f50f603304331a2f831c689982f41086 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +var obj = { + *method([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +obj.method([[23]]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-ary-rest-init.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000000000000000000000000000000000..703d5c039148fac4f1fdf6a35b4144250b46ce4a --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +var obj = { + *method([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + 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-ary-ptrn-elem-ary-rest-iter.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..3cff8bffadfd80e3c5dd0672198e2bade02103ae --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +var obj = { + *method([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +obj.method([values]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..f89a144cf02decc6b37bfaae5ebb14e21f6f0b67 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Nested array destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +var obj = { + *method([[x]]) {} +}; + +assert.throws(TypeError, function() { + obj.method([null]); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-init-exhausted.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..14d074758f769206ac9f83d0db4cc74df32ddf80 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Destructuring initializer with an exhausted iterator (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method([x = 23]) { + assert.sameValue(x, 23); + 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-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..41ac1e1425ae4cb0ecabcb39c74d5424f6e98071 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: SingleNameBinding does assign name to arrow functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + 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-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..20a04f10bc4cb3a9996ec76bc5b986274fa49bce --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method([cls = class {}, xCls = class X {}]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + 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-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..b0c4e686c8c98feddaf7998c1ed1656a89b32124 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + 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-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..24a61cd0bb531262a2f7132b096cdb35d26bda85 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + 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-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..8c92a59664bd6741b755a76283b4d131ce8703de --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + 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-ary-ptrn-elem-id-init-hole.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000000000000000000000000000000000..3131921e279c0526b46f912fa479c15e8ec39775 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Destructuring initializer with a "hole" (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method([x = 23]) { + assert.sameValue(x, 23); + // another statement + 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-ary-ptrn-elem-id-init-skipped.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..d6b9730a6f899f3dd0b755ae40a32c12eaf1f4b8 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var obj = { + *method([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +obj.method([null, 0, false, '']).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..7123ab31c82205aac19bb5a0284276fc316ac2f1 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Destructuring initializer returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +var obj = { + *method([x = (function() { throw new Test262Error(); })()]) {} +}; + +assert.throws(Test262Error, function() { + obj.method([undefined]); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-init-undef.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..52199f10fb4dbbe2d24a27cec1a615ad9f2a004b --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Destructuring initializer with an undefined value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method([undefined]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..477eefb0992b04446f3666284acf2a73f17fbbe1 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var obj = { + *method([ x = unresolvableReference ]) {} +}; + +assert.throws(ReferenceError, function() { + obj.method([]); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-iter-complete.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000000000000000000000000000000000..fd1b1705f5e5e1b3e6b07cbac675446f111738a0 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: SingleNameBinding when value iteration completes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method([x]) { + assert.sameValue(x, undefined); + 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-ary-ptrn-elem-id-iter-done.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000000000000000000000000000000000..3c839033eaaab3bf92937169a09a6112b62e3e7e --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method([_, x]) { + assert.sameValue(x, undefined); + 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-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..54009339216cb1eda397c205fa1a52835f5fe05d --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +var obj = { + *method([x]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(g); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..e061915d418f3b092260631a31ce7c247bb70a0d --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +var obj = { + *method([x]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(g); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-iter-val.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..b9641ccac2f20b26c25c803556cf9186e4b2e292 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-obj-id-init.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..14a1988e5ebe2b0be5ac77dde08574747ed36e50 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + *method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + 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-ary-ptrn-elem-obj-id.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..840b3969464b91f8e85a826850530e39c38e5c31 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-obj-id.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + *method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +obj.method([{ x: 11, y: 22, z: 33 }]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-obj-prop-id-init.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..bb249870b1465d34b63d209899df3eeb899080e8 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + 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-ary-ptrn-elem-obj-prop-id.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..1ba97b7e4b934151aba750633853956d34228446 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +obj.method([{ u: 777, w: 888, y: 999 }]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..b11f76fc56b02135b171ac78eda8143aae45f5fd --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Nested object destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +var obj = { + *method([{ x }]) {} +}; + +assert.throws(TypeError, function() { + obj.method([null]); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..83cbbd6d53cc70075ac8e1155f20d4a48498915a --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Nested object destructuring with a value of `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +var obj = { + *method([{ x }]) {} +}; + +assert.throws(TypeError, function() { + obj.method([]); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elision-exhausted.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..b2e35e6c313c979dce35f323e2eda8d33cf43c8d --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elision-exhausted.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Elision accepts exhausted iterator (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +var obj = { + *method([,]) { + + callCount = callCount + 1; + } +}; + +obj.method(iter).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elision-step-err.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..3f936dd66ba78336097aa6bf3c4c0c850119eb14 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elision-step-err.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Elision advances iterator and forwards abrupt completions (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +var obj = { + *method([,]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elision.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..739a9c547234d576ecfed1dec600c914e7f34324 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-elision.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Elision advances iterator (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var obj = { + *method([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +obj.method(g()).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-empty.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..9fd33eac46016b8060ac9d5e0231ab5421fdd40c --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-empty.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var obj = { + *method([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +obj.method(iter).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-ary-elem.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000000000000000000000000000000000..1180dbdf70fe50d68ea1a8c7fe72ddec33640495 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Rest element containing an array BindingElementList pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +obj.method([3, 4, 5]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-ary-elision.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..fe97ffe822b400c2421035032984484204c465e7 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Rest element containing an elision (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var obj = { + *method([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +obj.method(g()).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-ary-empty.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..f09c9d98f4db8648390679ea7c1e1fe271035033 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Rest element containing an "empty" array pattern (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var obj = { + *method([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +obj.method(iter).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-ary-rest.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..5aea42fbbb0b452d8e22dcf179387e3cf76ce6dc --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Rest element containing a rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var obj = { + *method([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +obj.method(values).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..17156be2ed0a044581f09849084e683b56a8361f --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Rest element following elision elements (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +var obj = { + *method([, ...x]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-id-elision.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..1fc1ea43a30c85ee6dd90d78426d3d1a8478edd6 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-id-elision.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Rest element following elision elements (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +var obj = { + *method([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +obj.method(values).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-id-exhausted.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..8b39089749c38b2c5c07b4c0b406f8106663338f --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: RestElement applied to an exhausted iterator (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +var obj = { + *method([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +obj.method([1, 2]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..c89674f914a47cf38bf4a760563869353f2eefde --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +var obj = { + *method([...x]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..4599ed1076d6233554089ab063da1952017af337 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +var obj = { + *method([...x]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-id.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-id.js new file mode 100644 index 0000000000000000000000000000000000000000..072a0e58aaebb1fd30cc224ba52b7d0552925e57 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-id.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Lone rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var obj = { + *method([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +obj.method(values).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-init-ary.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..40ae01fde561f9ce59986c9fd6176537f320a0fe --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-init-ary.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Reset element (nested array pattern) does not support initializer (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var obj = { + *method([...[ x ] = []]) { + + 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-ary-ptrn-rest-init-id.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000000000000000000000000000000000..bf51ed72cad293f1489a11136141a45e04c74173 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-init-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Reset element (identifier) does not support initializer (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var obj = { + *method([...x = []]) { + + 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-ary-ptrn-rest-init-obj.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..a4fa2453042a3994ce9a0a86664837e729ebd67f --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-init-obj.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Reset element (nested object pattern) does not support initializer (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var obj = { + *method([...{ x } = []]) { + + 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-ary-ptrn-rest-not-final-ary.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..4740c9b424555d3b0d56a86dbdd7e1cfc83fc35d --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var obj = { + *method([...[x], y]) { + + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-not-final-id.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000000000000000000000000000000000..e26f893221199e3fdc359f5ef5e58cb7319e8b7f --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Rest element (identifier) may not be followed by any element (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var obj = { + *method([...x, y]) { + + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-not-final-obj.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..2bdd01a591a7c6412eeb13b5a486e00c458ff006 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var obj = { + *method([...{ x }, y]) { + + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-obj-id.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..e79da1e9cd4f9be8db871fe08b5eebfbeebc1c68 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-obj-id.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var obj = { + *method([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-obj-prop-id.js b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..64b9e940ec7fd0bd38dc5cfbab40cf5f86ef81dc --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var obj = { + *method([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; + } +}; + +obj.method([7, 8, 9]).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-init-null.js b/test/language/expressions/object/dstr-gen-meth-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..1410397775883449cd831d7267e79f02b1b0b942 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-init-null.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var obj = { + *method({}) {} +}; + +assert.throws(TypeError, function() { + obj.method(null); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-init-undefined.js b/test/language/expressions/object/dstr-gen-meth-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..b3e15001d90a6d5c35a440ea5049f1f795535848 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-init-undefined.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var obj = { + *method({}) {} +}; + +assert.throws(TypeError, function() { + obj.method(undefined); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-empty.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..d5b280b40e1eeb52fb9e64fb0bbce31df98610b5 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-empty.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: No property access occurs for an "empty" object binding pattern (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +var obj = { + *method({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +obj.method(obj).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-id-get-value-err.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..ad94c0678d0f8ff52aa6ebafdd3c5c0d80aac30e --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-id-get-value-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +var obj = { + *method({ poisoned }) {} +}; + +assert.throws(Test262Error, function() { + obj.method(poisonedProperty); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-id-init-fn-name-arrow.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..07cc10b36ce0e2e831b7ddbaaa78eeef1086ef4b --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var obj = { + *method({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + 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-id-init-fn-name-class.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..e88add4a75d223dc13d535e1f0a08584c3c6f8c0 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var obj = { + *method({ cls = class {}, xCls = class X {} }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + 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-id-init-fn-name-cover.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..86bc8efe786dfa96ed68670e90296f25b72ebf79 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var obj = { + *method({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + 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-id-init-fn-name-fn.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..b1d49c8b5024fbf07017d5aadfb64af7ef07d2f5 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var obj = { + *method({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + 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-id-init-fn-name-gen.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..2e8677473f409f40a5d47b2840d11ee487798a6b --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var obj = { + *method({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + 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-id-init-skipped.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..7dd1e090d00d00ec2d10c36052fea7d455e64b89 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-id-init-skipped.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var obj = { + *method({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +obj.method({ w: null, x: 0, y: false, z: '' }).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-id-init-throws.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..1efa140426860bcfcb2a5be64e724548966771c4 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-id-init-throws.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +var obj = { + *method({ x = thrower() }) {} +}; + +assert.throws(Test262Error, function() { + obj.method({}); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..63ba3e5f488c6076ea8200e783c5bd3d953fa8c3 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var obj = { + *method({ x = unresolvableReference }) {} +}; + +assert.throws(ReferenceError, function() { + obj.method({}); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-id-trailing-comma.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..2b4c25cbe9835a39ddd0289a712714153bc8646b --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var obj = { + *method({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-list-err.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..511d4721416818dba77c00c1cd19189c263f8c7d --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-list-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +var obj = { + *method({ a, b = thrower(), c = ++initCount }) {} +}; + +assert.throws(Test262Error, function() { + obj.method({}); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-ary-init.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000000000000000000000000000000000..07980a43c5787e382fec518fbc4954ab193b0254 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-ary-init.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var obj = { + *method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + 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-prop-ary-trailing-comma.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..fc740e24f4e764586d5ae0b1e80b9ea3728165bc --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var obj = { + *method({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +obj.method({ x: [45] }).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..72aeb074aa6bb6edbb2c380829b608d82fa535a9 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var obj = { + *method({ w: [x, y, z] = [4, 5, 6] }) {} +}; + +assert.throws(TypeError, function() { + obj.method({ w: null }); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-ary.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..5335b0512c3faf1a7c8779cbdcc8741a47d8aad7 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-ary.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var obj = { + *method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +obj.method({ w: [7, undefined, ] }).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-eval-err.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..d399bba616e223ef8b29b131a638eb7190401751 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-eval-err.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Evaluation of property name returns an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +var obj = { + *method({ [thrower()]: x }) {} +}; + +assert.throws(Test262Error, function() { + obj.method({}); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..56e354cea70e9075ea1f11a2757dccc4bb86f644 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +var obj = { + *method({ poisoned: x = ++initEvalCount }) {} +}; + +assert.throws(Test262Error, function() { + obj.method(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-id-init-skipped.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..f3a84e8e995e1ac64c60f0de70a6a49d5cfabe97 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var obj = { + *method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +obj.method({ s: null, u: 0, w: false, y: '' }).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..10f88f75944ecec2ceae8000986d515efa496c57 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +var obj = { + *method({ x: y = thrower() }) {} +}; + +assert.throws(Test262Error, function() { + obj.method({}); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..4b27e0dddadd45613c07f8be10913e0198ae1bd3 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var obj = { + *method({ x: y = unresolvableReference }) {} +}; + +assert.throws(ReferenceError, function() { + obj.method({}); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-id-init.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..7298bf532f1c38ec1d59191ee399183295709c0f --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-id-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Binding as specified via property name, identifier, and initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + 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-prop-id-trailing-comma.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..b52af2e56dc794b3a6276ca9aa166d9d1f5585d4 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var obj = { + *method({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-id.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..28d9d355a5fef9c421b2ed16d2ed18396c1c83f9 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-id.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Binding as specified via property name and identifier (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-obj-init.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000000000000000000000000000000000..66a091e6d01e877c84712f69fcbb1556ec44fb51 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-obj-init.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var obj = { + *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +obj.method({ w: undefined }).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..827bcc83422e262643088927031dbed4db760258 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var obj = { + *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) {} +}; + +assert.throws(TypeError, function() { + obj.method({ w: null }); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..6c7b5cd12e310505be555645d3649604a525dfe2 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var obj = { + *method({ w: { x, y, z } = undefined }) {} +}; + +assert.throws(TypeError, function() { + obj.method({ }); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-obj.js b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..d8b5ae39d854745cc847d9a355d4ec300eea6c59 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-obj-ptrn-prop-obj.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var obj = { + *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +obj.method({ w: { x: undefined, z: 7 } }).next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-init-iter-close.js b/test/language/expressions/object/dstr-meth-ary-init-iter-close.js new file mode 100644 index 0000000000000000000000000000000000000000..576c09edef8f41ddf218978dae81f7e34b503a60 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-init-iter-close.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/meth.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var obj = { + method([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +obj.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-init-iter-get-err.js b/test/language/expressions/object/dstr-meth-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..520c0e52ff7e1622126169b7b47cf2f7929dbdfb --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-init-iter-get-err.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/meth.template +/*--- +description: Abrupt completion returned by GetIterator (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +var obj = { + method([x]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); diff --git a/test/language/expressions/object/dstr-meth-ary-init-iter-no-close.js b/test/language/expressions/object/dstr-meth-ary-init-iter-no-close.js new file mode 100644 index 0000000000000000000000000000000000000000..33443c2169beb5026bf3d0f1f7a609b90d3b259f --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-init-iter-no-close.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/meth.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var obj = { + method([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +obj.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-name-iter-val.js b/test/language/expressions/object/dstr-meth-ary-name-iter-val.js index 6a8229f6e17722edaa1e4d2eb2309831274c1d95..f8c6811eeef40b8b93b8124990ab07b671ebac22 100644 --- a/test/language/expressions/object/dstr-meth-ary-name-iter-val.js +++ b/test/language/expressions/object/dstr-meth-ary-name-iter-val.js @@ -3,7 +3,9 @@ // - src/dstr-binding/default/meth.template /*--- description: SingleNameBinding with normal value iteration (method) +esid: sec-runtime-semantics-definemethod es6id: 14.3.8 +features: [destructuring-binding] flags: [generated] info: | MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } @@ -70,4 +72,4 @@ var obj = { }; obj.method([1, 2, 3]); -assert.sameValue(callCount, 1); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-elem-init.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000000000000000000000000000000000..96840f49d9f3210b23bc918c0000d0403623ad0c --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-elem-iter.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..a2feed812ca00c24316a54c6c0ab1ee4040626d0 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +obj.method([[7, 8, 9]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-elision-init.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000000000000000000000000000000000..ad7df9f628bf75d3cdfa5eff58001e52ec4034b5 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var obj = { + method([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-elision-iter.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..979ba839aebcdd171bf90893c4e350dad0d96674 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +var obj = { + method([[,] = g()]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +obj.method([[]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-empty-init.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000000000000000000000000000000000..f93b36196cd58a4bf36aec1e72c6123fdae31061 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +var obj = { + method([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-empty-iter.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..8f5afba9e9c05a46116b78a419f1c815b5b462c9 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +var obj = { + method([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +obj.method([[23]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-rest-init.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000000000000000000000000000000000..7b73a34f0c2444e8b2f8d156ba86bff6deb6dc22 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +var obj = { + method([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-rest-iter.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..df7fc29e69f7fea40aaedba40c0c900a1c02db77 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +var obj = { + method([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +obj.method([values]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..7a9f88e26c142c42a778a4b8d596e80ce4d80e7f --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/meth.template +/*--- +description: Nested array destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +var obj = { + method([[x]]) {} +}; + +assert.throws(TypeError, function() { + obj.method([null]); +}); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-exhausted.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..4eca408946dc6e620eaa83dfeb1e771606493bcc --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/meth.template +/*--- +description: Destructuring initializer with an exhausted iterator (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..541e8eb4a20311b27cf4e9370454640438131453 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/meth.template +/*--- +description: SingleNameBinding does assign name to arrow functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..a4b56e481a2dbd2d5c7273ef20e38ec6ce8bb00e --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method([cls = class {}, xCls = class X {}]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..087505469e5e9a4d1d0861820ad5b1b528342044 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/meth.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..2de6650698e46770f476c562e31ccb83884fb071 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..af4a4ae4ef78ae4416b9790299a18e78494d7ae9 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-hole.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000000000000000000000000000000000..3ac0633c9c96a438ffd7fb2d1428cce353551eb1 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/meth.template +/*--- +description: Destructuring initializer with a "hole" (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method([x = 23]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +obj.method([,]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-skipped.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..bbda447597588d7120fea328bb906566695229c8 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var obj = { + method([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +obj.method([null, 0, false, '']); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..a22c3f0fb65be480776c584851801c212da82bb6 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/meth.template +/*--- +description: Destructuring initializer returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +var obj = { + method([x = (function() { throw new Test262Error(); })()]) {} +}; + +assert.throws(Test262Error, function() { + obj.method([undefined]); +}); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-undef.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..a38ea3ab9b5b20cb3b66c73db9fda45e1a7e75b0 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/meth.template +/*--- +description: Destructuring initializer with an undefined value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method([undefined]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..11d0f205f60d33131cb81ab5fbf62fceea1060a1 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var obj = { + method([ x = unresolvableReference ]) {} +}; + +assert.throws(ReferenceError, function() { + obj.method([]); +}); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-iter-complete.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000000000000000000000000000000000..342a538c9f6435453817c2108c8db2db02565949 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/meth.template +/*--- +description: SingleNameBinding when value iteration completes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method([x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-iter-done.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000000000000000000000000000000000..96a5ae99a7c8b45487da6f7344a63fbfd73c8b5e --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method([_, x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..e5a6cad9817d5e72bc70400837d82bd58220b455 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +var obj = { + method([x]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(g); +}); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..bc25d75e529927afeb81469d97acca6bc063b71c --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +var obj = { + method([x]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(g); +}); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-iter-val.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..12713c7faa378077535a54cbcf19bf66676e31b3 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-obj-id-init.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..32e3aeea70a9957c35b02c34b93cae97a4f8fa3f --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-obj-id.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..d6ea8601a2b058382ce4a90c767ee2a12db1234e --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-obj-id.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +obj.method([{ x: 11, y: 22, z: 33 }]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-obj-prop-id-init.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..ee792a53e4b5c77e5ff9e10833f1d302d5161313 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-obj-prop-id.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..ffc316ad682d79de58e68e01f2e1e8cd2271b198 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +obj.method([{ u: 777, w: 888, y: 999 }]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..065b1b5b846aacacb22112ca81536f9de0b4b7ea --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/meth.template +/*--- +description: Nested object destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +var obj = { + method([{ x }]) {} +}; + +assert.throws(TypeError, function() { + obj.method([null]); +}); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..8928afe746a5f2b0c450544f32a81d72fac2df28 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/meth.template +/*--- +description: Nested object destructuring with a value of `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +var obj = { + method([{ x }]) {} +}; + +assert.throws(TypeError, function() { + obj.method([]); +}); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elision-exhausted.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..ebf33ed2712b27ef69a1ea0427373fe8c47b492f --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elision-exhausted.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/meth.template +/*--- +description: Elision accepts exhausted iterator (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +var obj = { + method([,]) { + + callCount = callCount + 1; + } +}; + +obj.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elision-step-err.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..34e771d115d27a5804b073f726ffc30fb2016450 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elision-step-err.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/meth.template +/*--- +description: Elision advances iterator and forwards abrupt completions (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +var obj = { + method([,]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-elision.js b/test/language/expressions/object/dstr-meth-ary-ptrn-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..9a70d838c84cc3c00f1d86e9e4e53fdc51e132ab --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-elision.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/meth.template +/*--- +description: Elision advances iterator (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var obj = { + method([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +obj.method(g()); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-empty.js b/test/language/expressions/object/dstr-meth-ary-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..8d836742e99bf1342dc8accab9c73d940dcb3fbb --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-empty.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/meth.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var obj = { + method([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +obj.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-rest-ary-elem.js b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000000000000000000000000000000000..548265b9cee89379c6179f691326d667ab2ecff4 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/meth.template +/*--- +description: Rest element containing an array BindingElementList pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +obj.method([3, 4, 5]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-rest-ary-elision.js b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..6b57d2a533823eee14f5f04bcb927494f3c830dd --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/meth.template +/*--- +description: Rest element containing an elision (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var obj = { + method([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +obj.method(g()); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-rest-ary-empty.js b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..335888369c805b1e602df1e05264fe4324097721 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/meth.template +/*--- +description: Rest element containing an "empty" array pattern (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var obj = { + method([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +obj.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-rest-ary-rest.js b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..99dcb69a29249758eaea3883845499944a7b4992 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/meth.template +/*--- +description: Rest element containing a rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var obj = { + method([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +obj.method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..bd2c23b662d1fa4531e196d461db69e54d935303 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/meth.template +/*--- +description: Rest element following elision elements (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +var obj = { + method([, ...x]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-rest-id-elision.js b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..58f1083126d1ef8bfe6499a1c398ce434b25173b --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-id-elision.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/meth.template +/*--- +description: Rest element following elision elements (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +var obj = { + method([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +obj.method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-rest-id-exhausted.js b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..f78b578563e30fceefed8bc29cb0de57807bf733 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/meth.template +/*--- +description: RestElement applied to an exhausted iterator (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +var obj = { + method([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +obj.method([1, 2]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..b75ffc57f5afbaafd0c39a44df2516c57e339a98 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +var obj = { + method([...x]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..b01825cd71ee00b82458bf03c5a2d7e68a1c0441 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +var obj = { + method([...x]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(iter); +}); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-rest-id.js b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-id.js new file mode 100644 index 0000000000000000000000000000000000000000..05e4e21f0af3e3808195399101f87fd60a8a8b54 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-id.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/meth.template +/*--- +description: Lone rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var obj = { + method([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +obj.method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-rest-init-ary.js b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..95fbd4f758d831d2eab6143b834a7771408cd72c --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-init-ary.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/meth.template +/*--- +description: Reset element (nested array pattern) does not support initializer (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var obj = { + method([...[ x ] = []]) { + + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-rest-init-id.js b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000000000000000000000000000000000..992b5f68d51ff725a0b8324a582041b1ad93f858 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-init-id.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/meth.template +/*--- +description: Reset element (identifier) does not support initializer (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var obj = { + method([...x = []]) { + + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-rest-init-obj.js b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..5aef422ff2951f153c48a01b416068c7fae19ebd --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-init-obj.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/meth.template +/*--- +description: Reset element (nested object pattern) does not support initializer (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var obj = { + method([...{ x } = []]) { + + callCount = callCount + 1; + } +}; + +obj.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-rest-not-final-ary.js b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..dd6bd66ea9b1f9cbff16a496b8eced74b7fb5052 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/meth.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var obj = { + method([...[x], y]) { + + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-rest-not-final-id.js b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000000000000000000000000000000000..3621353f4be541e24625d2297165cc758d75b7ee --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/meth.template +/*--- +description: Rest element (identifier) may not be followed by any element (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var obj = { + method([...x, y]) { + + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-rest-not-final-obj.js b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..2c8d69e029115e73384f8fa6f66814015b7cd161 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/meth.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var obj = { + method([...{ x }, y]) { + + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-rest-obj-id.js b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..9537dfefd2f6a5aa0bbb9c8a8ab5f47698059668 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-obj-id.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/meth.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var obj = { + method([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-ary-ptrn-rest-obj-prop-id.js b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..bb18facce3e638c58d134aee8c577e4e6d260185 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/meth.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var obj = { + method([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; + } +}; + +obj.method([7, 8, 9]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-obj-init-null.js b/test/language/expressions/object/dstr-meth-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..335fb3315bdebac8a8a658409003bfbf4c49c48b --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-init-null.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var obj = { + method({}) {} +}; + +assert.throws(TypeError, function() { + obj.method(null); +}); diff --git a/test/language/expressions/object/dstr-meth-obj-init-undefined.js b/test/language/expressions/object/dstr-meth-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..24eeab369e953738e1e2da8f5abc2ca5b8fbc18c --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-init-undefined.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var obj = { + method({}) {} +}; + +assert.throws(TypeError, function() { + obj.method(undefined); +}); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-empty.js b/test/language/expressions/object/dstr-meth-obj-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..e080b6b07c0483b8f463e9205b0cf7ac6c52b182 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-empty.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/meth.template +/*--- +description: No property access occurs for an "empty" object binding pattern (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +var obj = { + method({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +obj.method(obj); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-id-get-value-err.js b/test/language/expressions/object/dstr-meth-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..3d1b364a97e78c076f71e339a41e7c37de6b9f7b --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-id-get-value-err.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +var obj = { + method({ poisoned }) {} +}; + +assert.throws(Test262Error, function() { + obj.method(poisonedProperty); +}); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-id-init-fn-name-arrow.js b/test/language/expressions/object/dstr-meth-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..9bd6d678981cbff78023b45315c4c49d43bd5dd9 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/meth.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var obj = { + method({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +obj.method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-id-init-fn-name-class.js b/test/language/expressions/object/dstr-meth-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..8dac1d7ba75cc2c113c260f8d42406e638a276f6 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var obj = { + method({ cls = class {}, xCls = class X {} }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; + } +}; + +obj.method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-id-init-fn-name-cover.js b/test/language/expressions/object/dstr-meth-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..3ad5e83dc593acb80fc756f9a7e73220e079cf6a --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var obj = { + method({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +obj.method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-id-init-fn-name-fn.js b/test/language/expressions/object/dstr-meth-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..0d924b8d730e968d697c601e1ca4962a581e7689 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var obj = { + method({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +obj.method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-id-init-fn-name-gen.js b/test/language/expressions/object/dstr-meth-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..713542a61a866bca5a814592ed8bfa308632f63f --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var obj = { + method({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +obj.method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-id-init-skipped.js b/test/language/expressions/object/dstr-meth-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..6b017e51c12cbebec430dd297acf7dc5f2d74b08 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-id-init-skipped.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var obj = { + method({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +obj.method({ w: null, x: 0, y: false, z: '' }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-id-init-throws.js b/test/language/expressions/object/dstr-meth-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..d2d17b5277b7f1403d704503b540cab2dc689c4e --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-id-init-throws.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/meth.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +var obj = { + method({ x = thrower() }) {} +}; + +assert.throws(Test262Error, function() { + obj.method({}); +}); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/object/dstr-meth-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..1f68f87bd228170279593fd472807dc656127d4b --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var obj = { + method({ x = unresolvableReference }) {} +}; + +assert.throws(ReferenceError, function() { + obj.method({}); +}); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-id-trailing-comma.js b/test/language/expressions/object/dstr-meth-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..465f6d97e0ef05056d4ef79c7f2aa445792707fb --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var obj = { + method({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-list-err.js b/test/language/expressions/object/dstr-meth-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..cdcb562415fcfc48725ff8fcaba4dc3b18c07710 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-list-err.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/meth.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +var obj = { + method({ a, b = thrower(), c = ++initCount }) {} +}; + +assert.throws(Test262Error, function() { + obj.method({}); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-prop-ary-init.js b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000000000000000000000000000000000..a7ac162337dedcfd6a014fad736c9c16215054ea --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-ary-init.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var obj = { + method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +obj.method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-prop-ary-trailing-comma.js b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..d537dcfb2d12612aa986f2a977d05d20dcded0fa --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var obj = { + method({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +obj.method({ x: [45] }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..73a13ec663d0e5cef9ff5dc676d582aa5a4c5335 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var obj = { + method({ w: [x, y, z] = [4, 5, 6] }) {} +}; + +assert.throws(TypeError, function() { + obj.method({ w: null }); +}); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-prop-ary.js b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..0036bdf3b3581503074da477e1e8ed3fe5af8a31 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-ary.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var obj = { + method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +obj.method({ w: [7, undefined, ] }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-prop-eval-err.js b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..89a9618ac148b0db34d472f83d0c7ef22ae008e2 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-eval-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/meth.template +/*--- +description: Evaluation of property name returns an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +var obj = { + method({ [thrower()]: x }) {} +}; + +assert.throws(Test262Error, function() { + obj.method({}); +}); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..4a5877135b3062c8f9e1345d6948f185fbf4abf4 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +var obj = { + method({ poisoned: x = ++initEvalCount }) {} +}; + +assert.throws(Test262Error, function() { + obj.method(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-prop-id-init-skipped.js b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..785aa25d5adc9b8b069d09c5878bc238ac93aa4a --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var obj = { + method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +obj.method({ s: null, u: 0, w: false, y: '' }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..861f9c6e4686cc7ef83d4f3e2588c4b5801cd8fa --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/meth.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +var obj = { + method({ x: y = thrower() }) {} +}; + +assert.throws(Test262Error, function() { + obj.method({}); +}); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..bf1fb2d175d157d928094b70d5cb6e8df8ce0e60 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +var obj = { + method({ x: y = unresolvableReference }) {} +}; + +assert.throws(ReferenceError, function() { + obj.method({}); +}); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-prop-id-init.js b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..ff35ef76d8331d06d3bf63929f0557fed5750ad0 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-id-init.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/meth.template +/*--- +description: Binding as specified via property name, identifier, and initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method({ }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-prop-id-trailing-comma.js b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..70897fc809791bec3cdb4fa030835a08c2eb6911 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var obj = { + method({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-prop-id.js b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..f67e5ecfe43fe2c59e19ae207ef0fe7e9b99dad6 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/meth.template +/*--- +description: Binding as specified via property name and identifier (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-prop-obj-init.js b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000000000000000000000000000000000..038a6b309f0ee3066694651616a7b6638ef896aa --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-obj-init.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var obj = { + method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +obj.method({ w: undefined }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..0a6bc1c83673d16995acd3ff60666703fec8cf06 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var obj = { + method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) {} +}; + +assert.throws(TypeError, function() { + obj.method({ w: null }); +}); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..5190af995f8c6b38153bb3a765171c419e5e0c39 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var obj = { + method({ w: { x, y, z } = undefined }) {} +}; + +assert.throws(TypeError, function() { + obj.method({ }); +}); diff --git a/test/language/expressions/object/dstr-meth-obj-ptrn-prop-obj.js b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..b40a885e41f96a9d4a015aac35ab2aa1cec67ef9 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-obj-ptrn-prop-obj.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var obj = { + method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +obj.method({ w: { x: undefined, z: 7 } }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-init-iter-close.js b/test/language/statements/class/dstr-gen-meth-ary-init-iter-close.js new file mode 100644 index 0000000000000000000000000000000000000000..1ccf1f2ced9f6ba34fdc3777a6ebb9ecf56fde70 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-init-iter-close.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + *method([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +new C().method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-init-iter-get-err.js b/test/language/statements/class/dstr-gen-meth-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..48c2b2c28dbc58e3f4837cfe5d72751af6f8f995 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-init-iter-get-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Abrupt completion returned by GetIterator (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +class C { + *method([x]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); diff --git a/test/language/statements/class/dstr-gen-meth-ary-init-iter-no-close.js b/test/language/statements/class/dstr-gen-meth-ary-init-iter-no-close.js new file mode 100644 index 0000000000000000000000000000000000000000..3b09577c28d2d05aa8471c738fe8729c844fcbc1 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-init-iter-no-close.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + *method([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-name-iter-val.js b/test/language/statements/class/dstr-gen-meth-ary-name-iter-val.js index 62c452fa484b5368eba0b156b9ede5719d30abaa..25528c77ee450f9e2acdf90d3397712e53655caa 100644 --- a/test/language/statements/class/dstr-gen-meth-ary-name-iter-val.js +++ b/test/language/statements/class/dstr-gen-meth-ary-name-iter-val.js @@ -3,7 +3,9 @@ // - src/dstr-binding/default/cls-decl-gen-meth.template /*--- description: SingleNameBinding with normal value iteration (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation es6id: 14.5.16 +features: [destructuring-binding] flags: [generated] info: | ClassDeclaration : class BindingIdentifier ClassTail @@ -89,4 +91,4 @@ class C { }; new C().method([1, 2, 3]).next(); -assert.sameValue(callCount, 1); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000000000000000000000000000000000..f1e1a1b6bba83db06e643d7b3ecc60cea12b0645 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + 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-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..72c0c41e6c9643b20456da47d05a378bcc9da4e8 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +new C().method([[7, 8, 9]]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000000000000000000000000000000000..5ac1e41bcd29915b353a9b3ff5ea52540c2e1934 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + *method([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + 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-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..018991114b25dda940dd3fbdacb909c748d7fe6d --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +class C { + *method([[,] = g()]) { + assert.sameValue(callCount, 0); + 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-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000000000000000000000000000000000..1eaf62a7340469a3af3ea55742094b048187e404 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +class C { + *method([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + 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-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..4779067283862992b59bb5130b90e13311f2888b --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +class C { + *method([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([[23]]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000000000000000000000000000000000..1bb49159260022fced6ab23b10892abfecfb1fdb --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +class C { + *method([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + 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-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..4313bb715d3f6dc61d66e4e3da33e0b1873d26ab --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +class C { + *method([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([values]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-ary-val-null.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..faabbc62b23c4a0047d1af69b7c0e99277b72121 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Nested array destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +class C { + *method([[x]]) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method([null]); +}); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..5cfdcebed1eaada53ce7bc46fe9025f3baa27336 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Destructuring initializer with an exhausted iterator (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([x = 23]) { + assert.sameValue(x, 23); + 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-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..7e104fe1412d3e6327a919cec8d37cfd6d52e0dd --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding does assign name to arrow functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + 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-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..9ae56ce7eb3b0e8fd2da4cf844e7718b41f117de --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([cls = class {}, xCls = class X {}]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + 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-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..c00406754fc4f27dc51ac06b07c06b237038e527 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + 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-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..0def75d5ddea805c8bce78003d22aaa0e8dbc20e --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + 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-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..9a747af8939b418ec7517a3bb0216cca64f5b70f --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + 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-ary-ptrn-elem-id-init-hole.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000000000000000000000000000000000..e5fc782850674226bd579b6ec5c9a462a21668a5 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Destructuring initializer with a "hole" (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([x = 23]) { + assert.sameValue(x, 23); + // another statement + 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-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..b9e703ebba5d07d0c4ee5080cd50b2a635e7466c --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + *method([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([null, 0, false, '']).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-init-throws.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..0a7b28267e49fc4e068af1c9c469e496cb30b655 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Destructuring initializer returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +class C { + *method([x = (function() { throw new Test262Error(); })()]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method([undefined]); +}); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-init-undef.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..d735ef02cc192fcf9f467de54c6dd03fff08ec92 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Destructuring initializer with an undefined value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method([undefined]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..42ef0cd652ac6f85aee8ee34bd3e1cf279ec98c3 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +class C { + *method([ x = unresolvableReference ]) {} +}; +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method([]); +}); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000000000000000000000000000000000..3bd2eddd3c6c6046de8f21536549367d7bddb127 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding when value iteration completes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([x]) { + assert.sameValue(x, undefined); + 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-ary-ptrn-elem-id-iter-done.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000000000000000000000000000000000..c7ed4040d5b3944364d5da52e855aa7e1beccf8f --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([_, x]) { + assert.sameValue(x, undefined); + 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-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..e4755c4d72b19aa80ab784fb98ab7d06e2a23140 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +class C { + *method([x]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(g); +}); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..6807a13e0f8f45bab27da5e03969b690faabff24 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +class C { + *method([x]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(g); +}); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-iter-val.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..33629e1506d7287b85bcf283699ec2178d9b3e27 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-obj-id-init.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..3c0cae42bec32a9db41f5d1563e1e01cdbf710c1 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + 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-ary-ptrn-elem-obj-id.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..c8ca1aadac5671561f12b5783037e427cc181601 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-obj-id.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +new C().method([{ x: 11, y: 22, z: 33 }]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..82673ab149cc84c7a10c0c05d5114ffd5b02fd15 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + 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-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..009ac90f78ea6600b3b97459a7ab86a742bcc804 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method([{ u: 777, w: 888, y: 999 }]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-obj-val-null.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..4188a525cb0f2d88eb055203ea098a54d51b6e17 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Nested object destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +class C { + *method([{ x }]) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method([null]); +}); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..b6497f68393641642408a60e718c45545969c7af --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Nested object destructuring with a value of `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +class C { + *method([{ x }]) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method([]); +}); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-elision-exhausted.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..4697731e6fe0b547fe8897c9541b615958a0b461 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elision-exhausted.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Elision accepts exhausted iterator (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +class C { + *method([,]) { + + callCount = callCount + 1; + } +}; + +new C().method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-elision-step-err.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..1a685fe8cdea9ef3077a5eeeb0190238a64a1a49 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elision-step-err.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Elision advances iterator and forwards abrupt completions (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +class C { + *method([,]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-elision.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..e79d606bb465f0d0a2beeae1adf443900f135ab6 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-elision.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Elision advances iterator (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + *method([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +new C().method(g()).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-empty.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..46aafd45339096307b969f95f97fc8eaf7543ca7 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-empty.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + *method([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +new C().method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-ary-elem.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000000000000000000000000000000000..c0ddfb67eb4788a1bbbd7c3e22e2437af64dcdc5 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,107 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest element containing an array BindingElementList pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +new C().method([3, 4, 5]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-ary-elision.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..80778ecd07e853b497bce9a03c66da778a190dee --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,113 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest element containing an elision (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + *method([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +new C().method(g()).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-ary-empty.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..a30c2627dd89cb9dda1cbb7a211a522aa1900025 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest element containing an "empty" array pattern (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + *method([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +new C().method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-ary-rest.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..b8611dc4159615d10884949ee4bbc82a0f2d86f1 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest element containing a rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + *method([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +new C().method(values).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..10cfa111a284156d39e1c7ca1e7ee52837f0df21 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Rest element following elision elements (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +class C { + *method([, ...x]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-id-elision.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..a13ea84dd1e650c1c3d003a040ff97b1c23aa3a2 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-id-elision.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest element following elision elements (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +class C { + *method([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method(values).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-id-exhausted.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..116ca95d1aa952903e55e07d4319bf889064d009 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: RestElement applied to an exhausted iterator (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +class C { + *method([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +new C().method([1, 2]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..336987f2600464602e4198458f30f0394000e9c3 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +class C { + *method([...x]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..8513c2d2d7da53f9f0522b6a42c737164ab9ed5c --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +class C { + *method([...x]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-id.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-id.js new file mode 100644 index 0000000000000000000000000000000000000000..6dab6ffd8e38d61656e3b80f9d865a875a5c5d6d --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-id.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Lone rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + *method([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method(values).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-init-ary.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..b8f19544a255f69434d81aadb641921826d0658d --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-init-ary.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Reset element (nested array pattern) does not support initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + *method([...[ x ] = []]) { + + 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-ary-ptrn-rest-init-id.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000000000000000000000000000000000..7fbe3e2c767b31e47f7a97175ad852084d3a611e --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-init-id.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Reset element (identifier) does not support initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + *method([...x = []]) { + + 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-ary-ptrn-rest-init-obj.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..25005cb993813c54da33106f26abe1dcaced4245 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-init-obj.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Reset element (nested object pattern) does not support initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + *method([...{ x } = []]) { + + 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-ary-ptrn-rest-not-final-ary.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..d58971534f76097177ae86945ff2c26739c0c55c --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + *method([...[x], y]) { + + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-not-final-id.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000000000000000000000000000000000..b9ab2cedb409255679734067774f1c49685f7077 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest element (identifier) may not be followed by any element (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + *method([...x, y]) { + + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-not-final-obj.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..7410dd79aae8d705c0b3f0bdbbac822b72064e8b --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + *method([...{ x }, y]) { + + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-obj-id.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..52452d3f2901e584b9824fa36b0f9be84e480ac2 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-obj-id.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + *method([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..a09c3daed337824e35469720fc3fa62eafc86572 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + *method([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; + } +}; + +new C().method([7, 8, 9]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-obj-init-null.js b/test/language/statements/class/dstr-gen-meth-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..4b53469b2bbfb15fe4c0d9c535d4a2175d749909 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-init-null.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + *method({}) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(null); +}); diff --git a/test/language/statements/class/dstr-gen-meth-obj-init-undefined.js b/test/language/statements/class/dstr-gen-meth-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..5433f00cbd47515041e2c171f951a96ad625bce2 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-init-undefined.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + *method({}) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(undefined); +}); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-empty.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..71b997ab5bcac1123717a2bdc42b75b02d906df0 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-empty.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: No property access occurs for an "empty" object binding pattern (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +class C { + *method({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(obj).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-id-get-value-err.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..65a45a7f58cd0b0451b08597bd2b839e53afd30b --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-id-get-value-err.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +class C { + *method({ poisoned }) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(poisonedProperty); +}); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..9bd3639d2e51e4168746ed1471866abfbe81877c --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + *method({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + 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-id-init-fn-name-class.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..d867df5e4ce240b3844ebc2bc96adc75d38a1185 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + *method({ cls = class {}, xCls = class X {} }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + 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-id-init-fn-name-cover.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..dc96516126f737abb7bc1ce6e141f93d069880a7 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + *method({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + 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-id-init-fn-name-fn.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..8035d750fc4e0993554786ca8fa242d0f58b2834 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + *method({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + 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-id-init-fn-name-gen.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..bae94de9fd2ca1dc73d176e3a6b875e8a1025519 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + *method({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + 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-id-init-skipped.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..01cc6bf9444bdcb1271181569e76ba0db8389d5d --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-id-init-skipped.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + *method({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method({ w: null, x: 0, y: false, z: '' }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-id-init-throws.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..d60561a8df5ad73170f5cdb7dfdc57a981bd3b8a --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-id-init-throws.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +class C { + *method({ x = thrower() }) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method({}); +}); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-id-init-unresolvable.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..24dedf3c929975ac35c666f93d3b30b8252bb27b --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +class C { + *method({ x = unresolvableReference }) {} +}; +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method({}); +}); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-id-trailing-comma.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..35b7f5cc7758becd0afb5cfe1b81a526901cfbf4 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + *method({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-list-err.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..a4b04db3064afd4a147b50d2557d8282d003d42e --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-list-err.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +class C { + *method({ a, b = thrower(), c = ++initCount }) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method({}); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-ary-init.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000000000000000000000000000000000..37252cb4755bd011b0daa15ad72f0de6d851e2b4 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-ary-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + *method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + 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-prop-ary-trailing-comma.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..ef747de1ba0788c6897a0532b3c10ad3e34f7cb4 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + *method({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +new C().method({ x: [45] }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-ary-value-null.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..1b4d1514b00d2474e4e06e02dac60f8d70086cfc --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +class C { + *method({ w: [x, y, z] = [4, 5, 6] }) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method({ w: null }); +}); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-ary.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..4073814b4eb7cf0e68b73117a7780095859a9e4e --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-ary.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + *method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method({ w: [7, undefined, ] }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-eval-err.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..1f7060f1c368f13aafcedc2e064e2ff70b590399 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-eval-err.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Evaluation of property name returns an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +class C { + *method({ [thrower()]: x }) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method({}); +}); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..8474499a4ca53e85d32972829dd6a7ac13d96d74 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +class C { + *method({ poisoned: x = ++initEvalCount }) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..5f49a30e8cc1574a4865d51bef3b04a2cbbc6265 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + *method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method({ s: null, u: 0, w: false, y: '' }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-id-init-throws.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..bd5e4162e819fb4e327a7b09c74b24b8a556bca0 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +class C { + *method({ x: y = thrower() }) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method({}); +}); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..28452f0b24e094e59e8aad3a85a3d968b03d9ae8 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +class C { + *method({ x: y = unresolvableReference }) {} +}; +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method({}); +}); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-id-init.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..28e2cdecf8bdbce30b49fa40a4a95f0a6b4fee83 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-id-init.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Binding as specified via property name, identifier, and initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + 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-prop-id-trailing-comma.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..d28a7fb7956d94c75b4fa378628deec0ccaf6a8f --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + *method({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-id.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..523974c0314e1be582c4de78af65e9c2b366f857 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-id.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Binding as specified via property name and identifier (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-obj-init.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000000000000000000000000000000000..0cb021c773538260858c9bbc98bfb165dd9a9265 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-obj-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method({ w: undefined }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-obj-value-null.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..f2fa7ca9d8e8ea4fb549b297bb2944e2fa3ea32b --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +class C { + *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method({ w: null }); +}); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..5e2c065c5a8c5073897370fe908aab0984f20942 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +class C { + *method({ w: { x, y, z } = undefined }) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method({ }); +}); diff --git a/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-obj.js b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..2f86d6115bfdb6c1c4fbdc14adc7b39c6ff325f4 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-obj-ptrn-prop-obj.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method({ w: { x: undefined, z: 7 } }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-init-iter-close.js b/test/language/statements/class/dstr-gen-meth-static-ary-init-iter-close.js new file mode 100644 index 0000000000000000000000000000000000000000..017744012bf480fb56fdff2416ff9c70df7e6344 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-init-iter-close.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + static *method([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +C.method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-init-iter-get-err.js b/test/language/statements/class/dstr-gen-meth-static-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..0341fc0c992a72db6c8de51df3429600a1303392 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-init-iter-get-err.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Abrupt completion returned by GetIterator (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +class C { + static *method([x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-init-iter-no-close.js b/test/language/statements/class/dstr-gen-meth-static-ary-init-iter-no-close.js new file mode 100644 index 0000000000000000000000000000000000000000..880cd847c02c55c9312f100172164a3f085a7fa4 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-init-iter-no-close.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + static *method([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +C.method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-name-iter-val.js b/test/language/statements/class/dstr-gen-meth-static-ary-name-iter-val.js index 5d4d66bab24f6b57c36e952c87ca4d846066bcbd..7ec4dab1942dafbc343b42c91666349b71cb36c4 100644 --- a/test/language/statements/class/dstr-gen-meth-static-ary-name-iter-val.js +++ b/test/language/statements/class/dstr-gen-meth-static-ary-name-iter-val.js @@ -3,7 +3,9 @@ // - src/dstr-binding/default/cls-decl-gen-meth-static.template /*--- description: SingleNameBinding with normal value iteration (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation es6id: 14.5.15 +features: [destructuring-binding] flags: [generated] info: | ClassDeclaration : class BindingIdentifier ClassTail @@ -89,4 +91,4 @@ class C { }; C.method([1, 2, 3]).next(); -assert.sameValue(callCount, 1); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000000000000000000000000000000000..7a27d5e3663da6c61e50a34f517f855dc2afdb77 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + 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-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..a36f2b2c5ad8c5f63f1bcbbd315967f8d156d3c4 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +C.method([[7, 8, 9]]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000000000000000000000000000000000..bd8b18141323a5fd76de1a2200306fd7a65c9644 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static *method([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + 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-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..44c9371765b55c983685077788059d9f3c882b7a --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +class C { + static *method([[,] = g()]) { + assert.sameValue(callCount, 0); + 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-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000000000000000000000000000000000..b6755ca605fd5202be298b0b2b9401ad8f3b7bfd --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +class C { + static *method([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + 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-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..536689955431c92016882522f950168c0c6ecc7d --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +class C { + static *method([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method([[23]]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000000000000000000000000000000000..051634016cd4cce6377b722222a67ad4817044e7 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +class C { + static *method([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + 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-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..d77c2265f6397ecdb01d6dc3b8ee462aecf143c5 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +class C { + static *method([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method([values]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-ary-val-null.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..1f37784cd3c3cb00b341055c1a8907bfc0c180f9 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Nested array destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +class C { + static *method([[x]]) {} +}; + +assert.throws(TypeError, function() { + C.method([null]); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..c24e61de79f15c6ec8c3942e124309c877c323df --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Destructuring initializer with an exhausted iterator (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([x = 23]) { + assert.sameValue(x, 23); + 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-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..af275ae39258662553b9e1050521bbe33793d4ad --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding does assign name to arrow functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + 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-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..975d7fb241db019c97b93a9f6f7bbde272be9218 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([cls = class {}, xCls = class X {}]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + 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-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..aa831c2fb0343c5d5ce66eed32fbb1c85dd458e4 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + 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-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..ecd6c4b862a004b035ae650d7e92c404f7c2ae48 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + 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-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..17ad78335645353da3fda76b4dfc33d263f92633 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + 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-ary-ptrn-elem-id-init-hole.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000000000000000000000000000000000..9e1ad14801292f73be13e59e0b9e1a0e91eb2f71 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Destructuring initializer with a "hole" (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([x = 23]) { + assert.sameValue(x, 23); + // another statement + 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-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..abb3099704a74798864f6abcf7b29c62dde6f05f --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static *method([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method([null, 0, false, '']).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-throws.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..45da6e391ecc2a0eb0fa23b6782a0e0dda7a3d3b --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Destructuring initializer returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +class C { + static *method([x = (function() { throw new Test262Error(); })()]) {} +}; + +assert.throws(Test262Error, function() { + C.method([undefined]); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-undef.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..94e203789327ab1f8906dc99c70fc4a141a2cd16 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Destructuring initializer with an undefined value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method([undefined]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..572239d658836e7691db1d7aea5d38faa8061ff7 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +class C { + static *method([ x = unresolvableReference ]) {} +}; + +assert.throws(ReferenceError, function() { + C.method([]); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000000000000000000000000000000000..719ed8a6853c7877b03b8c71bfe6bc9a0da158fc --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding when value iteration completes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([x]) { + assert.sameValue(x, undefined); + 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-ary-ptrn-elem-id-iter-done.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000000000000000000000000000000000..dab1d65e2b04c8892c528ed4715dd0d439cef883 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([_, x]) { + assert.sameValue(x, undefined); + 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-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..8930f003d72fa802e45fba9765eb162231332044 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +class C { + static *method([x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(g); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..27720435b6e6416bb149dd1ba8b953cbf95c05f4 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +class C { + static *method([x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(g); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-iter-val.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..4d917d3c35b4f22084b66df36df75759784e1d19 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-obj-id-init.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..af46b932eb19dfb17fbb75dbe1480f1b42bb7859 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + 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-ary-ptrn-elem-obj-id.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..761e8df6c854ff2d8ff88d1784981e7e1027f17d --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-obj-id.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +C.method([{ x: 11, y: 22, z: 33 }]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..62de6004b06fa85c81247d6255f94f9a328e6ec9 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + 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-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..2caec9c32a57ceb46a908aa486fa797a3a1481f8 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method([{ u: 777, w: 888, y: 999 }]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-obj-val-null.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..956c7a0c3de281162b44533c0ecdc2c4363c16b8 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Nested object destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +class C { + static *method([{ x }]) {} +}; + +assert.throws(TypeError, function() { + C.method([null]); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..222557befbbb0fb6fce7b9a65d8cc5f1de00d7dc --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Nested object destructuring with a value of `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +class C { + static *method([{ x }]) {} +}; + +assert.throws(TypeError, function() { + C.method([]); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elision-exhausted.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..fa6af77d5df8c5a325322364a207fecf994726d4 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elision-exhausted.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Elision accepts exhausted iterator (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +class C { + static *method([,]) { + + callCount = callCount + 1; + } +}; + +C.method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elision-step-err.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..8630543945d30397c4aedfc4ecb5d51a946ebb98 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elision-step-err.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Elision advances iterator and forwards abrupt completions (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +class C { + static *method([,]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elision.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..10c93757a7e03768d53ad37c993946aa4471f2fd --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-elision.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Elision advances iterator (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static *method([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +C.method(g()).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-empty.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..7f835968d50d0d808cee17069d5f4c4400c2d7eb --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-empty.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + static *method([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +C.method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-ary-elem.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000000000000000000000000000000000..8e747c3a6bfc3301733e5515ac0e24fb02627ec3 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,107 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest element containing an array BindingElementList pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +C.method([3, 4, 5]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-ary-elision.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..88f81394e53d7ec55dc9a49980fb8a214eb365d8 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,113 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest element containing an elision (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static *method([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +C.method(g()).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-ary-empty.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..b9a19642386b9166fc7134fa4dc094e2f32d3708 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest element containing an "empty" array pattern (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + static *method([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +C.method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-ary-rest.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..99cc4298e0978300981b2c22462b188639086d6b --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest element containing a rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + static *method([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +C.method(values).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..6ef134646da795e07a40572da8c64387c2a00f4b --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Rest element following elision elements (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +class C { + static *method([, ...x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-id-elision.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..de13059b012c3182a1a67dab98345a7509067f63 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-id-elision.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest element following elision elements (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +class C { + static *method([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method(values).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-id-exhausted.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..1e5890caa112384279b2af6f1ca0d72ef2d0ab72 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: RestElement applied to an exhausted iterator (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +class C { + static *method([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +C.method([1, 2]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..2acbd16410726b33625ea3645dabb975f76ddbef --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +class C { + static *method([...x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..68f7bb45ea34f4ad8cf9a8bdb2a235c054bff703 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +class C { + static *method([...x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-id.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-id.js new file mode 100644 index 0000000000000000000000000000000000000000..43cdf34c9c48326d5b5a2d01d0608cad6306d95b --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-id.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Lone rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + static *method([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method(values).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-init-ary.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..88edc1d662e7e2fa6a4447b8faf6b17322312914 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-init-ary.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Reset element (nested array pattern) does not support initializer (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + static *method([...[ x ] = []]) { + + 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-ary-ptrn-rest-init-id.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000000000000000000000000000000000..ec0e83cdbf17253acc397e7966228fcdf3b6d121 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-init-id.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Reset element (identifier) does not support initializer (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + static *method([...x = []]) { + + 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-ary-ptrn-rest-init-obj.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..826b9b6ada76572dd772067fc54015a76f609b67 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-init-obj.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Reset element (nested object pattern) does not support initializer (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + static *method([...{ x } = []]) { + + 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-ary-ptrn-rest-not-final-ary.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..144f19ff89b7c6a0f74483f26ac12ddecdaacfb8 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + static *method([...[x], y]) { + + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-not-final-id.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000000000000000000000000000000000..1808b2b07bc5d8057b768ae087d2d2e7bec1a672 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest element (identifier) may not be followed by any element (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + static *method([...x, y]) { + + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-not-final-obj.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..1de0c4506d8428dfe83fc34d3e5b4c3cb6ca6d72 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + static *method([...{ x }, y]) { + + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-obj-id.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..4834ed538ac79bab33f97b4c12072efe59dba326 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-obj-id.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + static *method([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..e2c6260997ce8f82bd1339990ac4b870cb99555c --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + static *method([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; + } +}; + +C.method([7, 8, 9]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-init-null.js b/test/language/statements/class/dstr-gen-meth-static-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..0e75f4e2be5f581b9870210bd98421de8e03d4b0 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-init-null.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + static *method({}) {} +}; + +assert.throws(TypeError, function() { + C.method(null); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-init-undefined.js b/test/language/statements/class/dstr-gen-meth-static-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..5b21b64f3debce69c50360155f35ec78ca8df687 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-init-undefined.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + static *method({}) {} +}; + +assert.throws(TypeError, function() { + C.method(undefined); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-empty.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..68631b6b3e7d12b0b3afc7c2a8ffa62138945f17 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-empty.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: No property access occurs for an "empty" object binding pattern (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +class C { + static *method({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +C.method(obj).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-id-get-value-err.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..3627a83b0c9ce4db4eb353970b3efd655e945e8b --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-id-get-value-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +class C { + static *method({ poisoned }) {} +}; + +assert.throws(Test262Error, function() { + C.method(poisonedProperty); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..9cb0825afc6ec3394a51e94431ff266eb92c1fe8 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static *method({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + 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-id-init-fn-name-class.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..b3596af778bf39afff9cd7a0b902c36f42f1641b --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static *method({ cls = class {}, xCls = class X {} }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + 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-id-init-fn-name-cover.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..9518d312f2195c7786a82d243978670f5a4f7e4c --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static *method({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + 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-id-init-fn-name-fn.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..abd587a40fec7d843f3c23ca512a6a5c15b08546 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static *method({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + 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-id-init-fn-name-gen.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..62b66f2f20fb05ce0cc33553b673b03fbfa4b393 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static *method({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + 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-id-init-skipped.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..43d1f6b08db6ed2a2b3fb63a8c543600232aa307 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-id-init-skipped.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static *method({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method({ w: null, x: 0, y: false, z: '' }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-id-init-throws.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..b98c72f642624f9e09f2da826de67943c2da241b --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-id-init-throws.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +class C { + static *method({ x = thrower() }) {} +}; + +assert.throws(Test262Error, function() { + C.method({}); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-id-init-unresolvable.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..21e1296ec7bad7f7cd45c0ee90783221f4688fe6 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +class C { + static *method({ x = unresolvableReference }) {} +}; + +assert.throws(ReferenceError, function() { + C.method({}); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-id-trailing-comma.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..84a4cc87ed9cbfc8d17e48dcd0b58209929e76e6 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static *method({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-list-err.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..96656900adee830ef662340cc8794473d5a2d810 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-list-err.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +class C { + static *method({ a, b = thrower(), c = ++initCount }) {} +}; + +assert.throws(Test262Error, function() { + C.method({}); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-ary-init.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000000000000000000000000000000000..c8130589392f5f0339a1f58bcc4500feb39a9ffc --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-ary-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static *method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + 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-prop-ary-trailing-comma.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..345b8e3864e01ee076940265b3aa19c90298e69d --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static *method({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +C.method({ x: [45] }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-ary-value-null.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..7e20fbcdbd188a1a069feec039a36c22b4768ae3 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +class C { + static *method({ w: [x, y, z] = [4, 5, 6] }) {} +}; + +assert.throws(TypeError, function() { + C.method({ w: null }); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-ary.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..0e05e0087494fe907bb1bc2215cf6d211a19fce4 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-ary.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static *method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method({ w: [7, undefined, ] }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-eval-err.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..a5910f24540a7ba4376573468a76d4e04fa6c392 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-eval-err.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Evaluation of property name returns an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +class C { + static *method({ [thrower()]: x }) {} +}; + +assert.throws(Test262Error, function() { + C.method({}); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..e469dd03105730269a9217694263855e81fd2c04 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +class C { + static *method({ poisoned: x = ++initEvalCount }) {} +}; + +assert.throws(Test262Error, function() { + C.method(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..96bb6bfe10f59898159c5d87870ab538c124e941 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static *method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method({ s: null, u: 0, w: false, y: '' }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-id-init-throws.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..867953d5af740181f464b1a25bf675a29a7ea9d0 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +class C { + static *method({ x: y = thrower() }) {} +}; + +assert.throws(Test262Error, function() { + C.method({}); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..75094e736320301cfb3677fe3d8481a920c52cbf --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +class C { + static *method({ x: y = unresolvableReference }) {} +}; + +assert.throws(ReferenceError, function() { + C.method({}); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-id-init.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..f165ce9aa96f5210aec12992a095ae8e0c19e9ef --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-id-init.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Binding as specified via property name, identifier, and initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + 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-prop-id-trailing-comma.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..f83a1727c9ef2bf31a7e8568613bf1417e160ef9 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static *method({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-id.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..a1a2d4daf2f4642b06aeb924bfe3040886b1f340 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-id.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Binding as specified via property name and identifier (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-obj-init.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000000000000000000000000000000000..5796bb64e4706b963861ba411957bb6435516ae7 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-obj-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method({ w: undefined }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-obj-value-null.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..b39a1c6e704eeaeffde3bb8a3e7e33150c1a3dd8 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +class C { + static *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) {} +}; + +assert.throws(TypeError, function() { + C.method({ w: null }); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..29af3f8384f21ec6af235cf092367ccc376771d7 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +class C { + static *method({ w: { x, y, z } = undefined }) {} +}; + +assert.throws(TypeError, function() { + C.method({ }); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-obj.js b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..d9c21a24b8ebfa5760006a42b3dc5e1d547bb974 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-obj-ptrn-prop-obj.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method({ w: { x: undefined, z: 7 } }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-init-iter-close.js b/test/language/statements/class/dstr-meth-ary-init-iter-close.js new file mode 100644 index 0000000000000000000000000000000000000000..c33d036e3b4d2e01cd2af018c09b5044621a864b --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-init-iter-close.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + method([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +new C().method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-init-iter-get-err.js b/test/language/statements/class/dstr-meth-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..528cd825bd7f419b4e61b99eb4211ed94473b945 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-init-iter-get-err.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Abrupt completion returned by GetIterator (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +class C { + method([x]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); diff --git a/test/language/statements/class/dstr-meth-ary-init-iter-no-close.js b/test/language/statements/class/dstr-meth-ary-init-iter-no-close.js new file mode 100644 index 0000000000000000000000000000000000000000..c3147e667217d614710c92a79016bdda51ed3398 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-init-iter-no-close.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + method([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-name-iter-val.js b/test/language/statements/class/dstr-meth-ary-name-iter-val.js index 974d3277bf0300bccd84bf111fd0b046639e819c..cd5f24ab672254db9278ff4e8a35d4b6216c7459 100644 --- a/test/language/statements/class/dstr-meth-ary-name-iter-val.js +++ b/test/language/statements/class/dstr-meth-ary-name-iter-val.js @@ -3,7 +3,9 @@ // - src/dstr-binding/default/cls-decl-meth.template /*--- description: SingleNameBinding with normal value iteration (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation es6id: 14.5.15 +features: [destructuring-binding] flags: [generated] info: | ClassDeclaration : class BindingIdentifier ClassTail @@ -87,4 +89,4 @@ class C { }; new C().method([1, 2, 3]); -assert.sameValue(callCount, 1); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000000000000000000000000000000000..ea6846f6b997092a5d5b71906bec4d27b6cb9846 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..5ce2ef9edf099c7dbc77d70ea0b7344e03c60191 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +new C().method([[7, 8, 9]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000000000000000000000000000000000..afa5771415bd48a2d352706c449156905e690966 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + method([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..553c7be720993f61458fb7563abff6ba897dd487 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +class C { + method([[,] = g()]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([[]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000000000000000000000000000000000..7135a6bb41fce2f285b12e060006d971b52432d1 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +class C { + method([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..f52ec3e9365454ba615ca67cac323adfd575710d --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +class C { + method([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([[23]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000000000000000000000000000000000..2c1ca7773a6e1dc49ba850307f430fc67eeaeb8e --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +class C { + method([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..92762694d6831ee77658e106a629d9451c124756 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +class C { + method([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([values]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-val-null.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..f3cb0d4ad43b77dca2982f1c5cbcd55210d8d8a5 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Nested array destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +class C { + method([[x]]) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method([null]); +}); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..1a87c4b8993d4a9406b6d663a0ff308e7bd33053 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Destructuring initializer with an exhausted iterator (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..50849ba7c73f8dc25024319ee73ca922a70e2f61 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding does assign name to arrow functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..d9387f6ccfcd2428ed33b5f276441844e053e3a1 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([cls = class {}, xCls = class X {}]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..2936a71efdda555eb367da6cc40a896ea1c68188 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..a6e9edb1265a53cd8a9374f84a8c85c5e60b51ac --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..bc5b2a425905a9b376f21dc9f9f055ca8d7eb78f --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-hole.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000000000000000000000000000000000..f3334043edf92da40187bb249058226fe0fa3276 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Destructuring initializer with a "hole" (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([x = 23]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +new C().method([,]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..83b462e6975da9953e4f1108ad035ca37ece0853 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + method([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([null, 0, false, '']); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-throws.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..ed0b4e6331c952bb0d8cf35a4e650ae15459144d --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Destructuring initializer returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +class C { + method([x = (function() { throw new Test262Error(); })()]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method([undefined]); +}); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-undef.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..17ee68d0a8018f34aff0a80423e160d0d0dfb656 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Destructuring initializer with an undefined value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method([undefined]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..9bfd5b38ef7b6f3ffe44decca2c12e197e5761a9 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +class C { + method([ x = unresolvableReference ]) {} +}; + +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method([]); +}); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000000000000000000000000000000000..72a2976f3a02bb7aa2e15be437a4e5959f0ca144 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding when value iteration completes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-iter-done.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000000000000000000000000000000000..a91af49c1a8e1a0dcdd13aabb60a014fe6412d3c --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([_, x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..f9fe3586ccc4f35be42eb9ec09fc75cf6c5c6a30 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +class C { + method([x]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(g); +}); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..95eee8a460be14dd1af8c0da7965241a5db65753 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +class C { + method([x]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(g); +}); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-iter-val.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..2cdd0356e6c32ad47a0a96f2f5a853877a145196 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-obj-id-init.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..f2fa2b3d5bf652448cda69e3d27708a264b09999 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-obj-id.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..583bb5b36fb7f79198d37f2732f6e2ebbb295a75 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-obj-id.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +new C().method([{ x: 11, y: 22, z: 33 }]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..79851dcd0160bdb9544440bd66ffd89507d21d95 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..aed4d0689dd88609aa3b3bb2dc27b81f126720bf --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method([{ u: 777, w: 888, y: 999 }]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-obj-val-null.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..a6205a9ee9bf89769018aaae02be9dc6da6d18c9 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Nested object destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +class C { + method([{ x }]) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method([null]); +}); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/class/dstr-meth-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..1c0eda90edda17085f772a2deb2453a9677304f2 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Nested object destructuring with a value of `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +class C { + method([{ x }]) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method([]); +}); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elision-exhausted.js b/test/language/statements/class/dstr-meth-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..4eb40ddf82d75fc7ff3f6751a91fe691ee1fd7ee --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elision-exhausted.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Elision accepts exhausted iterator (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +class C { + method([,]) { + + callCount = callCount + 1; + } +}; + +new C().method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elision-step-err.js b/test/language/statements/class/dstr-meth-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..846d902a4ae2a7b682eb5f9338be7fbb62d835d1 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elision-step-err.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Elision advances iterator and forwards abrupt completions (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +class C { + method([,]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-elision.js b/test/language/statements/class/dstr-meth-ary-ptrn-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..e5b6a98d61626af41f1a9b7c645b6725200707b6 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-elision.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Elision advances iterator (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + method([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +new C().method(g()); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-empty.js b/test/language/statements/class/dstr-meth-ary-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..17d2331c9b26d3579e7fc3da9d16c2aa51826167 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-empty.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + method([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +new C().method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-rest-ary-elem.js b/test/language/statements/class/dstr-meth-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000000000000000000000000000000000..4cc2029dfe3e14aae7325736a530a10a6767c143 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest element containing an array BindingElementList pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +new C().method([3, 4, 5]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-rest-ary-elision.js b/test/language/statements/class/dstr-meth-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..55c529a515d58290d2ba4793748fc30feaefdbd2 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,111 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest element containing an elision (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + method([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +new C().method(g()); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-rest-ary-empty.js b/test/language/statements/class/dstr-meth-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..c4c5c48d8f13b4581d19337538c8eabd67eb1396 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest element containing an "empty" array pattern (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + method([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +new C().method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-rest-ary-rest.js b/test/language/statements/class/dstr-meth-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..70b77ec31f2e50cfa5913c6d3293a6445dbe8e14 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest element containing a rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + method([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +new C().method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/class/dstr-meth-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..dad8b6cca8db196c082605d7f0ea51a7229e65ac --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Rest element following elision elements (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +class C { + method([, ...x]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-rest-id-elision.js b/test/language/statements/class/dstr-meth-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..06f660c7f75ea168c223500caa01dc6b8c556521 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-rest-id-elision.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest element following elision elements (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +class C { + method([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-rest-id-exhausted.js b/test/language/statements/class/dstr-meth-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..652c77503c8dc9986491fd41d3ddaa1215ff502b --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: RestElement applied to an exhausted iterator (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +class C { + method([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +new C().method([1, 2]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/class/dstr-meth-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..25a0d9c1274c68ef3c4be56348b1d880e37a8a8e --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +class C { + method([...x]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/class/dstr-meth-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..52308d2443ca6a62ed23ee80cb10a89a0135c653 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +class C { + method([...x]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-rest-id.js b/test/language/statements/class/dstr-meth-ary-ptrn-rest-id.js new file mode 100644 index 0000000000000000000000000000000000000000..747125f1f025c3dfc5ad593489b3fec5be6d510e --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-rest-id.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Lone rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + method([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-rest-init-ary.js b/test/language/statements/class/dstr-meth-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..8cb54374f7b5b351753aa1a79d6c1ba42b1d196f --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-rest-init-ary.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Reset element (nested array pattern) does not support initializer (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + method([...[ x ] = []]) { + + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-rest-init-id.js b/test/language/statements/class/dstr-meth-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000000000000000000000000000000000..eef64a7107bf0bc203a33f97b03eac5c2f2e2e46 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-rest-init-id.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Reset element (identifier) does not support initializer (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + method([...x = []]) { + + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-rest-init-obj.js b/test/language/statements/class/dstr-meth-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..55f0eead75d08eaa473d3b9e05b3cf6c935b2746 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-rest-init-obj.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Reset element (nested object pattern) does not support initializer (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + method([...{ x } = []]) { + + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-rest-not-final-ary.js b/test/language/statements/class/dstr-meth-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..8d6252f98ccaf3969b83077753b241040d6280cf --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + method([...[x], y]) { + + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-rest-not-final-id.js b/test/language/statements/class/dstr-meth-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000000000000000000000000000000000..ff48e6e2fbab286042fd109d673d03aef7960fb6 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest element (identifier) may not be followed by any element (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + method([...x, y]) { + + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-rest-not-final-obj.js b/test/language/statements/class/dstr-meth-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..c56040d01968b136001bf29ac5046e83516e4fb6 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + method([...{ x }, y]) { + + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-rest-obj-id.js b/test/language/statements/class/dstr-meth-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..c40c8bdbe851fcafd78c9d40d36d2af17cd814ed --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-rest-obj-id.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + method([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/class/dstr-meth-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..9459fd0af6e25bac9872f2fa4be2ddeee8383529 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + method([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; + } +}; + +new C().method([7, 8, 9]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-obj-init-null.js b/test/language/statements/class/dstr-meth-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..f0189cb02368732c997b1727c0894bfe88d2ba81 --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-init-null.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + method({}) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(null); +}); diff --git a/test/language/statements/class/dstr-meth-obj-init-undefined.js b/test/language/statements/class/dstr-meth-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..7bbb83837caee89730c7af0afcd8dc729ee706ad --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-init-undefined.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + method({}) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(undefined); +}); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-empty.js b/test/language/statements/class/dstr-meth-obj-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..9d2565214f6c0da8d2d8331618f1bb1856e87a13 --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-empty.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: No property access occurs for an "empty" object binding pattern (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +class C { + method({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(obj); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-id-get-value-err.js b/test/language/statements/class/dstr-meth-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..41fa21a701cd322179d4cc6e6af985098a58ecc6 --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-id-get-value-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +class C { + method({ poisoned }) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(poisonedProperty); +}); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/class/dstr-meth-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..970289f074808873a9a76aa2436d1a27f7947154 --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + method({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + 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-id-init-fn-name-class.js b/test/language/statements/class/dstr-meth-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..a6abcc4f97390326559d471b42d85e881ce605bd --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + method({ cls = class {}, xCls = class X {} }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + 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-id-init-fn-name-cover.js b/test/language/statements/class/dstr-meth-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..2d6e2515f50d2e664329cd4d4e9ab62f665b86aa --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + method({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + 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-id-init-fn-name-fn.js b/test/language/statements/class/dstr-meth-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..e93df4fe9aada4afff5f43a6d5d8a87b83d37f34 --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + method({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + 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-id-init-fn-name-gen.js b/test/language/statements/class/dstr-meth-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..e8f6fb35f947fb08eb2045d2d393b6f336e4ed18 --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + method({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + 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-id-init-skipped.js b/test/language/statements/class/dstr-meth-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..bc728fbc17fabfeeb91823a3f17c42acc534a39d --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-id-init-skipped.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + method({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method({ w: null, x: 0, y: false, z: '' }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-id-init-throws.js b/test/language/statements/class/dstr-meth-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..49a7f07d797796b6a213eda40e7cd5dad0499c27 --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-id-init-throws.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +class C { + method({ x = thrower() }) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method({}); +}); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-id-init-unresolvable.js b/test/language/statements/class/dstr-meth-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..19e3e89d251044552313604f353553ae5805be5e --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +class C { + method({ x = unresolvableReference }) {} +}; + +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method({}); +}); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-id-trailing-comma.js b/test/language/statements/class/dstr-meth-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..02dfd1a6b139c37d46a3b4e5fe6abbc155f42a9a --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + method({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-list-err.js b/test/language/statements/class/dstr-meth-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..a7e20b10a7da55d517afc3bfff9b255d84880dc4 --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-list-err.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +class C { + method({ a, b = thrower(), c = ++initCount }) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method({}); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-prop-ary-init.js b/test/language/statements/class/dstr-meth-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000000000000000000000000000000000..47ff4434af9d8aaacf565c243ffc7bbd101be4ee --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-prop-ary-init.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + 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-prop-ary-trailing-comma.js b/test/language/statements/class/dstr-meth-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..1a80c0281e941454ea127b80d8fb4b248b5739ad --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + method({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +new C().method({ x: [45] }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-prop-ary-value-null.js b/test/language/statements/class/dstr-meth-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..d310518dbe8dc4887e9d22e628c17b58aec6aed8 --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +class C { + method({ w: [x, y, z] = [4, 5, 6] }) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method({ w: null }); +}); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-prop-ary.js b/test/language/statements/class/dstr-meth-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..4fdfa0990e88eb7f3f9acb2e2dd90ff944cb963d --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-prop-ary.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method({ w: [7, undefined, ] }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-prop-eval-err.js b/test/language/statements/class/dstr-meth-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..0733599b0f7358692066b6e9daf3703ef351dcbd --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-prop-eval-err.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Evaluation of property name returns an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +class C { + method({ [thrower()]: x }) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method({}); +}); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/class/dstr-meth-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..0893a90989f8c383808672181dd7841794bdf336 --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +class C { + method({ poisoned: x = ++initEvalCount }) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/class/dstr-meth-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..2de49c112cc98baa627cc91e806bf907eaab52c9 --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method({ s: null, u: 0, w: false, y: '' }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-prop-id-init-throws.js b/test/language/statements/class/dstr-meth-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..ca15101dd7f19b30589f5ac6e36ed51b7c9ca1b3 --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +class C { + method({ x: y = thrower() }) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method({}); +}); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/class/dstr-meth-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..76feabb530f5ed702c28adcaac78be558d894532 --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +class C { + method({ x: y = unresolvableReference }) {} +}; + +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method({}); +}); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-prop-id-init.js b/test/language/statements/class/dstr-meth-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..eb591bd0d3201759fb86dcf180072c88b81ce92d --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-prop-id-init.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Binding as specified via property name, identifier, and initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + 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-prop-id-trailing-comma.js b/test/language/statements/class/dstr-meth-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..0d31f5f1edb580a39334b0799adfdb01855d756b --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + method({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-prop-id.js b/test/language/statements/class/dstr-meth-obj-ptrn-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..b3fb134973a3ba0dcd2240c7401d197ece39d458 --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-prop-id.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Binding as specified via property name and identifier (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-prop-obj-init.js b/test/language/statements/class/dstr-meth-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000000000000000000000000000000000..ba628de0ed8d83a23b3537760a1bf52dba04d774 --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-prop-obj-init.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method({ w: undefined }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-prop-obj-value-null.js b/test/language/statements/class/dstr-meth-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..a1063cd10259ed651ed9a2c798d2abefcac2f9af --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +class C { + method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method({ w: null }); +}); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/class/dstr-meth-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..60c8e9637abefbd2d18e4669588b6163c15f3443 --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +class C { + method({ w: { x, y, z } = undefined }) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method({ }); +}); diff --git a/test/language/statements/class/dstr-meth-obj-ptrn-prop-obj.js b/test/language/statements/class/dstr-meth-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..2ed132ebdfe8826d421b836da5629068ab8eb182 --- /dev/null +++ b/test/language/statements/class/dstr-meth-obj-ptrn-prop-obj.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method({ w: { x: undefined, z: 7 } }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-init-iter-close.js b/test/language/statements/class/dstr-meth-static-ary-init-iter-close.js new file mode 100644 index 0000000000000000000000000000000000000000..9c4978279c0ef431f629d0dd5df355ee29483c96 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-init-iter-close.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + static method([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +C.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-init-iter-get-err.js b/test/language/statements/class/dstr-meth-static-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..dfdf2c8418a9f05481eb22112a852a97f95f172a --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-init-iter-get-err.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Abrupt completion returned by GetIterator (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +class C { + static method([x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); diff --git a/test/language/statements/class/dstr-meth-static-ary-init-iter-no-close.js b/test/language/statements/class/dstr-meth-static-ary-init-iter-no-close.js new file mode 100644 index 0000000000000000000000000000000000000000..8d9b7638a1518c3876339279ecc97ca150af4d76 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-init-iter-no-close.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + static method([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +C.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-name-iter-val.js b/test/language/statements/class/dstr-meth-static-ary-name-iter-val.js index 340faf8138c591bef392a37402e199f5c1f82b08..7ef67cd2bba5b93497e72497b530d001a581cebc 100644 --- a/test/language/statements/class/dstr-meth-static-ary-name-iter-val.js +++ b/test/language/statements/class/dstr-meth-static-ary-name-iter-val.js @@ -3,7 +3,9 @@ // - src/dstr-binding/default/cls-decl-meth-static.template /*--- description: SingleNameBinding with normal value iteration (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation es6id: 14.5.15 +features: [destructuring-binding] flags: [generated] info: | ClassDeclaration : class BindingIdentifier ClassTail @@ -87,4 +89,4 @@ class C { }; C.method([1, 2, 3]); -assert.sameValue(callCount, 1); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000000000000000000000000000000000..5e50c5826eaf6e098299df998a9f27ae81eb3711 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..147221d83f80d5167a60a344dc3f5f7af047f35d --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +C.method([[7, 8, 9]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000000000000000000000000000000000..b8a27f6c42dcfc607abc97620e9a3293808d17d9 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static method([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..285423e91d172c5a18dd58cdae8ced6f5b902489 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +class C { + static method([[,] = g()]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +C.method([[]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000000000000000000000000000000000..867f14cb4a6fcfcbb9570eea835bee33361b5224 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +class C { + static method([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..5736756e2fa1575e0cababb64070aa0e8bcbf221 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +class C { + static method([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method([[23]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000000000000000000000000000000000..7d8752842e1fdde2592bbce13e88532e1945a657 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +class C { + static method([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..2fbf5f12e99adeab4b7a735473393d081e9d95a9 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +class C { + static method([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method([values]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-val-null.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..d8a629f8a7786fdcc3777e8f85cc9ef03804bd4f --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Nested array destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +class C { + static method([[x]]) {} +}; + +assert.throws(TypeError, function() { + C.method([null]); +}); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..3ae62e640faef0ad78cdd28051a8df2cfb7622b5 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Destructuring initializer with an exhausted iterator (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..7d854f9cddccb9bb500a677b098ee6afb3d7b4e3 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding does assign name to arrow functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..ca8b61e55cd8741e9ff5a9c4697aaa49db653f28 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([cls = class {}, xCls = class X {}]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..711acbfcb4a99b6d6ccd442c2259dd3a15342b0a --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..999fa1bfc3a15b27fa923aea37b6a07debf4fd64 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..544be80f9d39d2dc31231903d08b55bd0143bb1a --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-hole.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000000000000000000000000000000000..84e93e78f812e1f9c28461abe36a697602f60b15 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Destructuring initializer with a "hole" (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([x = 23]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +C.method([,]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..a564f6c73b2739a1e129f73a1dd7eff818f242c2 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static method([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method([null, 0, false, '']); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-throws.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..00e372ceeb7669374f6cc673ca7d94190efd10b4 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Destructuring initializer returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +class C { + static method([x = (function() { throw new Test262Error(); })()]) {} +}; + +assert.throws(Test262Error, function() { + C.method([undefined]); +}); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-undef.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..0aa7dfcaf14e1f36474348f06bb6101a704199ec --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Destructuring initializer with an undefined value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method([undefined]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..94ce509c6c8f15c2b76cb1be00380f8b273effb7 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +class C { + static method([ x = unresolvableReference ]) {} +}; + +assert.throws(ReferenceError, function() { + C.method([]); +}); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000000000000000000000000000000000..c5ed5a20b9c01eab6a86cc1220af0ce3e2d8aebc --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding when value iteration completes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-iter-done.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000000000000000000000000000000000..43a033879726e8251a9a486b01c27eebb8a33b6d --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([_, x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..36c487fbd0f43d0fa07ae7b442073d2947413a86 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +class C { + static method([x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(g); +}); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..4228c88bdb3e2f68ca7811aaf521db7f43879af8 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +class C { + static method([x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(g); +}); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-iter-val.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..8a21783b66465b4779bc3f2a81a084b2405b4d81 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-obj-id-init.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..ee6f0c321873e0a6603ea0af19b6b869897e3b1f --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-obj-id.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..7a117a63d263f9b23dbba70660e84230d1786828 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-obj-id.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +C.method([{ x: 11, y: 22, z: 33 }]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..5d55cb5ea8a96b0817cbe3070a3175c3a4807d57 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..b04a9633e3fd91fd60fbd066fa882286279b5aaa --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method([{ u: 777, w: 888, y: 999 }]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-obj-val-null.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..d38ff1d5c4c256cdc518eb37f583d96f31f5a270 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Nested object destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +class C { + static method([{ x }]) {} +}; + +assert.throws(TypeError, function() { + C.method([null]); +}); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..3ba20ed219cb5340ab83668316ba072e803e1f41 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Nested object destructuring with a value of `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +class C { + static method([{ x }]) {} +}; + +assert.throws(TypeError, function() { + C.method([]); +}); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elision-exhausted.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..341737d3b4ccbe031df23c37acadfdf89f4999e1 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elision-exhausted.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Elision accepts exhausted iterator (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +class C { + static method([,]) { + + callCount = callCount + 1; + } +}; + +C.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elision-step-err.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..724413b934f26148e32b66e7b2dedf5dc3d91b80 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elision-step-err.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Elision advances iterator and forwards abrupt completions (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +class C { + static method([,]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-elision.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..61390c32d988c8f9f12e4aedfcd48f25510b2bb3 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-elision.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Elision advances iterator (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static method([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +C.method(g()); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-empty.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..2a6067d6bcb187ce9580f2c6a8cc7547c379f3e1 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-empty.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + static method([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +C.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-ary-elem.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000000000000000000000000000000000..022fb4a90129c67d430e8f5a5d828fe67496ace6 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest element containing an array BindingElementList pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +C.method([3, 4, 5]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-ary-elision.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..50e137ac66b39e589542c3eab2a500855f9880e0 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,111 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest element containing an elision (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static method([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +C.method(g()); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-ary-empty.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..b26a95af539255850c2a949ac68ea1e5726727a2 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest element containing an "empty" array pattern (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + static method([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +C.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-ary-rest.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..26a1a7449f9cffeebc40fc4eec8746caf3ebab29 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest element containing a rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + static method([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +C.method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..c2f91f9ea9055d93a668f03ca2475fa1df1c496f --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Rest element following elision elements (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +class C { + static method([, ...x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-id-elision.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..a4cff52b7e2cf6d720374bb11767e2fc466ea286 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-id-elision.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest element following elision elements (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +class C { + static method([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-id-exhausted.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..145b03f7ada582246408fa75b9d5459326f8bc19 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: RestElement applied to an exhausted iterator (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +class C { + static method([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +C.method([1, 2]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..a0d8fbe1cba6e93b0bf767c8bc5ab2584efaf2e6 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +class C { + static method([...x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..09b028b9d20cad7e8a33b66189d19917b58148ba --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +class C { + static method([...x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-id.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-id.js new file mode 100644 index 0000000000000000000000000000000000000000..d027d1308ee19c0fc64e2d47c63511b98a3b5b6e --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-id.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Lone rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + static method([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-init-ary.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..089161f35abaa64deb19ee75f9eda5eecd522391 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-init-ary.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Reset element (nested array pattern) does not support initializer (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + static method([...[ x ] = []]) { + + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-init-id.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000000000000000000000000000000000..1594c4948a1e1a607eb32073e72e091659d72e73 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-init-id.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Reset element (identifier) does not support initializer (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + static method([...x = []]) { + + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-init-obj.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..01d4be49d320d82e95a89777e9bb39950ed3d8e0 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-init-obj.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Reset element (nested object pattern) does not support initializer (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + static method([...{ x } = []]) { + + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-not-final-ary.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..66721e04609af7e52c05f5e07cba94a51de90e1a --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + static method([...[x], y]) { + + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-not-final-id.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000000000000000000000000000000000..d9d2bb65fc651da1a73023bea8f346da55ec0525 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest element (identifier) may not be followed by any element (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + static method([...x, y]) { + + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-not-final-obj.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..968eb66a14119f1ab41c45e066c19f27f4757bf6 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + static method([...{ x }, y]) { + + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-obj-id.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..7c696919ab302decf7a7c5d545526eb9f2c0aaa5 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-obj-id.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + static method([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..e8620ef9507c58449255f1f0badff692cfebb3af --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + static method([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; + } +}; + +C.method([7, 8, 9]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-obj-init-null.js b/test/language/statements/class/dstr-meth-static-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..de206edbe78236aa3edcdb48ba6f4ae1fdaea4f2 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-init-null.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + static method({}) {} +}; + +assert.throws(TypeError, function() { + C.method(null); +}); diff --git a/test/language/statements/class/dstr-meth-static-obj-init-undefined.js b/test/language/statements/class/dstr-meth-static-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..8223709daf9e4d85e4c3ab8aaaf18776cd3fcbf7 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-init-undefined.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + static method({}) {} +}; + +assert.throws(TypeError, function() { + C.method(undefined); +}); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-empty.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..bd05b75f413873ff2b7f78f4bd7ee415832411eb --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-empty.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: No property access occurs for an "empty" object binding pattern (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +class C { + static method({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +C.method(obj); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-id-get-value-err.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..5bf591292f7d60e7edbf83dbdd4c98e57c64a9e0 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-id-get-value-err.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +class C { + static method({ poisoned }) {} +}; + +assert.throws(Test262Error, function() { + C.method(poisonedProperty); +}); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..53a27ab827129b0ceca9d6aec490a6326e418f58 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static method({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + 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-id-init-fn-name-class.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..26ae6f87cfd54239dfd4886fe7a44aca60efdeb8 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static method({ cls = class {}, xCls = class X {} }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + 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-id-init-fn-name-cover.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..1d5c59a07696149b25d18e8126bdf4e0204d00ee --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static method({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + 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-id-init-fn-name-fn.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..c90f5c687d70f15a632a5a0b8140eec79a577da5 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static method({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + 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-id-init-fn-name-gen.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..307fe54dbcb53c305a97af1816a7ff19f04cc690 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static method({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + 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-id-init-skipped.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..11a1ec782c8070165b6aa1e6c4f5d9027e9a7bb7 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-id-init-skipped.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static method({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method({ w: null, x: 0, y: false, z: '' }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-id-init-throws.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..477ffc3fcd7ec81efe57395a93a87cc441461b21 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-id-init-throws.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +class C { + static method({ x = thrower() }) {} +}; + +assert.throws(Test262Error, function() { + C.method({}); +}); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-id-init-unresolvable.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..316f67b6066230b249e1a66cbc7e556cec01e884 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +class C { + static method({ x = unresolvableReference }) {} +}; + +assert.throws(ReferenceError, function() { + C.method({}); +}); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-id-trailing-comma.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..fda228bc00e2be543c6ed1009602122b7cc474e2 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static method({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-list-err.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..5fa6749f9b72f938456848270fbadb5544bde301 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-list-err.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +class C { + static method({ a, b = thrower(), c = ++initCount }) {} +}; + +assert.throws(Test262Error, function() { + C.method({}); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-ary-init.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000000000000000000000000000000000..ce215b71a6dba126ec0a9637d460bb873f9eb371 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-ary-init.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + 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-prop-ary-trailing-comma.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..7ae01d53427012187e89cdf29e584bbe6a24bf02 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static method({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +C.method({ x: [45] }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-ary-value-null.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..f1c6ae92ef6c8fdb49b272e31de43c57113cacf3 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +class C { + static method({ w: [x, y, z] = [4, 5, 6] }) {} +}; + +assert.throws(TypeError, function() { + C.method({ w: null }); +}); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-ary.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..3269e3238858c45cb9fe2a68a75a1c2348a9e29a --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-ary.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method({ w: [7, undefined, ] }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-eval-err.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..d4e5e6d0c75de442002babaa9de961ca8824a1a6 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-eval-err.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Evaluation of property name returns an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +class C { + static method({ [thrower()]: x }) {} +}; + +assert.throws(Test262Error, function() { + C.method({}); +}); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..3d0fab1bd96e94ff1a99d16c22ecdec5e476064e --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +class C { + static method({ poisoned: x = ++initEvalCount }) {} +}; + +assert.throws(Test262Error, function() { + C.method(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..4139f761e8bdcdc513e505138753110b264035e1 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method({ s: null, u: 0, w: false, y: '' }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-id-init-throws.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..35ce063a119c5ba6e185afdca8f73248ba11f080 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +class C { + static method({ x: y = thrower() }) {} +}; + +assert.throws(Test262Error, function() { + C.method({}); +}); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..9b40df9b39abba41c332fa4a4d26f7fecf6f8a24 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +class C { + static method({ x: y = unresolvableReference }) {} +}; + +assert.throws(ReferenceError, function() { + C.method({}); +}); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-id-init.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..df8344f48c6f47f6b675aa826fd69e4198c605e4 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-id-init.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Binding as specified via property name, identifier, and initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + 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-prop-id-trailing-comma.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..5068fa8f0b97125848e66a5908fd366475c30105 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static method({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-id.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..a9468c51da79b8e88c28c23844353f7d81ca7729 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-id.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Binding as specified via property name and identifier (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-obj-init.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000000000000000000000000000000000..ef1aba702ef354c2b6caebfa1942e1845890e64e --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-obj-init.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method({ w: undefined }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-obj-value-null.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..e17c86a641253612abac1cfa4a0c83ee4f8e2be8 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +class C { + static method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) {} +}; + +assert.throws(TypeError, function() { + C.method({ w: null }); +}); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..0bcc5b1c92d66213f472611953a2df3abc5569e8 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +class C { + static method({ w: { x, y, z } = undefined }) {} +}; + +assert.throws(TypeError, function() { + C.method({ }); +}); diff --git a/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-obj.js b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..e3ee2ab78cd00f292f66c3606c51038dd27c68d9 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-obj-ptrn-prop-obj.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method({ w: { x: undefined, z: 7 } }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/const/dstr-ary-init-iter-close.js b/test/language/statements/const/dstr-ary-init-iter-close.js new file mode 100644 index 0000000000000000000000000000000000000000..2b396e3d68b52e57e1d46b24c992945295ca45ff --- /dev/null +++ b/test/language/statements/const/dstr-ary-init-iter-close.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [Symbol.iterator, 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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +const [x] = iter; + +assert.sameValue(doneCallCount, 1); diff --git a/test/language/statements/const/dstr-ary-init-iter-get-err.js b/test/language/statements/const/dstr-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..96f4b09bc1aa4d5336b3d056f32067cdb0f88f92 --- /dev/null +++ b/test/language/statements/const/dstr-ary-init-iter-get-err.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/const-stmt.template +/*--- +description: Abrupt completion returned by GetIterator (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [Symbol.iterator, 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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + const [x] = iter; +}); diff --git a/test/language/statements/const/dstr-ary-init-iter-no-close.js b/test/language/statements/const/dstr-ary-init-iter-no-close.js new file mode 100644 index 0000000000000000000000000000000000000000..7d0474d4fc717867f73631f6737e2ad297c9280a --- /dev/null +++ b/test/language/statements/const/dstr-ary-init-iter-no-close.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [Symbol.iterator, 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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +const [x] = iter; + +assert.sameValue(doneCallCount, 0); diff --git a/test/language/statements/const/dstr-ary-name-iter-val.js b/test/language/statements/const/dstr-ary-name-iter-val.js index af6570d8c25f84383ce2ae57ebaa36e5fe94318a..caecb2e200914efda41b51999716379a76fa38f3 100644 --- a/test/language/statements/const/dstr-ary-name-iter-val.js +++ b/test/language/statements/const/dstr-ary-name-iter-val.js @@ -3,7 +3,9 @@ // - src/dstr-binding/default/const-stmt.template /*--- description: SingleNameBinding with normal value iteration (`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 diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/const/dstr-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000000000000000000000000000000000..a39e485b95003521c714d214f3068bb7e1263cc0 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +const [[x, y, z] = [4, 5, 6]] = []; + +assert.sameValue(x, 4); +assert.sameValue(y, 5); +assert.sameValue(z, 6); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/const/dstr-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..c3827392ea1c9a264dd293143ca041617c562693 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +const [[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]; + +assert.sameValue(x, 7); +assert.sameValue(y, 8); +assert.sameValue(z, 9); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/const/dstr-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000000000000000000000000000000000..6f4c58dd04d16b1f8ebb0b958a0084e155846599 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +const [[,] = g()] = []; + +assert.sameValue(first, 1); +assert.sameValue(second, 0); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/const/dstr-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..77eb56c46022774aaafe53bd80210cdeffd0f828 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +const [[,] = g()] = [[]]; + +assert.sameValue(callCount, 0); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/const/dstr-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000000000000000000000000000000000..08efe6f6a54563f6639bb7477f49115f87cc514b --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +const [[] = function() { initCount += 1; return iter; }()] = []; + +assert.sameValue(initCount, 1); +assert.sameValue(iterCount, 0); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/const/dstr-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..95b64600007017354b1d5afafc7114124f0acfd8 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +const [[] = function() { initCount += 1; }()] = [[23]]; + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/const/dstr-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000000000000000000000000000000000..d6bd21427266e2b041f7f3c6f7cb845982803594 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +const [[...x] = values] = []; + +assert(Array.isArray(x)); +assert.sameValue(x[0], 2); +assert.sameValue(x[1], 1); +assert.sameValue(x[2], 3); +assert.sameValue(x.length, 3); +assert.notSameValue(x, values); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/const/dstr-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..7fe1aa1f77367766e9e82cfa75fd8829e242def2 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +const [[...x] = function() { initCount += 1; }()] = [values]; + +assert(Array.isArray(x)); +assert.sameValue(x[0], 2); +assert.sameValue(x[1], 1); +assert.sameValue(x[2], 3); +assert.sameValue(x.length, 3); +assert.notSameValue(x, values); +assert.sameValue(initCount, 0); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-ary-val-null.js b/test/language/statements/const/dstr-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..ed6f46d78681cea3b3eebfb76b1e4c5ca40621bc --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/const-stmt.template +/*--- +description: Nested array destructuring with a null value (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +assert.throws(TypeError, function() { + const [[x]] = [null]; +}); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/const/dstr-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..30e49fd307c2eb052441cf5670fb8ad4fdaae70c --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Destructuring initializer with an exhausted iterator (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +const [x = 23] = []; + +assert.sameValue(x, 23); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/const/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..0c675d57d708aa37946baa807382534600d5a661 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +const [arrow = () => {}] = []; + +assert.sameValue(arrow.name, 'arrow'); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/const/dstr-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..21aca7b2227b36a5414dbd8ee69e6faa8ffbb96e --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +const [cls = class {}, xCls = class X {}] = []; + +assert.sameValue(cls.name, 'cls'); +assert.notSameValue(xCls.name, 'xCls'); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/const/dstr-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..72073874d92f2c68ef4d77bee368fdbbe1db2e83 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +const [cover = (function () {}), xCover = (0, function() {})] = []; + +assert.sameValue(cover.name, 'cover'); +assert.notSameValue(xCover.name, 'xCover'); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/const/dstr-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..9070a2ad2cf506c6e8d19762bcca710a56c07170 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +const [fn = function () {}, xFn = function x() {}] = []; + +assert.sameValue(fn.name, 'fn'); +assert.notSameValue(xFn.name, 'xFn'); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/const/dstr-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..665d9de94781ddf3da0c89e17c1bc42d701a89eb --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +const [gen = function* () {}, xGen = function* x() {}] = []; + +assert.sameValue(gen.name, 'gen'); +assert.notSameValue(xGen.name, 'xGen'); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-id-init-hole.js b/test/language/statements/const/dstr-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000000000000000000000000000000000..c840404d3207fb10e002c05cabe2f47254210d85 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Destructuring initializer with a "hole" (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +const [x = 23] = [,]; + +assert.sameValue(x, 23); +// another statement diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/const/dstr-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..befea5832227e198fe15cc076a43916bb8cef07a --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +const [w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']; + +assert.sameValue(w, null); +assert.sameValue(x, 0); +assert.sameValue(y, false); +assert.sameValue(z, ''); +assert.sameValue(initCount, 0); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-id-init-throws.js b/test/language/statements/const/dstr-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..f3b0b48b5871862aee8dc05bb9decaaee06f2d58 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/const-stmt.template +/*--- +description: Destructuring initializer returns an abrupt completion (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +assert.throws(Test262Error, function() { + const [x = (function() { throw new Test262Error(); })()] = [undefined]; +}); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-id-init-undef.js b/test/language/statements/const/dstr-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..d8fee2d08afb72d210782875754454bc049f82ee --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Destructuring initializer with an undefined value (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +const [x = 23] = [undefined]; + +assert.sameValue(x, 23); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/const/dstr-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..dd7c5a4601c1fcc8c5aa6890c47bec5be696ec20 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/const-stmt.template +/*--- +description: Destructuring initializer is an unresolvable reference (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + const [ x = unresolvableReference ] = []; +}); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/const/dstr-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000000000000000000000000000000000..81967ba9b2992395088a6b50269108a98e465bc1 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: SingleNameBinding when value iteration completes (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +const [x] = []; + +assert.sameValue(x, undefined); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-id-iter-done.js b/test/language/statements/const/dstr-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000000000000000000000000000000000..ff5c132774c7fe83f3c2196bc2ccdd9b8f9c3693 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +const [_, x] = []; + +assert.sameValue(x, undefined); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/const/dstr-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..d6fcb7c326fdd5eff3b0d28cc8aa511f79e060d6 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/const-stmt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +assert.throws(Test262Error, function() { + const [x] = g; +}); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/const/dstr-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..d4ca2ddbfe5acbf10d76ef20a597eb62eae6776a --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/const-stmt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +assert.throws(Test262Error, function() { + const [x] = g; +}); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-id-iter-val.js b/test/language/statements/const/dstr-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..e8e9f41d4aca1100a4bfe41d90b27924aa8f7458 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +const [x, y, z] = [1, 2, 3]; + +assert.sameValue(x, 1); +assert.sameValue(y, 2); +assert.sameValue(z, 3); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-obj-id-init.js b/test/language/statements/const/dstr-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..469db58d64209a511e3f9a81b15c97ee2f15df36 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +const [{ x, y, z } = { x: 44, y: 55, z: 66 }] = []; + +assert.sameValue(x, 44); +assert.sameValue(y, 55); +assert.sameValue(z, 66); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-obj-id.js b/test/language/statements/const/dstr-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..d75365b766822cc25616c12000e0a92f25977611 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-obj-id.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +const [{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]; + +assert.sameValue(x, 11); +assert.sameValue(y, 22); +assert.sameValue(z, 33); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/const/dstr-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..405a88ece34163740cfc4dab06af85270ad681eb --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +const [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []; + +assert.sameValue(v, 444); +assert.sameValue(x, 555); +assert.sameValue(z, 666); + +assert.throws(ReferenceError, function() { + u; +}); +assert.throws(ReferenceError, function() { + w; +}); +assert.throws(ReferenceError, function() { + y; +}); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/const/dstr-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..140cb32a60f057c59e31ab421600d291a1c4bb77 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +const [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]; + +assert.sameValue(v, 777); +assert.sameValue(x, 888); +assert.sameValue(z, 999); + +assert.throws(ReferenceError, function() { + u; +}); +assert.throws(ReferenceError, function() { + w; +}); +assert.throws(ReferenceError, function() { + y; +}); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-obj-val-null.js b/test/language/statements/const/dstr-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..6c4260c3dd7e538bc7011c6d2a403d42a13d089c --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/const-stmt.template +/*--- +description: Nested object destructuring with a null value (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +assert.throws(TypeError, function() { + const [{ x }] = [null]; +}); diff --git a/test/language/statements/const/dstr-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/const/dstr-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..548e3b4e529df878b851bec5f2866fcc6879d64d --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/const-stmt.template +/*--- +description: Nested object destructuring with a value of `undefined` (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +assert.throws(TypeError, function() { + const [{ x }] = []; +}); diff --git a/test/language/statements/const/dstr-ary-ptrn-elision-exhausted.js b/test/language/statements/const/dstr-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..d6ea5bf0dd6e0d21d170396ee8b14523bcf68638 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elision-exhausted.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Elision accepts exhausted iterator (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [generator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +const [,] = iter; + + diff --git a/test/language/statements/const/dstr-ary-ptrn-elision-step-err.js b/test/language/statements/const/dstr-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..55ee2c5299aef273aa7f4cd656dbabc70058640c --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elision-step-err.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/const-stmt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [generator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +assert.throws(Test262Error, function() { + const [,] = iter; +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/const/dstr-ary-ptrn-elision.js b/test/language/statements/const/dstr-ary-ptrn-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..46a83ebde98e8d84c70dbee1139c12691c059bd6 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-elision.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Elision advances iterator (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [generator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +const [,] = g(); + +assert.sameValue(first, 1); +assert.sameValue(second, 0); diff --git a/test/language/statements/const/dstr-ary-ptrn-empty.js b/test/language/statements/const/dstr-ary-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..05bfa5cec2bdebecfb2cb49f5c140ba18aa4ef7d --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-empty.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +const [] = iter; + +assert.sameValue(iterations, 0); diff --git a/test/language/statements/const/dstr-ary-ptrn-rest-ary-elem.js b/test/language/statements/const/dstr-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000000000000000000000000000000000..fca70b102d7b0f0320b151185044de3792a1f12b --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Rest element containing an array BindingElementList pattern (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +const [...[x, y, z]] = [3, 4, 5]; + +assert.sameValue(x, 3); +assert.sameValue(y, 4); +assert.sameValue(z, 5); diff --git a/test/language/statements/const/dstr-ary-ptrn-rest-ary-elision.js b/test/language/statements/const/dstr-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..725298f1ef513dad8a7f82224f446b1e84c439cb --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Rest element containing an elision (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +const [...[,]] = g(); + +assert.sameValue(first, 1); +assert.sameValue(second, 1); diff --git a/test/language/statements/const/dstr-ary-ptrn-rest-ary-empty.js b/test/language/statements/const/dstr-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..488253ca6b3c234793e2be0e77a822fc2a48ac87 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Rest element containing an "empty" array pattern (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +const [...[]] = iter; + +assert.sameValue(iterations, 1); diff --git a/test/language/statements/const/dstr-ary-ptrn-rest-ary-rest.js b/test/language/statements/const/dstr-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..6c0d37cbf65268949bc4449aa975b0ed2a6b4b7f --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Rest element containing a rest element (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +const [...[...x]] = values; + +assert(Array.isArray(x)); +assert.sameValue(x.length, 3); +assert.sameValue(x[0], 1); +assert.sameValue(x[1], 2); +assert.sameValue(x[2], 3); +assert.notSameValue(x, values); + diff --git a/test/language/statements/const/dstr-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/const/dstr-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..9580fcd592c53afbbe173fa28db566ad3d102872 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/const-stmt.template +/*--- +description: Rest element following elision elements (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +assert.throws(Test262Error, function() { + const [, ...x] = iter; +}); diff --git a/test/language/statements/const/dstr-ary-ptrn-rest-id-elision.js b/test/language/statements/const/dstr-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..457b329c14312a1d1fc88c9c8950106ba9434458 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-rest-id-elision.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Rest element following elision elements (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +const [ , , ...x] = values; + +assert(Array.isArray(x)); +assert.sameValue(x.length, 3); +assert.sameValue(x[0], 3); +assert.sameValue(x[1], 4); +assert.sameValue(x[2], 5); +assert.notSameValue(x, values); diff --git a/test/language/statements/const/dstr-ary-ptrn-rest-id-exhausted.js b/test/language/statements/const/dstr-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..070802aa3189067507bbfbbf1fdfff3e7e19e583 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: RestElement applied to an exhausted iterator (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [Symbol.iterator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +const [, , ...x] = [1, 2]; + +assert(Array.isArray(x)); +assert.sameValue(x.length, 0); diff --git a/test/language/statements/const/dstr-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/const/dstr-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..9f3ae3b9e2934fde4cb0432624c6c9dfd918a699 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/const-stmt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +assert.throws(Test262Error, function() { + const [...x] = iter; +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/const/dstr-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/const/dstr-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..7fa7f6c00c7c1053b2fefb148a7e686cf99ab258 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/const-stmt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [Symbol.iterator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +assert.throws(Test262Error, function() { + const [...x] = iter; +}); diff --git a/test/language/statements/const/dstr-ary-ptrn-rest-id.js b/test/language/statements/const/dstr-ary-ptrn-rest-id.js new file mode 100644 index 0000000000000000000000000000000000000000..1a7f80009aa7e931ef79aee4bb87a4ffd53a0946 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-rest-id.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Lone rest element (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +const [...x] = values; + +assert(Array.isArray(x)); +assert.sameValue(x.length, 3); +assert.sameValue(x[0], 1); +assert.sameValue(x[1], 2); +assert.sameValue(x[2], 3); +assert.notSameValue(x, values); diff --git a/test/language/statements/const/dstr-ary-ptrn-rest-init-ary.js b/test/language/statements/const/dstr-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..3631e50ca45b60362855ceb4a5934b7f8815df6f --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-rest-init-ary.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Reset element (nested array pattern) does not support initializer (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +const [...[ x ] = []] = []; + + diff --git a/test/language/statements/const/dstr-ary-ptrn-rest-init-id.js b/test/language/statements/const/dstr-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000000000000000000000000000000000..f1a2bc47189b1ef40cfacd0d0010c13f6ffe3b25 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-rest-init-id.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Reset element (identifier) does not support initializer (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +const [...x = []] = []; + + diff --git a/test/language/statements/const/dstr-ary-ptrn-rest-init-obj.js b/test/language/statements/const/dstr-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..36808de24006d2d4eb15e1487e7a7749111b7305 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-rest-init-obj.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Reset element (nested object pattern) does not support initializer (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +const [...{ x } = []] = []; + + diff --git a/test/language/statements/const/dstr-ary-ptrn-rest-not-final-ary.js b/test/language/statements/const/dstr-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..d4db64bde32cc727d7983e7f5ea074f8af8dcd63 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +const [...[x], y] = [1, 2, 3]; + + diff --git a/test/language/statements/const/dstr-ary-ptrn-rest-not-final-id.js b/test/language/statements/const/dstr-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000000000000000000000000000000000..343f2dd9656daedd50468643858a6da5ef47a3c6 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Rest element (identifier) may not be followed by any element (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +const [...x, y] = [1, 2, 3]; + + diff --git a/test/language/statements/const/dstr-ary-ptrn-rest-not-final-obj.js b/test/language/statements/const/dstr-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..6f48b9ce531a95eee69f1757d01eff01be52bf8b --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (`const` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +const [...{ x }, y] = [1, 2, 3]; + + diff --git a/test/language/statements/const/dstr-ary-ptrn-rest-obj-id.js b/test/language/statements/const/dstr-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..c4b40e3e4e23668471b5b3e5ce46d8707edfd8e5 --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-rest-obj-id.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Rest element containing an object binding pattern (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +const [...{ length }] = [1, 2, 3]; + +assert.sameValue(length, 3); diff --git a/test/language/statements/const/dstr-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/const/dstr-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..f9137c5a2164d56fdaba1c0ae9d2962ce6e534cb --- /dev/null +++ b/test/language/statements/const/dstr-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Rest element containing an object binding pattern (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +const [...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]; + +assert.sameValue(v, 7); +assert.sameValue(w, 8); +assert.sameValue(x, 9); +assert.sameValue(y, undefined); +assert.sameValue(z, 3); + +assert.throws(ReferenceError, function() { + length; +}); diff --git a/test/language/statements/const/dstr-obj-init-null.js b/test/language/statements/const/dstr-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..7822e921bfdaef567b964c0a21666ecaf1271503 --- /dev/null +++ b/test/language/statements/const/dstr-obj-init-null.js @@ -0,0 +1,29 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/const-stmt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (`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. + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +assert.throws(TypeError, function() { + const {} = null; +}); diff --git a/test/language/statements/const/dstr-obj-init-undefined.js b/test/language/statements/const/dstr-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..40e3a65f1a93dec0da70b97dd9e817826c49da50 --- /dev/null +++ b/test/language/statements/const/dstr-obj-init-undefined.js @@ -0,0 +1,29 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/const-stmt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (`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. + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +assert.throws(TypeError, function() { + const {} = undefined; +}); diff --git a/test/language/statements/const/dstr-obj-ptrn-empty.js b/test/language/statements/const/dstr-obj-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..8f3c02bf6fc223fb1612f28baf80ac326f5cb4d2 --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-empty.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (`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. + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +const {} = obj; + +assert.sameValue(accessCount, 0); diff --git a/test/language/statements/const/dstr-obj-ptrn-id-get-value-err.js b/test/language/statements/const/dstr-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..596559042ad560d5378fb3ab9106a4497851a252 --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-id-get-value-err.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/const-stmt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + const { poisoned } = poisonedProperty; +}); diff --git a/test/language/statements/const/dstr-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/const/dstr-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..4ef4dd4d3ee96be3de7ca983a5145f429e53083a --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +const { arrow = () => {} } = {}; + +assert.sameValue(arrow.name, 'arrow'); diff --git a/test/language/statements/const/dstr-obj-ptrn-id-init-fn-name-class.js b/test/language/statements/const/dstr-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..899e1d291cd7d103e5be02006433ac2d7e1d3c7b --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +const { cls = class {}, xCls = class X {} } = {}; + +assert.sameValue(cls.name, 'cls'); +assert.notSameValue(xCls.name, 'xCls'); diff --git a/test/language/statements/const/dstr-obj-ptrn-id-init-fn-name-cover.js b/test/language/statements/const/dstr-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..d2f8870f49c194d9441b91b027e9bfc79e51c28e --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +const { cover = (function () {}), xCover = (0, function() {}) } = {}; + +assert.sameValue(cover.name, 'cover'); +assert.notSameValue(xCover.name, 'xCover'); diff --git a/test/language/statements/const/dstr-obj-ptrn-id-init-fn-name-fn.js b/test/language/statements/const/dstr-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..f241e45b62b65cc9b603276a03a80b9ff65d5146 --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +const { fn = function () {}, xFn = function x() {} } = {}; + +assert.sameValue(fn.name, 'fn'); +assert.notSameValue(xFn.name, 'xFn'); diff --git a/test/language/statements/const/dstr-obj-ptrn-id-init-fn-name-gen.js b/test/language/statements/const/dstr-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..45467e7f689e96fccffe4ffb6f6d2b7d71c735e8 --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +const { gen = function* () {}, xGen = function* x() {} } = {}; + +assert.sameValue(gen.name, 'gen'); +assert.notSameValue(xGen.name, 'xGen'); diff --git a/test/language/statements/const/dstr-obj-ptrn-id-init-skipped.js b/test/language/statements/const/dstr-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..31c5460e14bc2cdd73a5655aedea836b50117942 --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-id-init-skipped.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +const { w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }; + +assert.sameValue(w, null); +assert.sameValue(x, 0); +assert.sameValue(y, false); +assert.sameValue(z, ''); +assert.sameValue(initCount, 0); diff --git a/test/language/statements/const/dstr-obj-ptrn-id-init-throws.js b/test/language/statements/const/dstr-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..eb4f4e1da46ccde336bdb551edf44089d1a8ab93 --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-id-init-throws.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/const-stmt.template +/*--- +description: Error thrown when evaluating the initializer (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + const { x = thrower() } = {}; +}); diff --git a/test/language/statements/const/dstr-obj-ptrn-id-init-unresolvable.js b/test/language/statements/const/dstr-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..83f6fcc78eb2c42c0f6b6716714f497552bd5b1a --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/const-stmt.template +/*--- +description: Destructuring initializer is an unresolvable reference (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + const { x = unresolvableReference } = {}; +}); diff --git a/test/language/statements/const/dstr-obj-ptrn-id-trailing-comma.js b/test/language/statements/const/dstr-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..f99dd78ac9b0d18a409452c528141db5d07fcb9a --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (`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. + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +const { x, } = { x: 23 }; + +assert.sameValue(x, 23); diff --git a/test/language/statements/const/dstr-obj-ptrn-list-err.js b/test/language/statements/const/dstr-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..621138f0480989b51443d8c5fa9c5031f2e775b2 --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-list-err.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/const-stmt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (`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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + const { a, b = thrower(), c = ++initCount } = {}; +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/const/dstr-obj-ptrn-prop-ary-init.js b/test/language/statements/const/dstr-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000000000000000000000000000000000..dbc4e88c221eb0c05b1b9812677241d61eea2bce --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-prop-ary-init.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +const { w: [x, y, z] = [4, 5, 6] } = {}; + +assert.sameValue(x, 4); +assert.sameValue(y, 5); +assert.sameValue(z, 6); + +assert.throws(ReferenceError, function() { + w; +}); diff --git a/test/language/statements/const/dstr-obj-ptrn-prop-ary-trailing-comma.js b/test/language/statements/const/dstr-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..373db33be7909659ba702ec99d5836821982750a --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (`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. + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +const { x: [y], } = { x: [45] }; + +assert.sameValue(y,45); diff --git a/test/language/statements/const/dstr-obj-ptrn-prop-ary-value-null.js b/test/language/statements/const/dstr-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..be7e5f608fd816340f55662fa53dfef955d31cbd --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/const-stmt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + const { w: [x, y, z] = [4, 5, 6] } = { w: null }; +}); diff --git a/test/language/statements/const/dstr-obj-ptrn-prop-ary.js b/test/language/statements/const/dstr-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..7fbd7b9a3f23267708695d1bffc7bf2b253a5700 --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-prop-ary.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +const { w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }; + +assert.sameValue(x, 7); +assert.sameValue(y, undefined); +assert.sameValue(z, undefined); + +assert.throws(ReferenceError, function() { + w; +}); diff --git a/test/language/statements/const/dstr-obj-ptrn-prop-eval-err.js b/test/language/statements/const/dstr-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..08b75482f73efaed1227502d87af97529ce7d7ff --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-prop-eval-err.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/const-stmt.template +/*--- +description: Evaluation of property name returns an abrupt completion (`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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + const { [thrower()]: x } = {}; +}); diff --git a/test/language/statements/const/dstr-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/const/dstr-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..ebd950b2094e6ff4cc95ababe0f3282099cf6472 --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/const-stmt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + const { poisoned: x = ++initEvalCount } = poisonedProperty; +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/const/dstr-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/const/dstr-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..4b562a9f15fcedb72a6eefed21bb039318c4ffb2 --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +const { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }; + +assert.sameValue(t, null); +assert.sameValue(v, 0); +assert.sameValue(x, false); +assert.sameValue(z, ''); +assert.sameValue(initCount, 0); + +assert.throws(ReferenceError, function() { + s; +}); +assert.throws(ReferenceError, function() { + u; +}); +assert.throws(ReferenceError, function() { + w; +}); +assert.throws(ReferenceError, function() { + y; +}); diff --git a/test/language/statements/const/dstr-obj-ptrn-prop-id-init-throws.js b/test/language/statements/const/dstr-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..f17648147a5360ba3fab4d345dc050782f7ec1a7 --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/const-stmt.template +/*--- +description: Error thrown when evaluating the initializer (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + const { x: y = thrower() } = {}; +}); diff --git a/test/language/statements/const/dstr-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/const/dstr-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..0332a25448fa5c6df1810b6b80964bbd3d7597b2 --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/const-stmt.template +/*--- +description: Destructuring initializer is an unresolvable reference (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + const { x: y = unresolvableReference } = {}; +}); diff --git a/test/language/statements/const/dstr-obj-ptrn-prop-id-init.js b/test/language/statements/const/dstr-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..af9f8e89b0cb0a23047931267ece2d7f80540df5 --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-prop-id-init.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +const { x: y = 33 } = { }; + +assert.sameValue(y, 33); +assert.throws(ReferenceError, function() { + x; +}); diff --git a/test/language/statements/const/dstr-obj-ptrn-prop-id-trailing-comma.js b/test/language/statements/const/dstr-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..770caecb91f13d99a3535908675b31a6ee1b162a --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (`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. + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +const { x: y, } = { x: 23 }; + +assert.sameValue(y, 23); + +assert.throws(ReferenceError, function() { + x; +}); diff --git a/test/language/statements/const/dstr-obj-ptrn-prop-id.js b/test/language/statements/const/dstr-obj-ptrn-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..19fb9ff7b33ca72ae758849e76f6c9265b050815 --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-prop-id.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Binding as specified via property name and identifier (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +const { x: y } = { x: 23 }; + +assert.sameValue(y, 23); +assert.throws(ReferenceError, function() { + x; +}); diff --git a/test/language/statements/const/dstr-obj-ptrn-prop-obj-init.js b/test/language/statements/const/dstr-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000000000000000000000000000000000..ddeaad06c3140235cac6f30e2f9c05a49b899bbf --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-prop-obj-init.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }; + +assert.sameValue(x, 4); +assert.sameValue(y, 5); +assert.sameValue(z, 6); + +assert.throws(ReferenceError, function() { + w; +}); diff --git a/test/language/statements/const/dstr-obj-ptrn-prop-obj-value-null.js b/test/language/statements/const/dstr-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..9c44ce28e71068cc499fbbe884b859d43478172f --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/const-stmt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }; +}); diff --git a/test/language/statements/const/dstr-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/const/dstr-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..1b92f9e1999748ac7d4a6ec64fb315e430014cb4 --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/const-stmt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + const { w: { x, y, z } = undefined } = { }; +}); diff --git a/test/language/statements/const/dstr-obj-ptrn-prop-obj.js b/test/language/statements/const/dstr-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..a9c1305e47890904fc4e355b5e1831ee9dfe2659 --- /dev/null +++ b/test/language/statements/const/dstr-obj-ptrn-prop-obj.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }; + +assert.sameValue(x, undefined); +assert.sameValue(y, undefined); +assert.sameValue(z, 7); + +assert.throws(ReferenceError, function() { + w; +}); diff --git a/test/language/statements/for-of/dstr-const-ary-init-iter-close.js b/test/language/statements/for-of/dstr-const-ary-init-iter-close.js new file mode 100644 index 0000000000000000000000000000000000000000..f79bfb95196735ca4c5beda5ef7fed80fe5e4ea4 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-init-iter-close.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var iterCount = 0; + +for (const [x] of [iter]) { + assert.sameValue(doneCallCount, 1); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-init-iter-get-err.js b/test/language/statements/for-of/dstr-const-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..262dba14df06bd39cc570702dc8398d480d929d0 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-init-iter-get-err.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/for-of-const.template +/*--- +description: Abrupt completion returned by GetIterator (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + for (const [x] of [iter]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-const-ary-init-iter-no-close.js b/test/language/statements/for-of/dstr-const-ary-init-iter-no-close.js new file mode 100644 index 0000000000000000000000000000000000000000..848ed4bb9806ab8c669f973260553085c853e181 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-init-iter-no-close.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var iterCount = 0; + +for (const [x] of [iter]) { + assert.sameValue(doneCallCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-name-iter-val.js b/test/language/statements/for-of/dstr-const-ary-name-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..48b4c3b6297820bd543ecd6a4a38ab6e26f3c6fc --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-name-iter-val.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: SingleNameBinding with normal value iteration (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const [x, y, z] of [[1, 2, 3]]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000000000000000000000000000000000..56c02d06c7dca100bcd91d376da866df0ea35cba --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (const [[x, y, z] = [4, 5, 6]] of [[]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..6c74dbb7679d3459589d665211863c517f60163c --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (const [[x, y, z] = [4, 5, 6]] of [[[7, 8, 9]]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000000000000000000000000000000000..55887efef108652b4533f464b6b89f50279611ed --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; + +for (const [[,] = g()] of [[]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..6950aeb95c8293ca018ef837d36bb0369aa0f7a4 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var iterCount = 0; + +for (const [[,] = g()] of [[[]]]) { + assert.sameValue(callCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000000000000000000000000000000000..5c9df655315028ba5a62fba0cf928588d264dc93 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var iterCount = 0; + +for (const [[] = function() { initCount += 1; return iter; }()] of [[]]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..2ebada4b59debea45e40e241ec2183668ca59ecf --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var iterCount = 0; + +for (const [[] = function() { initCount += 1; }()] of [[[23]]]) { + assert.sameValue(initCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000000000000000000000000000000000..482cf423ecfea112f883f78e423e1b41fe7e4aa2 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var iterCount = 0; + +for (const [[...x] = values] of [[]]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..d484e480b0bcfd4b2579d33caa3bfbd26b766b1e --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var iterCount = 0; + +for (const [[...x] = function() { initCount += 1; }()] of [[values]]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-val-null.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..4525859b97b7d8f32712ca5d231bd7f665822292 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/for-of-const.template +/*--- +description: Nested array destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +assert.throws(TypeError, function() { + for (const [[x]] of [[null]]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..00a0d42cfbc64b1b2679446f9385c3ebe0b0c8ef --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Destructuring initializer with an exhausted iterator (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const [x = 23] of [[]]) { + assert.sameValue(x, 23); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..9d883e712bda8e9d39662007dba1f454061f4d62 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: SingleNameBinding does assign name to arrow functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const [arrow = () => {}] of [[]]) { + assert.sameValue(arrow.name, 'arrow'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..e1432dcb0fe3490ec3d7dafb987d2fb80a5dd03d --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const [cls = class {}, xCls = class X {}] of [[]]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..70c5770ffb2426d46f7d8a9af5d8bac970b6ac2c --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const [cover = (function () {}), xCover = (0, function() {})] of [[]]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..030ad29624f89e981be5f71d26dd6b8d3ec5c29e --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const [fn = function () {}, xFn = function x() {}] of [[]]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..a821cdbc4ce0ceb95de2cbd82ca64de995b2c078 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const [gen = function* () {}, xGen = function* x() {}] of [[]]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-hole.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000000000000000000000000000000000..d8728419993d43db5f37e4237a9c3cf3ecf38631 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Destructuring initializer with a "hole" (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const [x = 23] of [[,]]) { + assert.sameValue(x, 23); + // another statement + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..4260019b09276a506e846e7021b04cb59c47cef9 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; + +for (const [w = counter(), x = counter(), y = counter(), z = counter()] of [[null, 0, false, '']]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-throws.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..0fd1d8c5a65ef59a6d5d8dd39c0ef556a28d5842 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/for-of-const.template +/*--- +description: Destructuring initializer returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +assert.throws(Test262Error, function() { + for (const [x = (function() { throw new Test262Error(); })()] of [[undefined]]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-undef.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..fd7a5828512ad942380edf267ae3ba10b5a428ff --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Destructuring initializer with an undefined value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const [x = 23] of [[undefined]]) { + assert.sameValue(x, 23); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..752214729179133d398bef39ec878ca810889190 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/for-of-const.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + for (const [ x = unresolvableReference ] of [[]]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000000000000000000000000000000000..b480b22deea1636e5578f2bec99c465b8569dc67 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: SingleNameBinding when value iteration completes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const [x] of [[]]) { + assert.sameValue(x, undefined); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-iter-done.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000000000000000000000000000000000..995f4cc03bbd8d50732fb95cb86d84f0c388cbfb --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const [_, x] of [[]]) { + assert.sameValue(x, undefined); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..dffd8866a125a2ce23cd2a5dc3e3da43503adf69 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/for-of-const.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +assert.throws(Test262Error, function() { + for (const [x] of [g]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..00fb58784aee610b197bbc84bed00e8a275d310d --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/for-of-const.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +assert.throws(Test262Error, function() { + for (const [x] of [g]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-iter-val.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..165c478f021392f6f5fc5baf00486350a4b94234 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const [x, y, z] of [[1, 2, 3]]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-obj-id-init.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..c353ad57b7c80ca539680e268fa8880a0c3d34bc --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (const [{ x, y, z } = { x: 44, y: 55, z: 66 }] of [[]]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-obj-id.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..37bbc264f5ba08d4884783815ae6bffabc3bb36d --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-obj-id.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (const [{ x, y, z } = { x: 44, y: 55, z: 66 }] of [[{ x: 11, y: 22, z: 33 }]]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..e1cf00e7063e8214ecdf08a3d592e86c838eccd1 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (const [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of [[]]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..eeac2417c1cbf9afe814c31d4a829b7c87bcb499 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (const [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of [[{ u: 777, w: 888, y: 999 }]]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-obj-val-null.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..cb2993429df0d5169c73501177b786e9b3ed61c2 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/for-of-const.template +/*--- +description: Nested object destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +assert.throws(TypeError, function() { + for (const [{ x }] of [[null]]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..c28a3967a6832ef3e0e9b1cf60337e38d22e364c --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/for-of-const.template +/*--- +description: Nested object destructuring with a value of `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +assert.throws(TypeError, function() { + for (const [{ x }] of [[]]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elision-exhausted.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..c251b3d490cc390aeed18ccf414cc8e81d344cb9 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elision-exhausted.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Elision accepts exhausted iterator (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var iterCount = 0; + +for (const [,] of [iter]) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elision-step-err.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..40fe0d7006ea7d91236f6c01be4efdba96dcdf0d --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elision-step-err.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/for-of-const.template +/*--- +description: Elision advances iterator and forwards abrupt completions (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +assert.throws(Test262Error, function() { + for (const [,] of [iter]) { + return; + } +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-elision.js b/test/language/statements/for-of/dstr-const-ary-ptrn-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..cf284bbe7eae3100b90078452f7b58a7f28fd23e --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-elision.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Elision advances iterator (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; + +for (const [,] of [g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-empty.js b/test/language/statements/for-of/dstr-const-ary-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..432ba55d47d4a740db8cd2e412d7d9ed0cf4cfbc --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-empty.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var iterCount = 0; + +for (const [] of [iter]) { + assert.sameValue(iterations, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-rest-ary-elem.js b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000000000000000000000000000000000..44a02dc5465bacbccc0bb357b60e4e076a35e49c --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Rest element containing an array BindingElementList pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const [...[x, y, z]] of [[3, 4, 5]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-rest-ary-elision.js b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..4d37732d30abcf0814c7d74bf95163396b00aa90 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Rest element containing an elision (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; + +for (const [...[,]] of [g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-rest-ary-empty.js b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..ec1176290f6d05d0a7518885c1300ec1e3966edd --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Rest element containing an "empty" array pattern (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var iterCount = 0; + +for (const [...[]] of [iter]) { + assert.sameValue(iterations, 1); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-rest-ary-rest.js b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..3b2675a4d238a9bb57c25856073b3056b699784e --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Rest element containing a rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var iterCount = 0; + +for (const [...[...x]] of [values]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..eea481da2f2c8ced751c951ff45757646bfc1b9c --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/for-of-const.template +/*--- +description: Rest element following elision elements (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +assert.throws(Test262Error, function() { + for (const [, ...x] of [iter]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-rest-id-elision.js b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..c1396d246c300327d1a6ee416367a63a668138b3 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-id-elision.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Rest element following elision elements (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var iterCount = 0; + +for (const [ , , ...x] of [values]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-rest-id-exhausted.js b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..1a9bc8019f0e7feb5c5354382a67e2ce2b9bc5c0 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: RestElement applied to an exhausted iterator (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var iterCount = 0; + +for (const [, , ...x] of [[1, 2]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..fa59347a1d2015554cb98bc777c335745ce3e831 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/for-of-const.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +assert.throws(Test262Error, function() { + for (const [...x] of [iter]) { + return; + } +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..5f29477f8b5878120989c8e2a49341d83cc085be --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/for-of-const.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +assert.throws(Test262Error, function() { + for (const [...x] of [iter]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-rest-id.js b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-id.js new file mode 100644 index 0000000000000000000000000000000000000000..8e938bf0cca213ae06fc30ae1c5b97853026e4e3 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-id.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Lone rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var iterCount = 0; + +for (const [...x] of [values]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-rest-init-ary.js b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..b2633de511aaf86fd6c569bef2f86bbb1a8a0d24 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-init-ary.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Reset element (nested array pattern) does not support initializer (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: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (const [...[ x ] = []] of [[]]) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-rest-init-id.js b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000000000000000000000000000000000..fe304e8f9464884918f965083cd31258afdfd0ae --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-init-id.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Reset element (identifier) does not support initializer (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: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (const [...x = []] of [[]]) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-rest-init-obj.js b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..91fdbad76228f1e0beb057e4437f47bebd363414 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-init-obj.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Reset element (nested object pattern) does not support initializer (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: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (const [...{ x } = []] of [[]]) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-rest-not-final-ary.js b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..c6820570ef7ab2c4237d5c2b66d03c1a3cbc667f --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (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: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (const [...[x], y] of [[1, 2, 3]]) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-rest-not-final-id.js b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000000000000000000000000000000000..e778dbec05a5775d196d0c320a7280c12f1630cc --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Rest element (identifier) may not be followed by any element (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: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (const [...x, y] of [[1, 2, 3]]) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-rest-not-final-obj.js b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..cde39eb2900ed87038d5d8362e9f2b060c0273c0 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (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: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (const [...{ x }, y] of [[1, 2, 3]]) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-rest-obj-id.js b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..80916792f3c0570156778e1ae80c68f0866f8135 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-obj-id.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var iterCount = 0; + +for (const [...{ length }] of [[1, 2, 3]]) { + assert.sameValue(length, 3); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..1f8c4af3811505db85063015fc96a11f63375909 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var iterCount = 0; + +for (const [...{ 0: v, 1: w, 2: x, 3: y, length: z }] of [[7, 8, 9]]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-obj-init-null.js b/test/language/statements/for-of/dstr-const-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..161d68bd995a0148714a7013168a073ad7af2338 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-init-null.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/for-of-const.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +assert.throws(TypeError, function() { + for (const {} of [null]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-const-obj-init-undefined.js b/test/language/statements/for-of/dstr-const-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..acd6b7e72b7caa0510c911ede6e352cc92cd513d --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-init-undefined.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/for-of-const.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +assert.throws(TypeError, function() { + for (const {} of [undefined]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-empty.js b/test/language/statements/for-of/dstr-const-obj-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..4028ccf8130f29cb7ca7226b6c278d91d231ab3f --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-empty.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: No property access occurs for an "empty" object binding pattern (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var iterCount = 0; + +for (const {} of [obj]) { + assert.sameValue(accessCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-id-get-value-err.js b/test/language/statements/for-of/dstr-const-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..3c744899c01e72c8f0533382fe59648de8dff871 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-id-get-value-err.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/for-of-const.template +/*--- +description: Error thrown when accessing the corresponding property of the value 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 ( 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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + for (const { poisoned } of [poisonedProperty]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/for-of/dstr-const-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..81ce9d2fbab7f007abd987da771d456a167c5882 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (const { arrow = () => {} } of [{}]) { + assert.sameValue(arrow.name, 'arrow'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-id-init-fn-name-class.js b/test/language/statements/for-of/dstr-const-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..d1327acba4a7f3ba7829536e441ef006605116c5 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (const { cls = class {}, xCls = class X {} } of [{}]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-id-init-fn-name-cover.js b/test/language/statements/for-of/dstr-const-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..13bb13686a082ebaa69b6708e1272fb226d55e65 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (const { cover = (function () {}), xCover = (0, function() {}) } of [{}]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-id-init-fn-name-fn.js b/test/language/statements/for-of/dstr-const-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..feb85f0aab15cefe823c9039036e23d398aacbfb --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (const { fn = function () {}, xFn = function x() {} } of [{}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-id-init-fn-name-gen.js b/test/language/statements/for-of/dstr-const-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..134d1c6da443c0d2bcc5732017befca7ac562da1 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (const { gen = function* () {}, xGen = function* x() {} } of [{}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-id-init-skipped.js b/test/language/statements/for-of/dstr-const-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..529c888b5ef37312a6722f528add0a6231cec3a6 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-id-init-skipped.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; + +for (const { w = counter(), x = counter(), y = counter(), z = counter() } of [{ w: null, x: 0, y: false, z: '' }]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-id-init-throws.js b/test/language/statements/for-of/dstr-const-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..84614430d81526e76e0b7c68ec8113f526f8283f --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-id-init-throws.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/for-of-const.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + for (const { x = thrower() } of [{}]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-id-init-unresolvable.js b/test/language/statements/for-of/dstr-const-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..76e6e5751e36f640ba98458f4be4c22ef4d13e0c --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/for-of-const.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + for (const { x = unresolvableReference } of [{}]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-id-trailing-comma.js b/test/language/statements/for-of/dstr-const-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..3ba10027b2fa4c209bbb04cdafd04994f3add840 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; + +for (const { x, } of [{ x: 23 }]) { + assert.sameValue(x, 23); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-list-err.js b/test/language/statements/for-of/dstr-const-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..c9e9199e39b0fb700cf83bfd9b2113ed7335e8f5 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-list-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/for-of-const.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + for (const { a, b = thrower(), c = ++initCount } of [{}]) { + return; + } +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-prop-ary-init.js b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000000000000000000000000000000000..8c47a36bd806f6ea6fc84ba30743dc6992a9dab7 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-ary-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; + +for (const { w: [x, y, z] = [4, 5, 6] } of [{}]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-prop-ary-trailing-comma.js b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..15658acf1b5b879964ac98f085360656ec9d5b10 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; + +for (const { x: [y], } of [{ x: [45] }]) { + assert.sameValue(y,45); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-prop-ary-value-null.js b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..00afe54e1b6c9b25dbf00cf069663754043229cc --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/for-of-const.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + for (const { w: [x, y, z] = [4, 5, 6] } of [{ w: null }]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-prop-ary.js b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..df38c72775133f2d3de121b735ff0cf37f3a2075 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-ary.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; + +for (const { w: [x, y, z] = [4, 5, 6] } of [{ w: [7, undefined, ] }]) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-prop-eval-err.js b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..55983e0b16edebfe6afd25ddd70cf195f48cd8d1 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-eval-err.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/for-of-const.template +/*--- +description: Evaluation of property name returns an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + for (const { [thrower()]: x } of [{}]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..5585d8ca7d939c29b0afb46fef51b21d72590076 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/for-of-const.template +/*--- +description: Error thrown when accessing the corresponding property of the value 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 ( 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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + for (const { poisoned: x = ++initEvalCount } of [poisonedProperty]) { + return; + } +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..83c48d58397730a640e0c88121c17714aafd9828 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; + +for (const { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } of [{ s: null, u: 0, w: false, y: '' }]) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-prop-id-init-throws.js b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..d0bdb2176fcda193ee1e4b6f66e1acc204eeac21 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/for-of-const.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + for (const { x: y = thrower() } of [{}]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..36e70e69ff58b8197e326b80cc0b0b57b1dcc850 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/for-of-const.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + for (const { x: y = unresolvableReference } of [{}]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-prop-id-init.js b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..4c1b1a096c375e214aa62dfb2f6054bcda3e84bd --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-id-init.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Binding as specified via property name, identifier, and initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const { x: y = 33 } of [{ }]) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-prop-id-trailing-comma.js b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..87fef7c41cc3141aa70a395eea717f3c177e3edf --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; + +for (const { x: y, } of [{ x: 23 }]) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-prop-id.js b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..765b88bc34e95a13de5718e650e537d9fbb778fd --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-id.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Binding as specified via property name and identifier (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const { x: y } of [{ x: 23 }]) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-prop-obj-init.js b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000000000000000000000000000000000..de2ed2dfbc44a51f6e8a9567b885ee761729a6b2 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-obj-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; + +for (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: undefined }]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-prop-obj-value-null.js b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..35dc6db4183670a3c067ac7cf2c5cce140afe4b0 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/for-of-const.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + for (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: null }]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..4c15d9737dea12232c7440d29e1931ed3b30f00c --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/for-of-const.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + for (const { w: { x, y, z } = undefined } of [{ }]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-const-obj-ptrn-prop-obj.js b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..3f0635ddc2f4f6451910692c108069ff19a79d30 --- /dev/null +++ b/test/language/statements/for-of/dstr-const-obj-ptrn-prop-obj.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/for-of-const.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; + +for (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: { x: undefined, z: 7 } }]) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-init-iter-close.js b/test/language/statements/for-of/dstr-let-ary-init-iter-close.js new file mode 100644 index 0000000000000000000000000000000000000000..e9c0d1d5ebdee076399cad8a116fa110e1f0d252 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-init-iter-close.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var iterCount = 0; + +for (let [x] of [iter]) { + assert.sameValue(doneCallCount, 1); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-init-iter-get-err.js b/test/language/statements/for-of/dstr-let-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..e9e38d75e5e4416cd85ec92b4c5f43dff5c27367 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-init-iter-get-err.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/for-of-let.template +/*--- +description: Abrupt completion returned by GetIterator (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + for (let [x] of [iter]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-let-ary-init-iter-no-close.js b/test/language/statements/for-of/dstr-let-ary-init-iter-no-close.js new file mode 100644 index 0000000000000000000000000000000000000000..acb932163f9df57b9353a52ff22d5368c6d3e952 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-init-iter-no-close.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var iterCount = 0; + +for (let [x] of [iter]) { + assert.sameValue(doneCallCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-name-iter-val.js b/test/language/statements/for-of/dstr-let-ary-name-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..11359d266e63543835fad06d1537117f6b2245a9 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-name-iter-val.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: SingleNameBinding with normal value iteration (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let [x, y, z] of [[1, 2, 3]]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000000000000000000000000000000000..8b4c05f879febc073092af2d9d4efcc300e586c3 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (let [[x, y, z] = [4, 5, 6]] of [[]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..6a4fcd46b11e69231aa1e40e48960d69efc80c57 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (let [[x, y, z] = [4, 5, 6]] of [[[7, 8, 9]]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000000000000000000000000000000000..c94cba1b085b998ca6a762341aebfc95924f5b94 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; + +for (let [[,] = g()] of [[]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..22f3783944569eeccba5903472e6fc55a8911628 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var iterCount = 0; + +for (let [[,] = g()] of [[[]]]) { + assert.sameValue(callCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000000000000000000000000000000000..95ad580164eb43ab1b1f75281f920d80ac86c921 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var iterCount = 0; + +for (let [[] = function() { initCount += 1; return iter; }()] of [[]]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..7abe1329d5095d2ba435db22edae2c4d6521d465 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var iterCount = 0; + +for (let [[] = function() { initCount += 1; }()] of [[[23]]]) { + assert.sameValue(initCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000000000000000000000000000000000..c244521e06ec6a34cafe52c4832afc4012306eba --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var iterCount = 0; + +for (let [[...x] = values] of [[]]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..821d1bba529c5a0d0e14d2b9bfecffa252258c79 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var iterCount = 0; + +for (let [[...x] = function() { initCount += 1; }()] of [[values]]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-val-null.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..c0561711abf0b5c986838b37e2328a15f41d2f36 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/for-of-let.template +/*--- +description: Nested array destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +assert.throws(TypeError, function() { + for (let [[x]] of [[null]]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..2a93a12793f930e753f7f7558e6eaf92288e74bd --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Destructuring initializer with an exhausted iterator (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let [x = 23] of [[]]) { + assert.sameValue(x, 23); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..e9d06fbe7c558fa3412f6d3bbe841b1a686c5e8a --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: SingleNameBinding does assign name to arrow functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let [arrow = () => {}] of [[]]) { + assert.sameValue(arrow.name, 'arrow'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..782e71ff89bc50e11e3a4498592422af627ae8a2 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let [cls = class {}, xCls = class X {}] of [[]]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..ca1ad119ae795ebfb698d896c5d9a701773b6239 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let [cover = (function () {}), xCover = (0, function() {})] of [[]]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..6953c602c2d788018dee0933c255ca58fa29d33a --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let [fn = function () {}, xFn = function x() {}] of [[]]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..4f0cecc2e229f452ff06f2644291515cff15b12a --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let [gen = function* () {}, xGen = function* x() {}] of [[]]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-hole.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000000000000000000000000000000000..7a3696077a49c6623399af7103fedc760d4012bd --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Destructuring initializer with a "hole" (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let [x = 23] of [[,]]) { + assert.sameValue(x, 23); + // another statement + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..048680755d97ac264b73bf3077391c65f4fd5ab3 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; + +for (let [w = counter(), x = counter(), y = counter(), z = counter()] of [[null, 0, false, '']]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-throws.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..54a113ae540c2590089de0cd39e0d3559f0fc8b7 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/for-of-let.template +/*--- +description: Destructuring initializer returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +assert.throws(Test262Error, function() { + for (let [x = (function() { throw new Test262Error(); })()] of [[undefined]]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-undef.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..a8c13166039a20a68fd907c0ffbe0b976ae628a9 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Destructuring initializer with an undefined value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let [x = 23] of [[undefined]]) { + assert.sameValue(x, 23); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..a94badf8b5e1fbe1bb446cfd05fc3de26145c0cf --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/for-of-let.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + for (let [ x = unresolvableReference ] of [[]]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000000000000000000000000000000000..1b733b5a90a1adf30b7adb51da6366cf7bd741bf --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: SingleNameBinding when value iteration completes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let [x] of [[]]) { + assert.sameValue(x, undefined); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-iter-done.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000000000000000000000000000000000..3e530e362ba8dd069dfa2ba01a512a1a84c2249c --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let [_, x] of [[]]) { + assert.sameValue(x, undefined); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..87cda337ad165a09f8e9b80ab8c5396b2cb0c89a --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/for-of-let.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +assert.throws(Test262Error, function() { + for (let [x] of [g]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..1e77a68c7aed8a9449341e0eb9aac921b06d8ca5 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/for-of-let.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +assert.throws(Test262Error, function() { + for (let [x] of [g]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-iter-val.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..9d51b4133ff432c077cc16a8f60460da1effd32c --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let [x, y, z] of [[1, 2, 3]]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-obj-id-init.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..a00441b9b472320a46629215d0213362f1c30b09 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (let [{ x, y, z } = { x: 44, y: 55, z: 66 }] of [[]]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-obj-id.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..b18d7cc951e06cc114f097f5ad38ad59db72262b --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-obj-id.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (let [{ x, y, z } = { x: 44, y: 55, z: 66 }] of [[{ x: 11, y: 22, z: 33 }]]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..07f729b1fcbf9b61be05ef8c5c48697b4030b47a --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (let [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of [[]]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..0751115dd18e7bd9da6ca0edf93d409978c09153 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (let [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of [[{ u: 777, w: 888, y: 999 }]]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-obj-val-null.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..6382c9dd2e52eba875d5e38a2d36c84a9be833d0 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/for-of-let.template +/*--- +description: Nested object destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +assert.throws(TypeError, function() { + for (let [{ x }] of [[null]]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..127361ad424a8e91dadf7d3c80cb01dcc50840ee --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/for-of-let.template +/*--- +description: Nested object destructuring with a value of `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +assert.throws(TypeError, function() { + for (let [{ x }] of [[]]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elision-exhausted.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..db7dbe33988b01524e9583e6c3f1bc8c955a9c2e --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elision-exhausted.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Elision accepts exhausted iterator (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var iterCount = 0; + +for (let [,] of [iter]) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elision-step-err.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..4893e49cb39a2784411051bd42f6bce48b8f550a --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elision-step-err.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/for-of-let.template +/*--- +description: Elision advances iterator and forwards abrupt completions (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +assert.throws(Test262Error, function() { + for (let [,] of [iter]) { + return; + } +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-elision.js b/test/language/statements/for-of/dstr-let-ary-ptrn-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..7112cc8eed037beb77d026a540a325f415359000 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-elision.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Elision advances iterator (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; + +for (let [,] of [g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-empty.js b/test/language/statements/for-of/dstr-let-ary-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..17d1ee16cc421d800b1c212862cb9d134a8982ea --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-empty.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var iterCount = 0; + +for (let [] of [iter]) { + assert.sameValue(iterations, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-rest-ary-elem.js b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000000000000000000000000000000000..b36d8cb22b70779671c6a9a12436ec550958aedd --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Rest element containing an array BindingElementList pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let [...[x, y, z]] of [[3, 4, 5]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-rest-ary-elision.js b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..34e9bdc19b01322287b91a0bb7d83c0d5ccbabf0 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Rest element containing an elision (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; + +for (let [...[,]] of [g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-rest-ary-empty.js b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..54d2933b1f21ddadea21ecdee6a3f0897ae54075 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Rest element containing an "empty" array pattern (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var iterCount = 0; + +for (let [...[]] of [iter]) { + assert.sameValue(iterations, 1); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-rest-ary-rest.js b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..535425bd17bcc40f0f60894d340014b8bc4621d1 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Rest element containing a rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var iterCount = 0; + +for (let [...[...x]] of [values]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..f8269ad640a517892cfa6e589ddd492406d53c4c --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/for-of-let.template +/*--- +description: Rest element following elision elements (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +assert.throws(Test262Error, function() { + for (let [, ...x] of [iter]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-rest-id-elision.js b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..d5d76d04b3c529b7cb652d9c8a42be551fb93e15 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-id-elision.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Rest element following elision elements (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var iterCount = 0; + +for (let [ , , ...x] of [values]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-rest-id-exhausted.js b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..35e5c552cb538348d118e6d10c44d439e60b8971 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: RestElement applied to an exhausted iterator (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var iterCount = 0; + +for (let [, , ...x] of [[1, 2]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..61f79622101af0ccfebaa9ea9163d3606f1d6240 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/for-of-let.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +assert.throws(Test262Error, function() { + for (let [...x] of [iter]) { + return; + } +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..b9d1f41ec8d922ebfe9f38d8f1c2dc28fdfbb078 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/for-of-let.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +assert.throws(Test262Error, function() { + for (let [...x] of [iter]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-rest-id.js b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-id.js new file mode 100644 index 0000000000000000000000000000000000000000..af0778eec9c44bcc542b76fb514aceebbef151c4 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-id.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Lone rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var iterCount = 0; + +for (let [...x] of [values]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-rest-init-ary.js b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..6bb3c0f230577f9a6e570b0329d545dd2a54df1f --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-init-ary.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Reset element (nested array pattern) does not support initializer (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: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (let [...[ x ] = []] of [[]]) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-rest-init-id.js b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000000000000000000000000000000000..acad1cad55501d0c860a94210f89d8974cef9fd3 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-init-id.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Reset element (identifier) does not support initializer (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: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (let [...x = []] of [[]]) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-rest-init-obj.js b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..b113904c6fa7b4905ff66e1b216fcbc28190e407 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-init-obj.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Reset element (nested object pattern) does not support initializer (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: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (let [...{ x } = []] of [[]]) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-rest-not-final-ary.js b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..d8ab5d9d2cee8d7f13e4fff5b30dc4da297772cb --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (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: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (let [...[x], y] of [[1, 2, 3]]) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-rest-not-final-id.js b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000000000000000000000000000000000..b6745f569e1034c56aaeda782bee96767e36f069 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Rest element (identifier) may not be followed by any element (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: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (let [...x, y] of [[1, 2, 3]]) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-rest-not-final-obj.js b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..9fa497cbf72e4c122d2d6952ed1c41337bf0cd5b --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (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: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (let [...{ x }, y] of [[1, 2, 3]]) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-rest-obj-id.js b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..997c136adbabf2339c8e2e79f879d96127aa21a2 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-obj-id.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var iterCount = 0; + +for (let [...{ length }] of [[1, 2, 3]]) { + assert.sameValue(length, 3); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..df325a3e272c32ef25219431dbb75c433236d965 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var iterCount = 0; + +for (let [...{ 0: v, 1: w, 2: x, 3: y, length: z }] of [[7, 8, 9]]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-obj-init-null.js b/test/language/statements/for-of/dstr-let-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..e1e5ac2b98588e08e9796d027867fe8f0b1fee93 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-init-null.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/for-of-let.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +assert.throws(TypeError, function() { + for (let {} of [null]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-let-obj-init-undefined.js b/test/language/statements/for-of/dstr-let-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..9b0d769ba73d3224ad79db34f30fe68d5fbd089d --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-init-undefined.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/for-of-let.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +assert.throws(TypeError, function() { + for (let {} of [undefined]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-empty.js b/test/language/statements/for-of/dstr-let-obj-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..25239a7184acce45620d72cc2202ad18ff43901c --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-empty.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: No property access occurs for an "empty" object binding pattern (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var iterCount = 0; + +for (let {} of [obj]) { + assert.sameValue(accessCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-id-get-value-err.js b/test/language/statements/for-of/dstr-let-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..129e844f7afb1990fac0c2d739beec37d65dcdf2 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-id-get-value-err.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/for-of-let.template +/*--- +description: Error thrown when accessing the corresponding property of the value 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 ( 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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + for (let { poisoned } of [poisonedProperty]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/for-of/dstr-let-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..563a757a5701a67df086892b7ad02fcb8fdb9875 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (let { arrow = () => {} } of [{}]) { + assert.sameValue(arrow.name, 'arrow'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-id-init-fn-name-class.js b/test/language/statements/for-of/dstr-let-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..c62e18a5383e1e1f6d447e6e07b640cfc0892b26 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (let { cls = class {}, xCls = class X {} } of [{}]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-id-init-fn-name-cover.js b/test/language/statements/for-of/dstr-let-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..825e27fabd05fc38dc2f350321ede49cce2b776f --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (let { cover = (function () {}), xCover = (0, function() {}) } of [{}]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-id-init-fn-name-fn.js b/test/language/statements/for-of/dstr-let-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..92ab9235edbb742a782f8f0bb4723f6392940a2f --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (let { fn = function () {}, xFn = function x() {} } of [{}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-id-init-fn-name-gen.js b/test/language/statements/for-of/dstr-let-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..5fc38fa6cb90461da7f5802763c2a01381a19023 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (let { gen = function* () {}, xGen = function* x() {} } of [{}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-id-init-skipped.js b/test/language/statements/for-of/dstr-let-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..05f9dd0afebf8dc78d5071f1177da56114fe99e1 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-id-init-skipped.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; + +for (let { w = counter(), x = counter(), y = counter(), z = counter() } of [{ w: null, x: 0, y: false, z: '' }]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-id-init-throws.js b/test/language/statements/for-of/dstr-let-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..3578a01069734c3960588208ab53c5ce1fb016a7 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-id-init-throws.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/for-of-let.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + for (let { x = thrower() } of [{}]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-id-init-unresolvable.js b/test/language/statements/for-of/dstr-let-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..247259e5d94d299bb15321baf9ae4745400a7e21 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/for-of-let.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + for (let { x = unresolvableReference } of [{}]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-id-trailing-comma.js b/test/language/statements/for-of/dstr-let-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..fca7af2d86515f3635f7fe022f5cb13c98a89fb6 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; + +for (let { x, } of [{ x: 23 }]) { + assert.sameValue(x, 23); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-list-err.js b/test/language/statements/for-of/dstr-let-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..fdf553e91efd5753c5e0d4de7bdaea6798ae96c3 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-list-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/for-of-let.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + for (let { a, b = thrower(), c = ++initCount } of [{}]) { + return; + } +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-prop-ary-init.js b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000000000000000000000000000000000..2750b0500193a6960829b8f0d224ac891f863225 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-ary-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; + +for (let { w: [x, y, z] = [4, 5, 6] } of [{}]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-prop-ary-trailing-comma.js b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..27a9e4a56697fb5dfe6a00316ecac1a74a7efe3f --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; + +for (let { x: [y], } of [{ x: [45] }]) { + assert.sameValue(y,45); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-prop-ary-value-null.js b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..90dfadfb568ca7d35c71d07e37399f2b94188e5a --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/for-of-let.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + for (let { w: [x, y, z] = [4, 5, 6] } of [{ w: null }]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-prop-ary.js b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..83fe43cfc872dabf3ca053d46fb2f39c91d2dbdf --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-ary.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; + +for (let { w: [x, y, z] = [4, 5, 6] } of [{ w: [7, undefined, ] }]) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-prop-eval-err.js b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..e120fd9fed7f9a89f7ad5169a05502a4b95c1f30 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-eval-err.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/for-of-let.template +/*--- +description: Evaluation of property name returns an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + for (let { [thrower()]: x } of [{}]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..b9b732469b5664f938658e08c630c7d3fd22ef49 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/for-of-let.template +/*--- +description: Error thrown when accessing the corresponding property of the value 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 ( 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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + for (let { poisoned: x = ++initEvalCount } of [poisonedProperty]) { + return; + } +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..1bd122b64bb6f556cc5831cf94e2e67f33abd4c2 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; + +for (let { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } of [{ s: null, u: 0, w: false, y: '' }]) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-prop-id-init-throws.js b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..d4d6d5c81003e9b0c98a2d33d9aa6e2e9f00d3f4 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/for-of-let.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + for (let { x: y = thrower() } of [{}]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..bc97486e4ec95d32f6b72b165bfd06a0b8658d5e --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/for-of-let.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + for (let { x: y = unresolvableReference } of [{}]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-prop-id-init.js b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..d025b4cfc9e1132d1b504e3af1ff8eab44a6eea9 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-id-init.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Binding as specified via property name, identifier, and initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let { x: y = 33 } of [{ }]) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-prop-id-trailing-comma.js b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..859557e3e05e5a77ed9463736f6315a2a74ad4fa --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; + +for (let { x: y, } of [{ x: 23 }]) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-prop-id.js b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..d89285a252fe45f25b85bca961dde568f7cf9fd2 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-id.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Binding as specified via property name and identifier (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let { x: y } of [{ x: 23 }]) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-prop-obj-init.js b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000000000000000000000000000000000..38593ea2c3a995261137573365a7a311b96cd1af --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-obj-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; + +for (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: undefined }]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-prop-obj-value-null.js b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..e44ea23aa562ed96b517442acadb9aac0b6a17d6 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/for-of-let.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + for (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: null }]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..f301ad7fce02923ef213acb2f4a93bc6b64efe69 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/for-of-let.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + for (let { w: { x, y, z } = undefined } of [{ }]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-let-obj-ptrn-prop-obj.js b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..5c924938811d1dd1c90f949a1b02165f3391a7e0 --- /dev/null +++ b/test/language/statements/for-of/dstr-let-obj-ptrn-prop-obj.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/for-of-let.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; + +for (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: { x: undefined, z: 7 } }]) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-init-iter-close.js b/test/language/statements/for-of/dstr-var-ary-init-iter-close.js new file mode 100644 index 0000000000000000000000000000000000000000..a7c37461f8476f64759d2cb4730f9297fdabb303 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-init-iter-close.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var iterCount = 0; + +for (var [x] of [iter]) { + assert.sameValue(doneCallCount, 1); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-init-iter-get-err.js b/test/language/statements/for-of/dstr-var-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..cbdf72d511f7e273e4747296c2bfc732ce4d8019 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-init-iter-get-err.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/for-of-var.template +/*--- +description: Abrupt completion returned by GetIterator (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + for (var [x] of [iter]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-var-ary-init-iter-no-close.js b/test/language/statements/for-of/dstr-var-ary-init-iter-no-close.js new file mode 100644 index 0000000000000000000000000000000000000000..a406c5d25ce3a66696578fb741fb2c8b2cae22f5 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-init-iter-no-close.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var iterCount = 0; + +for (var [x] of [iter]) { + assert.sameValue(doneCallCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-name-iter-val.js b/test/language/statements/for-of/dstr-var-ary-name-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..9df1fddae0bc6f985149c3b8b74b761485be0420 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-name-iter-val.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: SingleNameBinding with normal value iteration (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var [x, y, z] of [[1, 2, 3]]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000000000000000000000000000000000..3f79c467d517467294731e7a9efe726cce0a6db4 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (var [[x, y, z] = [4, 5, 6]] of [[]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..b22d9838105db1f32fee3878422bcafacb05c716 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (var [[x, y, z] = [4, 5, 6]] of [[[7, 8, 9]]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000000000000000000000000000000000..fa66ff708244035b6a3aa4cf1ba418324394f9ef --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; + +for (var [[,] = g()] of [[]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..42c4353e28ac9d7a21ff5edc33abc08624e29b9d --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var iterCount = 0; + +for (var [[,] = g()] of [[[]]]) { + assert.sameValue(callCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000000000000000000000000000000000..c545d59dfbe11164ab9efaccb35cd0dfd4568826 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var iterCount = 0; + +for (var [[] = function() { initCount += 1; return iter; }()] of [[]]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..829fbe75281b6aafb2468d273552a5bb673abebd --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var iterCount = 0; + +for (var [[] = function() { initCount += 1; }()] of [[[23]]]) { + assert.sameValue(initCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000000000000000000000000000000000..27cfb4c9e0eef78996ee32d52caa939a17acf2bd --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var iterCount = 0; + +for (var [[...x] = values] of [[]]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..736831bf610cf706e6930c1217c8db163ab16e52 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var iterCount = 0; + +for (var [[...x] = function() { initCount += 1; }()] of [[values]]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-val-null.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..b58673328492481003291a1e191191b9760bfcc3 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/for-of-var.template +/*--- +description: Nested array destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +assert.throws(TypeError, function() { + for (var [[x]] of [[null]]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..e1b42814aa625f940f395a2b260dfbabf534a37f --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Destructuring initializer with an exhausted iterator (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var [x = 23] of [[]]) { + assert.sameValue(x, 23); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..051d8b711f5593ae22909f6605175b4d7f40a034 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: SingleNameBinding does assign name to arrow functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var [arrow = () => {}] of [[]]) { + assert.sameValue(arrow.name, 'arrow'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..bbb81bf337326de5cb87a69c366575d97e76fb3e --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var [cls = class {}, xCls = class X {}] of [[]]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..d267830995aae837c4458cad2e5384c420087e37 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var [cover = (function () {}), xCover = (0, function() {})] of [[]]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..cbc5ab84b2a5296e57eb850d9cb259398280e936 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var [fn = function () {}, xFn = function x() {}] of [[]]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..6b1b838696e6805c570ee51c38e154edb14e703d --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var [gen = function* () {}, xGen = function* x() {}] of [[]]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-hole.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000000000000000000000000000000000..a92ff49c833ddd6b3bcfc2c01866271cc30c98cc --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Destructuring initializer with a "hole" (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var [x = 23] of [[,]]) { + assert.sameValue(x, 23); + // another statement + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..a65b68af3411447a50a9423ac3722c89ac08c6ac --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; + +for (var [w = counter(), x = counter(), y = counter(), z = counter()] of [[null, 0, false, '']]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-throws.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..cd344c7d429e44c666f5510b307913372947f156 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/for-of-var.template +/*--- +description: Destructuring initializer returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +assert.throws(Test262Error, function() { + for (var [x = (function() { throw new Test262Error(); })()] of [[undefined]]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-undef.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..09e8d07c3bf490fb21795d98e26b4b0e2b57fe47 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Destructuring initializer with an undefined value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var [x = 23] of [[undefined]]) { + assert.sameValue(x, 23); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..250d4f51f61bbba9f77706ba13cd99dcd9a32fcb --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/for-of-var.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + for (var [ x = unresolvableReference ] of [[]]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000000000000000000000000000000000..5cd3e2b4402c79521572d911e067b2f2f360c9ac --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: SingleNameBinding when value iteration completes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var [x] of [[]]) { + assert.sameValue(x, undefined); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-iter-done.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000000000000000000000000000000000..0322cc3e25cd22e995dbc17f2319dc779d1b8544 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var [_, x] of [[]]) { + assert.sameValue(x, undefined); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..c92e770d7b8aafe468c5056e72535281efb49185 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/for-of-var.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +assert.throws(Test262Error, function() { + for (var [x] of [g]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..f7f9b028bf820e1b85334e673bdfb3e0ee726f85 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/for-of-var.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +assert.throws(Test262Error, function() { + for (var [x] of [g]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-iter-val.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..03783698953a616a1ff61e42eec489f2a4c7ad49 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var [x, y, z] of [[1, 2, 3]]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-obj-id-init.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..d7b3afea04c33345372b43070ba9c6b10d7d831b --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (var [{ x, y, z } = { x: 44, y: 55, z: 66 }] of [[]]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-obj-id.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..835ca661c24ffe9c31d361b66a8851f57da9b63e --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-obj-id.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (var [{ x, y, z } = { x: 44, y: 55, z: 66 }] of [[{ x: 11, y: 22, z: 33 }]]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..4592860fee0945b7d68200f4f8ea128f96d25f70 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (var [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of [[]]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..f13f4c707e5bf2a204337d89e8528f76ad1e263b --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (var [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] of [[{ u: 777, w: 888, y: 999 }]]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-obj-val-null.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..b77a79f2edc614922ebee3116fec259787fa7f8c --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/for-of-var.template +/*--- +description: Nested object destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +assert.throws(TypeError, function() { + for (var [{ x }] of [[null]]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..46d6f3eaca3be116e0671e6db9e247cb06bda1f3 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/for-of-var.template +/*--- +description: Nested object destructuring with a value of `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +assert.throws(TypeError, function() { + for (var [{ x }] of [[]]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elision-exhausted.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..35ffa8376f8b7513ea5665f8a6220c10e90337d8 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elision-exhausted.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Elision accepts exhausted iterator (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var iterCount = 0; + +for (var [,] of [iter]) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elision-step-err.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..ca32f99e77c1c381245b02ab62b17b72051d86f7 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elision-step-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/for-of-var.template +/*--- +description: Elision advances iterator and forwards abrupt completions (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +assert.throws(Test262Error, function() { + for (var [,] of [iter]) { + return; + } +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-elision.js b/test/language/statements/for-of/dstr-var-ary-ptrn-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..4ac4e7e809313580944167972162fecd79bad2de --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-elision.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Elision advances iterator (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; + +for (var [,] of [g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-empty.js b/test/language/statements/for-of/dstr-var-ary-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..024dafec406da9b2169abb1184a23da444687812 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-empty.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var iterCount = 0; + +for (var [] of [iter]) { + assert.sameValue(iterations, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-rest-ary-elem.js b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000000000000000000000000000000000..ff6acba156a733efe340ab92432a2d196b9f86bb --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Rest element containing an array BindingElementList pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var [...[x, y, z]] of [[3, 4, 5]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-rest-ary-elision.js b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..83b8cf111344d472e484343cc854ef58dc0dc602 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Rest element containing an elision (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; + +for (var [...[,]] of [g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-rest-ary-empty.js b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..3c3f34a9e79acdc7745f0cd67dc96fc040ec08e1 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Rest element containing an "empty" array pattern (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var iterCount = 0; + +for (var [...[]] of [iter]) { + assert.sameValue(iterations, 1); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-rest-ary-rest.js b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..75e7e6002cfa3a9e0ff7f92e59f81d4d4f0b3718 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Rest element containing a rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var iterCount = 0; + +for (var [...[...x]] of [values]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..fba29c243f6c5632942756079c43baf121d27dec --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/for-of-var.template +/*--- +description: Rest element following elision elements (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +assert.throws(Test262Error, function() { + for (var [, ...x] of [iter]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-rest-id-elision.js b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..5c8cf47122c68b1f728aca05e1ca0fe981c0f6cf --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-id-elision.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Rest element following elision elements (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var iterCount = 0; + +for (var [ , , ...x] of [values]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-rest-id-exhausted.js b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..d5963888cefd58d60c0b954e802ff486ebe0f612 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: RestElement applied to an exhausted iterator (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var iterCount = 0; + +for (var [, , ...x] of [[1, 2]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..4b889e5669982b765e1f1cdbc3afee88fcbd4637 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/for-of-var.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +assert.throws(Test262Error, function() { + for (var [...x] of [iter]) { + return; + } +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..fb09fa8cf9f32c1dd655cbe758e1957c5c826999 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/for-of-var.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (for-of statement) +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +es6id: 13.7.5.11 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +assert.throws(Test262Error, function() { + for (var [...x] of [iter]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-rest-id.js b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-id.js new file mode 100644 index 0000000000000000000000000000000000000000..452889319e0758d0d54a81110c60136a8e7a6474 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-id.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Lone rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var iterCount = 0; + +for (var [...x] of [values]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-rest-init-ary.js b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..626e63998bec03520d15797594c53f22b1e93814 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-init-ary.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Reset element (nested array pattern) does not support initializer (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: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (var [...[ x ] = []] of [[]]) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-rest-init-id.js b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000000000000000000000000000000000..071a3d26c513e1baf10c212e2da948a14a26728b --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-init-id.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Reset element (identifier) does not support initializer (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: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (var [...x = []] of [[]]) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-rest-init-obj.js b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..dd4378dbb1f191e2d1723ab5f568f0b0f188fd27 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-init-obj.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Reset element (nested object pattern) does not support initializer (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: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (var [...{ x } = []] of [[]]) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-rest-not-final-ary.js b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..4c62cf9218f785a07dfc52e670da446165d20854 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (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: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (var [...[x], y] of [[1, 2, 3]]) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-rest-not-final-id.js b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000000000000000000000000000000000..222f744f54b9ce60a4af303d32a5e19474532516 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Rest element (identifier) may not be followed by any element (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: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (var [...x, y] of [[1, 2, 3]]) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-rest-not-final-obj.js b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..4bea709a299d0c6ac17f3fe1ce4743e305f61085 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (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: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (var [...{ x }, y] of [[1, 2, 3]]) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-rest-obj-id.js b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..0adf90b1013f616e311199fa38331542fa14c745 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-obj-id.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var iterCount = 0; + +for (var [...{ length }] of [[1, 2, 3]]) { + assert.sameValue(length, 3); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..ec51f71e1c7e78875d2492a66d310aed118c7b5f --- /dev/null +++ b/test/language/statements/for-of/dstr-var-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var iterCount = 0; + +for (var [...{ 0: v, 1: w, 2: x, 3: y, length: z }] of [[7, 8, 9]]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-obj-init-null.js b/test/language/statements/for-of/dstr-var-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..181f7367ab179ef4af99bc398211b8e839923d55 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-init-null.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/for-of-var.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +assert.throws(TypeError, function() { + for (var {} of [null]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-var-obj-init-undefined.js b/test/language/statements/for-of/dstr-var-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..f66d0dbb90695e0cd7cefbf33f78116e1a36e516 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-init-undefined.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/for-of-var.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +assert.throws(TypeError, function() { + for (var {} of [undefined]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-empty.js b/test/language/statements/for-of/dstr-var-obj-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..a175225bc464b4f998a2844bf845b7eb3ea5bc1a --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-empty.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: No property access occurs for an "empty" object binding pattern (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var iterCount = 0; + +for (var {} of [obj]) { + assert.sameValue(accessCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-id-get-value-err.js b/test/language/statements/for-of/dstr-var-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..9fdecf32797a5ab6b265221afd312bd820abed11 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-id-get-value-err.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/for-of-var.template +/*--- +description: Error thrown when accessing the corresponding property of the value 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 ( 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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + for (var { poisoned } of [poisonedProperty]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/for-of/dstr-var-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..56c89a2635ffbcf978f803ca749336cdde2f78c3 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (var { arrow = () => {} } of [{}]) { + assert.sameValue(arrow.name, 'arrow'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-id-init-fn-name-class.js b/test/language/statements/for-of/dstr-var-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..e9c048d6872a555eeddb34d0f6ad31cdb7c970fd --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (var { cls = class {}, xCls = class X {} } of [{}]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-id-init-fn-name-cover.js b/test/language/statements/for-of/dstr-var-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..8c6f8ad72796e6750e9b3b8be1a4e7b7440d2de0 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (var { cover = (function () {}), xCover = (0, function() {}) } of [{}]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-id-init-fn-name-fn.js b/test/language/statements/for-of/dstr-var-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..550e4c553b0126aa48bc243ebefe6b09147914e5 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (var { fn = function () {}, xFn = function x() {} } of [{}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-id-init-fn-name-gen.js b/test/language/statements/for-of/dstr-var-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..938100e5455c442f5d721861ce620dd0185a01a3 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (var { gen = function* () {}, xGen = function* x() {} } of [{}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-id-init-skipped.js b/test/language/statements/for-of/dstr-var-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..6fb563b2b0be512bbc038a2092268189ce22a9b9 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-id-init-skipped.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; + +for (var { w = counter(), x = counter(), y = counter(), z = counter() } of [{ w: null, x: 0, y: false, z: '' }]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-id-init-throws.js b/test/language/statements/for-of/dstr-var-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..4ffc7dbba613f2377c82bbd04594965ea372e407 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-id-init-throws.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/for-of-var.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + for (var { x = thrower() } of [{}]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-id-init-unresolvable.js b/test/language/statements/for-of/dstr-var-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..c2e0e163958eeb538da3b28231bfaccb1c67b8bf --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/for-of-var.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + for (var { x = unresolvableReference } of [{}]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-id-trailing-comma.js b/test/language/statements/for-of/dstr-var-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..a4125b3dac44bf7c53acd9c986666fb625cd1d40 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; + +for (var { x, } of [{ x: 23 }]) { + assert.sameValue(x, 23); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-list-err.js b/test/language/statements/for-of/dstr-var-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..51d9738949f903d775cf7fc6c390b9c6ccee0854 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-list-err.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/for-of-var.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + for (var { a, b = thrower(), c = ++initCount } of [{}]) { + return; + } +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-prop-ary-init.js b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000000000000000000000000000000000..585fdd917ad5a8dded625b0a9e932b829ca34522 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-ary-init.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; + +for (var { w: [x, y, z] = [4, 5, 6] } of [{}]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-prop-ary-trailing-comma.js b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..bacb9e1aa198774035c0fc7e4ad1abb4e6ab75a0 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; + +for (var { x: [y], } of [{ x: [45] }]) { + assert.sameValue(y,45); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-prop-ary-value-null.js b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..a5738314d56875e5a9a3a70250e7c07e536f3fdf --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/for-of-var.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + for (var { w: [x, y, z] = [4, 5, 6] } of [{ w: null }]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-prop-ary.js b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..23cb3ec8a3210b558e2d7520791f1c7bbe8461dd --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-ary.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; + +for (var { w: [x, y, z] = [4, 5, 6] } of [{ w: [7, undefined, ] }]) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-prop-eval-err.js b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..cea2f02f9466068ca4f8c646fac44d27b429f0c4 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-eval-err.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/for-of-var.template +/*--- +description: Evaluation of property name returns an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + for (var { [thrower()]: x } of [{}]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..7959e93f1005d3a977f3345a74fcc3589f26376e --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/for-of-var.template +/*--- +description: Error thrown when accessing the corresponding property of the value 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 ( 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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + for (var { poisoned: x = ++initEvalCount } of [poisonedProperty]) { + return; + } +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..9bb8bdccfaa2ff516847e551503cfbf928540528 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; + +for (var { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } of [{ s: null, u: 0, w: false, y: '' }]) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-prop-id-init-throws.js b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..c26f4ba48c0ef3e27318ac658d0b6a6d54d98cb5 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/for-of-var.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + for (var { x: y = thrower() } of [{}]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..6feba1917fc9d51e700996e083ba4e615b2e62a9 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/for-of-var.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + for (var { x: y = unresolvableReference } of [{}]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-prop-id-init.js b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..382c8bc213bfe0a26e3ca9165376fd56a97285f1 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-id-init.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Binding as specified via property name, identifier, and initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var { x: y = 33 } of [{ }]) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-prop-id-trailing-comma.js b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..276517ba4d5bbb5d7e94719b570cb8e8cce23217 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; + +for (var { x: y, } of [{ x: 23 }]) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-prop-id.js b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..0d6521f77c10decba2bcde52f3e6bad82433eebc --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-id.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Binding as specified via property name and identifier (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var { x: y } of [{ x: 23 }]) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-prop-obj-init.js b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000000000000000000000000000000000..411256ac40c81f5ea43dd2ecfebccc86ea169800 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-obj-init.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; + +for (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: undefined }]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-prop-obj-value-null.js b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..e192a38bfbb4d3b4cadb42a253faaab0d0576177 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/for-of-var.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + for (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: null }]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..75893106303cdb3c8956ca07b9e8b6adc54d4c43 --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/for-of-var.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + for (var { w: { x, y, z } = undefined } of [{ }]) { + return; + } +}); diff --git a/test/language/statements/for-of/dstr-var-obj-ptrn-prop-obj.js b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..669703c24bbddb6e0b6fc14aca50eff4835a4fdd --- /dev/null +++ b/test/language/statements/for-of/dstr-var-obj-ptrn-prop-obj.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/for-of-var.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; + +for (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } of [{ w: { x: undefined, z: 7 } }]) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-init-iter-close.js b/test/language/statements/for/dstr-const-ary-init-iter-close.js new file mode 100644 index 0000000000000000000000000000000000000000..199173ace7b0bc6482cbd24cfffc695cdfbf5f21 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-init-iter-close.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [Symbol.iterator, 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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var iterCount = 0; + +for (const [x] = iter; iterCount < 1; ) { + assert.sameValue(doneCallCount, 1); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-init-iter-get-err.js b/test/language/statements/for/dstr-const-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..d7222ace53e847de748bd442940f104c7087f3ed --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-init-iter-get-err.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/for-const.template +/*--- +description: Abrupt completion returned by GetIterator (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [Symbol.iterator, 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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + for (const [x] = iter; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-const-ary-init-iter-no-close.js b/test/language/statements/for/dstr-const-ary-init-iter-no-close.js new file mode 100644 index 0000000000000000000000000000000000000000..e72487fce42a56e9b4823acdd1c98d0670bc94fd --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-init-iter-no-close.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [Symbol.iterator, 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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var iterCount = 0; + +for (const [x] = iter; iterCount < 1; ) { + assert.sameValue(doneCallCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-name-iter-val.js b/test/language/statements/for/dstr-const-ary-name-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..7ff79601382845f747a6025f51c3f5e33f202578 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-name-iter-val.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/for-const.template +/*--- +description: SingleNameBinding with normal value iteration (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const [x, y, z] = [1, 2, 3]; iterCount < 1; ) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000000000000000000000000000000000..422aeae41abde4d7534833cf4c4e63eb2f5b51f1 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/for-const.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (const [[x, y, z] = [4, 5, 6]] = []; iterCount < 1; ) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..599985994940939ea2ae335ec1c1f00456a92a84 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/for-const.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (const [[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]; iterCount < 1; ) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000000000000000000000000000000000..2ed303812651b5bc0de35b6ff26ad74307fc24f1 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/for-const.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; + +for (const [[,] = g()] = []; iterCount < 1; ) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..148813d581eb808a229612ac5b693a8bd9174f6a --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/for-const.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var iterCount = 0; + +for (const [[,] = g()] = [[]]; iterCount < 1; ) { + assert.sameValue(callCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000000000000000000000000000000000..d62a303f7f9fc1bffd22d271ed6100f7da4a082b --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/for-const.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var iterCount = 0; + +for (const [[] = function() { initCount += 1; return iter; }()] = []; iterCount < 1; ) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..bcf758da89dd515279feac46d067ad25a708e0da --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/for-const.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var iterCount = 0; + +for (const [[] = function() { initCount += 1; }()] = [[23]]; iterCount < 1; ) { + assert.sameValue(initCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000000000000000000000000000000000..45cfdc3bf5c4fb446eb1fc947e5da39830f7cb41 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/for-const.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var iterCount = 0; + +for (const [[...x] = values] = []; iterCount < 1; ) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..08decf470db67916c27f936253148bf40a8d661c --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/for-const.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var iterCount = 0; + +for (const [[...x] = function() { initCount += 1; }()] = [values]; iterCount < 1; ) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-val-null.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..da43ecc0da9df5fa4bef27f8edb1cb4643f195ab --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/for-const.template +/*--- +description: Nested array destructuring with a null value (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +assert.throws(TypeError, function() { + for (const [[x]] = [null]; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..14f092fde2f52d71c3432498a906747d72d4d005 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Destructuring initializer with an exhausted iterator (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const [x = 23] = []; iterCount < 1; ) { + assert.sameValue(x, 23); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..299a0d2e344dba4d6aa2295c420ff3615f26e287 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/for-const.template +/*--- +description: SingleNameBinding does assign name to arrow functions (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const [arrow = () => {}] = []; iterCount < 1; ) { + assert.sameValue(arrow.name, 'arrow'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..62e5f6d352c1ecee91eed7b05bdb9f8f7dc845ed --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/for-const.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const [cls = class {}, xCls = class X {}] = []; iterCount < 1; ) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..df30f31f859a798c0e34c1afe7bc06202613b269 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/for-const.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const [cover = (function () {}), xCover = (0, function() {})] = []; iterCount < 1; ) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..a785fe240db788a9a32fab9c1162f5a0af4551f7 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/for-const.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const [fn = function () {}, xFn = function x() {}] = []; iterCount < 1; ) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..314d7ae67ad96c9339ef72335a4718f8c2f35e1e --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/for-const.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const [gen = function* () {}, xGen = function* x() {}] = []; iterCount < 1; ) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-hole.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000000000000000000000000000000000..9406f5d400caa18d6f2040e10df54f7fff3b2ce0 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Destructuring initializer with a "hole" (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const [x = 23] = [,]; iterCount < 1; ) { + assert.sameValue(x, 23); + // another statement + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..78a367cd845dc25cd6a5df5e7c056ab79b958a85 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; + +for (const [w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']; iterCount < 1; ) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-throws.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..06b6dd08c85a28c3e7238d55787f86ae26f943d5 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/for-const.template +/*--- +description: Destructuring initializer returns an abrupt completion (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +assert.throws(Test262Error, function() { + for (const [x = (function() { throw new Test262Error(); })()] = [undefined]; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-undef.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..f133fcae11d5b649f8da8a288f0d5b2c54a9d4af --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Destructuring initializer with an undefined value (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const [x = 23] = [undefined]; iterCount < 1; ) { + assert.sameValue(x, 23); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..cef4b3eb622eb6fd1caf8e37616b157161a68baf --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/for-const.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + for (const [ x = unresolvableReference ] = []; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000000000000000000000000000000000..352f9be0419d38c64f86929f49f6c1a1c1e8af49 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/for-const.template +/*--- +description: SingleNameBinding when value iteration completes (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const [x] = []; iterCount < 1; ) { + assert.sameValue(x, undefined); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-id-iter-done.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000000000000000000000000000000000..12294b11d9af08392810d07e0eecf8c2b2bad050 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/for-const.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const [_, x] = []; iterCount < 1; ) { + assert.sameValue(x, undefined); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..ab186d30ebef3361325d64706b48e29e8d13c00d --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/for-const.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +assert.throws(Test262Error, function() { + for (const [x] = g; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..c3e8a65055916293edf5015d0115c70d010260a8 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/for-const.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +assert.throws(Test262Error, function() { + for (const [x] = g; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-id-iter-val.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..f1716f43931552da0659363cce525c6bb5de9f62 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/for-const.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const [x, y, z] = [1, 2, 3]; iterCount < 1; ) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-obj-id-init.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..a79b6c2afd0fcb14b494cf01cea389fc4ad171ba --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/for-const.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (const [{ x, y, z } = { x: 44, y: 55, z: 66 }] = []; iterCount < 1; ) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-obj-id.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..bf8f413d4b3ee21ccc3aac163c71df8a77054f29 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-obj-id.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/for-const.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (const [{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]; iterCount < 1; ) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..1b857243da632a9f6c794c1394554a1e64e25520 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/for-const.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (const [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []; iterCount < 1; ) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..e1821d58e57fb02f6fc9dc55743dc830364cb568 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/for-const.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (const [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]; iterCount < 1; ) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-obj-val-null.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..7a689e95cac295a0749cc612b78c57cb9de1c4c9 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/for-const.template +/*--- +description: Nested object destructuring with a null value (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +assert.throws(TypeError, function() { + for (const [{ x }] = [null]; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/for/dstr-const-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..4d19f6910bb1a2c669f9022a4d2ddfc69ef3c0fd --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/for-const.template +/*--- +description: Nested object destructuring with a value of `undefined` (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +assert.throws(TypeError, function() { + for (const [{ x }] = []; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elision-exhausted.js b/test/language/statements/for/dstr-const-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..1d83640a4eab6612fac137f868b64ab7cb00b1b9 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elision-exhausted.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Elision accepts exhausted iterator (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var iterCount = 0; + +for (const [,] = iter; iterCount < 1; ) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elision-step-err.js b/test/language/statements/for/dstr-const-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..bee4d2950c8cf73257ffd7638b6713ebc23c2c9f --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elision-step-err.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/for-const.template +/*--- +description: Elision advances iterator and forwards abrupt completions (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +assert.throws(Test262Error, function() { + for (const [,] = iter; ; ) { + return; + } +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-elision.js b/test/language/statements/for/dstr-const-ary-ptrn-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..1774609e3003700b2cf69faac955357017440fe1 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-elision.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Elision advances iterator (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; + +for (const [,] = g(); iterCount < 1; ) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-empty.js b/test/language/statements/for/dstr-const-ary-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..c538a70eef37e14bc0989056b49c42aefba63f5b --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-empty.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/for-const.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var iterCount = 0; + +for (const [] = iter; iterCount < 1; ) { + assert.sameValue(iterations, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-rest-ary-elem.js b/test/language/statements/for/dstr-const-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000000000000000000000000000000000..a94d15bb8aada828499fa24528f1b5a41bba5ec2 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Rest element containing an array BindingElementList pattern (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const [...[x, y, z]] = [3, 4, 5]; iterCount < 1; ) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-rest-ary-elision.js b/test/language/statements/for/dstr-const-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..c281d0311e3360080a73b9bd5051f29d6ff04527 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Rest element containing an elision (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; + +for (const [...[,]] = g(); iterCount < 1; ) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-rest-ary-empty.js b/test/language/statements/for/dstr-const-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..c84de0f46c78de175425001da34c494be3e67ed4 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Rest element containing an "empty" array pattern (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var iterCount = 0; + +for (const [...[]] = iter; iterCount < 1; ) { + assert.sameValue(iterations, 1); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-rest-ary-rest.js b/test/language/statements/for/dstr-const-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..cdb387895c7dd1a148aa9e317f62f4fb00c7f0db --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Rest element containing a rest element (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var iterCount = 0; + +for (const [...[...x]] = values; iterCount < 1; ) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/for/dstr-const-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..170e84057ee7b8ef7ac4409901a0a34e1ce32e04 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/for-const.template +/*--- +description: Rest element following elision elements (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +assert.throws(Test262Error, function() { + for (const [, ...x] = iter; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-rest-id-elision.js b/test/language/statements/for/dstr-const-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..aabec6ad3c2028c7b511f1ed0551bb1e26b0e6a9 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-rest-id-elision.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Rest element following elision elements (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var iterCount = 0; + +for (const [ , , ...x] = values; iterCount < 1; ) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-rest-id-exhausted.js b/test/language/statements/for/dstr-const-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..a8130acb0018b1b02544d016b313a133fdf97806 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/for-const.template +/*--- +description: RestElement applied to an exhausted iterator (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [Symbol.iterator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var iterCount = 0; + +for (const [, , ...x] = [1, 2]; iterCount < 1; ) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/for/dstr-const-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..313e80077caab527470e231b76b336df4564280b --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/for-const.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +assert.throws(Test262Error, function() { + for (const [...x] = iter; ; ) { + return; + } +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/for/dstr-const-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..33bfa859b8d8f1b3d7dec99d1ab47a1bdfa04dc6 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/for-const.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [Symbol.iterator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +assert.throws(Test262Error, function() { + for (const [...x] = iter; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-rest-id.js b/test/language/statements/for/dstr-const-ary-ptrn-rest-id.js new file mode 100644 index 0000000000000000000000000000000000000000..e0331e94e0801f37c288aa4a72175f1b55fc20ae --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-rest-id.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Lone rest element (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var iterCount = 0; + +for (const [...x] = values; iterCount < 1; ) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-rest-init-ary.js b/test/language/statements/for/dstr-const-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..7c048a19cb7266a96763f39fee45442dbdf381ca --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-rest-init-ary.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Reset element (nested array pattern) does not support initializer (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (const [...[ x ] = []] = []; iterCount < 1; ) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-rest-init-id.js b/test/language/statements/for/dstr-const-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000000000000000000000000000000000..93834e2c848e4e3b5491dffb25162177146749eb --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-rest-init-id.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Reset element (identifier) does not support initializer (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (const [...x = []] = []; iterCount < 1; ) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-rest-init-obj.js b/test/language/statements/for/dstr-const-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..ce18995dec7df618c8b0ad0adf0ba7de4e204168 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-rest-init-obj.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Reset element (nested object pattern) does not support initializer (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (const [...{ x } = []] = []; iterCount < 1; ) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-rest-not-final-ary.js b/test/language/statements/for/dstr-const-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..d75c3e49fb1ba8ae7e72044c020a02200a8e4e3c --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (const [...[x], y] = [1, 2, 3]; iterCount < 1; ) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-rest-not-final-id.js b/test/language/statements/for/dstr-const-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000000000000000000000000000000000..592cc782ae2de3ce2da740de4a4b959189c0734e --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Rest element (identifier) may not be followed by any element (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (const [...x, y] = [1, 2, 3]; iterCount < 1; ) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-rest-not-final-obj.js b/test/language/statements/for/dstr-const-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..576cdab260624e9e8fa86326dd325fe95a52da15 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (const [...{ x }, y] = [1, 2, 3]; iterCount < 1; ) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-rest-obj-id.js b/test/language/statements/for/dstr-const-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..dbdf29ea28f1d46b5ab81dbafcc25bfbd2c329cc --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-rest-obj-id.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Rest element containing an object binding pattern (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var iterCount = 0; + +for (const [...{ length }] = [1, 2, 3]; iterCount < 1; ) { + assert.sameValue(length, 3); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/for/dstr-const-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..e880554ea2248a82c8ebbae13623fa2c68475f46 --- /dev/null +++ b/test/language/statements/for/dstr-const-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Rest element containing an object binding pattern (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var iterCount = 0; + +for (const [...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]; iterCount < 1; ) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-obj-init-null.js b/test/language/statements/for/dstr-const-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..90cc62a7db6f97de32dfc0e7e204cf7f6d04537f --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-init-null.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/for-const.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (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. + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +assert.throws(TypeError, function() { + for (const {} = null; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-const-obj-init-undefined.js b/test/language/statements/for/dstr-const-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..dfc3f7164d27f86edf8d22a99a6d7110b579e94f --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-init-undefined.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/for-const.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (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. + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +assert.throws(TypeError, function() { + for (const {} = undefined; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-empty.js b/test/language/statements/for/dstr-const-obj-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..f55708dedf16aa7100553a1bfdff60fc9bc5e72a --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-empty.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/for-const.template +/*--- +description: No property access occurs for an "empty" object binding pattern (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. + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var iterCount = 0; + +for (const {} = obj; iterCount < 1; ) { + assert.sameValue(accessCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-id-get-value-err.js b/test/language/statements/for/dstr-const-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..9a029f3510adaf49f1052ae067d31f625fddc6fd --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-id-get-value-err.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/for-const.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + for (const { poisoned } = poisonedProperty; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/for/dstr-const-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..724e17f78695a9e57c99a9006905d3e2d8be23a4 --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/for-const.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (const { arrow = () => {} } = {}; iterCount < 1; ) { + assert.sameValue(arrow.name, 'arrow'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-id-init-fn-name-class.js b/test/language/statements/for/dstr-const-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..d32208f5c92ccd672ad245da7f4d51ec40b7c1af --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/for-const.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (const { cls = class {}, xCls = class X {} } = {}; iterCount < 1; ) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-id-init-fn-name-cover.js b/test/language/statements/for/dstr-const-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..4aab85caef0c03804212bb95ba775b385a044e91 --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/for-const.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (const { cover = (function () {}), xCover = (0, function() {}) } = {}; iterCount < 1; ) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-id-init-fn-name-fn.js b/test/language/statements/for/dstr-const-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..6608ece9e41bb1afff68fa8064ae2e912617a625 --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/for-const.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (const { fn = function () {}, xFn = function x() {} } = {}; iterCount < 1; ) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-id-init-fn-name-gen.js b/test/language/statements/for/dstr-const-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..212a78c70690938071fb2ec05fc9ca60bc6346b2 --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/for-const.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (const { gen = function* () {}, xGen = function* x() {} } = {}; iterCount < 1; ) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-id-init-skipped.js b/test/language/statements/for/dstr-const-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..c297334a441a2c2deec4017f4550dd2b8472eb58 --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-id-init-skipped.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; + +for (const { w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }; iterCount < 1; ) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-id-init-throws.js b/test/language/statements/for/dstr-const-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..e934362bc39e0c76b1f44aa25244567b359d7add --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-id-init-throws.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/for-const.template +/*--- +description: Error thrown when evaluating the initializer (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + for (const { x = thrower() } = {}; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-id-init-unresolvable.js b/test/language/statements/for/dstr-const-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..77743e0a53f7c5e2cb85d074b07f99863f2a556e --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/for-const.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + for (const { x = unresolvableReference } = {}; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-id-trailing-comma.js b/test/language/statements/for/dstr-const-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..f4040dbaf4728ae5167882732063457f48e9894b --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; + +for (const { x, } = { x: 23 }; iterCount < 1; ) { + assert.sameValue(x, 23); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-list-err.js b/test/language/statements/for/dstr-const-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..335e65b11b173d5ae807c8d326f8eee40119bd52 --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-list-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/for-const.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + for (const { a, b = thrower(), c = ++initCount } = {}; ; ) { + return; + } +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-prop-ary-init.js b/test/language/statements/for/dstr-const-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000000000000000000000000000000000..b2ae5997bd75f42f967a45a40c3001f6daafa3bd --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-prop-ary-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; + +for (const { w: [x, y, z] = [4, 5, 6] } = {}; iterCount < 1; ) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-prop-ary-trailing-comma.js b/test/language/statements/for/dstr-const-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..b2abd2474c6aa6182848ecc18d50248f799a5181 --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; + +for (const { x: [y], } = { x: [45] }; iterCount < 1; ) { + assert.sameValue(y,45); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-prop-ary-value-null.js b/test/language/statements/for/dstr-const-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..0f2dcb933f019754405a70477849cfd1590edfc5 --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/for-const.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + for (const { w: [x, y, z] = [4, 5, 6] } = { w: null }; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-prop-ary.js b/test/language/statements/for/dstr-const-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..a5a441b399a4b3aee43a68b1be40aef58e6b8155 --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-prop-ary.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; + +for (const { w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }; iterCount < 1; ) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-prop-eval-err.js b/test/language/statements/for/dstr-const-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..bb3747b62bc2b7e26683ee1a8729ed466d07d29a --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-prop-eval-err.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/for-const.template +/*--- +description: Evaluation of property name returns an abrupt completion (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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + for (const { [thrower()]: x } = {}; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/for/dstr-const-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..ba1b3e3252283bfdf7b1cf9ddebfb182ce27e12a --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/for-const.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + for (const { poisoned: x = ++initEvalCount } = poisonedProperty; ; ) { + return; + } +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/for/dstr-const-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..48151b5f62a0829a71c8a99412f1e1c7ba6b0ed1 --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; + +for (const { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }; iterCount < 1; ) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-prop-id-init-throws.js b/test/language/statements/for/dstr-const-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..2d1df338c2f2a71ec2ec63a6a79507cfcef7828b --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/for-const.template +/*--- +description: Error thrown when evaluating the initializer (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + for (const { x: y = thrower() } = {}; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/for/dstr-const-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..a7e7f2231fa1fb4bef502c0765162e3837b67eeb --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/for-const.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + for (const { x: y = unresolvableReference } = {}; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-prop-id-init.js b/test/language/statements/for/dstr-const-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..7734424c31aa9e9c3a17f3c016ad63d518b70a0d --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-prop-id-init.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Binding as specified via property name, identifier, and initializer (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const { x: y = 33 } = { }; iterCount < 1; ) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-prop-id-trailing-comma.js b/test/language/statements/for/dstr-const-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..edeba61620e210a585bbd09b37dfe167f0dc62f7 --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; + +for (const { x: y, } = { x: 23 }; iterCount < 1; ) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-prop-id.js b/test/language/statements/for/dstr-const-obj-ptrn-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..6739fa1eb8a180608594a3dbfb9617a096bc45d7 --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-prop-id.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Binding as specified via property name and identifier (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (const { x: y } = { x: 23 }; iterCount < 1; ) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-prop-obj-init.js b/test/language/statements/for/dstr-const-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000000000000000000000000000000000..fbd6f86ccc67db3185a2d1ba28394700036ca520 --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-prop-obj-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; + +for (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }; iterCount < 1; ) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-prop-obj-value-null.js b/test/language/statements/for/dstr-const-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..9912651fbde4640e2b535548d433d6d8b48fbd5c --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/for-const.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + for (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/for/dstr-const-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..590fbbc063ee1ae26a53af78b8754a159c2ba183 --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/for-const.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + for (const { w: { x, y, z } = undefined } = { }; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-const-obj-ptrn-prop-obj.js b/test/language/statements/for/dstr-const-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..ab764b04ddd33bc2f3136b19e81552ff318ba0f4 --- /dev/null +++ b/test/language/statements/for/dstr-const-obj-ptrn-prop-obj.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/for-const.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; + +for (const { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }; iterCount < 1; ) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-init-iter-close.js b/test/language/statements/for/dstr-let-ary-init-iter-close.js new file mode 100644 index 0000000000000000000000000000000000000000..1ee31f69d70fc9c0c4ff138ce37fa70e368046ca --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-init-iter-close.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [Symbol.iterator, 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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var iterCount = 0; + +for (let [x] = iter; iterCount < 1; ) { + assert.sameValue(doneCallCount, 1); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-init-iter-get-err.js b/test/language/statements/for/dstr-let-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..73c92a4f430f6720b70ff763fb94d21b3b243751 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-init-iter-get-err.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/for-let.template +/*--- +description: Abrupt completion returned by GetIterator (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [Symbol.iterator, 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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + for (let [x] = iter; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-let-ary-init-iter-no-close.js b/test/language/statements/for/dstr-let-ary-init-iter-no-close.js new file mode 100644 index 0000000000000000000000000000000000000000..dab6742138b3c353a32c5c8f31a2e5658e4837bb --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-init-iter-no-close.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [Symbol.iterator, 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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var iterCount = 0; + +for (let [x] = iter; iterCount < 1; ) { + assert.sameValue(doneCallCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-name-iter-val.js b/test/language/statements/for/dstr-let-ary-name-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..673cce3aa4960e49599f836926b5182c37fe4767 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-name-iter-val.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/for-let.template +/*--- +description: SingleNameBinding with normal value iteration (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let [x, y, z] = [1, 2, 3]; iterCount < 1; ) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000000000000000000000000000000000..8db55cdeb637c8d6b239d5aba0507bbece9915bf --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/for-let.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (let [[x, y, z] = [4, 5, 6]] = []; iterCount < 1; ) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..662a66e09aaf2d6207ebb5a6cc1da5964322c63c --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/for-let.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (let [[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]; iterCount < 1; ) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000000000000000000000000000000000..815e6e32198983aaa1e1284889b5820497a8b058 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/for-let.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; + +for (let [[,] = g()] = []; iterCount < 1; ) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..d4cb6af6be6905c070534c88884edc585eb948ad --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/for-let.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var iterCount = 0; + +for (let [[,] = g()] = [[]]; iterCount < 1; ) { + assert.sameValue(callCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000000000000000000000000000000000..9057b321c9223e834d1098201d18c7310ad1b701 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/for-let.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var iterCount = 0; + +for (let [[] = function() { initCount += 1; return iter; }()] = []; iterCount < 1; ) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..1c6c5361447af5a028dc1fafcfc3929d771dd91b --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/for-let.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var iterCount = 0; + +for (let [[] = function() { initCount += 1; }()] = [[23]]; iterCount < 1; ) { + assert.sameValue(initCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000000000000000000000000000000000..c329d6f778a4b9f6a64ae5e6cc72367e7e29270b --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/for-let.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var iterCount = 0; + +for (let [[...x] = values] = []; iterCount < 1; ) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..4a60b17662b26eb18b4740085b3b11eb561de32c --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/for-let.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var iterCount = 0; + +for (let [[...x] = function() { initCount += 1; }()] = [values]; iterCount < 1; ) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-val-null.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..feebe067caf0411140ee690d08c37b97bec60b2f --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/for-let.template +/*--- +description: Nested array destructuring with a null value (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +assert.throws(TypeError, function() { + for (let [[x]] = [null]; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..266a2d54817b9bdfecd2660a295d0615fb015474 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Destructuring initializer with an exhausted iterator (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let [x = 23] = []; iterCount < 1; ) { + assert.sameValue(x, 23); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..0f084089144dc62525ac569bd6acde4e4cb89e28 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/for-let.template +/*--- +description: SingleNameBinding does assign name to arrow functions (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let [arrow = () => {}] = []; iterCount < 1; ) { + assert.sameValue(arrow.name, 'arrow'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..e2954cdbde405bd32d6a5eb57513894746e763b2 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/for-let.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let [cls = class {}, xCls = class X {}] = []; iterCount < 1; ) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..515b6042f0d2dc270cf0bbc0435d073a0c3655d1 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/for-let.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let [cover = (function () {}), xCover = (0, function() {})] = []; iterCount < 1; ) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..bb12a7384c7bc90316f6dd0e0d424a904dc59717 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/for-let.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let [fn = function () {}, xFn = function x() {}] = []; iterCount < 1; ) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..e3f0ab5250e974c7b96b325e2198b7e814760358 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/for-let.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let [gen = function* () {}, xGen = function* x() {}] = []; iterCount < 1; ) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-hole.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000000000000000000000000000000000..a172d6ea5371750effaa9b1c3c2a885ab1ba5b5d --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Destructuring initializer with a "hole" (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let [x = 23] = [,]; iterCount < 1; ) { + assert.sameValue(x, 23); + // another statement + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..cd902383c1f2c9392562079736f686b99b05a5f4 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; + +for (let [w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']; iterCount < 1; ) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-throws.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..f4ccda938b0f43532960276ea6d2b0c38d66caec --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/for-let.template +/*--- +description: Destructuring initializer returns an abrupt completion (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +assert.throws(Test262Error, function() { + for (let [x = (function() { throw new Test262Error(); })()] = [undefined]; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-undef.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..04f8302edb41d9dfcdd04d35f13b8f75e2e481c9 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Destructuring initializer with an undefined value (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let [x = 23] = [undefined]; iterCount < 1; ) { + assert.sameValue(x, 23); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..763a411619c14338765f4f036d8f30fb1a0ed88d --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/for-let.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + for (let [ x = unresolvableReference ] = []; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000000000000000000000000000000000..89b42d3bb4b062c3673050f8af36b8d426feb327 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/for-let.template +/*--- +description: SingleNameBinding when value iteration completes (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let [x] = []; iterCount < 1; ) { + assert.sameValue(x, undefined); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-id-iter-done.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000000000000000000000000000000000..eceffa2e3650afbb7a49ec5d163419542c2d22b4 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/for-let.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let [_, x] = []; iterCount < 1; ) { + assert.sameValue(x, undefined); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..104e2561106a38c232c685cb2ca253aa5639b40b --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/for-let.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +assert.throws(Test262Error, function() { + for (let [x] = g; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..3c1cc4d2ad0d5418dedf83325d16b0dab9da49af --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/for-let.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +assert.throws(Test262Error, function() { + for (let [x] = g; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-id-iter-val.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..940c72e5182fbb23ab5a114035f192ed262291a6 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/for-let.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let [x, y, z] = [1, 2, 3]; iterCount < 1; ) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-obj-id-init.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..94d28183a9cae9027825c2ca31c7683525675533 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/for-let.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (let [{ x, y, z } = { x: 44, y: 55, z: 66 }] = []; iterCount < 1; ) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-obj-id.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..382aea89df274f3b7dd21bba3a7a216017fc76a9 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-obj-id.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/for-let.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (let [{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]; iterCount < 1; ) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..58e05b952023804e918fd1eacc901642489e989a --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/for-let.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (let [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []; iterCount < 1; ) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..5793888bd41d5262f9e3b9f0e7abb9391fa2998e --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/for-let.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (let [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]; iterCount < 1; ) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-obj-val-null.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..f250e5f141d6ac8fe69b37f9c60d32ca23471f20 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/for-let.template +/*--- +description: Nested object destructuring with a null value (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +assert.throws(TypeError, function() { + for (let [{ x }] = [null]; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/for/dstr-let-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..507d59bf1f269cd7e4da71a991731d55cf53c83f --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/for-let.template +/*--- +description: Nested object destructuring with a value of `undefined` (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +assert.throws(TypeError, function() { + for (let [{ x }] = []; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elision-exhausted.js b/test/language/statements/for/dstr-let-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..8cd658c63316766ac6059ce09f360d20ce84c034 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elision-exhausted.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Elision accepts exhausted iterator (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var iterCount = 0; + +for (let [,] = iter; iterCount < 1; ) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elision-step-err.js b/test/language/statements/for/dstr-let-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..3a7eb7afd28b5643aa6f46ad869bdde4a0cabefe --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elision-step-err.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/for-let.template +/*--- +description: Elision advances iterator and forwards abrupt completions (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +assert.throws(Test262Error, function() { + for (let [,] = iter; ; ) { + return; + } +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-elision.js b/test/language/statements/for/dstr-let-ary-ptrn-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..9f6110b819c65a302ac990d7572d5422d5a0e71b --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-elision.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Elision advances iterator (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; + +for (let [,] = g(); iterCount < 1; ) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-empty.js b/test/language/statements/for/dstr-let-ary-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..be1a4986915daf27ad5d7dd14ee5aa870d373785 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-empty.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/for-let.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var iterCount = 0; + +for (let [] = iter; iterCount < 1; ) { + assert.sameValue(iterations, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-rest-ary-elem.js b/test/language/statements/for/dstr-let-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000000000000000000000000000000000..222e09beaabf286655d8fc4360d3fc743504020d --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Rest element containing an array BindingElementList pattern (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let [...[x, y, z]] = [3, 4, 5]; iterCount < 1; ) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-rest-ary-elision.js b/test/language/statements/for/dstr-let-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..dff102807f3138287da565131faa721f172ad1b6 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Rest element containing an elision (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; + +for (let [...[,]] = g(); iterCount < 1; ) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-rest-ary-empty.js b/test/language/statements/for/dstr-let-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..3795ec79d2ad913da7f5bca8b6ca084de8190fde --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Rest element containing an "empty" array pattern (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var iterCount = 0; + +for (let [...[]] = iter; iterCount < 1; ) { + assert.sameValue(iterations, 1); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-rest-ary-rest.js b/test/language/statements/for/dstr-let-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..015d30555ab97ce188f2579fa1ddfff5040f853f --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Rest element containing a rest element (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var iterCount = 0; + +for (let [...[...x]] = values; iterCount < 1; ) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/for/dstr-let-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..0fb4ab341403e3a273bf6060a722ea402deffafb --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/for-let.template +/*--- +description: Rest element following elision elements (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +assert.throws(Test262Error, function() { + for (let [, ...x] = iter; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-rest-id-elision.js b/test/language/statements/for/dstr-let-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..319ae3896d3e1d6a865c5b6e1f4dbc5a605a14c9 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-rest-id-elision.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Rest element following elision elements (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var iterCount = 0; + +for (let [ , , ...x] = values; iterCount < 1; ) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-rest-id-exhausted.js b/test/language/statements/for/dstr-let-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..b3079a01aca950e536ecf35a80908ab86da050bd --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/for-let.template +/*--- +description: RestElement applied to an exhausted iterator (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [Symbol.iterator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var iterCount = 0; + +for (let [, , ...x] = [1, 2]; iterCount < 1; ) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/for/dstr-let-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..ea31a5accd4eed1859c0ccc91fd70187c33be9f4 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/for-let.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +assert.throws(Test262Error, function() { + for (let [...x] = iter; ; ) { + return; + } +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/for/dstr-let-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..76169352158e6ce4d1763a798f6d703c51905fe3 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/for-let.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [Symbol.iterator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +assert.throws(Test262Error, function() { + for (let [...x] = iter; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-rest-id.js b/test/language/statements/for/dstr-let-ary-ptrn-rest-id.js new file mode 100644 index 0000000000000000000000000000000000000000..9b5bdfcc6762e27025cd136a4cf0eeaf96a8e423 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-rest-id.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Lone rest element (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var iterCount = 0; + +for (let [...x] = values; iterCount < 1; ) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-rest-init-ary.js b/test/language/statements/for/dstr-let-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..afe478443ba09f9131aa09fbf17e990020ebf8f5 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-rest-init-ary.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Reset element (nested array pattern) does not support initializer (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (let [...[ x ] = []] = []; iterCount < 1; ) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-rest-init-id.js b/test/language/statements/for/dstr-let-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000000000000000000000000000000000..a6147a5ed7a92643903420d16b4b56958b067d58 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-rest-init-id.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Reset element (identifier) does not support initializer (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (let [...x = []] = []; iterCount < 1; ) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-rest-init-obj.js b/test/language/statements/for/dstr-let-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..8792d02b41dd07dbe5ad217daf4fb56ddf050775 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-rest-init-obj.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Reset element (nested object pattern) does not support initializer (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (let [...{ x } = []] = []; iterCount < 1; ) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-rest-not-final-ary.js b/test/language/statements/for/dstr-let-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..c5f70b29b2d77befb75864dde075d2d5f30f6dda --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (let [...[x], y] = [1, 2, 3]; iterCount < 1; ) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-rest-not-final-id.js b/test/language/statements/for/dstr-let-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000000000000000000000000000000000..adad2e9cdc844751066efd85994cda2ec51c9fba --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Rest element (identifier) may not be followed by any element (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (let [...x, y] = [1, 2, 3]; iterCount < 1; ) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-rest-not-final-obj.js b/test/language/statements/for/dstr-let-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..3c12299c881ab901f7e9415e50bd056815af9acb --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (let [...{ x }, y] = [1, 2, 3]; iterCount < 1; ) { + + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-rest-obj-id.js b/test/language/statements/for/dstr-let-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..479def4750e64b10c36c4db88d967bf7326125bc --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-rest-obj-id.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Rest element containing an object binding pattern (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var iterCount = 0; + +for (let [...{ length }] = [1, 2, 3]; iterCount < 1; ) { + assert.sameValue(length, 3); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/for/dstr-let-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..ccc30499f319fc309ff8516b950af0fcaca95d64 --- /dev/null +++ b/test/language/statements/for/dstr-let-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Rest element containing an object binding pattern (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var iterCount = 0; + +for (let [...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]; iterCount < 1; ) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-obj-init-null.js b/test/language/statements/for/dstr-let-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..d48f73235235109566c9fae7b3f82e54832351ed --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-init-null.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/for-let.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (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. + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +assert.throws(TypeError, function() { + for (let {} = null; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-let-obj-init-undefined.js b/test/language/statements/for/dstr-let-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..b4edf1cc9cffe9c5da5b3b59fe56f05cf6062399 --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-init-undefined.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/for-let.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (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. + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +assert.throws(TypeError, function() { + for (let {} = undefined; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-empty.js b/test/language/statements/for/dstr-let-obj-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..1f0ad832d0b700be530f9729ca9b8be7b641d235 --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-empty.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/for-let.template +/*--- +description: No property access occurs for an "empty" object binding pattern (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. + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var iterCount = 0; + +for (let {} = obj; iterCount < 1; ) { + assert.sameValue(accessCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-id-get-value-err.js b/test/language/statements/for/dstr-let-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..35919f3b34687c249560ff4b065c6f1555ce8e9f --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-id-get-value-err.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/for-let.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + for (let { poisoned } = poisonedProperty; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/for/dstr-let-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..7b0497d26d4c6d2581ce8d2eced765c0c9ec74bd --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/for-let.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (let { arrow = () => {} } = {}; iterCount < 1; ) { + assert.sameValue(arrow.name, 'arrow'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-id-init-fn-name-class.js b/test/language/statements/for/dstr-let-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..8ba844639f0062ba0d16e9b7088166282a0cb2fb --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/for-let.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (let { cls = class {}, xCls = class X {} } = {}; iterCount < 1; ) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-id-init-fn-name-cover.js b/test/language/statements/for/dstr-let-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..49390972f056e913ce17a5888f1431cda0f865cd --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/for-let.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (let { cover = (function () {}), xCover = (0, function() {}) } = {}; iterCount < 1; ) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-id-init-fn-name-fn.js b/test/language/statements/for/dstr-let-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..ec5f12832ff065a8ffdb595c38abf77dc6af2d8c --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/for-let.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (let { fn = function () {}, xFn = function x() {} } = {}; iterCount < 1; ) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-id-init-fn-name-gen.js b/test/language/statements/for/dstr-let-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..a7897d2b1a7f7332a46aac65e3c5c005f5d6d1ff --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/for-let.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (let { gen = function* () {}, xGen = function* x() {} } = {}; iterCount < 1; ) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-id-init-skipped.js b/test/language/statements/for/dstr-let-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..46b1a06f3158244877312a51784260a43b99d552 --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-id-init-skipped.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; + +for (let { w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }; iterCount < 1; ) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-id-init-throws.js b/test/language/statements/for/dstr-let-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..59fc9b88875abca954b317152c70df9b78637d63 --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-id-init-throws.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/for-let.template +/*--- +description: Error thrown when evaluating the initializer (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + for (let { x = thrower() } = {}; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-id-init-unresolvable.js b/test/language/statements/for/dstr-let-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..8da214b8ddcf40344862bebfac5cdee0150de022 --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/for-let.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + for (let { x = unresolvableReference } = {}; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-id-trailing-comma.js b/test/language/statements/for/dstr-let-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..d364634c254989c8ac7cc893616cbf3e312f069f --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; + +for (let { x, } = { x: 23 }; iterCount < 1; ) { + assert.sameValue(x, 23); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-list-err.js b/test/language/statements/for/dstr-let-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..07f06b971525d032ccc843fe1ca71b04c4b4ba28 --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-list-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/for-let.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + for (let { a, b = thrower(), c = ++initCount } = {}; ; ) { + return; + } +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-prop-ary-init.js b/test/language/statements/for/dstr-let-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000000000000000000000000000000000..a5b247a729d4bb490478cfb63eed40806cc9a778 --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-prop-ary-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; + +for (let { w: [x, y, z] = [4, 5, 6] } = {}; iterCount < 1; ) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-prop-ary-trailing-comma.js b/test/language/statements/for/dstr-let-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..533ee2545b98be4e7bc4319d1d61428829b5fb29 --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; + +for (let { x: [y], } = { x: [45] }; iterCount < 1; ) { + assert.sameValue(y,45); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-prop-ary-value-null.js b/test/language/statements/for/dstr-let-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..c2552d88c75afe741e43936ecb9d865ac28a5379 --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/for-let.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + for (let { w: [x, y, z] = [4, 5, 6] } = { w: null }; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-prop-ary.js b/test/language/statements/for/dstr-let-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..f5565451044f00e79807e11ee2e6eedb53abf4f5 --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-prop-ary.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; + +for (let { w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }; iterCount < 1; ) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-prop-eval-err.js b/test/language/statements/for/dstr-let-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..9a1a7b7a1c4bda58f169b765578cc5053203cff1 --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-prop-eval-err.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/for-let.template +/*--- +description: Evaluation of property name returns an abrupt completion (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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + for (let { [thrower()]: x } = {}; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/for/dstr-let-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..fb610615b3b7eaf73169dec7a12152bc4876a3f9 --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/for-let.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + for (let { poisoned: x = ++initEvalCount } = poisonedProperty; ; ) { + return; + } +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/for/dstr-let-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..f9a30e6291b1eed705d1ea33a688b8cfe2b716c8 --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; + +for (let { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }; iterCount < 1; ) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-prop-id-init-throws.js b/test/language/statements/for/dstr-let-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..6c51292b5532754dc8f702de5648f99ba76ff0e4 --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/for-let.template +/*--- +description: Error thrown when evaluating the initializer (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + for (let { x: y = thrower() } = {}; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/for/dstr-let-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..f6953ffa35a47e7cfd9f4bd3076237de6ecd359c --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/for-let.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + for (let { x: y = unresolvableReference } = {}; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-prop-id-init.js b/test/language/statements/for/dstr-let-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..11a02e6fe6e9f20bec3ca57aa834b11d030f9174 --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-prop-id-init.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Binding as specified via property name, identifier, and initializer (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let { x: y = 33 } = { }; iterCount < 1; ) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-prop-id-trailing-comma.js b/test/language/statements/for/dstr-let-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..8edca4fad4f84c49556055edd052db9b32996a59 --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; + +for (let { x: y, } = { x: 23 }; iterCount < 1; ) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-prop-id.js b/test/language/statements/for/dstr-let-obj-ptrn-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..ab30afc8aa484001d78de9ed837dab555984c6d9 --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-prop-id.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Binding as specified via property name and identifier (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (let { x: y } = { x: 23 }; iterCount < 1; ) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-prop-obj-init.js b/test/language/statements/for/dstr-let-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000000000000000000000000000000000..6d887fecec75ce3118f51b31be390763a28cbbd8 --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-prop-obj-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; + +for (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }; iterCount < 1; ) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-prop-obj-value-null.js b/test/language/statements/for/dstr-let-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..b0cb32fc0988ed16b1ef23bc50dbc51aff1b6577 --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/for-let.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + for (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/for/dstr-let-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..24c4fed14f9db8206917a9b2a6021206670cef51 --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/for-let.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + for (let { w: { x, y, z } = undefined } = { }; ; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-let-obj-ptrn-prop-obj.js b/test/language/statements/for/dstr-let-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..41268cfd0667f77c9ac0a4ab53e431e15592d8d0 --- /dev/null +++ b/test/language/statements/for/dstr-let-obj-ptrn-prop-obj.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/for-let.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; + +for (let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }; iterCount < 1; ) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-init-iter-close.js b/test/language/statements/for/dstr-var-ary-init-iter-close.js new file mode 100644 index 0000000000000000000000000000000000000000..5632d9fb2afd48ceb657fcce1ccaf70b09dcff24 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-init-iter-close.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [Symbol.iterator, 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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var iterCount = 0; + +for (var [x] = iter; iterCount < 1; ) { + assert.sameValue(doneCallCount, 1); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-init-iter-get-err.js b/test/language/statements/for/dstr-var-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..0f0d2a41a36b986d974110d6280ab9d5fdd46728 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-init-iter-get-err.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/for-var.template +/*--- +description: Abrupt completion returned by GetIterator (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [Symbol.iterator, 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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + for (var [x] = iter; iterCount < 1; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-var-ary-init-iter-no-close.js b/test/language/statements/for/dstr-var-ary-init-iter-no-close.js new file mode 100644 index 0000000000000000000000000000000000000000..5ab6a56fce278aa0859ca429bff9f0f7e1c0c053 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-init-iter-no-close.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [Symbol.iterator, 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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var iterCount = 0; + +for (var [x] = iter; iterCount < 1; ) { + assert.sameValue(doneCallCount, 0); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-name-iter-val.js b/test/language/statements/for/dstr-var-ary-name-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..8c5a2ee2d5fbda9b73e23de6aa54908a093bd1c6 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-name-iter-val.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/for-var.template +/*--- +description: SingleNameBinding with normal value iteration (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var [x, y, z] = [1, 2, 3]; iterCount < 1; ) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000000000000000000000000000000000..38dd7171c27903aab33b80d46afdca7ea0cf99de --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/for-var.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (var [[x, y, z] = [4, 5, 6]] = []; iterCount < 1; ) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..3f02ff8fc43f5b79515fd9df74145925c131aac3 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/for-var.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (var [[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]; iterCount < 1; ) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000000000000000000000000000000000..7b0d9afb8c95442de64880bee5286f6754764f27 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/for-var.template +/*--- +description: BindingElement with array binding pattern and initializer is used (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; + +for (var [[,] = g()] = []; iterCount < 1; ) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..3fd24c19babab3507297d09fa05ed684e9f3a86b --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/for-var.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var iterCount = 0; + +for (var [[,] = g()] = [[]]; iterCount < 1; ) { + assert.sameValue(callCount, 0); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000000000000000000000000000000000..66d58c6d5896816f14ed778e50e0d564161b0a01 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/for-var.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var iterCount = 0; + +for (var [[] = function() { initCount += 1; return iter; }()] = []; iterCount < 1; ) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..ab45c7042a335a39a2044149ae13527b2343f2e5 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/for-var.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var iterCount = 0; + +for (var [[] = function() { initCount += 1; }()] = [[23]]; iterCount < 1; ) { + assert.sameValue(initCount, 0); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000000000000000000000000000000000..2a77cd2ddce1f7094acc687f97b895090e7b96fd --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/for-var.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var iterCount = 0; + +for (var [[...x] = values] = []; iterCount < 1; ) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..a10b09bbd207c0b03036b7ba8a8f5dc6ac052faf --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/for-var.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var iterCount = 0; + +for (var [[...x] = function() { initCount += 1; }()] = [values]; iterCount < 1; ) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-val-null.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..b81a8daff8f1003bd0ee78300d4b00a9a67d329a --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/for-var.template +/*--- +description: Nested array destructuring with a null value (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +assert.throws(TypeError, function() { + for (var [[x]] = [null]; iterCount < 1; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..7a197aee2e217952b05f8b95d93144970d2802fd --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Destructuring initializer with an exhausted iterator (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var [x = 23] = []; iterCount < 1; ) { + assert.sameValue(x, 23); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..da8c4ef1b70f481909a7ac2e0d877f4842a60c9c --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/for-var.template +/*--- +description: SingleNameBinding does assign name to arrow functions (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var [arrow = () => {}] = []; iterCount < 1; ) { + assert.sameValue(arrow.name, 'arrow'); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..6fd4199d2ec3101e7b83dc6cdef89cebebb5e207 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/for-var.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var [cls = class {}, xCls = class X {}] = []; iterCount < 1; ) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..9eda1527a04fcd7b9e9a3d6fedc53a83ea5ecb91 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/for-var.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var [cover = (function () {}), xCover = (0, function() {})] = []; iterCount < 1; ) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..d0b422e499db8fad724809fd0d8c394477358ab6 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/for-var.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var [fn = function () {}, xFn = function x() {}] = []; iterCount < 1; ) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..3ead9776b24d0bc6fadd4e3132f6acdfa3b52de2 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/for-var.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var [gen = function* () {}, xGen = function* x() {}] = []; iterCount < 1; ) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-hole.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000000000000000000000000000000000..79895fd017b74f68e0a613c4b2b3838470163875 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Destructuring initializer with a "hole" (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var [x = 23] = [,]; iterCount < 1; ) { + assert.sameValue(x, 23); + // another statement + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..1608545d46cce11672036da989fefb6189581b22 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; + +for (var [w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']; iterCount < 1; ) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-throws.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..01ef19fa59d52ce3916519b35ff47341031a96b7 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/for-var.template +/*--- +description: Destructuring initializer returns an abrupt completion (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +assert.throws(Test262Error, function() { + for (var [x = (function() { throw new Test262Error(); })()] = [undefined]; iterCount < 1; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-undef.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..0bb58431e26c6ecc042a7c829e1965cef462fb14 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Destructuring initializer with an undefined value (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var [x = 23] = [undefined]; iterCount < 1; ) { + assert.sameValue(x, 23); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..28493b021279c7c95d53e23d7a1982633b26bd92 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/for-var.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + for (var [ x = unresolvableReference ] = []; iterCount < 1; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000000000000000000000000000000000..e74ab352b7e32d05ca6633ff8d40a9f5ef0eb114 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/for-var.template +/*--- +description: SingleNameBinding when value iteration completes (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var [x] = []; iterCount < 1; ) { + assert.sameValue(x, undefined); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-id-iter-done.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000000000000000000000000000000000..766a4faca7750ee6fd5f506ea13c75a4fd078f39 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/for-var.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var [_, x] = []; iterCount < 1; ) { + assert.sameValue(x, undefined); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..5a4684587864eeaf9b953e5c72dbd23f942a986e --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/for-var.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +assert.throws(Test262Error, function() { + for (var [x] = g; iterCount < 1; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..4fc07653751383257ecb98f9001129a1d5731d2e --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/for-var.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +assert.throws(Test262Error, function() { + for (var [x] = g; iterCount < 1; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-id-iter-val.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..7a5b97fcd285a6008eaace103c7267eef83c820a --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/for-var.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var [x, y, z] = [1, 2, 3]; iterCount < 1; ) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-obj-id-init.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..853a73cb670c1d0ae7330d6326853bff8e4313ea --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/for-var.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (var [{ x, y, z } = { x: 44, y: 55, z: 66 }] = []; iterCount < 1; ) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-obj-id.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..6719724a802b9c7cfb3ab315ec53d935d1c4355a --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-obj-id.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/for-var.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (var [{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]; iterCount < 1; ) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..e5c79c8348711fc541aecfbb5753c09315c676c9 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/for-var.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (var [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []; iterCount < 1; ) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..521fb7f31fe4cec0eaa4584320dd4d2e1bb9d253 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/for-var.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var iterCount = 0; + +for (var [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]; iterCount < 1; ) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-obj-val-null.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..6aa73ac370575fda268cc7d3d27f0306657ed03d --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/for-var.template +/*--- +description: Nested object destructuring with a null value (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +assert.throws(TypeError, function() { + for (var [{ x }] = [null]; iterCount < 1; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/for/dstr-var-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..64dc65d42a44451f726bfac269b7f1f01d11a8c5 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/for-var.template +/*--- +description: Nested object destructuring with a value of `undefined` (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +assert.throws(TypeError, function() { + for (var [{ x }] = []; iterCount < 1; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elision-exhausted.js b/test/language/statements/for/dstr-var-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..43accce902dc592f3383fde0d955be5322c36d9f --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elision-exhausted.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Elision accepts exhausted iterator (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var iterCount = 0; + +for (var [,] = iter; iterCount < 1; ) { + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elision-step-err.js b/test/language/statements/for/dstr-var-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..db271aa9eb83c8df7311a61965b9914a8cf6c9e6 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elision-step-err.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/for-var.template +/*--- +description: Elision advances iterator and forwards abrupt completions (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +assert.throws(Test262Error, function() { + for (var [,] = iter; iterCount < 1; ) { + return; + } +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-elision.js b/test/language/statements/for/dstr-var-ary-ptrn-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..b557a8204b7e02a0aaf2675e89d78739e349e096 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-elision.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Elision advances iterator (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; + +for (var [,] = g(); iterCount < 1; ) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-empty.js b/test/language/statements/for/dstr-var-ary-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..5b1bf8ca3c7f25428e339ed62f5093e7f0e3efb0 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-empty.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/for-var.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var iterCount = 0; + +for (var [] = iter; iterCount < 1; ) { + assert.sameValue(iterations, 0); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-rest-ary-elem.js b/test/language/statements/for/dstr-var-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000000000000000000000000000000000..3c9553cef030eba8a7b9348e5f32b354d2bb7719 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Rest element containing an array BindingElementList pattern (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var [...[x, y, z]] = [3, 4, 5]; iterCount < 1; ) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-rest-ary-elision.js b/test/language/statements/for/dstr-var-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..29bce69e27323eca907584fd38b85c438ce84cfe --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Rest element containing an elision (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var iterCount = 0; + +for (var [...[,]] = g(); iterCount < 1; ) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-rest-ary-empty.js b/test/language/statements/for/dstr-var-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..239f21322e123a04626d22c95a7a6c0fb0b0d5bf --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Rest element containing an "empty" array pattern (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var iterCount = 0; + +for (var [...[]] = iter; iterCount < 1; ) { + assert.sameValue(iterations, 1); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-rest-ary-rest.js b/test/language/statements/for/dstr-var-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..12c7f081a0934adf6a2bf1e5cec528de340b9d3e --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Rest element containing a rest element (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var iterCount = 0; + +for (var [...[...x]] = values; iterCount < 1; ) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/for/dstr-var-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..72a37a8a110480cdbd85d7d77ef3f40c38e41a87 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/for-var.template +/*--- +description: Rest element following elision elements (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +assert.throws(Test262Error, function() { + for (var [, ...x] = iter; iterCount < 1; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-rest-id-elision.js b/test/language/statements/for/dstr-var-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..cd5cc0e333a93e0b1a2e2195ba65c3fa8731dfc0 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-rest-id-elision.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Rest element following elision elements (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var iterCount = 0; + +for (var [ , , ...x] = values; iterCount < 1; ) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-rest-id-exhausted.js b/test/language/statements/for/dstr-var-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..74429b7ae8e1b023e7833ed56c9b28d5ea0feb91 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/for-var.template +/*--- +description: RestElement applied to an exhausted iterator (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [Symbol.iterator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var iterCount = 0; + +for (var [, , ...x] = [1, 2]; iterCount < 1; ) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/for/dstr-var-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..f5118d831cfd527d4dd81030e29616c8749f2183 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/for-var.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +assert.throws(Test262Error, function() { + for (var [...x] = iter; iterCount < 1; ) { + return; + } +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/for/dstr-var-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..4a8923e4b21162c271e7fad83a5aa98e6a742d5e --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/for-var.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [Symbol.iterator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +assert.throws(Test262Error, function() { + for (var [...x] = iter; iterCount < 1; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-rest-id.js b/test/language/statements/for/dstr-var-ary-ptrn-rest-id.js new file mode 100644 index 0000000000000000000000000000000000000000..2686d68c6c54cbd0471a6abc560718e1e2f3bd8f --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-rest-id.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Lone rest element (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var iterCount = 0; + +for (var [...x] = values; iterCount < 1; ) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-rest-init-ary.js b/test/language/statements/for/dstr-var-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..a8c12fcb75ece812804aaa5584ab17b4840348c4 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-rest-init-ary.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Reset element (nested array pattern) does not support initializer (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (var [...[ x ] = []] = []; iterCount < 1; ) { + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-rest-init-id.js b/test/language/statements/for/dstr-var-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000000000000000000000000000000000..5252a5ba361be2bbf67bec092ded374451c31a85 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-rest-init-id.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Reset element (identifier) does not support initializer (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (var [...x = []] = []; iterCount < 1; ) { + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-rest-init-obj.js b/test/language/statements/for/dstr-var-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..43df2f1a7372b600179de364a3274a80dff7b06f --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-rest-init-obj.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Reset element (nested object pattern) does not support initializer (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (var [...{ x } = []] = []; iterCount < 1; ) { + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-rest-not-final-ary.js b/test/language/statements/for/dstr-var-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..aed59f853cdb1bc3e3714c4b0e21733d8dd021e9 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (var [...[x], y] = [1, 2, 3]; iterCount < 1; ) { + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-rest-not-final-id.js b/test/language/statements/for/dstr-var-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000000000000000000000000000000000..97f03b6dfd9055ba7798e72a3c417cb058889fc0 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Rest element (identifier) may not be followed by any element (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (var [...x, y] = [1, 2, 3]; iterCount < 1; ) { + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-rest-not-final-obj.js b/test/language/statements/for/dstr-var-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..6c9ada3c3a4f24f4ef0015f05d03a55e8879b1e9 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (for statement) +esid: sec-for-statement-runtime-semantics-labelledevaluation +es6id: 13.7.4.7 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var iterCount = 0; + +for (var [...{ x }, y] = [1, 2, 3]; iterCount < 1; ) { + + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-rest-obj-id.js b/test/language/statements/for/dstr-var-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..2ea58d75f079a96a78f2ab944f01a70172c7ad47 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-rest-obj-id.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Rest element containing an object binding pattern (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var iterCount = 0; + +for (var [...{ length }] = [1, 2, 3]; iterCount < 1; ) { + assert.sameValue(length, 3); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/for/dstr-var-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..825201e52e50df4ed5c95df90adf964e714b8412 --- /dev/null +++ b/test/language/statements/for/dstr-var-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Rest element containing an object binding pattern (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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var iterCount = 0; + +for (var [...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]; iterCount < 1; ) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-obj-init-null.js b/test/language/statements/for/dstr-var-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..2644b745c3bb21ffbf0b51f4045be8afae288bfd --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-init-null.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/for-var.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (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. + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +assert.throws(TypeError, function() { + for (var {} = null; iterCount < 1; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-var-obj-init-undefined.js b/test/language/statements/for/dstr-var-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..629330912814b463c02f9b361eea2d8b8c99be12 --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-init-undefined.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/for-var.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (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. + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +assert.throws(TypeError, function() { + for (var {} = undefined; iterCount < 1; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-empty.js b/test/language/statements/for/dstr-var-obj-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..f73b1dc6376f73bddb90d56487875e7ced5432cb --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-empty.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/for-var.template +/*--- +description: No property access occurs for an "empty" object binding pattern (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. + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var iterCount = 0; + +for (var {} = obj; iterCount < 1; ) { + assert.sameValue(accessCount, 0); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-id-get-value-err.js b/test/language/statements/for/dstr-var-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..858960fa76b326acacf0b570302c673a14053808 --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-id-get-value-err.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/for-var.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + for (var { poisoned } = poisonedProperty; iterCount < 1; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/for/dstr-var-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..180e436c4d4055f166618d753002a6acbe86854a --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/for-var.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (var { arrow = () => {} } = {}; iterCount < 1; ) { + assert.sameValue(arrow.name, 'arrow'); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-id-init-fn-name-class.js b/test/language/statements/for/dstr-var-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..098865e4c95555ec4c45977249a3354bfb7a5de5 --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/for-var.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (var { cls = class {}, xCls = class X {} } = {}; iterCount < 1; ) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-id-init-fn-name-cover.js b/test/language/statements/for/dstr-var-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..65f48d171e58a7fac90d6eaef52b14fc2609fcb9 --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/for-var.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (var { cover = (function () {}), xCover = (0, function() {}) } = {}; iterCount < 1; ) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-id-init-fn-name-fn.js b/test/language/statements/for/dstr-var-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..38a67a7854217358b0a4bc217eeb2244a747f447 --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/for-var.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (var { fn = function () {}, xFn = function x() {} } = {}; iterCount < 1; ) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-id-init-fn-name-gen.js b/test/language/statements/for/dstr-var-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..51dfc4653117e24bfc5a68febdf6cd1393bfa921 --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/for-var.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var iterCount = 0; + +for (var { gen = function* () {}, xGen = function* x() {} } = {}; iterCount < 1; ) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-id-init-skipped.js b/test/language/statements/for/dstr-var-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..6270ca00a0d330da6118c95694172d84b4ad7507 --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-id-init-skipped.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; + +for (var { w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }; iterCount < 1; ) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-id-init-throws.js b/test/language/statements/for/dstr-var-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..28e2da167987091d3d5d2ed85c112600820559be --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-id-init-throws.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/for-var.template +/*--- +description: Error thrown when evaluating the initializer (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + for (var { x = thrower() } = {}; iterCount < 1; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-id-init-unresolvable.js b/test/language/statements/for/dstr-var-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..5b8ddf96030fa50abdda1887d54296df441251bb --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/for-var.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + for (var { x = unresolvableReference } = {}; iterCount < 1; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-id-trailing-comma.js b/test/language/statements/for/dstr-var-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..f8dde68bdbc4562eea0202d3128f945ef2ebf9a4 --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; + +for (var { x, } = { x: 23 }; iterCount < 1; ) { + assert.sameValue(x, 23); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-list-err.js b/test/language/statements/for/dstr-var-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..88af6ee20f1df3238ea2c95e64a67f79f4e93f49 --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-list-err.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/for-var.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + for (var { a, b = thrower(), c = ++initCount } = {}; iterCount < 1; ) { + return; + } +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-prop-ary-init.js b/test/language/statements/for/dstr-var-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000000000000000000000000000000000..962abc92e521076d64c2b8e772ad0a4d72b85640 --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-prop-ary-init.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; + +for (var { w: [x, y, z] = [4, 5, 6] } = {}; iterCount < 1; ) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-prop-ary-trailing-comma.js b/test/language/statements/for/dstr-var-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..2a2b3438f027c7ab3549a1dcc976c9f422a57d88 --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; + +for (var { x: [y], } = { x: [45] }; iterCount < 1; ) { + assert.sameValue(y,45); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-prop-ary-value-null.js b/test/language/statements/for/dstr-var-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..30ea5524e573a53a6e51487a8ed539e47193fecb --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/for-var.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + for (var { w: [x, y, z] = [4, 5, 6] } = { w: null }; iterCount < 1; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-prop-ary.js b/test/language/statements/for/dstr-var-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..0e42d93900fa7ea9476cfc99d1f7c6190b04fff6 --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-prop-ary.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; + +for (var { w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }; iterCount < 1; ) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-prop-eval-err.js b/test/language/statements/for/dstr-var-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..5a63f24b151e4fea47e5c492949972d04e55b96b --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-prop-eval-err.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/for-var.template +/*--- +description: Evaluation of property name returns an abrupt completion (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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + for (var { [thrower()]: x } = {}; iterCount < 1; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/for/dstr-var-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..d308d903ded52db9ba8d3ac167447ae6ebd0b316 --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/for-var.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + for (var { poisoned: x = ++initEvalCount } = poisonedProperty; iterCount < 1; ) { + return; + } +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/for/dstr-var-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..484b495d049a087d5838857a9d2a270c98426d22 --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var iterCount = 0; + +for (var { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }; iterCount < 1; ) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-prop-id-init-throws.js b/test/language/statements/for/dstr-var-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..fa24e3937069284f622b873f51ace1a44d48cb7a --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/for-var.template +/*--- +description: Error thrown when evaluating the initializer (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + for (var { x: y = thrower() } = {}; iterCount < 1; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/for/dstr-var-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..23bb3faadfea1effd269ec9b53e590913ab188eb --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/for-var.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + for (var { x: y = unresolvableReference } = {}; iterCount < 1; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-prop-id-init.js b/test/language/statements/for/dstr-var-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..2371fc067d20bf4d90cb264ad55ee394b9b2431a --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-prop-id-init.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Binding as specified via property name, identifier, and initializer (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var { x: y = 33 } = { }; iterCount < 1; ) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-prop-id-trailing-comma.js b/test/language/statements/for/dstr-var-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..254ae9faad3af82301288185071ac2801a1dd707 --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var iterCount = 0; + +for (var { x: y, } = { x: 23 }; iterCount < 1; ) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-prop-id.js b/test/language/statements/for/dstr-var-obj-ptrn-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..bb8573a3b714eff8daa8a124f3828510dc0fe8f5 --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-prop-id.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Binding as specified via property name and identifier (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var iterCount = 0; + +for (var { x: y } = { x: 23 }; iterCount < 1; ) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-prop-obj-init.js b/test/language/statements/for/dstr-var-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000000000000000000000000000000000..cf4e6e15ccc963bb48d3f11c470519cb18cd7075 --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-prop-obj-init.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; + +for (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }; iterCount < 1; ) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-prop-obj-value-null.js b/test/language/statements/for/dstr-var-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..ab19295fe147c77c98c80b5f930b80e246486f49 --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/for-var.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + for (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }; iterCount < 1; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/for/dstr-var-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..480e281e9a3f13feac111c1ca3a6627f50ffdc0a --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/for-var.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + for (var { w: { x, y, z } = undefined } = { }; iterCount < 1; ) { + return; + } +}); diff --git a/test/language/statements/for/dstr-var-obj-ptrn-prop-obj.js b/test/language/statements/for/dstr-var-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..f119b1fcba5e3777e0d58f81e45ada1625011563 --- /dev/null +++ b/test/language/statements/for/dstr-var-obj-ptrn-prop-obj.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/for-var.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var iterCount = 0; + +for (var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }; iterCount < 1; ) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + iterCount += 1; +} + +assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); diff --git a/test/language/statements/function/dstr-ary-init-iter-close.js b/test/language/statements/function/dstr-ary-init-iter-close.js new file mode 100644 index 0000000000000000000000000000000000000000..5c9185d85b0a46291e569ebb16d4159b454c16d8 --- /dev/null +++ b/test/language/statements/function/dstr-ary-init-iter-close.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +function f([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; +}; +f(iter); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-init-iter-get-err.js b/test/language/statements/function/dstr-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..6cdeb5a135f63610bd34e72d12320d72dde2230f --- /dev/null +++ b/test/language/statements/function/dstr-ary-init-iter-get-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Abrupt completion returned by GetIterator (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +function f([x]) {} + +assert.throws(Test262Error, function() { + f(iter); +}); diff --git a/test/language/statements/function/dstr-ary-init-iter-no-close.js b/test/language/statements/function/dstr-ary-init-iter-no-close.js new file mode 100644 index 0000000000000000000000000000000000000000..184d8a720b2d311ed9ae94bace418788e89bd7ae --- /dev/null +++ b/test/language/statements/function/dstr-ary-init-iter-no-close.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +function f([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; +}; +f(iter); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-name-iter-val.js b/test/language/statements/function/dstr-ary-name-iter-val.js index e74bf9acc6a7bb34a12afc8a80582ef3a5311f57..112279883d7e466c0978ecd20b5f45734cb9568b 100644 --- a/test/language/statements/function/dstr-ary-name-iter-val.js +++ b/test/language/statements/function/dstr-ary-name-iter-val.js @@ -3,7 +3,9 @@ // - src/dstr-binding/default/func-decl.template /*--- description: SingleNameBinding with normal value iteration (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject es6id: 14.1.19 +features: [destructuring-binding] flags: [generated] info: | FunctionDeclaration : @@ -66,4 +68,4 @@ function f([x, y, z]) { callCount = callCount + 1; }; f([1, 2, 3]); -assert.sameValue(callCount, 1); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/function/dstr-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000000000000000000000000000000000..d2ee1f7757ff214b9224cc4de2f394758e9d7ed9 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function f([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/function/dstr-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..0cf8731c4c30ff66c08340ced7ae2a5734576f1c --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function f([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; +}; +f([[7, 8, 9]]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/function/dstr-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000000000000000000000000000000000..cbb9bb562107d596902ba6140fac02c1d29ac17a --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is used (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +function f([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/function/dstr-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..3e48ab4dea59f76c2e317fa595321dd99b4fc73b --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +function f([[,] = g()]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; +}; +f([[]]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/function/dstr-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000000000000000000000000000000000..0648728f1cdf3716e6700b3c36e45f613dce835f --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +function f([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/function/dstr-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..9538cdfa0c913e5c7920c4dd1c916a7a19136df0 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +function f([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f([[23]]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/function/dstr-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000000000000000000000000000000000..c18987a3c5101d89e1b5152716599232271abc5b --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +function f([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/function/dstr-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..2481fd04e4333178a7f816d58993b969cf196fed --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +function f([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f([values]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-ary-val-null.js b/test/language/statements/function/dstr-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..145b42d5192c39ecbd8580ce0f6c4a9cf6274637 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Nested array destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +function f([[x]]) {} + +assert.throws(TypeError, function() { + f([null]); +}); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/function/dstr-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..24c74d07518681a82fef7c1791ea9e0b3d183b16 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Destructuring initializer with an exhausted iterator (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/function/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..0c29f3d5f091514ef6ed45a2ab6c5fb48d8dd59f --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding does assign name to arrow functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/function/dstr-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..d45ea5f54189d8cf49417501ccd351d07fb14964 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([cls = class {}, xCls = class X {}]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/function/dstr-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..b733c14841c5bd97dff2774b981768effa3c3371 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/function/dstr-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..4ac3bb4f8b9bef5b9360c7af137880e9fbeedfe4 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/function/dstr-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..677d2202fb5f046cd9ccc1bd00f88b2bb37bfcff --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-id-init-hole.js b/test/language/statements/function/dstr-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000000000000000000000000000000000..bb6f6fd80ddf30c3a144b68eb978a85241eb5b32 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Destructuring initializer with a "hole" (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([x = 23]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; +}; +f([,]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/function/dstr-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..be7c05a30615896f6ebacc6c3f60fb0e2832232e --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +function f([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f([null, 0, false, '']); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-id-init-throws.js b/test/language/statements/function/dstr-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..ed4a40360a620ade5f0df85a08efd5d7533d1f00 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Destructuring initializer returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +function f([x = (function() { throw new Test262Error(); })()]) {} + +assert.throws(Test262Error, function() { + f([undefined]); +}); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-id-init-undef.js b/test/language/statements/function/dstr-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..21d9df6eba358f333e4be2d4f8107836654aee55 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Destructuring initializer with an undefined value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; +f([undefined]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/function/dstr-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..f2a3f219485e559d065136e655d0f2a8e5144c71 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +function f([ x = unresolvableReference ]) {} + +assert.throws(ReferenceError, function() { + f([]); +}); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/function/dstr-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000000000000000000000000000000000..efbdc6d88fff2187afc85dd41f9b06665cc26dec --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding when value iteration completes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-id-iter-done.js b/test/language/statements/function/dstr-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000000000000000000000000000000000..6cf43ba66e9cb9f72189533ef208fda831ec17c5 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([_, x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/function/dstr-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..2a0ac62dbe691f2d3e7c3e8eb0e72a445bf3efd3 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +function f([x]) {} + +assert.throws(Test262Error, function() { + f(g); +}); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/function/dstr-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..cc49821cb1e4240cf17223ca0ef5565a4a32669b --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +function f([x]) {} + +assert.throws(Test262Error, function() { + f(g); +}); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-id-iter-val.js b/test/language/statements/function/dstr-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..7bade2dda5d35e1c64a6ef926a6fcc2ad50a3abe --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-obj-id-init.js b/test/language/statements/function/dstr-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..d196452fd11d970713734a4ee88309b690e9427c --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function f([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-obj-id.js b/test/language/statements/function/dstr-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..c0dbe0c288291e85796b885399f57369661cd381 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-obj-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function f([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; +}; +f([{ x: 11, y: 22, z: 33 }]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/function/dstr-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..fdc30064ff9d61ceb2645c747a43143faeb68dc8 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function f([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/function/dstr-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..be7dbe535f3c963f82bb322c29b49b538364456c --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function f([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; +f([{ u: 777, w: 888, y: 999 }]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-obj-val-null.js b/test/language/statements/function/dstr-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..e1482efd57839ec11efde5530a81e9b489b40997 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Nested object destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +function f([{ x }]) {} + +assert.throws(TypeError, function() { + f([null]); +}); diff --git a/test/language/statements/function/dstr-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/function/dstr-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..e805909dbac04afd201646ec502b150b91adc238 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Nested object destructuring with a value of `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +function f([{ x }]) {} + +assert.throws(TypeError, function() { + f([]); +}); diff --git a/test/language/statements/function/dstr-ary-ptrn-elision-exhausted.js b/test/language/statements/function/dstr-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..5c7bf9ed0a0e1a01bbc644cad9cafc8bd5c1c6d3 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elision-exhausted.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Elision accepts exhausted iterator (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +function f([,]) { + + callCount = callCount + 1; +}; +f(iter); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elision-step-err.js b/test/language/statements/function/dstr-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..9007aa21b46e572facd2117a6df6e411a047e826 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elision-step-err.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Elision advances iterator and forwards abrupt completions (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +function f([,]) {} + +assert.throws(Test262Error, function() { + f(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/function/dstr-ary-ptrn-elision.js b/test/language/statements/function/dstr-ary-ptrn-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..f909886d89320a6a34ff67271f3692aba7195adc --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-elision.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Elision advances iterator (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +function f([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; +f(g()); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-empty.js b/test/language/statements/function/dstr-ary-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..9c09e7bc782becff3447447462642dfa8955ffa1 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-empty.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +function f([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; +}; +f(iter); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-rest-ary-elem.js b/test/language/statements/function/dstr-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000000000000000000000000000000000..236dc5787a12c1fc506a62dcae5c6d462a6bd518 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest element containing an array BindingElementList pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; +}; +f([3, 4, 5]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-rest-ary-elision.js b/test/language/statements/function/dstr-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..7fa466faa830ce05e850d6cd16f8810e2a210fb5 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest element containing an elision (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +function f([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; +}; +f(g()); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-rest-ary-empty.js b/test/language/statements/function/dstr-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..b31d31d592c635e88ac970bed5f58d712a4e25b1 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest element containing an "empty" array pattern (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +function f([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; +}; +f(iter); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-rest-ary-rest.js b/test/language/statements/function/dstr-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..8315404c23390e33a648a73ea36cbed2dfc50716 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest element containing a rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +function f([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; +}; +f(values); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/function/dstr-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..72d66cfe225eaeb452440d7828911042317ae544 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Rest element following elision elements (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +function f([, ...x]) {} + +assert.throws(Test262Error, function() { + f(iter); +}); diff --git a/test/language/statements/function/dstr-ary-ptrn-rest-id-elision.js b/test/language/statements/function/dstr-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..30b41b5397fe81ddcf382bd0396d71baf981ed25 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-rest-id-elision.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest element following elision elements (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +function f([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; +f(values); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-rest-id-exhausted.js b/test/language/statements/function/dstr-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..c4779d395cc9facbdfb12a1eb69c540255d5380e --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: RestElement applied to an exhausted iterator (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +function f([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; +}; +f([1, 2]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/function/dstr-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..9b7e9da81d531450110951f9a456a8b44d193d66 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +function f([...x]) {} + +assert.throws(Test262Error, function() { + f(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/function/dstr-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/function/dstr-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..2f4bbab2f5171da211f2c31b8895ad0f146008a1 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +function f([...x]) {} + +assert.throws(Test262Error, function() { + f(iter); +}); diff --git a/test/language/statements/function/dstr-ary-ptrn-rest-id.js b/test/language/statements/function/dstr-ary-ptrn-rest-id.js new file mode 100644 index 0000000000000000000000000000000000000000..d162edd672b8a53d16c0e8865cc4cd8543b24040 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-rest-id.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Lone rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +function f([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; +f(values); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-rest-init-ary.js b/test/language/statements/function/dstr-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..461e1136d8df07d610414ace1fc4958d205aed76 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-rest-init-ary.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Reset element (nested array pattern) does not support initializer (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +function f([...[ x ] = []]) { + + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-rest-init-id.js b/test/language/statements/function/dstr-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000000000000000000000000000000000..99cf94a917f9e3982008ff8cd93874f962a05e60 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-rest-init-id.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Reset element (identifier) does not support initializer (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +function f([...x = []]) { + + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-rest-init-obj.js b/test/language/statements/function/dstr-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..79b0e76525f49393aa2e400cfe8cff7c986689c8 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-rest-init-obj.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Reset element (nested object pattern) does not support initializer (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +function f([...{ x } = []]) { + + callCount = callCount + 1; +}; +f([]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-rest-not-final-ary.js b/test/language/statements/function/dstr-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..0101f587656662045904e973daecbff8566265f5 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +function f([...[x], y]) { + + callCount = callCount + 1; +}; +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-rest-not-final-id.js b/test/language/statements/function/dstr-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000000000000000000000000000000000..04cbc7eb0cec454c131766595596f7643ec0a3cc --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest element (identifier) may not be followed by any element (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +function f([...x, y]) { + + callCount = callCount + 1; +}; +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-rest-not-final-obj.js b/test/language/statements/function/dstr-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..68160f30ea195ec5b4974f65ee8afc94ca9e9646 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +function f([...{ x }, y]) { + + callCount = callCount + 1; +}; +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-rest-obj-id.js b/test/language/statements/function/dstr-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..301760da0a3a735426d1d5193f5becb8d11672f6 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-rest-obj-id.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +function f([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; +}; +f([1, 2, 3]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/function/dstr-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..55c13c44c8a5abac757a5684a3accdce75ecd1c1 --- /dev/null +++ b/test/language/statements/function/dstr-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +function f([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; +}; +f([7, 8, 9]); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-obj-init-null.js b/test/language/statements/function/dstr-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..cb8fdbc574237a1c5e2e7669f7854f0ea984dffe --- /dev/null +++ b/test/language/statements/function/dstr-obj-init-null.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +function f({}) {} + +assert.throws(TypeError, function() { + f(null); +}); diff --git a/test/language/statements/function/dstr-obj-init-undefined.js b/test/language/statements/function/dstr-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..9515a023c78cb824593f857ad7c98b6a905e4831 --- /dev/null +++ b/test/language/statements/function/dstr-obj-init-undefined.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +function f({}) {} + +assert.throws(TypeError, function() { + f(undefined); +}); diff --git a/test/language/statements/function/dstr-obj-ptrn-empty.js b/test/language/statements/function/dstr-obj-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..e3b4f54c93a56b8789c342743ba8b43bc99adcca --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-empty.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: No property access occurs for an "empty" object binding pattern (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +function f({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; +}; +f(obj); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-obj-ptrn-id-get-value-err.js b/test/language/statements/function/dstr-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..467fa72b7d459b4412594d1f694ee64359a84981 --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-id-get-value-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +function f({ poisoned }) {} + +assert.throws(Test262Error, function() { + f(poisonedProperty); +}); diff --git a/test/language/statements/function/dstr-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/function/dstr-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..7e4bc26c50199c8b70ca9c6721c00f2e41067f30 --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function f({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; +f({}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-obj-ptrn-id-init-fn-name-class.js b/test/language/statements/function/dstr-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..f0c526cfe5cb07a0eb8758f80ca844617c8ad1d1 --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function f({ cls = class {}, xCls = class X {} }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; +}; +f({}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-obj-ptrn-id-init-fn-name-cover.js b/test/language/statements/function/dstr-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..5f6b69c30d52ab21a4e8ecf6f726496917734276 --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function f({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; +f({}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-obj-ptrn-id-init-fn-name-fn.js b/test/language/statements/function/dstr-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..52a95100f6fa3a78840664e3195cf0db27df3d43 --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function f({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; +f({}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-obj-ptrn-id-init-fn-name-gen.js b/test/language/statements/function/dstr-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..db0a16361d704aa255fbdf1c6782e75cfab98cc5 --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function f({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; +f({}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-obj-ptrn-id-init-skipped.js b/test/language/statements/function/dstr-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..e7abf9c40fa9b3fd152f50dc238a6a4f0e83466f --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-id-init-skipped.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +function f({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f({ w: null, x: 0, y: false, z: '' }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-obj-ptrn-id-init-throws.js b/test/language/statements/function/dstr-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..f1ff93cdd96da45ae708a1dba2f4aff26516d6b4 --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-id-init-throws.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +function f({ x = thrower() }) {} + +assert.throws(Test262Error, function() { + f({}); +}); diff --git a/test/language/statements/function/dstr-obj-ptrn-id-init-unresolvable.js b/test/language/statements/function/dstr-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..a2563ab2b29e5345122b354f73d269cff087676c --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +function f({ x = unresolvableReference }) {} + +assert.throws(ReferenceError, function() { + f({}); +}); diff --git a/test/language/statements/function/dstr-obj-ptrn-id-trailing-comma.js b/test/language/statements/function/dstr-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..989036225b05089d473139b5d6754fddd61ea347 --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +function f({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; +f({ x: 23 }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-obj-ptrn-list-err.js b/test/language/statements/function/dstr-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..ee163626cb181bfb0f9570b9f3084b3384cca7b6 --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-list-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +function f({ a, b = thrower(), c = ++initCount }) {} + +assert.throws(Test262Error, function() { + f({}); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/function/dstr-obj-ptrn-prop-ary-init.js b/test/language/statements/function/dstr-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000000000000000000000000000000000..ef74906b70977ff5c2bf6b8e843d6bc30c6070ad --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-prop-ary-init.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +function f({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f({}); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-obj-ptrn-prop-ary-trailing-comma.js b/test/language/statements/function/dstr-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..ef7d1be688632b6c9707d3280bdcfec69f6bba9e --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +function f({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; +}; +f({ x: [45] }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-obj-ptrn-prop-ary-value-null.js b/test/language/statements/function/dstr-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..b19dccccfd972753ffe682a846c087cbe65fbce0 --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +function f({ w: [x, y, z] = [4, 5, 6] }) {} + +assert.throws(TypeError, function() { + f({ w: null }); +}); diff --git a/test/language/statements/function/dstr-obj-ptrn-prop-ary.js b/test/language/statements/function/dstr-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..7a804b9768367cf9334111968145534401309b76 --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-prop-ary.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +function f({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f({ w: [7, undefined, ] }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-obj-ptrn-prop-eval-err.js b/test/language/statements/function/dstr-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..5614b44945231c0953f689ed896ee8297aa774ef --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-prop-eval-err.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Evaluation of property name returns an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +function f({ [thrower()]: x }) {} + +assert.throws(Test262Error, function() { + f({}); +}); diff --git a/test/language/statements/function/dstr-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/function/dstr-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..d31fcde6f39d773cc7f3af6634a356a77c6b55e3 --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +function f({ poisoned: x = ++initEvalCount }) {} + +assert.throws(Test262Error, function() { + f(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/function/dstr-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/function/dstr-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..9c598bb48d5b4ed9f3911b0bf7b4da339ea89bed --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +function f({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; +f({ s: null, u: 0, w: false, y: '' }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-obj-ptrn-prop-id-init-throws.js b/test/language/statements/function/dstr-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..b029181c954c3c57b7a9cc950d74991df9eb176e --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +function f({ x: y = thrower() }) {} + +assert.throws(Test262Error, function() { + f({}); +}); diff --git a/test/language/statements/function/dstr-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/function/dstr-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..95029ae6972305fdfc6c0b92c1fa9b373e41a458 --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +function f({ x: y = unresolvableReference }) {} + +assert.throws(ReferenceError, function() { + f({}); +}); diff --git a/test/language/statements/function/dstr-obj-ptrn-prop-id-init.js b/test/language/statements/function/dstr-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..2fa53dbf1ce603fc42d1452c28e6e795b852c68a --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-prop-id-init.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Binding as specified via property name, identifier, and initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; +f({ }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-obj-ptrn-prop-id-trailing-comma.js b/test/language/statements/function/dstr-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..723611af27a24d4f693f723fa4d8551f9bbc34b3 --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +function f({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; +f({ x: 23 }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-obj-ptrn-prop-id.js b/test/language/statements/function/dstr-obj-ptrn-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..83e7a3017453f5b9f6b6d091d7d6bbfac7b22641 --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-prop-id.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Binding as specified via property name and identifier (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; +f({ x: 23 }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-obj-ptrn-prop-obj-init.js b/test/language/statements/function/dstr-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000000000000000000000000000000000..c335cda5d393a78d8838a8076d1ea20287d7e6b7 --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-prop-obj-init.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +function f({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f({ w: undefined }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-obj-ptrn-prop-obj-value-null.js b/test/language/statements/function/dstr-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..886d9bc4c272cd89c7196d518cf40a9ace9f775a --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +function f({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) {} + +assert.throws(TypeError, function() { + f({ w: null }); +}); diff --git a/test/language/statements/function/dstr-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/function/dstr-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..17aa6dd3c4e5ed8f6166fa52a197ca6ba9da74e0 --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/func-decl.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +function f({ w: { x, y, z } = undefined }) {} + +assert.throws(TypeError, function() { + f({ }); +}); diff --git a/test/language/statements/function/dstr-obj-ptrn-prop-obj.js b/test/language/statements/function/dstr-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..9535d377ba849711799cfeae9330558c9b2fecaf --- /dev/null +++ b/test/language/statements/function/dstr-obj-ptrn-prop-obj.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +function f({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f({ w: { x: undefined, z: 7 } }); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-init-iter-close.js b/test/language/statements/generators/dstr-ary-init-iter-close.js new file mode 100644 index 0000000000000000000000000000000000000000..7493355382cbffdb33197c3888fda732b37c0dc4 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-init-iter-close.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +function* f([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; +}; +f(iter).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-init-iter-get-err.js b/test/language/statements/generators/dstr-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..340e60c50bdf74327c28f91f6c1c6f0b9d17b983 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-init-iter-get-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/gen-func-decl.template +/*--- +description: Abrupt completion returned by GetIterator (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +function* f([x]) {} + +assert.throws(Test262Error, function() { + f(iter); +}); diff --git a/test/language/statements/generators/dstr-ary-init-iter-no-close.js b/test/language/statements/generators/dstr-ary-init-iter-no-close.js new file mode 100644 index 0000000000000000000000000000000000000000..33b36cf473d91943962e6e5f02235ba236203fa1 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-init-iter-no-close.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +function* f([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; +}; +f(iter).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-name-iter-val.js b/test/language/statements/generators/dstr-ary-name-iter-val.js index 1db7c761a2abb6037cefd0decc89a18dd380f0c0..62ca40ba1aa26f140a7e9fc7fdd529a447f99278 100644 --- a/test/language/statements/generators/dstr-ary-name-iter-val.js +++ b/test/language/statements/generators/dstr-ary-name-iter-val.js @@ -3,7 +3,9 @@ // - src/dstr-binding/default/gen-func-decl.template /*--- description: SingleNameBinding with normal value iteration (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 } @@ -65,4 +67,4 @@ function* f([x, y, z]) { callCount = callCount + 1; }; f([1, 2, 3]).next(); -assert.sameValue(callCount, 1); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/generators/dstr-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000000000000000000000000000000000..178b968551a6c1a9215e9083e843a1d9e3d2ccff --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function* f([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; +}; +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/generators/dstr-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..b60799f56d698599b7c684d9babe49d917214847 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function* f([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; +}; +f([[7, 8, 9]]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/generators/dstr-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000000000000000000000000000000000..b188b9f73ca2ee06e89952f07f5160149c055e0c --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is used (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +function* f([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/generators/dstr-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..2697aa99ae00bfd81409ccc4ce71e5d0194d8243 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +function* f([[,] = g()]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; +}; +f([[]]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/generators/dstr-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000000000000000000000000000000000..e18c81d65a054965a6b9c6b94754ac86d97ed3b0 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +function* f([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; +}; +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/generators/dstr-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..e4d52d05080c90160ae3549d2b9d949e14680a19 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +function* f([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f([[23]]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/generators/dstr-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000000000000000000000000000000000..7bd385940144c7d992a6d4365cc39386e3b57475 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +function* f([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/generators/dstr-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..feadf2ea1e43f3a82eeaf3a3b224e29e980d5c9e --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +function* f([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f([values]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-ary-val-null.js b/test/language/statements/generators/dstr-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..51027c061df55758676236b8f3692994f50c1a09 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/gen-func-decl.template +/*--- +description: Nested array destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +function* f([[x]]) {} + +assert.throws(TypeError, function() { + f([null]); +}); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..f17730b33b5fdf9b9799bdf8cd29e637438a0722 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Destructuring initializer with an exhausted iterator (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..b3c9b01d8c1da36666e93cf4c42ec77d897503da --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: SingleNameBinding does assign name to arrow functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..a18868f0977f91aa95cf8ba1fe12221a0b0c5416 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f([cls = class {}, xCls = class X {}]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; +}; +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..cc047bc3e290e7099c221745c2d85df85f90485b --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..cfb41aba0616827eaeff97ed5bb0d7a540891660 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..9b58c8b5024166727556aa0ef4927f2adbbfc042 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-hole.js b/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000000000000000000000000000000000..12fb735bab367d984dd96d5b13c558cfc660a48e --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Destructuring initializer with a "hole" (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f([x = 23]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; +}; +f([,]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..60056c98b73dd5bd5d145e71bf72554e88230d17 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +function* f([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f([null, 0, false, '']).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-throws.js b/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..9ed3b6a24b399d0b668414c0b4d17d4887feea1a --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/gen-func-decl.template +/*--- +description: Destructuring initializer returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +function* f([x = (function() { throw new Test262Error(); })()]) {} + +assert.throws(Test262Error, function() { + f([undefined]); +}); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-undef.js b/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..2acdbed966f627aeb6714e644a79d663dab4262d --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Destructuring initializer with an undefined value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; +f([undefined]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..51412028b4eacc62c28afc238416cc38e9476a1f --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/gen-func-decl.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +function* f([ x = unresolvableReference ]) {} + +assert.throws(ReferenceError, function() { + f([]); +}); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/generators/dstr-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000000000000000000000000000000000..48168560d03c741e0c77420244f5ebde98c9d71b --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: SingleNameBinding when value iteration completes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f([x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-id-iter-done.js b/test/language/statements/generators/dstr-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000000000000000000000000000000000..1339789f1347ba851507eb74ce54e08b62641ed7 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f([_, x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/generators/dstr-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..50dab22fc1a8c780ceb866f9ab5e2483d957c36d --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/gen-func-decl.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +function* f([x]) {} + +assert.throws(Test262Error, function() { + f(g); +}); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/generators/dstr-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..f54cb007dd53aa8addc1744b4790699f690ef74c --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/gen-func-decl.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +function* f([x]) {} + +assert.throws(Test262Error, function() { + f(g); +}); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-id-iter-val.js b/test/language/statements/generators/dstr-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..1e9303ce4b6160abb78f8599daeb9be23e033b1a --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; +f([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-obj-id-init.js b/test/language/statements/generators/dstr-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..65ccc831f3051706ad42fe212de04830222b8399 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function* f([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; +}; +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-obj-id.js b/test/language/statements/generators/dstr-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..f8d86ab2f9e0f75b3c50a2130ac16d66993ad844 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-obj-id.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function* f([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; +}; +f([{ x: 11, y: 22, z: 33 }]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/generators/dstr-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..aef44d6891026f40e0881fa619c3e163dc52b943 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function* f([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/generators/dstr-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..20d25962ca7c98c9ebe83359af05ed6dcb1c7c21 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function* f([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; +f([{ u: 777, w: 888, y: 999 }]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-obj-val-null.js b/test/language/statements/generators/dstr-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..057d0bcb739decdeaf3af5d44b93e6f80349c088 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/gen-func-decl.template +/*--- +description: Nested object destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +function* f([{ x }]) {} + +assert.throws(TypeError, function() { + f([null]); +}); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/generators/dstr-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..f21bafeaca7008ef27095a6aa38267076d8ec9b1 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/gen-func-decl.template +/*--- +description: Nested object destructuring with a value of `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +function* f([{ x }]) {} + +assert.throws(TypeError, function() { + f([]); +}); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elision-exhausted.js b/test/language/statements/generators/dstr-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..1abef06ef5a3e95550fb4cb5e034a8c8c958ad6f --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elision-exhausted.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Elision accepts exhausted iterator (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +function* f([,]) { + + callCount = callCount + 1; +}; +f(iter).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elision-step-err.js b/test/language/statements/generators/dstr-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..0aaa561b202e81fa7779bdb109c6a08c6e898649 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elision-step-err.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/gen-func-decl.template +/*--- +description: Elision advances iterator and forwards abrupt completions (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +function* f([,]) {} + +assert.throws(Test262Error, function() { + f(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-elision.js b/test/language/statements/generators/dstr-ary-ptrn-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..e9d2a5b773ab05b5e9558f470cb00c221c9357fb --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-elision.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Elision advances iterator (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +function* f([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; +f(g()).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-empty.js b/test/language/statements/generators/dstr-ary-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..f45982db7c781e0ff1596485daf808ebb8ad6940 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-empty.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +function* f([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; +}; +f(iter).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-rest-ary-elem.js b/test/language/statements/generators/dstr-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000000000000000000000000000000000..b140b5ec8d593a2ff3dab4d56db6e5f53c7808dc --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Rest element containing an array BindingElementList pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; +}; +f([3, 4, 5]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-rest-ary-elision.js b/test/language/statements/generators/dstr-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..dc098c61efa7fd9af2d028da9b85b047fee75897 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Rest element containing an elision (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +function* f([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; +}; +f(g()).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-rest-ary-empty.js b/test/language/statements/generators/dstr-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..f80ba909acd1fc8071c955952520e2c1b5a8aed1 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Rest element containing an "empty" array pattern (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +function* f([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; +}; +f(iter).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-rest-ary-rest.js b/test/language/statements/generators/dstr-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..3d11c6650c6e04235238bebc782c9cdd8e375485 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Rest element containing a rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +function* f([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; +}; +f(values).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/generators/dstr-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..77147ebe100989ecc86546be2b14a8a99f47d59b --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/gen-func-decl.template +/*--- +description: Rest element following elision elements (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +function* f([, ...x]) {} + +assert.throws(Test262Error, function() { + f(iter); +}); diff --git a/test/language/statements/generators/dstr-ary-ptrn-rest-id-elision.js b/test/language/statements/generators/dstr-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..8704f0f05df1722118472d79101a53dbb1e77cb6 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-rest-id-elision.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Rest element following elision elements (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +function* f([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; +f(values).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-rest-id-exhausted.js b/test/language/statements/generators/dstr-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..9b47c96c35720599d81d4a5d9513622655d74b66 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: RestElement applied to an exhausted iterator (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +function* f([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; +}; +f([1, 2]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/generators/dstr-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..1fa91dc4d97c9e8a96a28d39e217ff702434be3a --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/gen-func-decl.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +function* f([...x]) {} + +assert.throws(Test262Error, function() { + f(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/generators/dstr-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..c8e4e67ceda89eccc884db9881ea9362285b04ae --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/gen-func-decl.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +function* f([...x]) {} + +assert.throws(Test262Error, function() { + f(iter); +}); diff --git a/test/language/statements/generators/dstr-ary-ptrn-rest-id.js b/test/language/statements/generators/dstr-ary-ptrn-rest-id.js new file mode 100644 index 0000000000000000000000000000000000000000..14bfa74e9b71ff94c3dcfdfb140c0143eff8bf2e --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-rest-id.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Lone rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +function* f([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; +f(values).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-rest-init-ary.js b/test/language/statements/generators/dstr-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..20c620416ddbb9fa3692f41f647e749adf793e6a --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-rest-init-ary.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Reset element (nested array pattern) does not support initializer (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +function* f([...[ x ] = []]) { + + callCount = callCount + 1; +}; +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-rest-init-id.js b/test/language/statements/generators/dstr-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000000000000000000000000000000000..83289d63c076795f034b12516d8a1c56c65dd1c3 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-rest-init-id.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Reset element (identifier) does not support initializer (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +function* f([...x = []]) { + + callCount = callCount + 1; +}; +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-rest-init-obj.js b/test/language/statements/generators/dstr-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..f68123f3936488a07b45322adc901d3b05629bc6 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-rest-init-obj.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Reset element (nested object pattern) does not support initializer (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +function* f([...{ x } = []]) { + + callCount = callCount + 1; +}; +f([]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-rest-not-final-ary.js b/test/language/statements/generators/dstr-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..9c8a41998044d6fa7bad8d342d86a72a5699c193 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +function* f([...[x], y]) { + + callCount = callCount + 1; +}; +f([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-rest-not-final-id.js b/test/language/statements/generators/dstr-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000000000000000000000000000000000..f60d2609ba813f55b7b8da326f77669bbd84074b --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Rest element (identifier) may not be followed by any element (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +function* f([...x, y]) { + + callCount = callCount + 1; +}; +f([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-rest-not-final-obj.js b/test/language/statements/generators/dstr-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..6911e19e97e1744507ad341476bb185c075aa5e2 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +function* f([...{ x }, y]) { + + callCount = callCount + 1; +}; +f([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-rest-obj-id.js b/test/language/statements/generators/dstr-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..77d59ed2387df2498ba35160fa00d573158a1096 --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-rest-obj-id.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +function* f([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; +}; +f([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/generators/dstr-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..e609bef4ed9d8c3161884536c454e2f677ba48ed --- /dev/null +++ b/test/language/statements/generators/dstr-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +function* f([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; +}; +f([7, 8, 9]).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-obj-init-null.js b/test/language/statements/generators/dstr-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..cb6058be3dde4d6fa579f3d3e7fa9213a4630e72 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-init-null.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/gen-func-decl.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +function* f({}) {} + +assert.throws(TypeError, function() { + f(null); +}); diff --git a/test/language/statements/generators/dstr-obj-init-undefined.js b/test/language/statements/generators/dstr-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..ac88fd230f9a9abb47ee979231b5d2790103ca20 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-init-undefined.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/gen-func-decl.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +function* f({}) {} + +assert.throws(TypeError, function() { + f(undefined); +}); diff --git a/test/language/statements/generators/dstr-obj-ptrn-empty.js b/test/language/statements/generators/dstr-obj-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..7e46f03ff862ff3877cb29acf9f9e738f8420a80 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-empty.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: No property access occurs for an "empty" object binding pattern (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +function* f({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; +}; +f(obj).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-obj-ptrn-id-get-value-err.js b/test/language/statements/generators/dstr-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..97ea1c238dbdd332179bcdfd61c86e2e39621a9e --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-id-get-value-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/gen-func-decl.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +function* f({ poisoned }) {} + +assert.throws(Test262Error, function() { + f(poisonedProperty); +}); diff --git a/test/language/statements/generators/dstr-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/generators/dstr-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..79d916fe40032613bf28f8016243be0233257e55 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function* f({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; +f({}).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-obj-ptrn-id-init-fn-name-class.js b/test/language/statements/generators/dstr-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..db0221af9b3fe95471f88e0b93c86acbdbc1b6c1 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function* f({ cls = class {}, xCls = class X {} }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; +}; +f({}).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-obj-ptrn-id-init-fn-name-cover.js b/test/language/statements/generators/dstr-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..d5ddaeb39f2559fee3ce1ff7a5ffbe04fbd48d1f --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function* f({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; +f({}).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-obj-ptrn-id-init-fn-name-fn.js b/test/language/statements/generators/dstr-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..c926eb58ea6f0e30cc2580513968604d1f3b99be --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function* f({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; +f({}).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-obj-ptrn-id-init-fn-name-gen.js b/test/language/statements/generators/dstr-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..c310b09f6cdffb0bcc95eedfdf7cfd714008f173 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function* f({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; +f({}).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-obj-ptrn-id-init-skipped.js b/test/language/statements/generators/dstr-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..bba7adad58f2f8e48ba5beb318ecc6a1ee37133e --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-id-init-skipped.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +function* f({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f({ w: null, x: 0, y: false, z: '' }).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-obj-ptrn-id-init-throws.js b/test/language/statements/generators/dstr-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..01bbf913f02fc3fc5e3cdb2e3ee950be4d885bf1 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-id-init-throws.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/gen-func-decl.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +function* f({ x = thrower() }) {} + +assert.throws(Test262Error, function() { + f({}); +}); diff --git a/test/language/statements/generators/dstr-obj-ptrn-id-init-unresolvable.js b/test/language/statements/generators/dstr-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..42ee0c1b23e67857ba0e981061edf611178a8540 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/gen-func-decl.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +function* f({ x = unresolvableReference }) {} + +assert.throws(ReferenceError, function() { + f({}); +}); diff --git a/test/language/statements/generators/dstr-obj-ptrn-id-trailing-comma.js b/test/language/statements/generators/dstr-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..62e6ce7267c8f76aa19c265c3c247e0724ea5e60 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +function* f({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; +f({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-obj-ptrn-list-err.js b/test/language/statements/generators/dstr-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..7f16a56fce04ff4b17abf7d589c191ccb0befca5 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-list-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/gen-func-decl.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +function* f({ a, b = thrower(), c = ++initCount }) {} + +assert.throws(Test262Error, function() { + f({}); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/generators/dstr-obj-ptrn-prop-ary-init.js b/test/language/statements/generators/dstr-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000000000000000000000000000000000..228ec11c1837f017b91c6ced5cb6439c0a3559e9 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-prop-ary-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +function* f({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f({}).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-obj-ptrn-prop-ary-trailing-comma.js b/test/language/statements/generators/dstr-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..641422256d5bcfd125154e1575f6b6a7550ed151 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +function* f({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; +}; +f({ x: [45] }).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-obj-ptrn-prop-ary-value-null.js b/test/language/statements/generators/dstr-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..8e5ac0f9b834e1a3686de6a981f36fc3f9ea05c1 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/gen-func-decl.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +function* f({ w: [x, y, z] = [4, 5, 6] }) {} + +assert.throws(TypeError, function() { + f({ w: null }); +}); diff --git a/test/language/statements/generators/dstr-obj-ptrn-prop-ary.js b/test/language/statements/generators/dstr-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..dd531adad1c423c9c5dd779e6a44baf3e2aeae18 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-prop-ary.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +function* f({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f({ w: [7, undefined, ] }).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-obj-ptrn-prop-eval-err.js b/test/language/statements/generators/dstr-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..a4a30ed6d1705f4654801373c16c430fdc2e0c87 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-prop-eval-err.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/gen-func-decl.template +/*--- +description: Evaluation of property name returns an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +function* f({ [thrower()]: x }) {} + +assert.throws(Test262Error, function() { + f({}); +}); diff --git a/test/language/statements/generators/dstr-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/generators/dstr-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..fe2f014ad72f2acca76bd642bcb316c80b96b4e0 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/gen-func-decl.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +function* f({ poisoned: x = ++initEvalCount }) {} + +assert.throws(Test262Error, function() { + f(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/generators/dstr-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/generators/dstr-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..a20f25724cf255c1b2921028d025edb663f8ef68 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +function* f({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; +f({ s: null, u: 0, w: false, y: '' }).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-obj-ptrn-prop-id-init-throws.js b/test/language/statements/generators/dstr-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..e7b9e0b85daaf3a31ae8ca6d6c0c613d63830200 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/gen-func-decl.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +function* f({ x: y = thrower() }) {} + +assert.throws(Test262Error, function() { + f({}); +}); diff --git a/test/language/statements/generators/dstr-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/generators/dstr-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..429112664fe89abd705213df8b13f15f756c7c89 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/gen-func-decl.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +function* f({ x: y = unresolvableReference }) {} + +assert.throws(ReferenceError, function() { + f({}); +}); diff --git a/test/language/statements/generators/dstr-obj-ptrn-prop-id-init.js b/test/language/statements/generators/dstr-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..1964df1ab71da0623c19d0cbe13ac8cdffcbda41 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-prop-id-init.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Binding as specified via property name, identifier, and initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; +f({ }).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-obj-ptrn-prop-id-trailing-comma.js b/test/language/statements/generators/dstr-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..cfa9d5c4fb933a1ca44b7fc5422261d7807f4707 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +function* f({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; +f({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-obj-ptrn-prop-id.js b/test/language/statements/generators/dstr-obj-ptrn-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..6563a4a9eb24ef02c3fb3cfd3425da3aad386bd8 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-prop-id.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Binding as specified via property name and identifier (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; +f({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-obj-ptrn-prop-obj-init.js b/test/language/statements/generators/dstr-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000000000000000000000000000000000..9371faf79863b16a61e5d0533ccaceae4ee8e984 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-prop-obj-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +function* f({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f({ w: undefined }).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-obj-ptrn-prop-obj-value-null.js b/test/language/statements/generators/dstr-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..27a4dd0015e77ed42efe3d60e8d0b68ad960de85 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/gen-func-decl.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +function* f({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) {} + +assert.throws(TypeError, function() { + f({ w: null }); +}); diff --git a/test/language/statements/generators/dstr-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/generators/dstr-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..a37ebfc7b59c643a6a9ac523dd48318d33515317 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/gen-func-decl.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +function* f({ w: { x, y, z } = undefined }) {} + +assert.throws(TypeError, function() { + f({ }); +}); diff --git a/test/language/statements/generators/dstr-obj-ptrn-prop-obj.js b/test/language/statements/generators/dstr-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..904d0ae16f749722479ffd4fa7b8ab38edc73b37 --- /dev/null +++ b/test/language/statements/generators/dstr-obj-ptrn-prop-obj.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +function* f({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f({ w: { x: undefined, z: 7 } }).next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/let/dstr-ary-init-iter-close.js b/test/language/statements/let/dstr-ary-init-iter-close.js new file mode 100644 index 0000000000000000000000000000000000000000..cef2b1dd7a0c70eb529cc11759b1513b2200b35f --- /dev/null +++ b/test/language/statements/let/dstr-ary-init-iter-close.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [Symbol.iterator, 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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +let [x] = iter; + +assert.sameValue(doneCallCount, 1); diff --git a/test/language/statements/let/dstr-ary-init-iter-get-err.js b/test/language/statements/let/dstr-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..106ad021528eec807fb684f35d95e85ebb2a589c --- /dev/null +++ b/test/language/statements/let/dstr-ary-init-iter-get-err.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/let-stmt.template +/*--- +description: Abrupt completion returned by GetIterator (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [Symbol.iterator, 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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + let [x] = iter; +}); diff --git a/test/language/statements/let/dstr-ary-init-iter-no-close.js b/test/language/statements/let/dstr-ary-init-iter-no-close.js new file mode 100644 index 0000000000000000000000000000000000000000..264f536177aa03bf89d2e52f602494aebfc1369f --- /dev/null +++ b/test/language/statements/let/dstr-ary-init-iter-no-close.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [Symbol.iterator, 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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +let [x] = iter; + +assert.sameValue(doneCallCount, 0); diff --git a/test/language/statements/let/dstr-ary-name-iter-val.js b/test/language/statements/let/dstr-ary-name-iter-val.js index 597676bcc39c0fea98ded9e622b6a358f452a346..fcf258c39d046d4ed736ce81b2ff27dba7ea5c7c 100644 --- a/test/language/statements/let/dstr-ary-name-iter-val.js +++ b/test/language/statements/let/dstr-ary-name-iter-val.js @@ -3,7 +3,9 @@ // - src/dstr-binding/default/let-stmt.template /*--- description: SingleNameBinding with normal value iteration (`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 diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/let/dstr-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000000000000000000000000000000000..4e77c3a60369d9af5364c851febe4132a8b8c262 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +let [[x, y, z] = [4, 5, 6]] = []; + +assert.sameValue(x, 4); +assert.sameValue(y, 5); +assert.sameValue(z, 6); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/let/dstr-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..c89f77394f9a26a39ccafc78522eacf0e5fc17f9 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +let [[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]; + +assert.sameValue(x, 7); +assert.sameValue(y, 8); +assert.sameValue(z, 9); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/let/dstr-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000000000000000000000000000000000..c8e5943168612afb7949ab18d8dc55ff0c2c1df0 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +let [[,] = g()] = []; + +assert.sameValue(first, 1); +assert.sameValue(second, 0); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/let/dstr-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..3703382ef3e2f3cfe3f880ac876cf0436349ca35 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +let [[,] = g()] = [[]]; + +assert.sameValue(callCount, 0); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/let/dstr-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000000000000000000000000000000000..2d792f0aa81e13e47230c56dfef63fd50a08f4b8 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +let [[] = function() { initCount += 1; return iter; }()] = []; + +assert.sameValue(initCount, 1); +assert.sameValue(iterCount, 0); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/let/dstr-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..4c5cb7ae509c758f820174e1656f51bbc4a3a2ef --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +let [[] = function() { initCount += 1; }()] = [[23]]; + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/let/dstr-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000000000000000000000000000000000..18c6533a6a2b13af1dd29d1f6429ad052992f532 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +let [[...x] = values] = []; + +assert(Array.isArray(x)); +assert.sameValue(x[0], 2); +assert.sameValue(x[1], 1); +assert.sameValue(x[2], 3); +assert.sameValue(x.length, 3); +assert.notSameValue(x, values); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/let/dstr-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..baa13e2ebd5b133061cf089e9bd48d3a3b4bc8f6 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +let [[...x] = function() { initCount += 1; }()] = [values]; + +assert(Array.isArray(x)); +assert.sameValue(x[0], 2); +assert.sameValue(x[1], 1); +assert.sameValue(x[2], 3); +assert.sameValue(x.length, 3); +assert.notSameValue(x, values); +assert.sameValue(initCount, 0); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-ary-val-null.js b/test/language/statements/let/dstr-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..7e514c11ef6cd1da1f4106cbad3d30fa1c655abf --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/let-stmt.template +/*--- +description: Nested array destructuring with a null value (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +assert.throws(TypeError, function() { + let [[x]] = [null]; +}); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/let/dstr-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..b921e716dcfd7291c11a8a1bb74b322439bb8f4a --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Destructuring initializer with an exhausted iterator (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +let [x = 23] = []; + +assert.sameValue(x, 23); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/let/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..735b3de9f80cf48d50bad96f2d92d35cefe201e2 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +let [arrow = () => {}] = []; + +assert.sameValue(arrow.name, 'arrow'); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/let/dstr-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..f4656331fc1a90748e7e101f7c13742c49fac788 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +let [cls = class {}, xCls = class X {}] = []; + +assert.sameValue(cls.name, 'cls'); +assert.notSameValue(xCls.name, 'xCls'); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/let/dstr-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..9dad685c66c15f8013f7c4c20c03cf6dfbc1a3dc --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +let [cover = (function () {}), xCover = (0, function() {})] = []; + +assert.sameValue(cover.name, 'cover'); +assert.notSameValue(xCover.name, 'xCover'); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/let/dstr-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..b89d7df85963787d5ebcf82f9b9ec223706db74f --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +let [fn = function () {}, xFn = function x() {}] = []; + +assert.sameValue(fn.name, 'fn'); +assert.notSameValue(xFn.name, 'xFn'); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/let/dstr-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..666ba776d534e6ecb5380756778bbd3d50b43a22 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +let [gen = function* () {}, xGen = function* x() {}] = []; + +assert.sameValue(gen.name, 'gen'); +assert.notSameValue(xGen.name, 'xGen'); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-id-init-hole.js b/test/language/statements/let/dstr-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000000000000000000000000000000000..338fdb84909ca3431039b6cdc196d37cebe545b5 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Destructuring initializer with a "hole" (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +let [x = 23] = [,]; + +assert.sameValue(x, 23); +// another statement diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/let/dstr-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..36040170eed93cac1b583fb49ee9516529d7dcc6 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +let [w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']; + +assert.sameValue(w, null); +assert.sameValue(x, 0); +assert.sameValue(y, false); +assert.sameValue(z, ''); +assert.sameValue(initCount, 0); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-id-init-throws.js b/test/language/statements/let/dstr-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..f241f70f22fa997b60783ed9920131d8a815ae0b --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/let-stmt.template +/*--- +description: Destructuring initializer returns an abrupt completion (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +assert.throws(Test262Error, function() { + let [x = (function() { throw new Test262Error(); })()] = [undefined]; +}); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-id-init-undef.js b/test/language/statements/let/dstr-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..02c853b83bff6d272af7c6b9987637d0fc3ae724 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Destructuring initializer with an undefined value (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +let [x = 23] = [undefined]; + +assert.sameValue(x, 23); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/let/dstr-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..270f3e16910a50f74ef2245a6a06761bdaf557ac --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/let-stmt.template +/*--- +description: Destructuring initializer is an unresolvable reference (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + let [ x = unresolvableReference ] = []; +}); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/let/dstr-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000000000000000000000000000000000..9c1b8827b2b612cc2c941d960c7d669bf70f07ee --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: SingleNameBinding when value iteration completes (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +let [x] = []; + +assert.sameValue(x, undefined); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-id-iter-done.js b/test/language/statements/let/dstr-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000000000000000000000000000000000..6419c24d9f67564539998a88b14e119da04bdfe6 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +let [_, x] = []; + +assert.sameValue(x, undefined); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/let/dstr-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..37f265a174619b40a63a2483c9a060ddcbd47d90 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/let-stmt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +assert.throws(Test262Error, function() { + let [x] = g; +}); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/let/dstr-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..7624c0d9ecb6007cae8d4df53abd9b49fad95664 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/let-stmt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +assert.throws(Test262Error, function() { + let [x] = g; +}); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-id-iter-val.js b/test/language/statements/let/dstr-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..ff1c34054e9dca8aa675fb1aa5faf203cee0ef4b --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +let [x, y, z] = [1, 2, 3]; + +assert.sameValue(x, 1); +assert.sameValue(y, 2); +assert.sameValue(z, 3); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-obj-id-init.js b/test/language/statements/let/dstr-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..e764d36cd58a05f1c4641c1ed324c55b95d409b5 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +let [{ x, y, z } = { x: 44, y: 55, z: 66 }] = []; + +assert.sameValue(x, 44); +assert.sameValue(y, 55); +assert.sameValue(z, 66); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-obj-id.js b/test/language/statements/let/dstr-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..6e56c2cda40ced8fdc78093aa470bb8c53ffc55c --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-obj-id.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +let [{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]; + +assert.sameValue(x, 11); +assert.sameValue(y, 22); +assert.sameValue(z, 33); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/let/dstr-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..c41ea4f545e471022d78223d209cb955330ef4e2 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +let [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []; + +assert.sameValue(v, 444); +assert.sameValue(x, 555); +assert.sameValue(z, 666); + +assert.throws(ReferenceError, function() { + u; +}); +assert.throws(ReferenceError, function() { + w; +}); +assert.throws(ReferenceError, function() { + y; +}); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/let/dstr-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..c5bc77abd4fc258564773334039faccddeb9d012 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +let [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]; + +assert.sameValue(v, 777); +assert.sameValue(x, 888); +assert.sameValue(z, 999); + +assert.throws(ReferenceError, function() { + u; +}); +assert.throws(ReferenceError, function() { + w; +}); +assert.throws(ReferenceError, function() { + y; +}); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-obj-val-null.js b/test/language/statements/let/dstr-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..8397f1849f1781204d9e3fc09f04f61c415822b0 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/let-stmt.template +/*--- +description: Nested object destructuring with a null value (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +assert.throws(TypeError, function() { + let [{ x }] = [null]; +}); diff --git a/test/language/statements/let/dstr-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/let/dstr-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..192c3a4a26b16838e0450bc79481324b1fa32f6a --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/let-stmt.template +/*--- +description: Nested object destructuring with a value of `undefined` (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +assert.throws(TypeError, function() { + let [{ x }] = []; +}); diff --git a/test/language/statements/let/dstr-ary-ptrn-elision-exhausted.js b/test/language/statements/let/dstr-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..fb101a9272b79c7ac3c616441d796b06f85bd454 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elision-exhausted.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Elision accepts exhausted iterator (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [generator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +let [,] = iter; + + diff --git a/test/language/statements/let/dstr-ary-ptrn-elision-step-err.js b/test/language/statements/let/dstr-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..31164e1dfa0c30da69382d5bd7a82dd4ff2298fb --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elision-step-err.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/let-stmt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [generator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +assert.throws(Test262Error, function() { + let [,] = iter; +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/let/dstr-ary-ptrn-elision.js b/test/language/statements/let/dstr-ary-ptrn-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..7926062651378a6d06ab73b7b0a4dff50c912d1e --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-elision.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Elision advances iterator (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [generator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +let [,] = g(); + +assert.sameValue(first, 1); +assert.sameValue(second, 0); diff --git a/test/language/statements/let/dstr-ary-ptrn-empty.js b/test/language/statements/let/dstr-ary-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..9641069d397cf3f8117162761dcc0ccc5f7caf16 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-empty.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +let [] = iter; + +assert.sameValue(iterations, 0); diff --git a/test/language/statements/let/dstr-ary-ptrn-rest-ary-elem.js b/test/language/statements/let/dstr-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000000000000000000000000000000000..5b7fd5426953d30ee790199a529e6c23c601f04a --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Rest element containing an array BindingElementList pattern (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +let [...[x, y, z]] = [3, 4, 5]; + +assert.sameValue(x, 3); +assert.sameValue(y, 4); +assert.sameValue(z, 5); diff --git a/test/language/statements/let/dstr-ary-ptrn-rest-ary-elision.js b/test/language/statements/let/dstr-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..a25b37dcd88805367587b7ddb6e0e035b4150ee8 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Rest element containing an elision (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +let [...[,]] = g(); + +assert.sameValue(first, 1); +assert.sameValue(second, 1); diff --git a/test/language/statements/let/dstr-ary-ptrn-rest-ary-empty.js b/test/language/statements/let/dstr-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..c117663412c1a9734ce3ccb96726dd574972ab86 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Rest element containing an "empty" array pattern (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +let [...[]] = iter; + +assert.sameValue(iterations, 1); diff --git a/test/language/statements/let/dstr-ary-ptrn-rest-ary-rest.js b/test/language/statements/let/dstr-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..8c5cdff71b2e7e685e1948666b8118526de859ea --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Rest element containing a rest element (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +let [...[...x]] = values; + +assert(Array.isArray(x)); +assert.sameValue(x.length, 3); +assert.sameValue(x[0], 1); +assert.sameValue(x[1], 2); +assert.sameValue(x[2], 3); +assert.notSameValue(x, values); + diff --git a/test/language/statements/let/dstr-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/let/dstr-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..dd3fad1e58e6cc38113e1155b0cec90913e4412d --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/let-stmt.template +/*--- +description: Rest element following elision elements (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +assert.throws(Test262Error, function() { + let [, ...x] = iter; +}); diff --git a/test/language/statements/let/dstr-ary-ptrn-rest-id-elision.js b/test/language/statements/let/dstr-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..58f804527fa94656e7e08304266fe96bbbee270c --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-rest-id-elision.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Rest element following elision elements (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +let [ , , ...x] = values; + +assert(Array.isArray(x)); +assert.sameValue(x.length, 3); +assert.sameValue(x[0], 3); +assert.sameValue(x[1], 4); +assert.sameValue(x[2], 5); +assert.notSameValue(x, values); diff --git a/test/language/statements/let/dstr-ary-ptrn-rest-id-exhausted.js b/test/language/statements/let/dstr-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..553262aa38678b6b3ce3eee093e24b2c97db146c --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: RestElement applied to an exhausted iterator (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [Symbol.iterator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +let [, , ...x] = [1, 2]; + +assert(Array.isArray(x)); +assert.sameValue(x.length, 0); diff --git a/test/language/statements/let/dstr-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/let/dstr-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..f4e1804f7882f9ea3ababe796a5ad83dcf3d9492 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/let-stmt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +assert.throws(Test262Error, function() { + let [...x] = iter; +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/let/dstr-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/let/dstr-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..d81206c0d219e3840454f4b2aab2c8302bb78958 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/let-stmt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [Symbol.iterator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +assert.throws(Test262Error, function() { + let [...x] = iter; +}); diff --git a/test/language/statements/let/dstr-ary-ptrn-rest-id.js b/test/language/statements/let/dstr-ary-ptrn-rest-id.js new file mode 100644 index 0000000000000000000000000000000000000000..93e5437a9b4838a4dee828a8c7cf0ee29141d046 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-rest-id.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Lone rest element (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +let [...x] = values; + +assert(Array.isArray(x)); +assert.sameValue(x.length, 3); +assert.sameValue(x[0], 1); +assert.sameValue(x[1], 2); +assert.sameValue(x[2], 3); +assert.notSameValue(x, values); diff --git a/test/language/statements/let/dstr-ary-ptrn-rest-init-ary.js b/test/language/statements/let/dstr-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..fe9651bd1ddcf1e4de042c6cddb6fc04b9263be5 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-rest-init-ary.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Reset element (nested array pattern) does not support initializer (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +let [...[ x ] = []] = []; + + diff --git a/test/language/statements/let/dstr-ary-ptrn-rest-init-id.js b/test/language/statements/let/dstr-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000000000000000000000000000000000..0f72b008b04eba571aa9016a7d0240d6dae974a6 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-rest-init-id.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Reset element (identifier) does not support initializer (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +let [...x = []] = []; + + diff --git a/test/language/statements/let/dstr-ary-ptrn-rest-init-obj.js b/test/language/statements/let/dstr-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..dd2f2ebee536d3afe097cdc6a20f70c831f44448 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-rest-init-obj.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Reset element (nested object pattern) does not support initializer (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +let [...{ x } = []] = []; + + diff --git a/test/language/statements/let/dstr-ary-ptrn-rest-not-final-ary.js b/test/language/statements/let/dstr-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..d34df0730bdf27b325ddf1bbf91b8e8b1d19d056 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +let [...[x], y] = [1, 2, 3]; + + diff --git a/test/language/statements/let/dstr-ary-ptrn-rest-not-final-id.js b/test/language/statements/let/dstr-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000000000000000000000000000000000..94ce80e72a1a00d2f1d2c2f317b7123df0d111de --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Rest element (identifier) may not be followed by any element (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +let [...x, y] = [1, 2, 3]; + + diff --git a/test/language/statements/let/dstr-ary-ptrn-rest-not-final-obj.js b/test/language/statements/let/dstr-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..acb22f4259fc7b01d9f3cbc1c2331efc318a2de7 --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (`let` statement) +esid: sec-let-and-const-declarations-runtime-semantics-evaluation +es6id: 13.3.1.4 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +let [...{ x }, y] = [1, 2, 3]; + + diff --git a/test/language/statements/let/dstr-ary-ptrn-rest-obj-id.js b/test/language/statements/let/dstr-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..8956625e426605cbb1434596040c90bb2a9f71ca --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-rest-obj-id.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Rest element containing an object binding pattern (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +let [...{ length }] = [1, 2, 3]; + +assert.sameValue(length, 3); diff --git a/test/language/statements/let/dstr-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/let/dstr-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..5ea4e9ff7ffecc3370f74f2cd85f729518c54eca --- /dev/null +++ b/test/language/statements/let/dstr-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Rest element containing an object binding pattern (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +let [...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]; + +assert.sameValue(v, 7); +assert.sameValue(w, 8); +assert.sameValue(x, 9); +assert.sameValue(y, undefined); +assert.sameValue(z, 3); + +assert.throws(ReferenceError, function() { + length; +}); diff --git a/test/language/statements/let/dstr-obj-init-null.js b/test/language/statements/let/dstr-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..6fdd350284133959800d489eafa539412d886a3e --- /dev/null +++ b/test/language/statements/let/dstr-obj-init-null.js @@ -0,0 +1,29 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/let-stmt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (`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. + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +assert.throws(TypeError, function() { + let {} = null; +}); diff --git a/test/language/statements/let/dstr-obj-init-undefined.js b/test/language/statements/let/dstr-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..d27acf11b739c35437060832f32c8a225dd7f7ed --- /dev/null +++ b/test/language/statements/let/dstr-obj-init-undefined.js @@ -0,0 +1,29 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/let-stmt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (`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. + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +assert.throws(TypeError, function() { + let {} = undefined; +}); diff --git a/test/language/statements/let/dstr-obj-ptrn-empty.js b/test/language/statements/let/dstr-obj-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..36ffd612b2e69717ca41b98bee077f791735b45b --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-empty.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (`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. + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +let {} = obj; + +assert.sameValue(accessCount, 0); diff --git a/test/language/statements/let/dstr-obj-ptrn-id-get-value-err.js b/test/language/statements/let/dstr-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..c15df05b146656867bd8a5059aa8ddc96b24553a --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-id-get-value-err.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/let-stmt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + let { poisoned } = poisonedProperty; +}); diff --git a/test/language/statements/let/dstr-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/let/dstr-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..9931b01f7476a054b32f823980a23f676ccf2d9e --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +let { arrow = () => {} } = {}; + +assert.sameValue(arrow.name, 'arrow'); diff --git a/test/language/statements/let/dstr-obj-ptrn-id-init-fn-name-class.js b/test/language/statements/let/dstr-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..a817b9c021fdd4ce9aae4a80faaa247c6700a553 --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +let { cls = class {}, xCls = class X {} } = {}; + +assert.sameValue(cls.name, 'cls'); +assert.notSameValue(xCls.name, 'xCls'); diff --git a/test/language/statements/let/dstr-obj-ptrn-id-init-fn-name-cover.js b/test/language/statements/let/dstr-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..1719ebcdbce06d333f0b890126e84cdd6a64853c --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +let { cover = (function () {}), xCover = (0, function() {}) } = {}; + +assert.sameValue(cover.name, 'cover'); +assert.notSameValue(xCover.name, 'xCover'); diff --git a/test/language/statements/let/dstr-obj-ptrn-id-init-fn-name-fn.js b/test/language/statements/let/dstr-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..20e382490b4c44f99cd9b432a80d0239fc32a11a --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +let { fn = function () {}, xFn = function x() {} } = {}; + +assert.sameValue(fn.name, 'fn'); +assert.notSameValue(xFn.name, 'xFn'); diff --git a/test/language/statements/let/dstr-obj-ptrn-id-init-fn-name-gen.js b/test/language/statements/let/dstr-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..247697f983078be2605b5379c8d4cdfeefff438f --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +let { gen = function* () {}, xGen = function* x() {} } = {}; + +assert.sameValue(gen.name, 'gen'); +assert.notSameValue(xGen.name, 'xGen'); diff --git a/test/language/statements/let/dstr-obj-ptrn-id-init-skipped.js b/test/language/statements/let/dstr-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..71d02fdaac7622a8e43e4cf6b3fbe84694e1ed25 --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-id-init-skipped.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +let { w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }; + +assert.sameValue(w, null); +assert.sameValue(x, 0); +assert.sameValue(y, false); +assert.sameValue(z, ''); +assert.sameValue(initCount, 0); diff --git a/test/language/statements/let/dstr-obj-ptrn-id-init-throws.js b/test/language/statements/let/dstr-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..810b9dd72b4cb6272c4daadbe837e68d9bb6faf5 --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-id-init-throws.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/let-stmt.template +/*--- +description: Error thrown when evaluating the initializer (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + let { x = thrower() } = {}; +}); diff --git a/test/language/statements/let/dstr-obj-ptrn-id-init-unresolvable.js b/test/language/statements/let/dstr-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..13f7d6a82535fa2e2043bae0eeb4d1ef285b564f --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/let-stmt.template +/*--- +description: Destructuring initializer is an unresolvable reference (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + let { x = unresolvableReference } = {}; +}); diff --git a/test/language/statements/let/dstr-obj-ptrn-id-trailing-comma.js b/test/language/statements/let/dstr-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..9c7e75afcabc969c267200f32ac031aaca9f886b --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (`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. + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +let { x, } = { x: 23 }; + +assert.sameValue(x, 23); diff --git a/test/language/statements/let/dstr-obj-ptrn-list-err.js b/test/language/statements/let/dstr-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..1cd12ddedea0bf1200156bdbcc5bda49f6d3bb60 --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-list-err.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/let-stmt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (`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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + let { a, b = thrower(), c = ++initCount } = {}; +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/let/dstr-obj-ptrn-prop-ary-init.js b/test/language/statements/let/dstr-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000000000000000000000000000000000..d8bb8cc9e3b52717d55fa06608f439c2eaa57094 --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-prop-ary-init.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +let { w: [x, y, z] = [4, 5, 6] } = {}; + +assert.sameValue(x, 4); +assert.sameValue(y, 5); +assert.sameValue(z, 6); + +assert.throws(ReferenceError, function() { + w; +}); diff --git a/test/language/statements/let/dstr-obj-ptrn-prop-ary-trailing-comma.js b/test/language/statements/let/dstr-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..195f37df0990bf69d8492a8efb21bf33a30fab6e --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (`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. + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +let { x: [y], } = { x: [45] }; + +assert.sameValue(y,45); diff --git a/test/language/statements/let/dstr-obj-ptrn-prop-ary-value-null.js b/test/language/statements/let/dstr-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..2feb4178a24a940558d58c276ca70dfecfb1268d --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/let-stmt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + let { w: [x, y, z] = [4, 5, 6] } = { w: null }; +}); diff --git a/test/language/statements/let/dstr-obj-ptrn-prop-ary.js b/test/language/statements/let/dstr-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..73653f315af551c243439bdd50deb16b7d0c98d3 --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-prop-ary.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +let { w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }; + +assert.sameValue(x, 7); +assert.sameValue(y, undefined); +assert.sameValue(z, undefined); + +assert.throws(ReferenceError, function() { + w; +}); diff --git a/test/language/statements/let/dstr-obj-ptrn-prop-eval-err.js b/test/language/statements/let/dstr-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..972e455362827136586ff4baaddff254745feef9 --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-prop-eval-err.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/let-stmt.template +/*--- +description: Evaluation of property name returns an abrupt completion (`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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + let { [thrower()]: x } = {}; +}); diff --git a/test/language/statements/let/dstr-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/let/dstr-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..1edb9f95355b2bd8f8cf790f681bee7454967546 --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/let-stmt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + let { poisoned: x = ++initEvalCount } = poisonedProperty; +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/let/dstr-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/let/dstr-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..7a071c7c5541129349ffebf99d872875a0238668 --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +let { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }; + +assert.sameValue(t, null); +assert.sameValue(v, 0); +assert.sameValue(x, false); +assert.sameValue(z, ''); +assert.sameValue(initCount, 0); + +assert.throws(ReferenceError, function() { + s; +}); +assert.throws(ReferenceError, function() { + u; +}); +assert.throws(ReferenceError, function() { + w; +}); +assert.throws(ReferenceError, function() { + y; +}); diff --git a/test/language/statements/let/dstr-obj-ptrn-prop-id-init-throws.js b/test/language/statements/let/dstr-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..6905800f384efd7aec20ebce3fd72c9cd17c5aec --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/let-stmt.template +/*--- +description: Error thrown when evaluating the initializer (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + let { x: y = thrower() } = {}; +}); diff --git a/test/language/statements/let/dstr-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/let/dstr-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..7aecc0c9c41ced0fee1ac51828161efd7d2d02ee --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/let-stmt.template +/*--- +description: Destructuring initializer is an unresolvable reference (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + let { x: y = unresolvableReference } = {}; +}); diff --git a/test/language/statements/let/dstr-obj-ptrn-prop-id-init.js b/test/language/statements/let/dstr-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..7ed87fc6dfe8e292cd302f26e25e897110c78d86 --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-prop-id-init.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +let { x: y = 33 } = { }; + +assert.sameValue(y, 33); +assert.throws(ReferenceError, function() { + x; +}); diff --git a/test/language/statements/let/dstr-obj-ptrn-prop-id-trailing-comma.js b/test/language/statements/let/dstr-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..5995bc3ac4ba747ff6442a943014db2cdcac5c26 --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (`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. + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +let { x: y, } = { x: 23 }; + +assert.sameValue(y, 23); + +assert.throws(ReferenceError, function() { + x; +}); diff --git a/test/language/statements/let/dstr-obj-ptrn-prop-id.js b/test/language/statements/let/dstr-obj-ptrn-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..1072b1fe13efd8df173b23c460c35ed3e48eab9e --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-prop-id.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Binding as specified via property name and identifier (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +let { x: y } = { x: 23 }; + +assert.sameValue(y, 23); +assert.throws(ReferenceError, function() { + x; +}); diff --git a/test/language/statements/let/dstr-obj-ptrn-prop-obj-init.js b/test/language/statements/let/dstr-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000000000000000000000000000000000..d84f12912d2d8a14c27f363609bf14e3a3cf321c --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-prop-obj-init.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }; + +assert.sameValue(x, 4); +assert.sameValue(y, 5); +assert.sameValue(z, 6); + +assert.throws(ReferenceError, function() { + w; +}); diff --git a/test/language/statements/let/dstr-obj-ptrn-prop-obj-value-null.js b/test/language/statements/let/dstr-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..dc52a82e6c7ab945f98770a90b619ca0391a6c57 --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/let-stmt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }; +}); diff --git a/test/language/statements/let/dstr-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/let/dstr-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..ad3a5c64974aaa4cffb01a25b72ec376f9106259 --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/let-stmt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + let { w: { x, y, z } = undefined } = { }; +}); diff --git a/test/language/statements/let/dstr-obj-ptrn-prop-obj.js b/test/language/statements/let/dstr-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..7b60375e4a3628609a181ceddf4ab2d3381b4122 --- /dev/null +++ b/test/language/statements/let/dstr-obj-ptrn-prop-obj.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +let { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }; + +assert.sameValue(x, undefined); +assert.sameValue(y, undefined); +assert.sameValue(z, 7); + +assert.throws(ReferenceError, function() { + w; +}); diff --git a/test/language/statements/try/dstr-ary-init-iter-close.js b/test/language/statements/try/dstr-ary-init-iter-close.js new file mode 100644 index 0000000000000000000000000000000000000000..a1896fff232ac11be86bbe9665eb9ed2e431cb2f --- /dev/null +++ b/test/language/statements/try/dstr-ary-init-iter-close.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/try.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var ranCatch = false; + +try { + throw iter; +} catch ([x]) { + assert.sameValue(doneCallCount, 1); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-init-iter-get-err.js b/test/language/statements/try/dstr-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..25aa8e4b9fc27c0a4c474abb74c0744a817d830c --- /dev/null +++ b/test/language/statements/try/dstr-ary-init-iter-get-err.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/try.template +/*--- +description: Abrupt completion returned by GetIterator (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + try { + throw iter; + } catch ([x]) {} +}); diff --git a/test/language/statements/try/dstr-ary-init-iter-no-close.js b/test/language/statements/try/dstr-ary-init-iter-no-close.js new file mode 100644 index 0000000000000000000000000000000000000000..1ef8e1373337dbc7e6fb97a72465768f929c10f2 --- /dev/null +++ b/test/language/statements/try/dstr-ary-init-iter-no-close.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/try.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var ranCatch = false; + +try { + throw iter; +} catch ([x]) { + assert.sameValue(doneCallCount, 0); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-name-iter-val.js b/test/language/statements/try/dstr-ary-name-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..c3fba505553e679c6dc5e55be06a3de09ed0971b --- /dev/null +++ b/test/language/statements/try/dstr-ary-name-iter-val.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/try.template +/*--- +description: SingleNameBinding with normal value iteration (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var ranCatch = false; + +try { + throw [1, 2, 3]; +} catch ([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/try/dstr-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000000000000000000000000000000000..3c3946cfcc33806d0a23472150244925b7c2ef45 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/try.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var ranCatch = false; + +try { + throw []; +} catch ([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/try/dstr-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..2254dd12dfc0719ad4cbf329b1071eaa8c83dac0 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/try.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var ranCatch = false; + +try { + throw [[7, 8, 9]]; +} catch ([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/try/dstr-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000000000000000000000000000000000..cec905a21a25ac5ab9accf6744b0a784ad06ad45 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/try.template +/*--- +description: BindingElement with array binding pattern and initializer is used (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var ranCatch = false; + +try { + throw []; +} catch ([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/try/dstr-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..32164d1ae1f10790eb376f57507207a306e1e684 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/try.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var ranCatch = false; + +try { + throw [[]]; +} catch ([[,] = g()]) { + assert.sameValue(callCount, 0); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/try/dstr-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000000000000000000000000000000000..26591d0715372adcae08c3ca5656f74fc55e8cf1 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/try.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var ranCatch = false; + +try { + throw []; +} catch ([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/try/dstr-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..7559f350d63e58b245042e87d95a12a7cef18b06 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/try.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var ranCatch = false; + +try { + throw [[23]]; +} catch ([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/try/dstr-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000000000000000000000000000000000..5d8b5e0548ce7db2ec48a38d8e386c1f9592edd3 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/try.template +/*--- +description: BindingElement with array binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var ranCatch = false; + +try { + throw []; +} catch ([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/try/dstr-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..58d6eba28e3e7074dee13dde9ea40ae6c8558937 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/try.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var ranCatch = false; + +try { + throw [values]; +} catch ([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-ary-val-null.js b/test/language/statements/try/dstr-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..0b15a99cee8ae3f54245552eb03fdd36920ddf2f --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/try.template +/*--- +description: Nested array destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +assert.throws(TypeError, function() { + try { + throw [null]; + } catch ([[x]]) {} +}); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/try/dstr-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..b53a50a10073d87d1d95452718d509d870aee77a --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/try.template +/*--- +description: Destructuring initializer with an exhausted iterator (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var ranCatch = false; + +try { + throw []; +} catch ([x = 23]) { + assert.sameValue(x, 23); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/try/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..b43c1331d3e8894aa8941575d814803b5aa3d554 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/try.template +/*--- +description: SingleNameBinding does assign name to arrow functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var ranCatch = false; + +try { + throw []; +} catch ([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/try/dstr-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..e07a97bde8dec92b78b317717b5b1d52a7bf3262 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/try.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var ranCatch = false; + +try { + throw []; +} catch ([cls = class {}, xCls = class X {}]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/try/dstr-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..cb218f5b05091f77add4b9c96eb207cb41f14d89 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/try.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var ranCatch = false; + +try { + throw []; +} catch ([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/try/dstr-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..f973a82f1c1e3ab7e3cde7e94f9328b6b23614d0 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/try.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var ranCatch = false; + +try { + throw []; +} catch ([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/try/dstr-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..9551cd9cae070c58cd110602f2c06736660bbdfb --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/try.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var ranCatch = false; + +try { + throw []; +} catch ([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-id-init-hole.js b/test/language/statements/try/dstr-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000000000000000000000000000000000..c7da723a7003f0e08b2557fcbf61e86a1e62ea7e --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/try.template +/*--- +description: Destructuring initializer with a "hole" (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var ranCatch = false; + +try { + throw [,]; +} catch ([x = 23]) { + assert.sameValue(x, 23); + // another statement + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/try/dstr-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..27b4110a06501a46bfcde3754a972a73441e153e --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/try.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var ranCatch = false; + +try { + throw [null, 0, false, '']; +} catch ([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-id-init-throws.js b/test/language/statements/try/dstr-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..37cdd1b5f1549a8b3a6257493d18e4e56844326f --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/try.template +/*--- +description: Destructuring initializer returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +assert.throws(Test262Error, function() { + try { + throw [undefined]; + } catch ([x = (function() { throw new Test262Error(); })()]) {} +}); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-id-init-undef.js b/test/language/statements/try/dstr-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..e8edee54598efa03a43e7dbd338e682e7324b1b4 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/try.template +/*--- +description: Destructuring initializer with an undefined value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var ranCatch = false; + +try { + throw [undefined]; +} catch ([x = 23]) { + assert.sameValue(x, 23); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/try/dstr-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..1f2096d6bb8277da707967741db3762ac8325bd0 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/try.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + try { + throw []; + } catch ([ x = unresolvableReference ]) {} +}); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/try/dstr-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000000000000000000000000000000000..f7f1a7a2cc2961d4cefdb0ab667c0fcc3380f8f1 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/try.template +/*--- +description: SingleNameBinding when value iteration completes (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var ranCatch = false; + +try { + throw []; +} catch ([x]) { + assert.sameValue(x, undefined); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-id-iter-done.js b/test/language/statements/try/dstr-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000000000000000000000000000000000..0e914c74d95cb4991b221536a58b873e0e316866 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/try.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var ranCatch = false; + +try { + throw []; +} catch ([_, x]) { + assert.sameValue(x, undefined); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/try/dstr-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..1c20d1a5b9430fe2aa451198376f545742115f17 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/try.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +assert.throws(Test262Error, function() { + try { + throw g; + } catch ([x]) {} +}); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/try/dstr-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..32dd59320ebfdae4dfd608168f90a8b1fb2f6528 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/try.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +assert.throws(Test262Error, function() { + try { + throw g; + } catch ([x]) {} +}); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-id-iter-val.js b/test/language/statements/try/dstr-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..e1b2b6787ed15bccc2f61f3ac0dea173cc0c7855 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/try.template +/*--- +description: SingleNameBinding when value iteration was completed previously (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var ranCatch = false; + +try { + throw [1, 2, 3]; +} catch ([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-obj-id-init.js b/test/language/statements/try/dstr-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..74cb92d10400f42584eb755c7a621cde5f665faf --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/try.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var ranCatch = false; + +try { + throw []; +} catch ([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-obj-id.js b/test/language/statements/try/dstr-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..21cfed20d9f1cf212831d0af051c46afd6e36994 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-obj-id.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/try.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var ranCatch = false; + +try { + throw [{ x: 11, y: 22, z: 33 }]; +} catch ([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/try/dstr-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..c9e01b82676bda3a703ca48702efd818bde334b1 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/try.template +/*--- +description: BindingElement with object binding pattern and initializer is used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var ranCatch = false; + +try { + throw []; +} catch ([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/try/dstr-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..ed8116e26d5237884f2810465d1a78c82a69aa80 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/try.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var ranCatch = false; + +try { + throw [{ u: 777, w: 888, y: 999 }]; +} catch ([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-obj-val-null.js b/test/language/statements/try/dstr-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..0d413ed52f1d8edfe9bacad7d638cc95eea3b2ec --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/try.template +/*--- +description: Nested object destructuring with a null value (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +assert.throws(TypeError, function() { + try { + throw [null]; + } catch ([{ x }]) {} +}); diff --git a/test/language/statements/try/dstr-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/try/dstr-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..ea41f0079eaee4854277e8d576a02ea20e50ab83 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/try.template +/*--- +description: Nested object destructuring with a value of `undefined` (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +assert.throws(TypeError, function() { + try { + throw []; + } catch ([{ x }]) {} +}); diff --git a/test/language/statements/try/dstr-ary-ptrn-elision-exhausted.js b/test/language/statements/try/dstr-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..b3cc358a5b5284d870d08e9fb13844208a4e487c --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elision-exhausted.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/try.template +/*--- +description: Elision accepts exhausted iterator (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var ranCatch = false; + +try { + throw iter; +} catch ([,]) { + + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elision-step-err.js b/test/language/statements/try/dstr-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..c906d819695fefaae8ba3993078d3fb8a4054bc0 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elision-step-err.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/try.template +/*--- +description: Elision advances iterator and forwards abrupt completions (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +assert.throws(Test262Error, function() { + try { + throw iter; + } catch ([,]) {} +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/try/dstr-ary-ptrn-elision.js b/test/language/statements/try/dstr-ary-ptrn-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..cf4b6f6fdf15afd412baa38978c41cc24df3440d --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-elision.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/try.template +/*--- +description: Elision advances iterator (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [generator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var ranCatch = false; + +try { + throw g(); +} catch ([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-empty.js b/test/language/statements/try/dstr-ary-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..251761dee79a6ae20e27c4a3fc646b2bad1a9e32 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-empty.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/try.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var ranCatch = false; + +try { + throw iter; +} catch ([]) { + assert.sameValue(iterations, 0); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-rest-ary-elem.js b/test/language/statements/try/dstr-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000000000000000000000000000000000..ee1a552f0feb7d600b4a0c7e7f144fad9b8c7280 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/try.template +/*--- +description: Rest element containing an array BindingElementList pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var ranCatch = false; + +try { + throw [3, 4, 5]; +} catch ([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-rest-ary-elision.js b/test/language/statements/try/dstr-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..25206c7a3aa3b9dcdc5afeaac78b3087a43605d8 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/try.template +/*--- +description: Rest element containing an elision (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var ranCatch = false; + +try { + throw g(); +} catch ([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-rest-ary-empty.js b/test/language/statements/try/dstr-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..155d155cd1e491ae5a635d5e20ba54a17b0a6d00 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/try.template +/*--- +description: Rest element containing an "empty" array pattern (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var ranCatch = false; + +try { + throw iter; +} catch ([...[]]) { + assert.sameValue(iterations, 1); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-rest-ary-rest.js b/test/language/statements/try/dstr-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..7a9bc1457d43261257fc716d94d4701280cd7530 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/try.template +/*--- +description: Rest element containing a rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var ranCatch = false; + +try { + throw values; +} catch ([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/try/dstr-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..ef720dd416f6a30b8a0739c5b917ac698b0f3497 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/try.template +/*--- +description: Rest element following elision elements (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +assert.throws(Test262Error, function() { + try { + throw iter; + } catch ([, ...x]) {} +}); diff --git a/test/language/statements/try/dstr-ary-ptrn-rest-id-elision.js b/test/language/statements/try/dstr-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..26c22ab2dc49154ac4f5368b9c7b5dca615f8947 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-rest-id-elision.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/try.template +/*--- +description: Rest element following elision elements (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var ranCatch = false; + +try { + throw values; +} catch ([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-rest-id-exhausted.js b/test/language/statements/try/dstr-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..8e8cc29d4bbbfccd33c8b6c259dc5d284152b183 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/try.template +/*--- +description: RestElement applied to an exhausted iterator (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var ranCatch = false; + +try { + throw [1, 2]; +} catch ([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/try/dstr-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..2278b798f595e23ee140a5bc0976e0828a9f343d --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/try.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [generators, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +assert.throws(Test262Error, function() { + try { + throw iter; + } catch ([...x]) {} +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/try/dstr-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/try/dstr-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..6e1e84f17f676ce0f201de2bc7097f440723bde4 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/try.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [Symbol.iterator, 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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +assert.throws(Test262Error, function() { + try { + throw iter; + } catch ([...x]) {} +}); diff --git a/test/language/statements/try/dstr-ary-ptrn-rest-id.js b/test/language/statements/try/dstr-ary-ptrn-rest-id.js new file mode 100644 index 0000000000000000000000000000000000000000..dc7c05b0b2e4962934b59e895e7729ab0b976ab5 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-rest-id.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/try.template +/*--- +description: Lone rest element (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var ranCatch = false; + +try { + throw values; +} catch ([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-rest-init-ary.js b/test/language/statements/try/dstr-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..f5bd7b04fc3fd481d278b2fac3f2caeac4c41458 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-rest-init-ary.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/try.template +/*--- +description: Reset element (nested array pattern) does not support initializer (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var ranCatch = false; + +try { + throw []; +} catch ([...[ x ] = []]) { + + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-rest-init-id.js b/test/language/statements/try/dstr-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000000000000000000000000000000000..099ef1ac3438b8c6aa3ee62fa7d109c0fc4ad35d --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-rest-init-id.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/try.template +/*--- +description: Reset element (identifier) does not support initializer (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var ranCatch = false; + +try { + throw []; +} catch ([...x = []]) { + + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-rest-init-obj.js b/test/language/statements/try/dstr-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..b02fddc4f1820040ae0693652969eaf52e8a598c --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-rest-init-obj.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/try.template +/*--- +description: Reset element (nested object pattern) does not support initializer (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var ranCatch = false; + +try { + throw []; +} catch ([...{ x } = []]) { + + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-rest-not-final-ary.js b/test/language/statements/try/dstr-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..b1a72b058c7382efae6d2a9242f4c62c79685cb6 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/try.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var ranCatch = false; + +try { + throw [1, 2, 3]; +} catch ([...[x], y]) { + + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-rest-not-final-id.js b/test/language/statements/try/dstr-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000000000000000000000000000000000..a9438d40e95396cfc6c11738d294882ba3c273b8 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/try.template +/*--- +description: Rest element (identifier) may not be followed by any element (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var ranCatch = false; + +try { + throw [1, 2, 3]; +} catch ([...x, y]) { + + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-rest-not-final-obj.js b/test/language/statements/try/dstr-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..110d38a03377bf37195a7c406912bed69403b199 --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/try.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (try statement) +esid: sec-runtime-semantics-catchclauseevaluation +es6id: 13.15.7 +features: [destructuring-binding] +flags: [generated] +negative: SyntaxError +info: | + Catch : catch ( CatchParameter ) Block + + [...] + 5. Let status be the result of performing BindingInitialization for + CatchParameter passing thrownValue and catchEnv as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var ranCatch = false; + +try { + throw [1, 2, 3]; +} catch ([...{ x }, y]) { + + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-rest-obj-id.js b/test/language/statements/try/dstr-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..5391b3d5369c6acd2652c2caf04d0cd797ffff3b --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-rest-obj-id.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/try.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var ranCatch = false; + +try { + throw [1, 2, 3]; +} catch ([...{ length }]) { + assert.sameValue(length, 3); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/try/dstr-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..62a6f2d5e6fe76722f834fff9c11c79df832ef2e --- /dev/null +++ b/test/language/statements/try/dstr-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/try.template +/*--- +description: Rest element containing an object binding pattern (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. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var ranCatch = false; + +try { + throw [7, 8, 9]; +} catch ([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-obj-init-null.js b/test/language/statements/try/dstr-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..3ce65c0440dc0f2b2eebca3072423bf068faf030 --- /dev/null +++ b/test/language/statements/try/dstr-obj-init-null.js @@ -0,0 +1,29 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/try.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +assert.throws(TypeError, function() { + try { + throw null; + } catch ({}) {} +}); diff --git a/test/language/statements/try/dstr-obj-init-undefined.js b/test/language/statements/try/dstr-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..df3ab228edef3c995e73e4afd0765ffb0ffb4b5f --- /dev/null +++ b/test/language/statements/try/dstr-obj-init-undefined.js @@ -0,0 +1,29 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/try.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +assert.throws(TypeError, function() { + try { + throw undefined; + } catch ({}) {} +}); diff --git a/test/language/statements/try/dstr-obj-ptrn-empty.js b/test/language/statements/try/dstr-obj-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..92e452cfe736c09037a724045aa07c2984c1920a --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-empty.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/try.template +/*--- +description: No property access occurs for an "empty" object binding pattern (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. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var ranCatch = false; + +try { + throw obj; +} catch ({}) { + assert.sameValue(accessCount, 0); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-obj-ptrn-id-get-value-err.js b/test/language/statements/try/dstr-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..11a2f6b470ae9b0e164f0db39f32bbea4962c788 --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-id-get-value-err.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/try.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + try { + throw poisonedProperty; + } catch ({ poisoned }) {} +}); diff --git a/test/language/statements/try/dstr-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/try/dstr-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..d7a8cc107d2c2ec9e2f9904681eba000626e5839 --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/try.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var ranCatch = false; + +try { + throw {}; +} catch ({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-obj-ptrn-id-init-fn-name-class.js b/test/language/statements/try/dstr-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..ead6e786a7166ab9ac9fbe205506ab29fe7e2a3f --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/try.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var ranCatch = false; + +try { + throw {}; +} catch ({ cls = class {}, xCls = class X {} }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-obj-ptrn-id-init-fn-name-cover.js b/test/language/statements/try/dstr-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..94c642d4459eac2d35b8e630eb13c7eda1190bfd --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/try.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var ranCatch = false; + +try { + throw {}; +} catch ({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-obj-ptrn-id-init-fn-name-fn.js b/test/language/statements/try/dstr-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..bb268a1357d170d8492c75a79a01b4867b3ca3d8 --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/try.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var ranCatch = false; + +try { + throw {}; +} catch ({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-obj-ptrn-id-init-fn-name-gen.js b/test/language/statements/try/dstr-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..248baabafaaf6f01979424582efcad30bab5d7d2 --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/try.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var ranCatch = false; + +try { + throw {}; +} catch ({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-obj-ptrn-id-init-skipped.js b/test/language/statements/try/dstr-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..925ea970eea3efcd9959fe51c6c5cd99a8c23182 --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-id-init-skipped.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/try.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var ranCatch = false; + +try { + throw { w: null, x: 0, y: false, z: '' }; +} catch ({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-obj-ptrn-id-init-throws.js b/test/language/statements/try/dstr-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..210854284458069e68e932c14ba2f82a5690bf8c --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-id-init-throws.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/try.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + try { + throw {}; + } catch ({ x = thrower() }) {} +}); diff --git a/test/language/statements/try/dstr-obj-ptrn-id-init-unresolvable.js b/test/language/statements/try/dstr-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..f1485b723331ed9c54d6e9037603b1dff08f0610 --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/try.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + try { + throw {}; + } catch ({ x = unresolvableReference }) {} +}); diff --git a/test/language/statements/try/dstr-obj-ptrn-id-trailing-comma.js b/test/language/statements/try/dstr-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..72e4fa8936d3239d739f544445a3a37f5416e300 --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/try.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var ranCatch = false; + +try { + throw { x: 23 }; +} catch ({ x, }) { + assert.sameValue(x, 23); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-obj-ptrn-list-err.js b/test/language/statements/try/dstr-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..1d59b40336a43d7c7906a04f27c4bf29d0720890 --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-list-err.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/try.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + try { + throw {}; + } catch ({ a, b = thrower(), c = ++initCount }) {} +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/try/dstr-obj-ptrn-prop-ary-init.js b/test/language/statements/try/dstr-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000000000000000000000000000000000..1406f0f6b0406787778865f14e74e9bdcef2d6f0 --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-prop-ary-init.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/try.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var ranCatch = false; + +try { + throw {}; +} catch ({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-obj-ptrn-prop-ary-trailing-comma.js b/test/language/statements/try/dstr-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..4470688ad080ec619a2c1f2ce2842e80db0284be --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/try.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var ranCatch = false; + +try { + throw { x: [45] }; +} catch ({ x: [y], }) { + assert.sameValue(y,45); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-obj-ptrn-prop-ary-value-null.js b/test/language/statements/try/dstr-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..d39615dbb26ed6c2135178f210f1e37dfc8a9b21 --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/try.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + try { + throw { w: null }; + } catch ({ w: [x, y, z] = [4, 5, 6] }) {} +}); diff --git a/test/language/statements/try/dstr-obj-ptrn-prop-ary.js b/test/language/statements/try/dstr-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..b2bea8b1de82f77be0b9d66b68079d74fff9eabf --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-prop-ary.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/try.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var ranCatch = false; + +try { + throw { w: [7, undefined, ] }; +} catch ({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-obj-ptrn-prop-eval-err.js b/test/language/statements/try/dstr-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..9615f2fb9f0014dc3c4687c23d510b8277699072 --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-prop-eval-err.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/try.template +/*--- +description: Evaluation of property name returns an abrupt completion (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. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + try { + throw {}; + } catch ({ [thrower()]: x }) {} +}); diff --git a/test/language/statements/try/dstr-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/try/dstr-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..c1d14ea6ebb325d39e3c95ad629d1cb258f48af4 --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/try.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + try { + throw poisonedProperty; + } catch ({ poisoned: x = ++initEvalCount }) {} +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/try/dstr-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/try/dstr-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..325a509a1c63e9793a29dab1f35619a0927642f8 --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/try.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var ranCatch = false; + +try { + throw { s: null, u: 0, w: false, y: '' }; +} catch ({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-obj-ptrn-prop-id-init-throws.js b/test/language/statements/try/dstr-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..fff0d78c251ea6f4d3b6a31e490f2d53309c4510 --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/try.template +/*--- +description: Error thrown when evaluating the initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + try { + throw {}; + } catch ({ x: y = thrower() }) {} +}); diff --git a/test/language/statements/try/dstr-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/try/dstr-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..4831d34e05cd18effdb9c823c2430f07fc7ffb84 --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/try.template +/*--- +description: Destructuring initializer is an unresolvable reference (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + try { + throw {}; + } catch ({ x: y = unresolvableReference }) {} +}); diff --git a/test/language/statements/try/dstr-obj-ptrn-prop-id-init.js b/test/language/statements/try/dstr-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..f8362103480fa83012fa80d1d13dab6cb165c02b --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-prop-id-init.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/try.template +/*--- +description: Binding as specified via property name, identifier, and initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var ranCatch = false; + +try { + throw { }; +} catch ({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-obj-ptrn-prop-id-trailing-comma.js b/test/language/statements/try/dstr-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..424b683c6c7ae84632e02c3833683de44eaec627 --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/try.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (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. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var ranCatch = false; + +try { + throw { x: 23 }; +} catch ({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-obj-ptrn-prop-id.js b/test/language/statements/try/dstr-obj-ptrn-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..8cfd91ea094344c40786404ebfcd15d85f95a7ac --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-prop-id.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/try.template +/*--- +description: Binding as specified via property name and identifier (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var ranCatch = false; + +try { + throw { x: 23 }; +} catch ({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-obj-ptrn-prop-obj-init.js b/test/language/statements/try/dstr-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000000000000000000000000000000000..d6cc2029e0dd9e53a61ab61da37d59e9305b112b --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-prop-obj-init.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/try.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var ranCatch = false; + +try { + throw { w: undefined }; +} catch ({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/try/dstr-obj-ptrn-prop-obj-value-null.js b/test/language/statements/try/dstr-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..8ebc814289c15f960d4745eb7d28a13880d11318 --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/try.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + try { + throw { w: null }; + } catch ({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) {} +}); diff --git a/test/language/statements/try/dstr-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/try/dstr-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..99b62dacbd54424e594817e4d391ab49d074d88a --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/try.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + try { + throw { }; + } catch ({ w: { x, y, z } = undefined }) {} +}); diff --git a/test/language/statements/try/dstr-obj-ptrn-prop-obj.js b/test/language/statements/try/dstr-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..e3f03562d87dcfe09010ee441a401bf9301e7100 --- /dev/null +++ b/test/language/statements/try/dstr-obj-ptrn-prop-obj.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/try.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (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. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var ranCatch = false; + +try { + throw { w: { x: undefined, z: 7 } }; +} catch ({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + ranCatch = true; +} + +assert(ranCatch, 'executed `catch` block'); diff --git a/test/language/statements/variable/dstr-ary-init-iter-close.js b/test/language/statements/variable/dstr-ary-init-iter-close.js new file mode 100644 index 0000000000000000000000000000000000000000..a7abe975ea4aa9dd7d0d5aabfddd095c1cc37edc --- /dev/null +++ b/test/language/statements/variable/dstr-ary-init-iter-close.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [Symbol.iterator, 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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var [x] = iter; + +assert.sameValue(doneCallCount, 1); diff --git a/test/language/statements/variable/dstr-ary-init-iter-get-err.js b/test/language/statements/variable/dstr-ary-init-iter-get-err.js new file mode 100644 index 0000000000000000000000000000000000000000..6bf080afb72bb693e3fac5ff45f593677281c95c --- /dev/null +++ b/test/language/statements/variable/dstr-ary-init-iter-get-err.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/var-stmt.template +/*--- +description: Abrupt completion returned by GetIterator (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [Symbol.iterator, 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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). + +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + var [x] = iter; +}); diff --git a/test/language/statements/variable/dstr-ary-init-iter-no-close.js b/test/language/statements/variable/dstr-ary-init-iter-no-close.js new file mode 100644 index 0000000000000000000000000000000000000000..7f8d14512e63e9a01984ca972e37c4b5b729690c --- /dev/null +++ b/test/language/statements/variable/dstr-ary-init-iter-no-close.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [Symbol.iterator, 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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var [x] = iter; + +assert.sameValue(doneCallCount, 0); diff --git a/test/language/statements/variable/dstr-ary-name-iter-val.js b/test/language/statements/variable/dstr-ary-name-iter-val.js index 9ca768a0bd4100d2940d260d416a77dd54771199..a40ecc9d549e95f7b9da90cd39a58dc69a9a9037 100644 --- a/test/language/statements/variable/dstr-ary-name-iter-val.js +++ b/test/language/statements/variable/dstr-ary-name-iter-val.js @@ -3,7 +3,9 @@ // - src/dstr-binding/default/var-stmt.template /*--- description: SingleNameBinding with normal value iteration (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation es6id: 13.3.2.4 +features: [destructuring-binding] flags: [generated] info: | VariableDeclaration : BindingPattern Initializer diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/variable/dstr-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000000000000000000000000000000000..207668ca909929518df52dd4c090e2b3fcb0cf8d --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var [[x, y, z] = [4, 5, 6]] = []; + +assert.sameValue(x, 4); +assert.sameValue(y, 5); +assert.sameValue(z, 6); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/variable/dstr-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..bff92f0623b32e059eaca55a64e17cfe80087c1f --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var [[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]; + +assert.sameValue(x, 7); +assert.sameValue(y, 8); +assert.sameValue(z, 9); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/variable/dstr-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000000000000000000000000000000000..d18b0e13c01d259db9e7918f676db2adc46b43ba --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var [[,] = g()] = []; + +assert.sameValue(first, 1); +assert.sameValue(second, 0); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/variable/dstr-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..e66a61f2c961e07a1a07b2b8a94e198fa1b0e562 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var [[,] = g()] = [[]]; + +assert.sameValue(callCount, 0); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/variable/dstr-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000000000000000000000000000000000..06fdd821950f002b91fcc48646dbe2c05a6250dd --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var [[] = function() { initCount += 1; return iter; }()] = []; + +assert.sameValue(initCount, 1); +assert.sameValue(iterCount, 0); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/variable/dstr-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..27a4155029fc330ac432d36e4318c33b252baa4e --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var [[] = function() { initCount += 1; }()] = [[23]]; + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/variable/dstr-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000000000000000000000000000000000..383e085750b4aba795b40bddcabd3481c67a033d --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var [[...x] = values] = []; + +assert(Array.isArray(x)); +assert.sameValue(x[0], 2); +assert.sameValue(x[1], 1); +assert.sameValue(x[2], 3); +assert.sameValue(x.length, 3); +assert.notSameValue(x, values); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/variable/dstr-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000000000000000000000000000000000..4baa03e0a4b8c70d81a000237e8b75fc19b28065 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var [[...x] = function() { initCount += 1; }()] = [values]; + +assert(Array.isArray(x)); +assert.sameValue(x[0], 2); +assert.sameValue(x[1], 1); +assert.sameValue(x[2], 3); +assert.sameValue(x.length, 3); +assert.notSameValue(x, values); +assert.sameValue(initCount, 0); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-ary-val-null.js b/test/language/statements/variable/dstr-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..0b1031b68791e3f08409a4de5f88819ae4729b2b --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/var-stmt.template +/*--- +description: Nested array destructuring with a null value (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be GetIterator(value). + 2. ReturnIfAbrupt(iterator). +---*/ + +assert.throws(TypeError, function() { + var [[x]] = [null]; +}); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..b3290fb7af411b455321e7c21358146eb633a88d --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Destructuring initializer with an exhausted iterator (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var [x = 23] = []; + +assert.sameValue(x, 23); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..25003c7387f6227e1cb565bd31a5a92756521155 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var [arrow = () => {}] = []; + +assert.sameValue(arrow.name, 'arrow'); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..d466371bfcf1a53565df1ba73a759c32e2d187b4 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var [cls = class {}, xCls = class X {}] = []; + +assert.sameValue(cls.name, 'cls'); +assert.notSameValue(xCls.name, 'xCls'); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..cb7796f3270d207dc25c5d67021fbbe1f329a054 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var [cover = (function () {}), xCover = (0, function() {})] = []; + +assert.sameValue(cover.name, 'cover'); +assert.notSameValue(xCover.name, 'xCover'); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..f94e23d0cb7ce3ed38921b87ef7c0c3b0fbffa13 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var [fn = function () {}, xFn = function x() {}] = []; + +assert.sameValue(fn.name, 'fn'); +assert.notSameValue(xFn.name, 'xFn'); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..add0a978fa77627212c1c3813e29a6834c1da5d4 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var [gen = function* () {}, xGen = function* x() {}] = []; + +assert.sameValue(gen.name, 'gen'); +assert.notSameValue(xGen.name, 'xGen'); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-hole.js b/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000000000000000000000000000000000..faddf2a50d60836fa6e6bf32029bf5116067a534 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Destructuring initializer with a "hole" (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var [x = 23] = [,]; + +assert.sameValue(x, 23); +// another statement diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..649f4e8005acf6731bcee4fb091fe789e2e29740 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var [w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']; + +assert.sameValue(w, null); +assert.sameValue(x, 0); +assert.sameValue(y, false); +assert.sameValue(z, ''); +assert.sameValue(initCount, 0); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-throws.js b/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..730858ca655488a1a9edb10fd9ff9fc62d51f092 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/var-stmt.template +/*--- +description: Destructuring initializer returns an abrupt completion (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +assert.throws(Test262Error, function() { + var [x = (function() { throw new Test262Error(); })()] = [undefined]; +}); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-undef.js b/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..17cfc12fcc63f3ef9c0050c3ce4fffed23c05fd5 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Destructuring initializer with an undefined value (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var [x = 23] = [undefined]; + +assert.sameValue(x, 23); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..c166156dfe8e7bdb00042ae6ca088eb5015ae11a --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/var-stmt.template +/*--- +description: Destructuring initializer is an unresolvable reference (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + var [ x = unresolvableReference ] = []; +}); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/variable/dstr-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000000000000000000000000000000000..9badf1c61c5d6079c81fe51dfa33be504bcb0fc8 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: SingleNameBinding when value iteration completes (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var [x] = []; + +assert.sameValue(x, undefined); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-id-iter-done.js b/test/language/statements/variable/dstr-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000000000000000000000000000000000..9894cdb7ba2277c42365a2c767e32f352abe6bc2 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var [_, x] = []; + +assert.sameValue(x, undefined); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/variable/dstr-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..8b30f885021b17f8dbf398c00b79aa46de66eafa --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/var-stmt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). +---*/ +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +assert.throws(Test262Error, function() { + var [x] = g; +}); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/variable/dstr-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..61c931e334521e9cdfff276200154fac8d49b754 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/var-stmt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(v). +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +assert.throws(Test262Error, function() { + var [x] = g; +}); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-id-iter-val.js b/test/language/statements/variable/dstr-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000000000000000000000000000000000..d853331683b12c58f5f6e5529a7ef7c17be348ce --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var [x, y, z] = [1, 2, 3]; + +assert.sameValue(x, 1); +assert.sameValue(y, 2); +assert.sameValue(z, 3); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-obj-id-init.js b/test/language/statements/variable/dstr-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..f91abc4694f35d649cdb85682af1b07033e7fbd2 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var [{ x, y, z } = { x: 44, y: 55, z: 66 }] = []; + +assert.sameValue(x, 44); +assert.sameValue(y, 55); +assert.sameValue(z, 66); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-obj-id.js b/test/language/statements/variable/dstr-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..27a5aee9ea4600e9c4caf5bdb765153a219082bb --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-obj-id.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var [{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]; + +assert.sameValue(x, 11); +assert.sameValue(y, 22); +assert.sameValue(z, 33); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/variable/dstr-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..fdfe9055e160771a5856f5fafa1838099952e1f8 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []; + +assert.sameValue(v, 444); +assert.sameValue(x, 555); +assert.sameValue(z, 666); + +assert.throws(ReferenceError, function() { + u; +}); +assert.throws(ReferenceError, function() { + w; +}); +assert.throws(ReferenceError, function() { + y; +}); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/variable/dstr-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..60f66dd8684b8040eb262958c026a10708aa9d3c --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var [{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]; + +assert.sameValue(v, 777); +assert.sameValue(x, 888); +assert.sameValue(z, 999); + +assert.throws(ReferenceError, function() { + u; +}); +assert.throws(ReferenceError, function() { + w; +}); +assert.throws(ReferenceError, function() { + y; +}); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-obj-val-null.js b/test/language/statements/variable/dstr-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000000000000000000000000000000000..e1f9692d12ca5d59481735864ab58442319edcfe --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/var-stmt.template +/*--- +description: Nested object destructuring with a null value (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +assert.throws(TypeError, function() { + var [{ x }] = [null]; +}); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/variable/dstr-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..8048e04bb915e55330595ef8d1466342d7bfeee5 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/var-stmt.template +/*--- +description: Nested object destructuring with a value of `undefined` (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. If iteratorRecord.[[done]] is false, then + [...] + e. Else + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ObjectBindingPattern + + 1. Let valid be RequireObjectCoercible(value). + 2. ReturnIfAbrupt(valid). +---*/ + +assert.throws(TypeError, function() { + var [{ x }] = []; +}); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elision-exhausted.js b/test/language/statements/variable/dstr-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..ff5fc0dbc404df55ed2b4e8e0504f9bb4651d91b --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elision-exhausted.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Elision accepts exhausted iterator (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [generator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var [,] = iter; + + diff --git a/test/language/statements/variable/dstr-ary-ptrn-elision-step-err.js b/test/language/statements/variable/dstr-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..24bd59c950d20b506677e011b4d87dcb0b4b85d0 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elision-step-err.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/var-stmt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [generator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + +---*/ +var following = 0; +var iter =function* () { + throw new Test262Error(); + following += 1; +}(); + +assert.throws(Test262Error, function() { + var [,] = iter; +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/variable/dstr-ary-ptrn-elision.js b/test/language/statements/variable/dstr-ary-ptrn-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..6690c6f75f2780fd5e5f183510d2e31bc4e1d17a --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-elision.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Elision advances iterator (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [generator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var [,] = g(); + +assert.sameValue(first, 1); +assert.sameValue(second, 0); diff --git a/test/language/statements/variable/dstr-ary-ptrn-empty.js b/test/language/statements/variable/dstr-ary-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..e862a71c8bac667fac09dbb0b0155d4fd3429916 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-empty.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var [] = iter; + +assert.sameValue(iterations, 0); diff --git a/test/language/statements/variable/dstr-ary-ptrn-rest-ary-elem.js b/test/language/statements/variable/dstr-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000000000000000000000000000000000..0c22acbfbed2d09d8b1e841493173b8e8e8372d8 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Rest element containing an array BindingElementList pattern (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var [...[x, y, z]] = [3, 4, 5]; + +assert.sameValue(x, 3); +assert.sameValue(y, 4); +assert.sameValue(z, 5); diff --git a/test/language/statements/variable/dstr-ary-ptrn-rest-ary-elision.js b/test/language/statements/variable/dstr-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..7fa92583618cef2b0ac7cc1f3975e80ac5da65f9 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Rest element containing an elision (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var [...[,]] = g(); + +assert.sameValue(first, 1); +assert.sameValue(second, 1); diff --git a/test/language/statements/variable/dstr-ary-ptrn-rest-ary-empty.js b/test/language/statements/variable/dstr-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..4ef7a3cdf9308341d9dda2dc5d39cb650359d043 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Rest element containing an "empty" array pattern (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var [...[]] = iter; + +assert.sameValue(iterations, 1); diff --git a/test/language/statements/variable/dstr-ary-ptrn-rest-ary-rest.js b/test/language/statements/variable/dstr-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..25b01498a693f5602049098c54594957eb069289 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Rest element containing a rest element (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var [...[...x]] = values; + +assert(Array.isArray(x)); +assert.sameValue(x.length, 3); +assert.sameValue(x[0], 1); +assert.sameValue(x[1], 2); +assert.sameValue(x[2], 3); +assert.notSameValue(x, values); + diff --git a/test/language/statements/variable/dstr-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/variable/dstr-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000000000000000000000000000000000..79900f614677231ba3af48e1f20bd339c533b8af --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/var-stmt.template +/*--- +description: Rest element following elision elements (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. + +---*/ +var iter = (function*() { throw new Test262Error(); })(); + +assert.throws(Test262Error, function() { + var [, ...x] = iter; +}); diff --git a/test/language/statements/variable/dstr-ary-ptrn-rest-id-elision.js b/test/language/statements/variable/dstr-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000000000000000000000000000000000..393254c526347d29b5ee7e659fe1d526796029ae --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-rest-id-elision.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Rest element following elision elements (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var [ , , ...x] = values; + +assert(Array.isArray(x)); +assert.sameValue(x.length, 3); +assert.sameValue(x[0], 3); +assert.sameValue(x[1], 4); +assert.sameValue(x[2], 5); +assert.notSameValue(x, values); diff --git a/test/language/statements/variable/dstr-ary-ptrn-rest-id-exhausted.js b/test/language/statements/variable/dstr-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000000000000000000000000000000000..0b4710f602a5626f60773c4a2ecbbd991fe693fd --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: RestElement applied to an exhausted iterator (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [Symbol.iterator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var [, , ...x] = [1, 2]; + +assert(Array.isArray(x)); +assert.sameValue(x.length, 0); diff --git a/test/language/statements/variable/dstr-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/variable/dstr-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000000000000000000000000000000000..c120c5fa8c7bdcbc9d9e890aef0bc144587f690b --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/var-stmt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [generators, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + a. If iteratorRecord.[[done]] is false, + i. Let next be IteratorStep(iteratorRecord.[[iterator]]). + ii. If next is an abrupt completion, set iteratorRecord.[[done]] to + true. + iii. ReturnIfAbrupt(next). + +---*/ +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); + +assert.throws(Test262Error, function() { + var [...x] = iter; +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); diff --git a/test/language/statements/variable/dstr-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/variable/dstr-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000000000000000000000000000000000..2f36c9865f707506f4bd54e2a222f7e614b3d693 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/var-stmt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [Symbol.iterator, 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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + c. Let nextValue be IteratorValue(next). + d. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to + true. + e. ReturnIfAbrupt(nextValue). + +---*/ +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; + +assert.throws(Test262Error, function() { + var [...x] = iter; +}); diff --git a/test/language/statements/variable/dstr-ary-ptrn-rest-id.js b/test/language/statements/variable/dstr-ary-ptrn-rest-id.js new file mode 100644 index 0000000000000000000000000000000000000000..b7935bf307b5a48deff00d5c026d5f5cba02f571 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-rest-id.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Lone rest element (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var [...x] = values; + +assert(Array.isArray(x)); +assert.sameValue(x.length, 3); +assert.sameValue(x[0], 1); +assert.sameValue(x[1], 2); +assert.sameValue(x[2], 3); +assert.notSameValue(x, values); diff --git a/test/language/statements/variable/dstr-ary-ptrn-rest-init-ary.js b/test/language/statements/variable/dstr-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..4642ceeec40e1453f3faee320847fdf6c400f0cf --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-rest-init-ary.js @@ -0,0 +1,29 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Reset element (nested array pattern) does not support initializer (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +negative: 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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var [...[ x ] = []] = []; + + diff --git a/test/language/statements/variable/dstr-ary-ptrn-rest-init-id.js b/test/language/statements/variable/dstr-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000000000000000000000000000000000..75059bf1d0c63fb6944c913e843f0b268e12e1dc --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-rest-init-id.js @@ -0,0 +1,29 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Reset element (identifier) does not support initializer (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +negative: 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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var [...x = []] = []; + + diff --git a/test/language/statements/variable/dstr-ary-ptrn-rest-init-obj.js b/test/language/statements/variable/dstr-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..9de68eaf6b9bd3ed1c77e810e180aa57531d80f1 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-rest-init-obj.js @@ -0,0 +1,29 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Reset element (nested object pattern) does not support initializer (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +negative: 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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var [...{ x } = []] = []; + + diff --git a/test/language/statements/variable/dstr-ary-ptrn-rest-not-final-ary.js b/test/language/statements/variable/dstr-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..c9ce8fa69012e39fe6719713378984c67b736703 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,29 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +negative: 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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var [...[x], y] = [1, 2, 3]; + + diff --git a/test/language/statements/variable/dstr-ary-ptrn-rest-not-final-id.js b/test/language/statements/variable/dstr-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000000000000000000000000000000000..902035f97ad6ba2bf8ec88d48ea4e055330dbf7e --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,29 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Rest element (identifier) may not be followed by any element (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +negative: 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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var [...x, y] = [1, 2, 3]; + + diff --git a/test/language/statements/variable/dstr-ary-ptrn-rest-not-final-obj.js b/test/language/statements/variable/dstr-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..8cfb4ab63aa577cfbc75a85ced9fbcc6549ef456 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,29 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (`var` statement) +esid: sec-variable-statement-runtime-semantics-evaluation +es6id: 13.3.2.4 +features: [destructuring-binding] +flags: [generated] +negative: 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. + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var [...{ x }, y] = [1, 2, 3]; + + diff --git a/test/language/statements/variable/dstr-ary-ptrn-rest-obj-id.js b/test/language/statements/variable/dstr-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000000000000000000000000000000000..2be6d263136cc7f36cc16f1865e70793088c49b5 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-rest-obj-id.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Rest element containing an object binding pattern (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var [...{ length }] = [1, 2, 3]; + +assert.sameValue(length, 3); diff --git a/test/language/statements/variable/dstr-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/variable/dstr-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..8eaa6019bc28f864996794d80729a25493f7f438 --- /dev/null +++ b/test/language/statements/variable/dstr-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Rest element containing an object binding pattern (`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. + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var [...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]; + +assert.sameValue(v, 7); +assert.sameValue(w, 8); +assert.sameValue(x, 9); +assert.sameValue(y, undefined); +assert.sameValue(z, 3); + +assert.throws(ReferenceError, function() { + length; +}); diff --git a/test/language/statements/variable/dstr-obj-init-null.js b/test/language/statements/variable/dstr-obj-init-null.js new file mode 100644 index 0000000000000000000000000000000000000000..9c868e62c0d28d4db5b605dafe95918ef6155601 --- /dev/null +++ b/test/language/statements/variable/dstr-obj-init-null.js @@ -0,0 +1,28 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/var-stmt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (`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. + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +assert.throws(TypeError, function() { + var {} = null; +}); diff --git a/test/language/statements/variable/dstr-obj-init-undefined.js b/test/language/statements/variable/dstr-obj-init-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..33f61ac7e1fdaddcf86ea1b8deb0bc86594793d4 --- /dev/null +++ b/test/language/statements/variable/dstr-obj-init-undefined.js @@ -0,0 +1,28 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/var-stmt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (`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. + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +assert.throws(TypeError, function() { + var {} = undefined; +}); diff --git a/test/language/statements/variable/dstr-obj-ptrn-empty.js b/test/language/statements/variable/dstr-obj-ptrn-empty.js new file mode 100644 index 0000000000000000000000000000000000000000..c2a970a56f753093ec866930f9097356c00d2df2 --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-empty.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (`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. + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var {} = obj; + +assert.sameValue(accessCount, 0); diff --git a/test/language/statements/variable/dstr-obj-ptrn-id-get-value-err.js b/test/language/statements/variable/dstr-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..d42e5dccd89bc6db1e796c9ffa73b15088ee5b69 --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-id-get-value-err.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/var-stmt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + var { poisoned } = poisonedProperty; +}); diff --git a/test/language/statements/variable/dstr-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/variable/dstr-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000000000000000000000000000000000..9d069e68c60f2750fcfe88fb2a0e862e22b81d71 --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var { arrow = () => {} } = {}; + +assert.sameValue(arrow.name, 'arrow'); diff --git a/test/language/statements/variable/dstr-obj-ptrn-id-init-fn-name-class.js b/test/language/statements/variable/dstr-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000000000000000000000000000000000..e39c6c37c815110f3c823b5e2144bc6c5b0cd00a --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var { cls = class {}, xCls = class X {} } = {}; + +assert.sameValue(cls.name, 'cls'); +assert.notSameValue(xCls.name, 'xCls'); diff --git a/test/language/statements/variable/dstr-obj-ptrn-id-init-fn-name-cover.js b/test/language/statements/variable/dstr-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000000000000000000000000000000000..650aaf5c9ef1451e772e522e9d193535e3924a3b --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var { cover = (function () {}), xCover = (0, function() {}) } = {}; + +assert.sameValue(cover.name, 'cover'); +assert.notSameValue(xCover.name, 'xCover'); diff --git a/test/language/statements/variable/dstr-obj-ptrn-id-init-fn-name-fn.js b/test/language/statements/variable/dstr-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..bddd1eff8392a58fed05a4df6ca85092ceb5a41c --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var { fn = function () {}, xFn = function x() {} } = {}; + +assert.sameValue(fn.name, 'fn'); +assert.notSameValue(xFn.name, 'xFn'); diff --git a/test/language/statements/variable/dstr-obj-ptrn-id-init-fn-name-gen.js b/test/language/statements/variable/dstr-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000000000000000000000000000000000..5aa4072800cac2c5b521ee9ff009e11c50dcaf72 --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var { gen = function* () {}, xGen = function* x() {} } = {}; + +assert.sameValue(gen.name, 'gen'); +assert.notSameValue(xGen.name, 'xGen'); diff --git a/test/language/statements/variable/dstr-obj-ptrn-id-init-skipped.js b/test/language/statements/variable/dstr-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..9131adf68e2e04ed73201dbade93f184889041d8 --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-id-init-skipped.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var { w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }; + +assert.sameValue(w, null); +assert.sameValue(x, 0); +assert.sameValue(y, false); +assert.sameValue(z, ''); +assert.sameValue(initCount, 0); diff --git a/test/language/statements/variable/dstr-obj-ptrn-id-init-throws.js b/test/language/statements/variable/dstr-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..12787d85ea916d8acdd0e8ab178a23aba34b3ae3 --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-id-init-throws.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/var-stmt.template +/*--- +description: Error thrown when evaluating the initializer (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + var { x = thrower() } = {}; +}); diff --git a/test/language/statements/variable/dstr-obj-ptrn-id-init-unresolvable.js b/test/language/statements/variable/dstr-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..f961ae6a1e7b99bbd2a431014bec79b127929f10 --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/var-stmt.template +/*--- +description: Destructuring initializer is an unresolvable reference (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + var { x = unresolvableReference } = {}; +}); diff --git a/test/language/statements/variable/dstr-obj-ptrn-id-trailing-comma.js b/test/language/statements/variable/dstr-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..a09279c786d831a9c77e14e132dbcc2e00843baa --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,29 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (`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. + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var { x, } = { x: 23 }; + +assert.sameValue(x, 23); diff --git a/test/language/statements/variable/dstr-obj-ptrn-list-err.js b/test/language/statements/variable/dstr-obj-ptrn-list-err.js new file mode 100644 index 0000000000000000000000000000000000000000..65528a39bd22deb3d3804d84c664392d47b57bf3 --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-list-err.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/var-stmt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (`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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPropertyList : BindingPropertyList , BindingProperty + + 1. Let status be the result of performing BindingInitialization for + BindingPropertyList using value and environment as arguments. + 2. ReturnIfAbrupt(status). +---*/ +var initCount = 0; +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + var { a, b = thrower(), c = ++initCount } = {}; +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/variable/dstr-obj-ptrn-prop-ary-init.js b/test/language/statements/variable/dstr-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000000000000000000000000000000000..b949d8429204a32555c9b20928bdba93b1c91cac --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-prop-ary-init.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var { w: [x, y, z] = [4, 5, 6] } = {}; + +assert.sameValue(x, 4); +assert.sameValue(y, 5); +assert.sameValue(z, 6); + +assert.throws(ReferenceError, function() { + w; +}); diff --git a/test/language/statements/variable/dstr-obj-ptrn-prop-ary-trailing-comma.js b/test/language/statements/variable/dstr-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..a07f2b5462a96b66948695e6379c4599764d332b --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,29 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (`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. + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var { x: [y], } = { x: [45] }; + +assert.sameValue(y,45); diff --git a/test/language/statements/variable/dstr-obj-ptrn-prop-ary-value-null.js b/test/language/statements/variable/dstr-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..fe0f33e1f34d5198145b7ac8f104cf2429499cc5 --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/var-stmt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + var { w: [x, y, z] = [4, 5, 6] } = { w: null }; +}); diff --git a/test/language/statements/variable/dstr-obj-ptrn-prop-ary.js b/test/language/statements/variable/dstr-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000000000000000000000000000000000..35fc5a3512d2ecfa33aaee0503111fd286009cd1 --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-prop-ary.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var { w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }; + +assert.sameValue(x, 7); +assert.sameValue(y, undefined); +assert.sameValue(z, undefined); + +assert.throws(ReferenceError, function() { + w; +}); diff --git a/test/language/statements/variable/dstr-obj-ptrn-prop-eval-err.js b/test/language/statements/variable/dstr-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000000000000000000000000000000000..a3b68d02797439fff9af2e9026be5cf01ad554c0 --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-prop-eval-err.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/var-stmt.template +/*--- +description: Evaluation of property name returns an abrupt completion (`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. + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + var { [thrower()]: x } = {}; +}); diff --git a/test/language/statements/variable/dstr-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/variable/dstr-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000000000000000000000000000000000..56d9d07ee52ff40b53e8c40b82c74ba452c6e851 --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/var-stmt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + var { poisoned: x = ++initEvalCount } = poisonedProperty; +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/variable/dstr-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/variable/dstr-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000000000000000000000000000000000..b7cd64428ed12d5eb0423cd640db31dedd6a8256 --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }; + +assert.sameValue(t, null); +assert.sameValue(v, 0); +assert.sameValue(x, false); +assert.sameValue(z, ''); +assert.sameValue(initCount, 0); + +assert.throws(ReferenceError, function() { + s; +}); +assert.throws(ReferenceError, function() { + u; +}); +assert.throws(ReferenceError, function() { + w; +}); +assert.throws(ReferenceError, function() { + y; +}); diff --git a/test/language/statements/variable/dstr-obj-ptrn-prop-id-init-throws.js b/test/language/statements/variable/dstr-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..c7ce89bf930be7898de9f817b5290d5efa6f5cd9 --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/var-stmt.template +/*--- +description: Error thrown when evaluating the initializer (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ +function thrower() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + var { x: y = thrower() } = {}; +}); diff --git a/test/language/statements/variable/dstr-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/variable/dstr-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000000000000000000000000000000000..3f1c9396126c773757234729cba2926cea0489dd --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/var-stmt.template +/*--- +description: Destructuring initializer is an unresolvable reference (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + + 6.2.3.1 GetValue (V) + + 1. ReturnIfAbrupt(V). + 2. If Type(V) is not Reference, return V. + 3. Let base be GetBase(V). + 4. If IsUnresolvableReference(V), throw a ReferenceError exception. +---*/ + +assert.throws(ReferenceError, function() { + var { x: y = unresolvableReference } = {}; +}); diff --git a/test/language/statements/variable/dstr-obj-ptrn-prop-id-init.js b/test/language/statements/variable/dstr-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000000000000000000000000000000000..58389f6f07cf4b4d15dc096af9be4f5a375900f2 --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-prop-id-init.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var { x: y = 33 } = { }; + +assert.sameValue(y, 33); +assert.throws(ReferenceError, function() { + x; +}); diff --git a/test/language/statements/variable/dstr-obj-ptrn-prop-id-trailing-comma.js b/test/language/statements/variable/dstr-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000000000000000000000000000000000..392bfd53529a09960cc5aa8b1021eb7984b9ef1d --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (`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. + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var { x: y, } = { x: 23 }; + +assert.sameValue(y, 23); + +assert.throws(ReferenceError, function() { + x; +}); diff --git a/test/language/statements/variable/dstr-obj-ptrn-prop-id.js b/test/language/statements/variable/dstr-obj-ptrn-prop-id.js new file mode 100644 index 0000000000000000000000000000000000000000..caa4db731583c64494a8b1e3e4a324ec86b28c80 --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-prop-id.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Binding as specified via property name and identifier (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var { x: y } = { x: 23 }; + +assert.sameValue(y, 23); +assert.throws(ReferenceError, function() { + x; +}); diff --git a/test/language/statements/variable/dstr-obj-ptrn-prop-obj-init.js b/test/language/statements/variable/dstr-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000000000000000000000000000000000..f89aa38d9e5850909177c826a9e509a87ba4083c --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-prop-obj-init.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }; + +assert.sameValue(x, 4); +assert.sameValue(y, 5); +assert.sameValue(z, 6); + +assert.throws(ReferenceError, function() { + w; +}); diff --git a/test/language/statements/variable/dstr-obj-ptrn-prop-obj-value-null.js b/test/language/statements/variable/dstr-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000000000000000000000000000000000..8fef0e13e4a5abc92dbb4f9dcfa441488e075891 --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/var-stmt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }; +}); diff --git a/test/language/statements/variable/dstr-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/variable/dstr-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000000000000000000000000000000000..863e2a508148785cb28fc512852eb29668ed15fd --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/var-stmt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +assert.throws(TypeError, function() { + var { w: { x, y, z } = undefined } = { }; +}); diff --git a/test/language/statements/variable/dstr-obj-ptrn-prop-obj.js b/test/language/statements/variable/dstr-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..69510855e0d1730734f131bd07d22390a4e97e23 --- /dev/null +++ b/test/language/statements/variable/dstr-obj-ptrn-prop-obj.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (`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. + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var { w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }; + +assert.sameValue(x, undefined); +assert.sameValue(y, undefined); +assert.sameValue(z, 7); + +assert.throws(ReferenceError, function() { + w; +});