summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Iterator/from/return-wrapper-if-not-iterator-instance.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--js/src/tests/non262/Iterator/from/return-wrapper-if-not-iterator-instance.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/js/src/tests/non262/Iterator/from/return-wrapper-if-not-iterator-instance.js b/js/src/tests/non262/Iterator/from/return-wrapper-if-not-iterator-instance.js
new file mode 100644
index 0000000000..4045801277
--- /dev/null
+++ b/js/src/tests/non262/Iterator/from/return-wrapper-if-not-iterator-instance.js
@@ -0,0 +1,24 @@
+// |reftest| skip-if(!this.hasOwnProperty('Iterator')) -- Iterator is not enabled unconditionally
+/*---
+ Iterator.from returns an iterator wrapper if O is not an instance of Iterator.
+---*/
+
+class TestIterator {
+ [Symbol.iterator]() {
+ return this;
+ }
+
+ next() {
+ return { done: false, value: 0 };
+ }
+}
+
+const iter = new TestIterator();
+assertEq(iter instanceof Iterator, false);
+
+const wrapper = Iterator.from(iter);
+assertEq(iter !== wrapper, true);
+assertEq(wrapper instanceof Iterator, true);
+
+if (typeof reportCompare === 'function')
+ reportCompare(0, 0);