Bug 1021835 - Part 4: Add testcases for primitive iterator. r=evilpie
authorTooru Fujisawa <arai_a@mac.com>
Sun, 13 Nov 2016 00:40:29 +0900
changeset 352384 7b4af0b1626b70d331c0769a91faa3f72a876dc2
parent 352383 953d2b8f17036a81990d82eac213622191019b8e
child 352385 5e2ec37ba69ffa5c78be6651815362d7c196c5f4
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersevilpie
bugs1021835
milestone52.0a1
Bug 1021835 - Part 4: Add testcases for primitive iterator. r=evilpie
js/src/tests/ecma_6/Map/constructor-iterator-primitive.js
js/src/tests/ecma_6/TypedArray/constructor-iterator-primitive.js
new file mode 100644
--- /dev/null
+++ b/js/src/tests/ecma_6/Map/constructor-iterator-primitive.js
@@ -0,0 +1,34 @@
+var BUGNUMBER = 1021835;
+var summary = "Returning non-object from @@iterator should throw";
+
+print(BUGNUMBER + ": " + summary);
+
+let ctors = [
+    Map,
+    Set,
+    WeakMap,
+    WeakSet
+];
+
+let primitives = [
+    1,
+    true,
+    undefined,
+    null,
+    "foo",
+    Symbol.iterator
+];
+
+for (let ctor of ctors) {
+    for (let primitive of primitives) {
+        let arg = {
+            [Symbol.iterator]() {
+                return primitive;
+            }
+        };
+        assertThrowsInstanceOf(() => new ctor(arg), TypeError);
+    }
+}
+
+if (typeof reportCompare === "function")
+  reportCompare(0, 0);
new file mode 100644
--- /dev/null
+++ b/js/src/tests/ecma_6/TypedArray/constructor-iterator-primitive.js
@@ -0,0 +1,29 @@
+var BUGNUMBER = 1021835;
+var summary = "Returning non-object from @@iterator should throw";
+
+print(BUGNUMBER + ": " + summary);
+
+let primitives = [
+    1,
+    true,
+    undefined,
+    null,
+    "foo",
+    Symbol.iterator
+];
+
+for (let ctor of typedArrayConstructors) {
+    for (let primitive of primitives) {
+        let arg = {
+            [Symbol.iterator]() {
+                return primitive;
+            }
+        };
+        assertThrowsInstanceOf(() => {
+            new ctor(arg);
+        }, TypeError);
+    }
+}
+
+if (typeof reportCompare === "function")
+  reportCompare(0, 0);