From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../prototype/lazy-methods-from-other-global.js | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 js/src/tests/non262/Iterator/prototype/lazy-methods-from-other-global.js (limited to 'js/src/tests/non262/Iterator/prototype/lazy-methods-from-other-global.js') diff --git a/js/src/tests/non262/Iterator/prototype/lazy-methods-from-other-global.js b/js/src/tests/non262/Iterator/prototype/lazy-methods-from-other-global.js new file mode 100644 index 0000000000..720baf08c7 --- /dev/null +++ b/js/src/tests/non262/Iterator/prototype/lazy-methods-from-other-global.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('Iterator')) + +const otherIteratorProto = newGlobal({newCompartment: true}).Iterator.prototype; + +const methods = [ + ["map", x => x], + ["filter", x => true], + ["take", Infinity], + ["drop", 0], + ["flatMap", x => [x]], +]; + +// Use the lazy Iterator methods from another global on an iterator from this global. +for (const [method, arg] of methods) { + const iterator = [1, 2, 3].values(); + const helper = otherIteratorProto[method].call(iterator, arg); + + for (const expected of [1, 2, 3]) { + const {done, value} = helper.next(); + assertEq(done, false); + assertEq(Array.isArray(value) ? value[1] : value, expected); + } + + const {done, value} = helper.next(); + assertEq(done, true); + assertEq(value, undefined); +} + +if (typeof reportCompare === 'function') + reportCompare(0, 0); -- cgit v1.2.3