Skip to content

Commit c452a67

Browse files
committed
Add test case where IteratorStepValue throws
1 parent cff91cd commit c452a67

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright (C) 2026 Garham Lee. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-runtime-semantics-bindinginitialization
6+
description: >
7+
IteratorStepValue throws when iteratorRecord.[[NextMethod]] is undefined.
8+
info: |
9+
Runtime Semantics: BindingInitialization (_value_, _environment_)
10+
11+
BindingPattern : ArrayBindingPattern
12+
1. Let _iteratorRecord_ be ? GetIterator(_value_, ~sync~).
13+
2. Let _result_ be Completion(IteratorBindingInitialization of |ArrayBindingPattern| with arguments _iteratorRecord_ and _environment_).
14+
15+
Runtime Semantics: IteratorBindingInitialization (_iteratorRecord_, _environment_)
16+
17+
BindingElement : BindingPattern Initializer?
18+
2. If _iteratorRecord_.[[Done]] is *false*, then
19+
a. Let _next_ be ? IteratorStepValue(_iteratorRecord_).
20+
21+
IteratorStepValue (_iteratorRecord_)
22+
1. Let _result_ be ? IteratorStep(_iteratorRecord_).
23+
24+
IteratorStep (_iteratorRecord_)
25+
1. Let _result_ be ? IteratorNext(_iteratorRecord_).
26+
27+
IteratorNext (_iteratorRecord_, optional _value_)
28+
1. If _value_ is not present, then
29+
a. Let _result_ be Completion(Call(_iteratorRecord_.[[NextMethod]], _iteratorRecord_.[[Iterator]])).
30+
6. Return _result_.
31+
features: [destructuring-binding, async-functions, async-iteration, Symbol.iterator]
32+
---*/
33+
assert.throws(TypeError, function () {
34+
var [[] = 1] = { [Symbol.iterator] : async function (x) {}};
35+
}, "IteratorStepValue throws when iteratorRecord.[[NextMethod]] is undefined.");

0 commit comments

Comments
 (0)