diff options
Diffstat (limited to 'js/src/tests/non262/Iterator/from/modify-return.js')
-rw-r--r-- | js/src/tests/non262/Iterator/from/modify-return.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/js/src/tests/non262/Iterator/from/modify-return.js b/js/src/tests/non262/Iterator/from/modify-return.js new file mode 100644 index 0000000000..dfda4dbe89 --- /dev/null +++ b/js/src/tests/non262/Iterator/from/modify-return.js @@ -0,0 +1,22 @@ +// |reftest| skip-if(!this.hasOwnProperty('Iterator')) -- Iterator is not enabled unconditionally +const iter = { + next: () => ({ done: false, value: 0 }), + return: (value = "old return") => ({ done: true, value }), +}; + +const wrap = Iterator.from(iter); + +let {done, value} = wrap.return("return argument ignored"); +assertEq(done, true); +assertEq(value, "old return"); + +iter.return = () => { throw new Error(); }; +assertThrowsInstanceOf(wrap.return, Error); + +iter.return = null; +let nullResult = wrap.return("return argument ignored"); +assertEq(nullResult.done, true); +assertEq(nullResult.value, undefined); + +if (typeof reportCompare === 'function') + reportCompare(0, 0); |