From 2c6a82e55f96cccff797f4c143931f214adf686a Mon Sep 17 00:00:00 2001
From: Leo Balter <leonardo.balter@gmail.com>
Date: Mon, 27 Mar 2017 21:42:06 -0400
Subject: [PATCH] Add cases for abrupt completions in yield* in async generator
 - next

Closes #883
---
 .../yield-star-next-call-done-get-abrupt.case | 56 +++++++++++++++
 .../yield-star-next-call-returns-abrupt.case  | 48 +++++++++++++
 ...yield-star-next-call-value-get-abrupt.case | 58 +++++++++++++++
 .../yield-star-next-get-abrupt.case           | 48 +++++++++++++
 ...eld-star-next-non-object-ignores-then.case | 68 ++++++++++++++++++
 ...-star-next-not-callable-boolean-throw.case | 45 ++++++++++++
 ...eld-star-next-not-callable-null-throw.case | 45 ++++++++++++
 ...d-star-next-not-callable-number-throw.case | 45 ++++++++++++
 ...d-star-next-not-callable-object-throw.case | 45 ++++++++++++
 ...d-star-next-not-callable-string-throw.case | 45 ++++++++++++
 ...d-star-next-not-callable-symbol-throw.case | 45 ++++++++++++
 ...tar-next-not-callable-undefined-throw.case | 45 ++++++++++++
 .../yield-star-next-then-get-abrupt.case      | 72 +++++++++++++++++++
 ...n-non-callable-boolean-fulfillpromise.case | 66 +++++++++++++++++
 ...then-non-callable-null-fulfillpromise.case | 66 +++++++++++++++++
 ...en-non-callable-number-fulfillpromise.case | 66 +++++++++++++++++
 ...en-non-callable-object-fulfillpromise.case | 66 +++++++++++++++++
 ...en-non-callable-string-fulfillpromise.case | 66 +++++++++++++++++
 ...en-non-callable-symbol-fulfillpromise.case | 66 +++++++++++++++++
 ...non-callable-undefined-fulfillpromise.case | 66 +++++++++++++++++
 .../yield-star-next-then-returns-abrupt.case  | 72 +++++++++++++++++++
 21 files changed, 1199 insertions(+)
 create mode 100644 src/async-generators/yield-star-next-call-done-get-abrupt.case
 create mode 100644 src/async-generators/yield-star-next-call-returns-abrupt.case
 create mode 100644 src/async-generators/yield-star-next-call-value-get-abrupt.case
 create mode 100644 src/async-generators/yield-star-next-get-abrupt.case
 create mode 100644 src/async-generators/yield-star-next-non-object-ignores-then.case
 create mode 100644 src/async-generators/yield-star-next-not-callable-boolean-throw.case
 create mode 100644 src/async-generators/yield-star-next-not-callable-null-throw.case
 create mode 100644 src/async-generators/yield-star-next-not-callable-number-throw.case
 create mode 100644 src/async-generators/yield-star-next-not-callable-object-throw.case
 create mode 100644 src/async-generators/yield-star-next-not-callable-string-throw.case
 create mode 100644 src/async-generators/yield-star-next-not-callable-symbol-throw.case
 create mode 100644 src/async-generators/yield-star-next-not-callable-undefined-throw.case
 create mode 100644 src/async-generators/yield-star-next-then-get-abrupt.case
 create mode 100644 src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case
 create mode 100644 src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case
 create mode 100644 src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case
 create mode 100644 src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case
 create mode 100644 src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case
 create mode 100644 src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case
 create mode 100644 src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case
 create mode 100644 src/async-generators/yield-star-next-then-returns-abrupt.case

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 0000000000..6749370ab2
--- /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 0000000000..37cb148a36
--- /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 0000000000..4dc8b62628
--- /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 0000000000..b18f937e3d
--- /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 0000000000..f33e4929fb
--- /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 0000000000..f4fd9ed74d
--- /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 0000000000..f4e86ead2a
--- /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 0000000000..5f6d1bcbdb
--- /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 0000000000..31920e02ca
--- /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 0000000000..70ce1dccb1
--- /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 0000000000..7cbae93c7b
--- /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 0000000000..c84fd9ae82
--- /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 0000000000..42ddf4edec
--- /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 0000000000..bfc4f121e2
--- /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 0000000000..33439725d9
--- /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 0000000000..fe7275a279
--- /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 0000000000..12956f1336
--- /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 0000000000..df82e6903e
--- /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 0000000000..3f3fad2648
--- /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 0000000000..bc96d5951b
--- /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 0000000000..cd12372c32
--- /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);
-- 
GitLab