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 322252 7b4af0b1626b70d331c0769a91faa3f72a876dc2
parent 322251 953d2b8f17036a81990d82eac213622191019b8e
child 322253 5e2ec37ba69ffa5c78be6651815362d7c196c5f4
push id83830
push userarai_a@mac.com
push dateSat, 12 Nov 2016 15:41:00 +0000
treeherdermozilla-inbound@7b4af0b1626b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersevilpie
bugs1021835
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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);