diff options
author | Rick Waldron <waldron.rick@gmail.com> | 2017-05-22 13:23:12 -0400 |
---|---|---|
committer | Rick Waldron <waldron.rick@gmail.com> | 2017-05-22 13:23:12 -0400 |
commit | b1620ab5b825c91e3f05ab5dd6df271e6b596c95 (patch) | |
tree | c3583a977f711aaec5e44f68d6746df9823c9701 /src/dstr-binding-for-await | |
parent | e522cbce57c47f1f0204950f697c56ea586ff294 (diff) | |
download | qtdeclarative-testsuites-b1620ab5b825c91e3f05ab5dd6df271e6b596c95.tar.gz |
src/dstr-binding-async-iteration => src/dstr-binding-for-await
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
Diffstat (limited to 'src/dstr-binding-for-await')
119 files changed, 3966 insertions, 0 deletions
diff --git a/src/dstr-binding-for-await/ary-init-iter-close.case b/src/dstr-binding-for-await/ary-init-iter-close.case new file mode 100644 index 000000000..860a773bf --- /dev/null +++ b/src/dstr-binding-for-await/ary-init-iter-close.case @@ -0,0 +1,37 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Iterator is closed when not exhausted by pattern evaluation +template: default +info: | + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] +features: [Symbol.iterator] +---*/ + +//- setup +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next() { + return { value: null, done: false }; + }, + return() { + doneCallCount += 1; + return {}; + } + }; +}; +//- elems +[x] +//- vals +iter +//- body +assert.sameValue(doneCallCount, 1); diff --git a/src/dstr-binding-for-await/ary-init-iter-get-err.case b/src/dstr-binding-for-await/ary-init-iter-get-err.case new file mode 100644 index 000000000..1ac51278b --- /dev/null +++ b/src/dstr-binding-for-await/ary-init-iter-get-err.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Abrupt completion returned by GetIterator +template: error +info: | + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iterator be ? GetIterator(value). +features: [Symbol.iterator] +---*/ + +//- setup +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; +//- elems +[x] +//- vals +iter +//- error +Test262Error diff --git a/src/dstr-binding-for-await/ary-init-iter-no-close.case b/src/dstr-binding-for-await/ary-init-iter-no-close.case new file mode 100644 index 000000000..8184d2f2e --- /dev/null +++ b/src/dstr-binding-for-await/ary-init-iter-no-close.case @@ -0,0 +1,37 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Iterator is not closed when exhausted by pattern evaluation +template: default +info: | + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] +features: [Symbol.iterator] +---*/ + +//- setup +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next() { + return { value: null, done: true }; + }, + return() { + doneCallCount += 1; + return {}; + } + }; +}; +//- elems +[x] +//- vals +iter +//- body +assert.sameValue(doneCallCount, 0); diff --git a/src/dstr-binding-for-await/ary-name-iter-val.case b/src/dstr-binding-for-await/ary-name-iter-val.case new file mode 100644 index 000000000..624994f47 --- /dev/null +++ b/src/dstr-binding-for-await/ary-name-iter-val.case @@ -0,0 +1,34 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: SingleNameBinding with normal value iteration +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 3. 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). + 4. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +[x, y, z] +//- vals +[1, 2, 3] +//- body +assert.sameValue(x, 1); +assert.sameValue(y, 2); +assert.sameValue(z, 3); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-init.case b/src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-init.case new file mode 100644 index 000000000..ae00dace2 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-init.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: BindingElement with array binding pattern and initializer is used +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_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. +---*/ + +//- elems +[[x, y, z] = [4, 5, 6]] +//- vals +[] +//- body +assert.sameValue(x, 4); +assert.sameValue(y, 5); +assert.sameValue(z, 6); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-iter.case b/src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-iter.case new file mode 100644 index 000000000..cb561cf1b --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-ary-elem-iter.case @@ -0,0 +1,28 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: BindingElement with array binding pattern and initializer is not used +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_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. +---*/ + +//- elems +[[x, y, z] = [4, 5, 6]] +//- vals +[[7, 8, 9]] +//- body +assert.sameValue(x, 7); +assert.sameValue(y, 8); +assert.sameValue(z, 9); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-init.case b/src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-init.case new file mode 100644 index 000000000..e09a765c7 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-init.case @@ -0,0 +1,35 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: BindingElement with array binding pattern and initializer is used +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_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. +features: [generators] +---*/ + +//- setup +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; +//- elems +[[,] = g()] +//- vals +[] +//- body +assert.sameValue(first, 1); +assert.sameValue(second, 0); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-iter.case b/src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-iter.case new file mode 100644 index 000000000..96f07a6d1 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-ary-elision-iter.case @@ -0,0 +1,32 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: BindingElement with array binding pattern and initializer is not used +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_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. +features: [generators] +---*/ + +//- setup +var callCount = 0; +function* g() { + callCount += 1; +}; +//- elems +[[,] = g()] +//- vals +[[]] +//- body +assert.sameValue(callCount, 0); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-init.case b/src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-init.case new file mode 100644 index 000000000..fcec666f2 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-init.case @@ -0,0 +1,30 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: BindingElement with array binding pattern and initializer is used +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_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. +---*/ + +//- setup +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); +//- elems +[[] = function() { initCount += 1; return iter; }()] +//- vals +[] +//- body +assert.sameValue(initCount, 1); +assert.sameValue(iterCount, 0); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-iter.case b/src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-iter.case new file mode 100644 index 000000000..c88783d15 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-ary-empty-iter.case @@ -0,0 +1,28 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: BindingElement with array binding pattern and initializer is not used +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_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. +---*/ + +//- setup +var initCount = 0; +//- elems +[[] = function() { initCount += 1; }()] +//- vals +[[23]] +//- body +assert.sameValue(initCount, 0); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-init.case b/src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-init.case new file mode 100644 index 000000000..59f46ff49 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-init.case @@ -0,0 +1,32 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: BindingElement with array binding pattern and initializer is used +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_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. +---*/ + +//- setup +var values = [2, 1, 3]; +//- elems +[[...x] = values] +//- vals +[] +//- body +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/src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-iter.case b/src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-iter.case new file mode 100644 index 000000000..b7269eac1 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-ary-rest-iter.case @@ -0,0 +1,35 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: BindingElement with array binding pattern and initializer is not used +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_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. +---*/ + +//- setup +var values = [2, 1, 3]; +var initCount = 0; +//- elems +[[...x] = function() { initCount += 1; }()] +//- vals +[values] +//- body +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/src/dstr-binding-for-await/ary-ptrn-elem-ary-val-null.case b/src/dstr-binding-for-await/ary-ptrn-elem-ary-val-null.case new file mode 100644 index 000000000..633f880f9 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-ary-val-null.case @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Nested array destructuring with a null value +template: error +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_opt + + 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). +---*/ + +//- elems +[[x]] +//- vals +[null] +//- error +TypeError diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-init-exhausted.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-exhausted.case new file mode 100644 index 000000000..df82792fe --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-exhausted.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Destructuring initializer with an exhausted iterator +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 4. If iteratorRecord.[[done]] is true, let v be undefined. + 5. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 6. If environment is undefined, return PutValue(lhs, v). + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +[x = 23] +//- vals +[] +//- body +assert.sameValue(x, 23); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-arrow.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-arrow.case new file mode 100644 index 000000000..23001a4dd --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-arrow.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: SingleNameBinding does assign name to arrow functions +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 5. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Set v to ? GetValue(defaultValue). + c. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 6. If environment is undefined, return PutValue(lhs, v). + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +[arrow = () => {}] +//- vals +[] +//- body +assert.sameValue(arrow.name, 'arrow'); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-class.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-class.case new file mode 100644 index 000000000..4185a236b --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-class.case @@ -0,0 +1,28 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: SingleNameBinding assigns `name` to "anonymous" classes +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 5. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Set v to ? GetValue(defaultValue). + c. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 6. If environment is undefined, return PutValue(lhs, v). + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +[cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] +//- vals +[] +//- body +assert.sameValue(cls.name, 'cls'); +assert.notSameValue(xCls.name, 'xCls'); +assert.notSameValue(xCls2.name, 'xCls2'); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-cover.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-cover.case new file mode 100644 index 000000000..e466b2b04 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-cover.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 5. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Set v to ? GetValue(defaultValue). + c. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 6. If environment is undefined, return PutValue(lhs, v). + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +[cover = (function () {}), xCover = (0, function() {})] +//- vals +[] +//- body +assert.sameValue(cover.name, 'cover'); +assert.notSameValue(xCover.name, 'xCover'); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-fn.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-fn.case new file mode 100644 index 000000000..e537c02c8 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-fn.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: SingleNameBinding assigns name to "anonymous" functions +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 5. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Set v to ? GetValue(defaultValue). + c. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 6. If environment is undefined, return PutValue(lhs, v). + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +[fn = function () {}, xFn = function x() {}] +//- vals +[] +//- body +assert.sameValue(fn.name, 'fn'); +assert.notSameValue(xFn.name, 'xFn'); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-gen.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-gen.case new file mode 100644 index 000000000..5b1736e88 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-fn-name-gen.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: SingleNameBinding assigns name to "anonymous" generator functions +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 5. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Set v to ? GetValue(defaultValue). + c. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 6. If environment is undefined, return PutValue(lhs, v). + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +[gen = function* () {}, xGen = function* x() {}] +//- vals +[] +//- body +assert.sameValue(gen.name, 'gen'); +assert.notSameValue(xGen.name, 'xGen'); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-init-hole.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-hole.case new file mode 100644 index 000000000..a234fffd8 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-hole.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Destructuring initializer with a "hole" +template: default +info: > + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 5. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 6. If environment is undefined, return PutValue(lhs, v). + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +[x = 23] +//- vals +[,] +//- body +assert.sameValue(x, 23); +// another statement diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-init-skipped.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-skipped.case new file mode 100644 index 000000000..84cf03cf4 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-skipped.case @@ -0,0 +1,32 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Destructuring initializer is not evaluated when value is not `undefined` +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- setup +var initCount = 0; +function counter() { + initCount += 1; +} +//- elems +[w = counter(), x = counter(), y = counter(), z = counter()] +//- vals +[null, 0, false, ''] +//- body +assert.sameValue(w, null); +assert.sameValue(x, 0); +assert.sameValue(y, false); +assert.sameValue(z, ''); +assert.sameValue(initCount, 0); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-init-throws.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-throws.case new file mode 100644 index 000000000..f4eb856aa --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-throws.case @@ -0,0 +1,22 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Destructuring initializer returns an abrupt completion +template: error +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 5. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Set v to ? GetValue(defaultValue). +---*/ + +//- elems +[x = (function() { throw new Test262Error(); })()] +//- vals +[undefined] +//- error +Test262Error diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-init-undef.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-undef.case new file mode 100644 index 000000000..3cbf54138 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-undef.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Destructuring initializer with an undefined value +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 5. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 6. If environment is undefined, return PutValue(lhs, v). + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +[x = 23] +//- vals +[undefined] +//- body +assert.sameValue(x, 23); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-init-unresolvable.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-unresolvable.case new file mode 100644 index 000000000..9dc9bf8f4 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-init-unresolvable.case @@ -0,0 +1,29 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Destructuring initializer is an unresolvable reference +template: error +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 5. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Set v to ? GetValue(defaultValue). + + 6.2.4.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. +---*/ + +//- elems +[ x = unresolvableReference ] +//- vals +[] +//- error +ReferenceError diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-complete.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-complete.case new file mode 100644 index 000000000..de40bed9e --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-complete.case @@ -0,0 +1,29 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: SingleNameBinding when value iteration completes +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 3. 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, + [...] + 4. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +[x] +//- vals +[] +//- body +assert.sameValue(x, undefined); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-done.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-done.case new file mode 100644 index 000000000..e21fb9eaf --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-done.case @@ -0,0 +1,24 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: SingleNameBinding when value iteration was completed previously +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 3. If iteratorRecord.[[done]] is false, then + [...] + 4. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +[_, x] +//- vals +[] +//- body +assert.sameValue(x, undefined); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-step-err.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-step-err.case new file mode 100644 index 000000000..34faa9e14 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-step-err.case @@ -0,0 +1,32 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Error forwarding when IteratorStep returns an abrupt completion +template: error +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 3. 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). +---*/ + +//- setup +var g = {}; +g[Symbol.iterator] = function() { + return { + next() { + throw new Test262Error(); + } + }; +}; +//- elems +[x] +//- vals +g +//- error +Test262Error diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val-err.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val-err.case new file mode 100644 index 000000000..d87224a32 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val-err.case @@ -0,0 +1,43 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Error forwarding when IteratorValue returns an abrupt completion +template: error +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 3. 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). +---*/ + +//- setup +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var g = {}; +g[Symbol.iterator] = function() { + return { + next() { + return poisonedValue; + } + }; +}; +//- elems +[x] +//- vals +g +//- error +Test262Error diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val.case b/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val.case new file mode 100644 index 000000000..364ffa6fb --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-id-iter-val.case @@ -0,0 +1,34 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: SingleNameBinding when value iteration was completed previously +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 3. 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). + 4. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +[x, y, z] +//- vals +[1, 2, 3] +//- body +assert.sameValue(x, 1); +assert.sameValue(y, 2); +assert.sameValue(z, 3); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-obj-id-init.case b/src/dstr-binding-for-await/ary-ptrn-elem-obj-id-init.case new file mode 100644 index 000000000..b3be0967b --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-obj-id-init.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: BindingElement with object binding pattern and initializer is used +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_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. +---*/ + +//- elems +[{ x, y, z } = { x: 44, y: 55, z: 66 }] +//- vals +[] +//- body +assert.sameValue(x, 44); +assert.sameValue(y, 55); +assert.sameValue(z, 66); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-obj-id.case b/src/dstr-binding-for-await/ary-ptrn-elem-obj-id.case new file mode 100644 index 000000000..d6ca94ed3 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-obj-id.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: BindingElement with object binding pattern and initializer is not used +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_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. +---*/ + +//- elems +[{ x, y, z } = { x: 44, y: 55, z: 66 }] +//- vals +[{ x: 11, y: 22, z: 33 }] +//- body +assert.sameValue(x, 11); +assert.sameValue(y, 22); +assert.sameValue(z, 33); diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id-init.case b/src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id-init.case new file mode 100644 index 000000000..10887bd28 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id-init.case @@ -0,0 +1,37 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: BindingElement with object binding pattern and initializer is used +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_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. +---*/ + +//- elems +[{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] +//- vals +[] +//- body +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/src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id.case b/src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id.case new file mode 100644 index 000000000..2c5bd0cbe --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-obj-prop-id.case @@ -0,0 +1,37 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: BindingElement with object binding pattern and initializer is not used +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_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. +---*/ + +//- elems +[{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] +//- vals +[{ u: 777, w: 888, y: 999 }] +//- body +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/src/dstr-binding-for-await/ary-ptrn-elem-obj-val-null.case b/src/dstr-binding-for-await/ary-ptrn-elem-obj-val-null.case new file mode 100644 index 000000000..bcdf94c98 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-obj-val-null.case @@ -0,0 +1,32 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Nested object destructuring with a null value +template: error +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_opt + + 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). +---*/ + +//- elems +[{ x }] +//- vals +[null] +//- error +TypeError diff --git a/src/dstr-binding-for-await/ary-ptrn-elem-obj-val-undef.case b/src/dstr-binding-for-await/ary-ptrn-elem-obj-val-undef.case new file mode 100644 index 000000000..f3603bc0a --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elem-obj-val-undef.case @@ -0,0 +1,32 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Nested object destructuring with a value of `undefined` +template: error +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPattern Initializer_opt + + 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). +---*/ + +//- elems +[{ x }] +//- vals +[] +//- error +TypeError diff --git a/src/dstr-binding-for-await/ary-ptrn-elision-exhausted.case b/src/dstr-binding-for-await/ary-ptrn-elision-exhausted.case new file mode 100644 index 000000000..2d7cd5094 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elision-exhausted.case @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Elision accepts exhausted iterator +template: default +info: | + 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). +features: [generator] +---*/ + +//- setup +var iter = function*() {}(); +iter.next(); +//- elems +[,] +//- vals +iter diff --git a/src/dstr-binding-for-await/ary-ptrn-elision-iter-close.case b/src/dstr-binding-for-await/ary-ptrn-elision-iter-close.case new file mode 100644 index 000000000..18c0046a3 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elision-iter-close.case @@ -0,0 +1,21 @@ +// Copyright (C) 2017 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: iter-close +desc: > + The iterator is properly consumed by the destructuring pattern +---*/ + +//- setup +const iter = (function* () { + yield; + yield; +})(); + +//- elems +[,] +//- iter +iter +//- assertions +assert.sameValue(iter.next().done, true, 'iteration occurred as expected'); diff --git a/src/dstr-binding-for-await/ary-ptrn-elision-step-err.case b/src/dstr-binding-for-await/ary-ptrn-elision-step-err.case new file mode 100644 index 000000000..1f1d69448 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elision-step-err.case @@ -0,0 +1,39 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Elision advances iterator and forwards abrupt completions +template: error +info: | + 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). +features: [generator] +---*/ + +//- setup +var following = 0; +var iter = function* () { + throw new Test262Error(); + following += 1; +}(); +//- elems +[,] +//- vals +iter +//- error +Test262Error +//- rejectBody +assert.sameValue(following, 0, "iterator is properly closed"); diff --git a/src/dstr-binding-for-await/ary-ptrn-elision.case b/src/dstr-binding-for-await/ary-ptrn-elision.case new file mode 100644 index 000000000..828e8413a --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-elision.case @@ -0,0 +1,42 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Elision advances iterator +template: default +info: | + 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). +features: [generator] +---*/ + +//- setup +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; +//- elems +[,] +//- vals +g() +//- body +assert.sameValue(first, 1); +assert.sameValue(second, 0); diff --git a/src/dstr-binding-for-await/ary-ptrn-empty.case b/src/dstr-binding-for-await/ary-ptrn-empty.case new file mode 100644 index 000000000..6a348ea18 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-empty.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: No iteration occurs for an "empty" array binding pattern +template: default +info: | + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). +features: [generators] +---*/ + +//- setup +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); +//- elems +[] +//- vals +iter +//- body +assert.sameValue(iterations, 0); diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-ary-elem.case b/src/dstr-binding-for-await/ary-ptrn-rest-ary-elem.case new file mode 100644 index 000000000..79a93524c --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-ary-elem.case @@ -0,0 +1,47 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: default +desc: Rest element containing an array BindingElementList pattern +info: | + 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 Initializer_opt + + [...] + 3. 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). + 4. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +[...[x, y, z]] +//- vals +[3, 4, 5] +//- body +assert.sameValue(x, 3); +assert.sameValue(y, 4); +assert.sameValue(z, 5); diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-ary-elision.case b/src/dstr-binding-for-await/ary-ptrn-rest-ary-elision.case new file mode 100644 index 000000000..d11cb7243 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-ary-elision.case @@ -0,0 +1,55 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: default +desc: Rest element containing an elision +info: | + 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). +features: [generators] +---*/ + +//- setup +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; +//- elems +[...[,]] +//- vals +g() +//- body +assert.sameValue(first, 1); +assert.sameValue(second, 1); diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-ary-empty.case b/src/dstr-binding-for-await/ary-ptrn-rest-ary-empty.case new file mode 100644 index 000000000..bbaea3f56 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-ary-empty.case @@ -0,0 +1,38 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: default +desc: Rest element containing an "empty" array pattern +info: | + 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). +features: [generators] +---*/ + +//- setup +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); +//- elems +[...[]] +//- vals +iter +//- body +assert.sameValue(iterations, 1); diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-ary-rest.case b/src/dstr-binding-for-await/ary-ptrn-rest-ary-rest.case new file mode 100644 index 000000000..428687e1c --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-ary-rest.case @@ -0,0 +1,34 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: default +desc: Rest element containing a rest element +info: | + 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. + [...] +---*/ + +//- setup +var values = [1, 2, 3]; +//- elems +[...[...x]] +//- vals +values +//- body +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/src/dstr-binding-for-await/ary-ptrn-rest-id-elision-next-err.case b/src/dstr-binding-for-await/ary-ptrn-rest-id-elision-next-err.case new file mode 100644 index 000000000..96ac1ad5a --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-id-elision-next-err.case @@ -0,0 +1,28 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: error +desc: Rest element following elision elements +info: > + 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. +features: [generators] +---*/ + +//- setup +var iter = (function*() { throw new Test262Error(); })(); +//- elems +[, ...x] +//- vals +iter +//- error +Test262Error diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-id-elision.case b/src/dstr-binding-for-await/ary-ptrn-rest-id-elision.case new file mode 100644 index 000000000..0643b134d --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-id-elision.case @@ -0,0 +1,32 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: default +desc: Rest element following elision elements +info: > + 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. +---*/ + +//- setup +var values = [1, 2, 3, 4, 5]; +//- elems +[ , , ...x] +//- vals +values +//- body +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/src/dstr-binding-for-await/ary-ptrn-rest-id-exhausted.case b/src/dstr-binding-for-await/ary-ptrn-rest-id-exhausted.case new file mode 100644 index 000000000..18ab5e958 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-id-exhausted.case @@ -0,0 +1,30 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: default +desc: RestElement applied to an exhausted iterator +info: > + 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). +features: [Symbol.iterator] +---*/ + +//- elems +[, , ...x] +//- vals +[1, 2] +//- body +assert(Array.isArray(x)); +assert.sameValue(x.length, 0); diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-id-iter-close.case b/src/dstr-binding-for-await/ary-ptrn-rest-id-iter-close.case new file mode 100644 index 000000000..2127b9eda --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-id-iter-close.case @@ -0,0 +1,21 @@ +// Copyright (C) 2017 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: iter-close +desc: > + The iterator is properly consumed by the destructuring pattern +---*/ + +//- setup +const iter = (function* () { + yield; + yield; +})(); + +//- elems +[...x] +//- iter +iter +//- assertions +assert.sameValue(iter.next().done, true, 'iteration occurred as expected'); diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-id-iter-step-err.case b/src/dstr-binding-for-await/ary-ptrn-rest-id-iter-step-err.case new file mode 100644 index 000000000..48b826f78 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-id-iter-step-err.case @@ -0,0 +1,38 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: error +desc: Error forwarding when IteratorStep returns an abrupt completion +info: > + 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). +features: [generators] +---*/ + +//- setup +var first = 0; +var second = 0; +var iter = function*() { + first += 1; + throw new Test262Error(); + second += 1; +}(); +//- elems +[...x] +//- vals +iter +//- error +Test262Error diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-id-iter-val-err.case b/src/dstr-binding-for-await/ary-ptrn-rest-id-iter-val-err.case new file mode 100644 index 000000000..5912533b8 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-id-iter-val-err.case @@ -0,0 +1,44 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: error +desc: Error forwarding when IteratorValue returns an abrupt completion +info: > + 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). +features: [Symbol.iterator] +---*/ + +//- setup +var poisonedValue = Object.defineProperty({}, 'value', { + get: function() { + throw new Test262Error(); + } +}); +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next() { + return poisonedValue; + } + }; +}; +//- elems +[...x] +//- vals +iter +//- error +Test262Error diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-id.case b/src/dstr-binding-for-await/ary-ptrn-rest-id.case new file mode 100644 index 000000000..93ea865be --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-id.case @@ -0,0 +1,32 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: default +desc: Lone rest element +info: > + 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). + [...] +---*/ + +//- setup +var values = [1, 2, 3]; +//- elems +[...x] +//- vals +values +//- body +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/src/dstr-binding-for-await/ary-ptrn-rest-init-ary.case b/src/dstr-binding-for-await/ary-ptrn-rest-init-ary.case new file mode 100644 index 000000000..8d302fa4c --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-init-ary.case @@ -0,0 +1,21 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: default +desc: Reset element (nested array pattern) does not support initializer +negative: + phase: early + type: SyntaxError +info: > + 13.3.3 Destructuring Binding Patterns + + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +//- elems +[...[ x ] = []] +//- vals +[] diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-init-id.case b/src/dstr-binding-for-await/ary-ptrn-rest-init-id.case new file mode 100644 index 000000000..157935b1a --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-init-id.case @@ -0,0 +1,21 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: default +desc: Reset element (identifier) does not support initializer +negative: + phase: early + type: SyntaxError +info: > + 13.3.3 Destructuring Binding Patterns + + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +//- elems +[...x = []] +//- vals +[] diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-init-obj.case b/src/dstr-binding-for-await/ary-ptrn-rest-init-obj.case new file mode 100644 index 000000000..e55c245fd --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-init-obj.case @@ -0,0 +1,21 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: default +desc: Reset element (nested object pattern) does not support initializer +negative: + phase: early + type: SyntaxError +info: > + 13.3.3 Destructuring Binding Patterns + + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +//- elems +[...{ x } = []] +//- vals +[] diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-not-final-ary.case b/src/dstr-binding-for-await/ary-ptrn-rest-not-final-ary.case new file mode 100644 index 000000000..4a7b66f86 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-not-final-ary.case @@ -0,0 +1,21 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: default +desc: Rest element (array binding pattern) may not be followed by any element +negative: + phase: early + type: SyntaxError +info: > + 13.3.3 Destructuring Binding Patterns + + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +//- elems +[...[x], y] +//- vals +[1, 2, 3] diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-not-final-id.case b/src/dstr-binding-for-await/ary-ptrn-rest-not-final-id.case new file mode 100644 index 000000000..b569bb020 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-not-final-id.case @@ -0,0 +1,21 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: default +desc: Rest element (identifier) may not be followed by any element +negative: + phase: early + type: SyntaxError +info: > + 13.3.3 Destructuring Binding Patterns + + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +//- elems +[...x, y] +//- vals +[1, 2, 3] diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-not-final-obj.case b/src/dstr-binding-for-await/ary-ptrn-rest-not-final-obj.case new file mode 100644 index 000000000..3540f3dd1 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-not-final-obj.case @@ -0,0 +1,21 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: default +desc: Rest element (object binding pattern) may not be followed by any element +negative: + phase: early + type: SyntaxError +info: > + 13.3.3 Destructuring Binding Patterns + + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +//- elems +[...{ x }, y] +//- vals +[1, 2, 3] diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-obj-id.case b/src/dstr-binding-for-await/ary-ptrn-rest-obj-id.case new file mode 100644 index 000000000..5270aadda --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-obj-id.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: default +desc: Rest element containing an object binding pattern +info: | + 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. + [...] +---*/ + +//- elems +[...{ length }] +//- vals +[1, 2, 3] +//- body +assert.sameValue(length, 3); diff --git a/src/dstr-binding-for-await/ary-ptrn-rest-obj-prop-id.case b/src/dstr-binding-for-await/ary-ptrn-rest-obj-prop-id.case new file mode 100644 index 000000000..17c410b43 --- /dev/null +++ b/src/dstr-binding-for-await/ary-ptrn-rest-obj-prop-id.case @@ -0,0 +1,34 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: default +desc: Rest element containing an object binding pattern +info: | + 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. + [...] +---*/ + +//- setup +let length = "outer"; +//- elems +[...{ 0: v, 1: w, 2: x, 3: y, length: z }] +//- vals +[7, 8, 9] +//- body +assert.sameValue(v, 7); +assert.sameValue(w, 8); +assert.sameValue(x, 9); +assert.sameValue(y, undefined); +assert.sameValue(z, 3); + +assert.sameValue(length, "outer", "the length prop is not set as a binding name"); diff --git a/src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template b/src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template new file mode 100644 index 000000000..a897bc969 --- /dev/null +++ b/src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template @@ -0,0 +1,54 @@ +// Copyright (C) 2017 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-func-dstr-const-async- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [/*{ vals }*/]; +})(); + +async function fn() { + for await (const /*{ elems }*/ of asyncIter) { + /*{ body }*/ + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-binding-for-await/default/for-await-of-async-func-const.template b/src/dstr-binding-for-await/default/for-await-of-async-func-const.template new file mode 100644 index 000000000..b4a0fffd8 --- /dev/null +++ b/src/dstr-binding-for-await/default/for-await-of-async-func-const.template @@ -0,0 +1,51 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-func-dstr-const- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; + +async function fn() { + for await (const /*{ elems }*/ of [/*{ vals }*/]) { + /*{ body }*/ + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template b/src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template new file mode 100644 index 000000000..6f971f061 --- /dev/null +++ b/src/dstr-binding-for-await/default/for-await-of-async-func-let-async.template @@ -0,0 +1,54 @@ +// Copyright (C) 2017 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-func-dstr-let-async- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [/*{ vals }*/]; +})(); + +async function fn() { + for await (let /*{ elems }*/ of asyncIter) { + /*{ body }*/ + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-binding-for-await/default/for-await-of-async-func-let.template b/src/dstr-binding-for-await/default/for-await-of-async-func-let.template new file mode 100644 index 000000000..c184e3b5f --- /dev/null +++ b/src/dstr-binding-for-await/default/for-await-of-async-func-let.template @@ -0,0 +1,52 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-func-dstr-let- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; + +async function fn() { + for await (let /*{ elems }*/ of [/*{ vals }*/]) { + /*{ body }*/ + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); + diff --git a/src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template b/src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template new file mode 100644 index 000000000..168232082 --- /dev/null +++ b/src/dstr-binding-for-await/default/for-await-of-async-func-var-async.template @@ -0,0 +1,54 @@ +// Copyright (C) 2017 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-func-dstr-var-async- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [/*{ vals }*/]; +})(); + +async function fn() { + for await (var /*{ elems }*/ of asyncIter) { + /*{ body }*/ + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-binding-for-await/default/for-await-of-async-func-var.template b/src/dstr-binding-for-await/default/for-await-of-async-func-var.template new file mode 100644 index 000000000..2d1e14265 --- /dev/null +++ b/src/dstr-binding-for-await/default/for-await-of-async-func-var.template @@ -0,0 +1,49 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-func-dstr-var- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + 1. Assert: lhs is a ForBinding. + 2. Let status be the result of performing BindingInitialization + for lhs passing nextValue and undefined as the arguments. + [...] +---*/ + +var iterCount = 0; + +async function fn() { + for await (var /*{ elems }*/ of [/*{ vals }*/]) { + /*{ body }*/ + + iterCount += 1; + } +} + +fn() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); + diff --git a/src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template b/src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template new file mode 100644 index 000000000..592433e70 --- /dev/null +++ b/src/dstr-binding-for-await/default/for-await-of-async-gen-const-async.template @@ -0,0 +1,54 @@ +// Copyright (C) 2017 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-gen-dstr-const-async- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [/*{ vals }*/]; +})(); + +async function *fn() { + for await (const /*{ elems }*/ of asyncIter) { + /*{ body }*/ + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-binding-for-await/default/for-await-of-async-gen-const.template b/src/dstr-binding-for-await/default/for-await-of-async-gen-const.template new file mode 100644 index 000000000..f8627fbd1 --- /dev/null +++ b/src/dstr-binding-for-await/default/for-await-of-async-gen-const.template @@ -0,0 +1,51 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-gen-dstr-const- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; + +async function *fn() { + for await (const /*{ elems }*/ of [/*{ vals }*/]) { + /*{ body }*/ + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template b/src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template new file mode 100644 index 000000000..aeb133ad4 --- /dev/null +++ b/src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template @@ -0,0 +1,54 @@ +// Copyright (C) 2017 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-gen-dstr-let-async- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [/*{ vals }*/]; +})(); + +async function *fn() { + for await (let /*{ elems }*/ of asyncIter) { + /*{ body }*/ + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-binding-for-await/default/for-await-of-async-gen-let.template b/src/dstr-binding-for-await/default/for-await-of-async-gen-let.template new file mode 100644 index 000000000..99a60f8dd --- /dev/null +++ b/src/dstr-binding-for-await/default/for-await-of-async-gen-let.template @@ -0,0 +1,52 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-gen-dstr-let- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; + +async function *fn() { + for await (let /*{ elems }*/ of [/*{ vals }*/]) { + /*{ body }*/ + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); + diff --git a/src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template b/src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template new file mode 100644 index 000000000..c251fda07 --- /dev/null +++ b/src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template @@ -0,0 +1,54 @@ +// Copyright (C) 2017 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-gen-dstr-var-async- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + [...] + iii. Else, + 1. Assert: lhsKind is lexicalBinding. + 2. Assert: lhs is a ForDeclaration. + 3. Let status be the result of performing BindingInitialization + for lhs passing nextValue and iterationEnv as arguments. + [...] +---*/ + +var iterCount = 0; +var asyncIter = (async function*() { + yield* [/*{ vals }*/]; +})(); + +async function *fn() { + for await (var /*{ elems }*/ of asyncIter) { + /*{ body }*/ + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); diff --git a/src/dstr-binding-for-await/default/for-await-of-async-gen-var.template b/src/dstr-binding-for-await/default/for-await-of-async-gen-var.template new file mode 100644 index 000000000..798f4fa22 --- /dev/null +++ b/src/dstr-binding-for-await/default/for-await-of-async-gen-var.template @@ -0,0 +1,49 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-gen-dstr-var- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. Else + i. If lhsKind is assignment, then + [...] + ii. Else if lhsKind is varBinding, then + 1. Assert: lhs is a ForBinding. + 2. Let status be the result of performing BindingInitialization + for lhs passing nextValue and undefined as the arguments. + [...] +---*/ + +var iterCount = 0; + +async function *fn() { + for await (var /*{ elems }*/ of [/*{ vals }*/]) { + /*{ body }*/ + + iterCount += 1; + } +} + +fn().next() + .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE) + .then($DONE, $DONE); + diff --git a/src/dstr-binding-for-await/error/for-await-of-async-func-const.template b/src/dstr-binding-for-await/error/for-await-of-async-func-const.template new file mode 100644 index 000000000..dc2fc2499 --- /dev/null +++ b/src/dstr-binding-for-await/error/for-await-of-async-func-const.template @@ -0,0 +1,48 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-func-dstr-const- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. 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. + [...] +---*/ + +async function fn() { + for await (const /*{ elems }*/ of [/*{ vals }*/]) { + return; + } +} + +fn() + .then(_ => { throw new Test262Error("Expected async function to reject, but resolved."); }, ({ constructor }) => assert.sameValue(constructor, /*{ error }*/)) + .then($DONE, $DONE); + diff --git a/src/dstr-binding-for-await/error/for-await-of-async-func-let.template b/src/dstr-binding-for-await/error/for-await-of-async-func-let.template new file mode 100644 index 000000000..291b51a64 --- /dev/null +++ b/src/dstr-binding-for-await/error/for-await-of-async-func-let.template @@ -0,0 +1,48 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-func-dstr-let- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. 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. + [...] +---*/ + +async function fn() { + for await (let /*{ elems }*/ of [/*{ vals }*/]) { + return; + } +} + +fn() + .then(_ => { throw new Test262Error("Expected async function to reject, but resolved."); }, ({ constructor }) => assert.sameValue(constructor, /*{ error }*/)) + .then($DONE, $DONE); + diff --git a/src/dstr-binding-for-await/error/for-await-of-async-func-var.template b/src/dstr-binding-for-await/error/for-await-of-async-func-var.template new file mode 100644 index 000000000..ab9ae9712 --- /dev/null +++ b/src/dstr-binding-for-await/error/for-await-of-async-func-var.template @@ -0,0 +1,47 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-func-dstr-var- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. 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. + [...] +---*/ + +async function fn() { + for await (var /*{ elems }*/ of [/*{ vals }*/]) { + return; + } +} + +fn() + .then(_ => { throw new Test262Error("Expected async function to reject, but resolved."); }, ({ constructor }) => assert.sameValue(constructor, /*{ error }*/)) + .then($DONE, $DONE); diff --git a/src/dstr-binding-for-await/error/for-await-of-async-gen-const.template b/src/dstr-binding-for-await/error/for-await-of-async-gen-const.template new file mode 100644 index 000000000..85241ea97 --- /dev/null +++ b/src/dstr-binding-for-await/error/for-await-of-async-gen-const.template @@ -0,0 +1,52 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-gen-dstr-const- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. 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. + [...] +---*/ + +async function * gen() { + for await (const /*{ elems }*/ of [/*{ vals }*/]) { + return; + } +} + +gen().next() + .then(_ => { + throw new Test262Error("Expected async function to reject, but resolved."); + }, ({ constructor }) => { + assert.sameValue(constructor, /*{ error }*/); + /*{ rejectBody }*/ + }) + .then($DONE, $DONE); diff --git a/src/dstr-binding-for-await/error/for-await-of-async-gen-let.template b/src/dstr-binding-for-await/error/for-await-of-async-gen-let.template new file mode 100644 index 000000000..f75e5e204 --- /dev/null +++ b/src/dstr-binding-for-await/error/for-await-of-async-gen-let.template @@ -0,0 +1,52 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-gen-dstr-let- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. 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. + [...] +---*/ + +async function * gen() { + for await (let /*{ elems }*/ of [/*{ vals }*/]) { + return; + } +} + +gen().next() + .then(_ => { + throw new Test262Error("Expected async function to reject, but resolved."); + }, ({ constructor }) => { + assert.sameValue(constructor, /*{ error }*/); + /*{ rejectBody }*/ + }) + .then($DONE, $DONE); diff --git a/src/dstr-binding-for-await/error/for-await-of-async-gen-var.template b/src/dstr-binding-for-await/error/for-await-of-async-gen-var.template new file mode 100644 index 000000000..c0bbe2f0f --- /dev/null +++ b/src/dstr-binding-for-await/error/for-await-of-async-gen-var.template @@ -0,0 +1,53 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-gen-dstr-var- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. 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. + [...] +---*/ + +async function * gen() { + for await (var /*{ elems }*/ of [/*{ vals }*/]) { + return; + } +} + +gen().next() + .then(_ => { + throw new Test262Error("Expected async function to reject, but resolved."); + }, ({ constructor }) => { + assert.sameValue(constructor, /*{ error }*/); + /*{ rejectBody }*/ + }) + .then($DONE, $DONE); + diff --git a/src/dstr-binding-for-await/iter-close/for-await-of-async-func-const.template b/src/dstr-binding-for-await/iter-close/for-await-of-async-func-const.template new file mode 100644 index 000000000..810e76c3f --- /dev/null +++ b/src/dstr-binding-for-await/iter-close/for-await-of-async-func-const.template @@ -0,0 +1,50 @@ +// Copyright (C) 2017 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/for-await-of/async-func-dstr-const- +name: for-await-of statement in an async function +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. 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. + [...] +---*/ + +async function fn() { + for await (const /*{ elems }*/ of [/*{ iter }*/]) { + return; + } +} + +fn() + .then(() => { + /*{ assertions }*/ + }) + .then($DONE, $DONE); diff --git a/src/dstr-binding-for-await/iter-close/for-await-of-async-func-let.template b/src/dstr-binding-for-await/iter-close/for-await-of-async-func-let.template new file mode 100644 index 000000000..b58a49e0d --- /dev/null +++ b/src/dstr-binding-for-await/iter-close/for-await-of-async-func-let.template @@ -0,0 +1,50 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-func-dstr-let- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. 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. + [...] +---*/ + +async function fn() { + for await (let /*{ elems }*/ of [/*{ iter }*/]) { + return; + } +} + +fn() + .then(() => { + /*{ assertions }*/ + }) + .then($DONE, $DONE); + diff --git a/src/dstr-binding-for-await/iter-close/for-await-of-async-func-var.template b/src/dstr-binding-for-await/iter-close/for-await-of-async-func-var.template new file mode 100644 index 000000000..4f38c2f89 --- /dev/null +++ b/src/dstr-binding-for-await/iter-close/for-await-of-async-func-var.template @@ -0,0 +1,46 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-func-dstr-var- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. 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. + [...] +---*/ + +async function fn() { + for await (var /*{ elems }*/ of [/*{ iter }*/]) { + return; + } +} + +fn() + .then(() => { + /*{ assertions }*/ + }) + .then($DONE, $DONE); diff --git a/src/dstr-binding-for-await/iter-close/for-await-of-async-gen-const.template b/src/dstr-binding-for-await/iter-close/for-await-of-async-gen-const.template new file mode 100644 index 000000000..718187bba --- /dev/null +++ b/src/dstr-binding-for-await/iter-close/for-await-of-async-gen-const.template @@ -0,0 +1,50 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-gen-dstr-const- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. 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. + [...] +---*/ + +async function* fn() { + for await (const /*{ elems }*/ of [/*{ iter }*/]) { + return; + } +} + +fn() + .next() + .then(() => { + /*{ assertions }*/ + }) + .then($DONE, $DONE); diff --git a/src/dstr-binding-for-await/iter-close/for-await-of-async-gen-let.template b/src/dstr-binding-for-await/iter-close/for-await-of-async-gen-let.template new file mode 100644 index 000000000..020dee9bc --- /dev/null +++ b/src/dstr-binding-for-await/iter-close/for-await-of-async-gen-let.template @@ -0,0 +1,50 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-gen-dstr-let- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( ForDeclaration of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, + lexicalBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. 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. + [...] +---*/ + +async function* fn() { + for await (let /*{ elems }*/ of [/*{ iter }*/]) { + return; + } +} + +fn() + .next() + .then(() => { + /*{ assertions }*/ + }) + .then($DONE, $DONE); diff --git a/src/dstr-binding-for-await/iter-close/for-await-of-async-gen-var.template b/src/dstr-binding-for-await/iter-close/for-await-of-async-gen-var.template new file mode 100644 index 000000000..0d95fda7d --- /dev/null +++ b/src/dstr-binding-for-await/iter-close/for-await-of-async-gen-var.template @@ -0,0 +1,47 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/for-await-of/async-gen-dstr-var- +name: for-await-of statement +esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation +features: [destructuring-binding, async-iteration] +flags: [async] +info: | + IterationStatement : + for await ( var ForBinding of AssignmentExpression ) Statement + + [...] + 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, + varBinding, labelSet, async). + + 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation + + [...] + 4. Let destructuring be IsDestructuring of lhs. + [...] + 6. Repeat + [...] + j. If destructuring is false, then + [...] + k. 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. + [...] +---*/ + +async function* fn() { + for await (var /*{ elems }*/ of [/*{ iter }*/]) { + return; + } +} + +fn() + .next() + .then(() => { + /*{ assertions }*/ + }) + .then($DONE, $DONE); diff --git a/src/dstr-binding-for-await/obj-init-null.case b/src/dstr-binding-for-await/obj-init-null.case new file mode 100644 index 000000000..23aa54c10 --- /dev/null +++ b/src/dstr-binding-for-await/obj-init-null.case @@ -0,0 +1,19 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: error +desc: Value specifed for object binding pattern must be object coercible (null) +info: | + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +//- elems +{} +//- vals +null +//- error +TypeError diff --git a/src/dstr-binding-for-await/obj-init-undefined.case b/src/dstr-binding-for-await/obj-init-undefined.case new file mode 100644 index 000000000..90d27b009 --- /dev/null +++ b/src/dstr-binding-for-await/obj-init-undefined.case @@ -0,0 +1,19 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: error +desc: Value specifed for object binding pattern must be object coercible (undefined) +info: | + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +//- elems +{} +//- vals +undefined +//- error +TypeError diff --git a/src/dstr-binding-for-await/obj-ptrn-empty.case b/src/dstr-binding-for-await/obj-ptrn-empty.case new file mode 100644 index 000000000..1431451d4 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-empty.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: default +desc: No property access occurs for an "empty" object binding pattern +info: | + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +//- setup +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); +//- elems +{} +//- vals +obj +//- body +assert.sameValue(accessCount, 0); diff --git a/src/dstr-binding-for-await/obj-ptrn-id-get-value-err.case b/src/dstr-binding-for-await/obj-ptrn-id-get-value-err.case new file mode 100644 index 000000000..b2362e7eb --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-id-get-value-err.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: error +desc: Error thrown when accessing the corresponding property of the value object +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 4. Let v be GetV(value, propertyName). + 5. ReturnIfAbrupt(v). +---*/ + +//- setup +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); +//- elems +{ poisoned } +//- vals +poisonedProperty +//- error +Test262Error diff --git a/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-arrow.case b/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-arrow.case new file mode 100644 index 000000000..998eff71d --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-arrow.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: SingleNameBinding assigns `name` to arrow functions +template: default +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 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). +---*/ + +//- elems +{ arrow = () => {} } +//- vals +{} +//- body +assert.sameValue(arrow.name, 'arrow'); diff --git a/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-class.case b/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-class.case new file mode 100644 index 000000000..32efdf247 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-class.case @@ -0,0 +1,28 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: SingleNameBinding assigns `name` to "anonymous" classes +template: default +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 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). +---*/ + +//- elems +{ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } +//- vals +{} +//- body +assert.sameValue(cls.name, 'cls'); +assert.notSameValue(xCls.name, 'xCls'); +assert.notSameValue(xCls2.name, 'xCls2'); diff --git a/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-cover.case b/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-cover.case new file mode 100644 index 000000000..219617289 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-cover.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar +template: default +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 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). +---*/ + +//- elems +{ cover = (function () {}), xCover = (0, function() {}) } +//- vals +{} +//- body +assert.sameValue(cover.name, 'cover'); +assert.notSameValue(xCover.name, 'xCover'); diff --git a/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-fn.case b/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-fn.case new file mode 100644 index 000000000..a2a99b438 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-fn.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: SingleNameBinding assigns name to "anonymous" functions +template: default +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 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). +---*/ + +//- elems +{ fn = function () {}, xFn = function x() {} } +//- vals +{} +//- body +assert.sameValue(fn.name, 'fn'); +assert.notSameValue(xFn.name, 'xFn'); diff --git a/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-gen.case b/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-gen.case new file mode 100644 index 000000000..3eb8bcd5d --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-id-init-fn-name-gen.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: SingleNameBinding assigns name to "anonymous" generator functions +template: default +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 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). +---*/ + +//- elems +{ gen = function* () {}, xGen = function* x() {} } +//- vals +{} +//- body +assert.sameValue(gen.name, 'gen'); +assert.notSameValue(xGen.name, 'xGen'); diff --git a/src/dstr-binding-for-await/obj-ptrn-id-init-skipped.case b/src/dstr-binding-for-await/obj-ptrn-id-init-skipped.case new file mode 100644 index 000000000..8d666d508 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-id-init-skipped.case @@ -0,0 +1,31 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Destructuring initializer is not evaluated when value is not `undefined` +template: default +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ + +//- setup +var initCount = 0; +function counter() { + initCount += 1; +} +//- elems +{ w = counter(), x = counter(), y = counter(), z = counter() } +//- vals +{ w: null, x: 0, y: false, z: '' } +//- body +assert.sameValue(w, null); +assert.sameValue(x, 0); +assert.sameValue(y, false); +assert.sameValue(z, ''); +assert.sameValue(initCount, 0); diff --git a/src/dstr-binding-for-await/obj-ptrn-id-init-throws.case b/src/dstr-binding-for-await/obj-ptrn-id-init-throws.case new file mode 100644 index 000000000..411983d82 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-id-init-throws.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: error +desc: Error thrown when evaluating the initializer +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). +---*/ + +//- setup +function thrower() { + throw new Test262Error(); +} +//- elems +{ x = thrower() } +//- vals +{} +//- error +Test262Error diff --git a/src/dstr-binding-for-await/obj-ptrn-id-init-unresolvable.case b/src/dstr-binding-for-await/obj-ptrn-id-init-unresolvable.case new file mode 100644 index 000000000..9e00a4aad --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-id-init-unresolvable.case @@ -0,0 +1,29 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Destructuring initializer is an unresolvable reference +template: error +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 5. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Set v to ? GetValue(defaultValue). + + 6.2.4.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. +---*/ + +//- elems +{ x = unresolvableReference } +//- vals +{} +//- error +ReferenceError diff --git a/src/dstr-binding-for-await/obj-ptrn-id-trailing-comma.case b/src/dstr-binding-for-await/obj-ptrn-id-trailing-comma.case new file mode 100644 index 000000000..3cfb1f710 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-id-trailing-comma.case @@ -0,0 +1,20 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: default +desc: Trailing comma is allowed following BindingPropertyList +info: | + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +//- elems +{ x, } +//- vals +{ x: 23 } +//- body +assert.sameValue(x, 23); diff --git a/src/dstr-binding-for-await/obj-ptrn-list-err.case b/src/dstr-binding-for-await/obj-ptrn-list-err.case new file mode 100644 index 000000000..fd545b398 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-list-err.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: error +desc: Binding property list evaluation is interrupted by an abrupt completion +info: | + 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). +---*/ + +//- setup +var initCount = 0; +function thrower() { + throw new Test262Error(); +} +//- elems +{ a, b = thrower(), c = ++initCount } +//- vals +{} +//- error +Test262Error diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-ary-init.case b/src/dstr-binding-for-await/obj-ptrn-prop-ary-init.case new file mode 100644 index 000000000..d5cded54a --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-ary-init.case @@ -0,0 +1,28 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: default +desc: Object binding pattern with "nested" array binding pattern using initializer +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 4. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Set v to ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +//- elems +{ w: [x, y, z] = [4, 5, 6] } +//- vals +{} +//- body +assert.sameValue(x, 4); +assert.sameValue(y, 5); +assert.sameValue(z, 6); + +assert.throws(ReferenceError, function() { + w; +}); diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-ary-trailing-comma.case b/src/dstr-binding-for-await/obj-ptrn-prop-ary-trailing-comma.case new file mode 100644 index 000000000..7cccbd084 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-ary-trailing-comma.case @@ -0,0 +1,20 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: default +desc: Trailing comma is allowed following BindingPropertyList +info: | + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +//- elems +{ x: [y], } +//- vals +{ x: [45] } +//- body +assert.sameValue(y,45); diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-ary-value-null.case b/src/dstr-binding-for-await/obj-ptrn-prop-ary-value-null.case new file mode 100644 index 000000000..af5b3ec08 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-ary-value-null.case @@ -0,0 +1,21 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: error +desc: Object binding pattern with "nested" array binding pattern taking the `null` value +info: | + 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. +---*/ + +//- elems +{ w: [x, y, z] = [4, 5, 6] } +//- vals +{ w: null } +//- error +TypeError diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-ary.case b/src/dstr-binding-for-await/obj-ptrn-prop-ary.case new file mode 100644 index 000000000..40a73c566 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-ary.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: default +desc: Object binding pattern with "nested" array binding pattern not using initializer +info: | + 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. +---*/ + +//- elems +{ w: [x, y, z] = [4, 5, 6] } +//- vals +{ w: [7, undefined, ] } +//- body +assert.sameValue(x, 7); +assert.sameValue(y, undefined); +assert.sameValue(z, undefined); + +assert.throws(ReferenceError, function() { + w; +}); diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-eval-err.case b/src/dstr-binding-for-await/obj-ptrn-prop-eval-err.case new file mode 100644 index 000000000..12e985009 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-eval-err.case @@ -0,0 +1,24 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Evaluation of property name returns an abrupt completion +template: error +info: | + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingProperty : PropertyName : BindingElement + + 1. Let P be the result of evaluating PropertyName + 2. ReturnIfAbrupt(P). +---*/ + +//- setup +function thrower() { + throw new Test262Error(); +} +//- elems +{ [thrower()]: x } +//- vals +{} +//- error +Test262Error diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-id-get-value-err.case b/src/dstr-binding-for-await/obj-ptrn-prop-id-get-value-err.case new file mode 100644 index 000000000..5b6c9d14d --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-id-get-value-err.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Error thrown when accessing the corresponding property of the value object +template: error +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializer_opt + + 1. Let v be GetV(value, propertyName). + 2. ReturnIfAbrupt(v). +---*/ + +//- setup +var initEvalCount = 0; +var poisonedProperty = Object.defineProperty({}, 'poisoned', { + get: function() { + throw new Test262Error(); + } +}); +//- elems +{ poisoned: x = ++initEvalCount } +//- vals +poisonedProperty +//- error +Test262Error diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-id-init-skipped.case b/src/dstr-binding-for-await/obj-ptrn-prop-id-init-skipped.case new file mode 100644 index 000000000..ad6d039b1 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-id-init-skipped.case @@ -0,0 +1,43 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Destructuring initializer is not evaluated when value is not `undefined` +template: default +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializer_opt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ + +//- setup +var initCount = 0; +function counter() { + initCount += 1; +} +//- elems +{ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } +//- vals +{ s: null, u: 0, w: false, y: '' } +//- body +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/src/dstr-binding-for-await/obj-ptrn-prop-id-init-throws.case b/src/dstr-binding-for-await/obj-ptrn-prop-id-init-throws.case new file mode 100644 index 000000000..07d185806 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-id-init-throws.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: error +desc: Error thrown when evaluating the initializer +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializer_opt + + [...] + 4. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Set v to ? GetValue(defaultValue). +---*/ + +//- setup +function thrower() { + throw new Test262Error(); +} +//- elems +{ x: y = thrower() } +//- vals +{} +//- error +Test262Error diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-id-init-unresolvable.case b/src/dstr-binding-for-await/obj-ptrn-prop-id-init-unresolvable.case new file mode 100644 index 000000000..d7192fad3 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-id-init-unresolvable.case @@ -0,0 +1,29 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Destructuring initializer is an unresolvable reference +template: error +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializer_opt + + [...] + 4. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Set v to ? GetValue(defaultValue). + + 6.2.4.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. +---*/ + +//- elems +{ x: y = unresolvableReference } +//- vals +{} +//- error +ReferenceError diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-id-init.case b/src/dstr-binding-for-await/obj-ptrn-prop-id-init.case new file mode 100644 index 000000000..4ec47bb8e --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-id-init.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: default +desc: Binding as specified via property name, identifier, and initializer +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +{ x: y = 33 } +//- vals +{ } +//- body +assert.sameValue(y, 33); +assert.throws(ReferenceError, function() { + x; +}); diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-id-trailing-comma.case b/src/dstr-binding-for-await/obj-ptrn-prop-id-trailing-comma.case new file mode 100644 index 000000000..c131b3e34 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-id-trailing-comma.case @@ -0,0 +1,24 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: default +desc: Trailing comma is allowed following BindingPropertyList +info: | + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +//- elems +{ x: y, } +//- vals +{ x: 23 } +//- body +assert.sameValue(y, 23); + +assert.throws(ReferenceError, function() { + x; +}); diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-id.case b/src/dstr-binding-for-await/obj-ptrn-prop-id.case new file mode 100644 index 000000000..6ddeaba2b --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-id.case @@ -0,0 +1,23 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: default +desc: Binding as specified via property name and identifier +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + [...] + 7. Return InitializeReferencedBinding(lhs, v). +---*/ + +//- elems +{ x: y } +//- vals +{ x: 23 } +//- body +assert.sameValue(y, 23); +assert.throws(ReferenceError, function() { + x; +}); diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-obj-init.case b/src/dstr-binding-for-await/obj-ptrn-prop-obj-init.case new file mode 100644 index 000000000..6132854fb --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-obj-init.case @@ -0,0 +1,28 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: default +desc: Object binding pattern with "nested" object binding pattern using initializer +info: | + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 4. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Set v to ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +//- elems +{ w: { x, y, z } = { x: 4, y: 5, z: 6 } } +//- vals +{ w: undefined } +//- body +assert.sameValue(x, 4); +assert.sameValue(y, 5); +assert.sameValue(z, 6); + +assert.throws(ReferenceError, function() { + w; +}); diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-obj-value-null.case b/src/dstr-binding-for-await/obj-ptrn-prop-obj-value-null.case new file mode 100644 index 000000000..2ea5ba4d0 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-obj-value-null.case @@ -0,0 +1,21 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: error +desc: Object binding pattern with "nested" object binding pattern taking the `null` value +info: | + 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. +---*/ + +//- elems +{ w: { x, y, z } = { x: 4, y: 5, z: 6 } } +//- vals +{ w: null } +//- error +TypeError diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-obj-value-undef.case b/src/dstr-binding-for-await/obj-ptrn-prop-obj-value-undef.case new file mode 100644 index 000000000..a19912f83 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-obj-value-undef.case @@ -0,0 +1,21 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: error +desc: Object binding pattern with "nested" object binding pattern taking the `null` value +info: | + 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. +---*/ + +//- elems +{ w: { x, y, z } = undefined } +//- vals +{ } +//- error +TypeError diff --git a/src/dstr-binding-for-await/obj-ptrn-prop-obj.case b/src/dstr-binding-for-await/obj-ptrn-prop-obj.case new file mode 100644 index 000000000..c38a0b8a2 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-prop-obj.case @@ -0,0 +1,27 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +template: default +desc: Object binding pattern with "nested" object binding pattern not using initializer +info: | + 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. +---*/ + +//- elems +{ w: { x, y, z } = { x: 4, y: 5, z: 6 } } +//- vals +{ w: { x: undefined, z: 7 } } +//- body +assert.sameValue(x, undefined); +assert.sameValue(y, undefined); +assert.sameValue(z, 7); + +assert.throws(ReferenceError, function() { + w; +}); diff --git a/src/dstr-binding-for-await/obj-ptrn-rest-getter.case b/src/dstr-binding-for-await/obj-ptrn-rest-getter.case new file mode 100644 index 000000000..c5360e5e5 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-rest-getter.case @@ -0,0 +1,26 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Getter is called when obj is being deconstructed to a rest Object +template: default +esid: pending +includes: [propertyHelper.js] +features: [object-rest] +---*/ + +//- setup +var count = 0; +//- elems +{...x} +//- vals +{ get v() { count++; return 2; } } +//- body +assert.sameValue(x.v, 2); +assert.sameValue(count, 1); + +verifyEnumerable(x, "v"); +verifyWritable(x, "v"); +verifyConfigurable(x, "v"); + diff --git a/src/dstr-binding-for-await/obj-ptrn-rest-nested-obj.case b/src/dstr-binding-for-await/obj-ptrn-rest-nested-obj.case new file mode 100644 index 000000000..8fb0bb2d1 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-rest-nested-obj.case @@ -0,0 +1,25 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an object literal, it should be parsed + parsed as a DestructuringAssignmentPattern and evaluated as a destructuring + assignment. +template: default +esid: pending +features: [object-rest] +---*/ + +//- setup +var obj = {a: 3, b: 4}; +//- elems +{a, b, ...{c, e}} +//- vals +{a: 1, b: 2, c: 3, d: 4, e: 5} +//- body +assert.sameValue(a, 1); +assert.sameValue(b, 2); +assert.sameValue(c, 3); +assert.sameValue(e, 5); + diff --git a/src/dstr-binding-for-await/obj-ptrn-rest-obj-nested-rest.case b/src/dstr-binding-for-await/obj-ptrn-rest-obj-nested-rest.case new file mode 100644 index 000000000..a6eb8c024 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-rest-obj-nested-rest.case @@ -0,0 +1,34 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + When DestructuringAssignmentTarget is an object literal, it should be parsed + parsed as a DestructuringAssignmentPattern and evaluated as a destructuring + assignment and object rest desconstruction is allowed in that case. +template: default +esid: pending +includes: [propertyHelper.js] +features: [object-rest] +---*/ + +//- elems +{a, b, ...{c, ...rest}} +//- vals +{a: 1, b: 2, c: 3, d: 4, e: 5} +//- body +assert.sameValue(a, 1); +assert.sameValue(b, 2); +assert.sameValue(c, 3); + +assert.sameValue(rest.d, 4); +assert.sameValue(rest.e, 5); + +verifyEnumerable(rest, "d"); +verifyWritable(rest, "d"); +verifyConfigurable(rest, "d"); + +verifyEnumerable(rest, "e"); +verifyWritable(rest, "e"); +verifyConfigurable(rest, "e"); + diff --git a/src/dstr-binding-for-await/obj-ptrn-rest-obj-own-property.case b/src/dstr-binding-for-await/obj-ptrn-rest-obj-own-property.case new file mode 100644 index 000000000..71c375adc --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-rest-obj-own-property.case @@ -0,0 +1,24 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Rest object contains just soruce object's own properties +template: default +esid: pending +includes: [propertyHelper.js] +features: [object-rest] +---*/ + +//- setup +var o = Object.create({ x: 1, y: 2 }); +o.z = 3; +//- elems +{ x, ...{y , z} } +//- vals +o +//- body +assert.sameValue(x, 1); +assert.sameValue(y, undefined); +assert.sameValue(z, 3); + diff --git a/src/dstr-binding-for-await/obj-ptrn-rest-skip-non-enumerable.case b/src/dstr-binding-for-await/obj-ptrn-rest-skip-non-enumerable.case new file mode 100644 index 000000000..869ffd241 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-rest-skip-non-enumerable.case @@ -0,0 +1,32 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Rest object doesn't contain non-enumerable properties +template: default +esid: pending +includes: [propertyHelper.js] +features: [object-rest] +---*/ + +//- setup +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); +//- elems +{...rest} +//- vals +o +//- body +assert.sameValue(rest.a, 3); +assert.sameValue(rest.b, 4); +assert.sameValue(rest.x, undefined); + +verifyEnumerable(rest, "a"); +verifyWritable(rest, "a"); +verifyConfigurable(rest, "a"); + +verifyEnumerable(rest, "b"); +verifyWritable(rest, "b"); +verifyConfigurable(rest, "b"); + diff --git a/src/dstr-binding-for-await/obj-ptrn-rest-val-obj.case b/src/dstr-binding-for-await/obj-ptrn-rest-val-obj.case new file mode 100644 index 000000000..0379ddd94 --- /dev/null +++ b/src/dstr-binding-for-await/obj-ptrn-rest-val-obj.case @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + Rest object contains just unextracted data +template: default +esid: pending +includes: [propertyHelper.js] +features: [object-rest] +---*/ + +//- elems +{a, b, ...rest} +//- vals +{x: 1, y: 2, a: 5, b: 3} +//- body +assert.sameValue(rest.x, 1); +assert.sameValue(rest.y, 2); +assert.sameValue(rest.a, undefined); +assert.sameValue(rest.b, undefined); + +verifyEnumerable(rest, "x"); +verifyWritable(rest, "x"); +verifyConfigurable(rest, "x"); + +verifyEnumerable(rest, "y"); +verifyWritable(rest, "y"); +verifyConfigurable(rest, "y"); + |