summaryrefslogtreecommitdiff
path: root/js/src/tests/test262/language/optional-chaining/iteration-statement-for-await-of.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/language/optional-chaining/iteration-statement-for-await-of.js')
-rw-r--r--js/src/tests/test262/language/optional-chaining/iteration-statement-for-await-of.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/optional-chaining/iteration-statement-for-await-of.js b/js/src/tests/test262/language/optional-chaining/iteration-statement-for-await-of.js
new file mode 100644
index 000000000..2f668fd36
--- /dev/null
+++ b/js/src/tests/test262/language/optional-chaining/iteration-statement-for-await-of.js
@@ -0,0 +1,36 @@
+// |reftest| async
+// Copyright 2019 Google, LLC. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: prod-OptionalExpression
+description: >
+ optional chain RHS of for await statement
+info: |
+ IterationStatement
+ for await (LeftHandSideExpression of AssignmentExpression) Statement
+features: [optional-chaining]
+flags: [async]
+---*/
+const obj = {
+ iterable: {
+ [Symbol.asyncIterator]() {
+ return {
+ i: 0,
+ next() {
+ if (this.i < 3) {
+ return Promise.resolve({ value: this.i++, done: false });
+ }
+ return Promise.resolve({ done: true });
+ }
+ };
+ }
+ }
+};
+async function checkAssertions() {
+ let count = 0;
+ for await (const num of obj?.iterable) {
+ count += num;
+ }
+ assert.sameValue(3, count);
+}
+checkAssertions().then($DONE, $DONE);