diff options
author | Leo Balter <leonardo.balter@gmail.com> | 2017-03-27 21:42:06 -0400 |
---|---|---|
committer | Leo Balter <leonardo.balter@gmail.com> | 2017-03-27 21:42:06 -0400 |
commit | 2c6a82e55f96cccff797f4c143931f214adf686a (patch) | |
tree | e2ec881889b4bae8373e09c2038d5ea220eb45ef /src | |
parent | 882b3cc0d073acb15f864504cea13fc07a0ec26e (diff) | |
download | qtdeclarative-testsuites-2c6a82e55f96cccff797f4c143931f214adf686a.tar.gz |
Add cases for abrupt completions in yield* in async generator - next
Closes #883
Diffstat (limited to 'src')
21 files changed, 1199 insertions, 0 deletions
diff --git a/src/async-generators/yield-star-next-call-done-get-abrupt.case b/src/async-generators/yield-star-next-call-done-get-abrupt.case new file mode 100644 index 000000000..6749370ab --- /dev/null +++ b/src/async-generators/yield-star-next-call-done-get-abrupt.case @@ -0,0 +1,56 @@ +// Copyright 2017 Tooru Fujisawa. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Abrupt completion while getting done +info: | + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... +features: [Symbol.asyncIterator] +flags: [async] +---*/ + +//- setup +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + +//- body + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +//- assertions +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); diff --git a/src/async-generators/yield-star-next-call-returns-abrupt.case b/src/async-generators/yield-star-next-call-returns-abrupt.case new file mode 100644 index 000000000..37cb148a3 --- /dev/null +++ b/src/async-generators/yield-star-next-call-returns-abrupt.case @@ -0,0 +1,48 @@ +// Copyright 2017 Tooru Fujisawa. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Abrupt completion while calling next +info: | + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... +features: [Symbol.asyncIterator] +flags: [async] +---*/ + +//- setup +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + +//- body + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +//- assertions +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); diff --git a/src/async-generators/yield-star-next-call-value-get-abrupt.case b/src/async-generators/yield-star-next-call-value-get-abrupt.case new file mode 100644 index 000000000..4dc8b6262 --- /dev/null +++ b/src/async-generators/yield-star-next-call-value-get-abrupt.case @@ -0,0 +1,58 @@ +// Copyright 2017 Tooru Fujisawa. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Abrupt completion while getting value +info: | + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... +features: [Symbol.asyncIterator] +flags: [async] +---*/ + +//- setup +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + +//- body + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +//- assertions +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); diff --git a/src/async-generators/yield-star-next-get-abrupt.case b/src/async-generators/yield-star-next-get-abrupt.case new file mode 100644 index 000000000..b18f937e3 --- /dev/null +++ b/src/async-generators/yield-star-next-get-abrupt.case @@ -0,0 +1,48 @@ +// Copyright 2017 Tooru Fujisawa. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Abrupt completion while getting next +info: | + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... +features: [Symbol.asyncIterator] +flags: [async] +---*/ + +//- setup +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + +//- body + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +//- assertions +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); diff --git a/src/async-generators/yield-star-next-non-object-ignores-then.case b/src/async-generators/yield-star-next-non-object-ignores-then.case new file mode 100644 index 000000000..f33e4929f --- /dev/null +++ b/src/async-generators/yield-star-next-non-object-ignores-then.case @@ -0,0 +1,68 @@ +// Copyright 2017 Tooru Fujisawa. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: If next() value is not-object, do not access respective then property +info: | + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... +features: [Symbol.asyncIterator] +flags: [async] +---*/ + +//- setup +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + +//- body + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +//- assertions +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); diff --git a/src/async-generators/yield-star-next-not-callable-boolean-throw.case b/src/async-generators/yield-star-next-not-callable-boolean-throw.case new file mode 100644 index 000000000..f4fd9ed74 --- /dev/null +++ b/src/async-generators/yield-star-next-not-callable-boolean-throw.case @@ -0,0 +1,45 @@ +// Copyright 2017 Tooru Fujisawa. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Not-callable next value in a yield star position - boolean +info: | + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... +features: [Symbol.asyncIterator] +flags: [async] +---*/ + +//- setup +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + +//- body + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +//- assertions +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); diff --git a/src/async-generators/yield-star-next-not-callable-null-throw.case b/src/async-generators/yield-star-next-not-callable-null-throw.case new file mode 100644 index 000000000..f4e86ead2 --- /dev/null +++ b/src/async-generators/yield-star-next-not-callable-null-throw.case @@ -0,0 +1,45 @@ +// Copyright 2017 Tooru Fujisawa. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Not-callable next value in a yield star position - null +info: | + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... +features: [Symbol.asyncIterator] +flags: [async] +---*/ + +//- setup +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + +//- body + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +//- assertions +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); diff --git a/src/async-generators/yield-star-next-not-callable-number-throw.case b/src/async-generators/yield-star-next-not-callable-number-throw.case new file mode 100644 index 000000000..5f6d1bcbd --- /dev/null +++ b/src/async-generators/yield-star-next-not-callable-number-throw.case @@ -0,0 +1,45 @@ +// Copyright 2017 Tooru Fujisawa. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Not-callable next value in a yield star position - number +info: | + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... +features: [Symbol.asyncIterator] +flags: [async] +---*/ + +//- setup +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + +//- body + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +//- assertions +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); diff --git a/src/async-generators/yield-star-next-not-callable-object-throw.case b/src/async-generators/yield-star-next-not-callable-object-throw.case new file mode 100644 index 000000000..31920e02c --- /dev/null +++ b/src/async-generators/yield-star-next-not-callable-object-throw.case @@ -0,0 +1,45 @@ +// Copyright 2017 Tooru Fujisawa. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Not-callable next value in a yield star position - object +info: | + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... +features: [Symbol.asyncIterator] +flags: [async] +---*/ + +//- setup +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + +//- body + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +//- assertions +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); diff --git a/src/async-generators/yield-star-next-not-callable-string-throw.case b/src/async-generators/yield-star-next-not-callable-string-throw.case new file mode 100644 index 000000000..70ce1dccb --- /dev/null +++ b/src/async-generators/yield-star-next-not-callable-string-throw.case @@ -0,0 +1,45 @@ +// Copyright 2017 Tooru Fujisawa. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Not-callable next value in a yield star position - string +info: | + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... +features: [Symbol.asyncIterator] +flags: [async] +---*/ + +//- setup +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + +//- body + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +//- assertions +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); diff --git a/src/async-generators/yield-star-next-not-callable-symbol-throw.case b/src/async-generators/yield-star-next-not-callable-symbol-throw.case new file mode 100644 index 000000000..7cbae93c7 --- /dev/null +++ b/src/async-generators/yield-star-next-not-callable-symbol-throw.case @@ -0,0 +1,45 @@ +// Copyright 2017 Tooru Fujisawa. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Not-callable next value in a yield star position - symbol +info: | + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... +features: [Symbol.asyncIterator] +flags: [async] +---*/ + +//- setup +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + +//- body + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +//- assertions +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); diff --git a/src/async-generators/yield-star-next-not-callable-undefined-throw.case b/src/async-generators/yield-star-next-not-callable-undefined-throw.case new file mode 100644 index 000000000..c84fd9ae8 --- /dev/null +++ b/src/async-generators/yield-star-next-not-callable-undefined-throw.case @@ -0,0 +1,45 @@ +// Copyright 2017 Tooru Fujisawa. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Not-callable next value in a yield star position - undefined +info: | + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... +features: [Symbol.asyncIterator] +flags: [async] +---*/ + +//- setup +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + +//- body + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +//- assertions +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); diff --git a/src/async-generators/yield-star-next-then-get-abrupt.case b/src/async-generators/yield-star-next-then-get-abrupt.case new file mode 100644 index 000000000..42ddf4ede --- /dev/null +++ b/src/async-generators/yield-star-next-then-get-abrupt.case @@ -0,0 +1,72 @@ +// Copyright 2017 Tooru Fujisawa. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Return abrupt after getting next().then +info: | + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... +features: [Symbol.asyncIterator] +flags: [async] +---*/ + +//- setup +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + +//- body + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +//- assertions +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); diff --git a/src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case b/src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case new file mode 100644 index 000000000..bfc4f121e --- /dev/null +++ b/src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case @@ -0,0 +1,66 @@ +// Copyright 2017 Tooru Fujisawa. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: FulfillPromise if next().then is not-callable (boolean) +info: | + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... +features: [Symbol.asyncIterator] +flags: [async] +---*/ + +//- setup +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + +//- body + yield* obj; + throw new Test262Error('completion closes iter'); + +//- assertions +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); diff --git a/src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case b/src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case new file mode 100644 index 000000000..33439725d --- /dev/null +++ b/src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case @@ -0,0 +1,66 @@ +// Copyright 2017 Tooru Fujisawa. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: FulfillPromise if next().then is not-callable (null) +info: | + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... +features: [Symbol.asyncIterator] +flags: [async] +---*/ + +//- setup +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + +//- body + yield* obj; + throw new Test262Error('completion closes iter'); + +//- assertions +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); diff --git a/src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case b/src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case new file mode 100644 index 000000000..fe7275a27 --- /dev/null +++ b/src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case @@ -0,0 +1,66 @@ +// Copyright 2017 Tooru Fujisawa. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: FulfillPromise if next().then is not-callable (number) +info: | + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... +features: [Symbol.asyncIterator] +flags: [async] +---*/ + +//- setup +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + +//- body + yield* obj; + throw new Test262Error('completion closes iter'); + +//- assertions +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); diff --git a/src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case b/src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case new file mode 100644 index 000000000..12956f133 --- /dev/null +++ b/src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case @@ -0,0 +1,66 @@ +// Copyright 2017 Tooru Fujisawa. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: FulfillPromise if next().then is not-callable (object) +info: | + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... +features: [Symbol.asyncIterator] +flags: [async] +---*/ + +//- setup +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + +//- body + yield* obj; + throw new Test262Error('completion closes iter'); + +//- assertions +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); diff --git a/src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case b/src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case new file mode 100644 index 000000000..df82e6903 --- /dev/null +++ b/src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case @@ -0,0 +1,66 @@ +// Copyright 2017 Tooru Fujisawa. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: FulfillPromise if next().then is not-callable (string) +info: | + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... +features: [Symbol.asyncIterator] +flags: [async] +---*/ + +//- setup +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + +//- body + yield* obj; + throw new Test262Error('completion closes iter'); + +//- assertions +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); diff --git a/src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case b/src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case new file mode 100644 index 000000000..3f3fad264 --- /dev/null +++ b/src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case @@ -0,0 +1,66 @@ +// Copyright 2017 Tooru Fujisawa. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: FulfillPromise if next().then is not-callable (symbol) +info: | + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... +features: [Symbol.asyncIterator] +flags: [async] +---*/ + +//- setup +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + +//- body + yield* obj; + throw new Test262Error('completion closes iter'); + +//- assertions +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); diff --git a/src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case b/src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case new file mode 100644 index 000000000..bc96d5951 --- /dev/null +++ b/src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case @@ -0,0 +1,66 @@ +// Copyright 2017 Tooru Fujisawa. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: FulfillPromise if next().then is not-callable (undefined) +info: | + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... +features: [Symbol.asyncIterator] +flags: [async] +---*/ + +//- setup +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + +//- body + yield* obj; + throw new Test262Error('completion closes iter'); + +//- assertions +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); diff --git a/src/async-generators/yield-star-next-then-returns-abrupt.case b/src/async-generators/yield-star-next-then-returns-abrupt.case new file mode 100644 index 000000000..cd12372c3 --- /dev/null +++ b/src/async-generators/yield-star-next-then-returns-abrupt.case @@ -0,0 +1,72 @@ +// Copyright 2017 Tooru Fujisawa. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Return abrupt after calling next().then +info: | + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... +features: [Symbol.asyncIterator] +flags: [async] +---*/ + +//- setup +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + +//- body + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +//- assertions +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); |