summaryrefslogtreecommitdiff
path: root/test/language/expressions/optional-chaining/iteration-statement-for-of-type-error.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/language/expressions/optional-chaining/iteration-statement-for-of-type-error.js')
-rw-r--r--test/language/expressions/optional-chaining/iteration-statement-for-of-type-error.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/language/expressions/optional-chaining/iteration-statement-for-of-type-error.js b/test/language/expressions/optional-chaining/iteration-statement-for-of-type-error.js
new file mode 100644
index 000000000..3cd18cd48
--- /dev/null
+++ b/test/language/expressions/optional-chaining/iteration-statement-for-of-type-error.js
@@ -0,0 +1,28 @@
+// 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 returning undefined in RHS of for of statement
+info: |
+ IterationStatement
+ for (LeftHandSideExpression of Expression) Statement
+features: [optional-chaining]
+---*/
+
+assert.throws(TypeError, function() {
+ for (const key of {}?.a) ;
+});
+
+assert.throws(TypeError, function() {
+ for (const key of {}?.a) {}
+});
+
+const obj = undefined;
+assert.throws(TypeError, function() {
+ for (const key of obj?.a) {}
+});
+
+assert.throws(TypeError, function() {
+ for (const key of obj?.a);
+});