MCPcopy Create free account
hub / github.com/nodejs/node / testExceptionPriority

Function testExceptionPriority

deps/v8/test/mjsunit/iterable-foreach.js:78–99  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

76
77// Exception in 'return' vs Exception in callback
78function testExceptionPriority() {
79 let iterable = {
80 [Symbol.iterator]() {
81 return {
82 next() { return { value: 1, done: false }; },
83 return() {
84 throw new Error("Exception in return");
85 }
86 };
87 }
88 };
89
90 try {
91 %IterableForEach(iterable, (x) => {
92 throw new Error("Exception in callback");
93 });
94 } catch (e) {
95 // The spec says if completion is a throw completion, return ? completion.
96 // So "Exception in callback" should be rethrown, suppressing "Exception in return".
97 assertEquals("Exception in callback", e.message);
98 }
99}
100testExceptionPriority();
101
102// Stack overflow

Callers 1

Calls 1

assertEqualsFunction · 0.50

Tested by

no test coverage detected