Align GetIterator with ES6 spec
authorarv <arv@chromium.org>
Thu, 19 Feb 2015 21:38:04 +0000 (13:38 -0800)
committerCommit bot <commit-bot@chromium.org>
Thu, 19 Feb 2015 21:38:18 +0000 (21:38 +0000)
BUG=None
LOG=N
R=adamk

Review URL: https://codereview.chromium.org/936793003

Cr-Commit-Position: refs/heads/master@{#26759}

src/collection.js
src/v8natives.js
src/weak-collection.js
test/mjsunit/es6/collections.js

index 94bda70..9b57166 100644 (file)
@@ -23,7 +23,7 @@ function SetConstructor(iterable) {
   var iter, adder;
 
   if (!IS_NULL_OR_UNDEFINED(iterable)) {
-    iter = GetIterator(ToObject(iterable));
+    iter = GetIterator(iterable);
     adder = this.add;
     if (!IS_SPEC_FUNCTION(adder)) {
       throw MakeTypeError('property_not_function', ['add', this]);
@@ -163,7 +163,7 @@ function MapConstructor(iterable) {
   var iter, adder;
 
   if (!IS_NULL_OR_UNDEFINED(iterable)) {
-    iter = GetIterator(ToObject(iterable));
+    iter = GetIterator(iterable);
     adder = this.set;
     if (!IS_SPEC_FUNCTION(adder)) {
       throw MakeTypeError('property_not_function', ['set', this]);
index 2314334..3cba466 100644 (file)
@@ -1879,21 +1879,11 @@ SetUpFunction();
 // ----------------------------------------------------------------------------
 // Iterator related spec functions.
 
-// ES6 rev 26, 2014-07-18
-// 7.4.1 CheckIterable ( obj )
-function ToIterable(obj) {
-  if (!IS_SPEC_OBJECT(obj)) {
-    return UNDEFINED;
-  }
-  return obj[symbolIterator];
-}
-
-
-// ES6 rev 26, 2014-07-18
-// 7.4.2 GetIterator ( obj, method )
+// ES6 rev 33, 2015-02-12
+// 7.4.1 GetIterator ( obj, method )
 function GetIterator(obj, method) {
   if (IS_UNDEFINED(method)) {
-    method = ToIterable(obj);
+    method = ToObject(obj)[symbolIterator];
   }
   if (!IS_SPEC_FUNCTION(method)) {
     throw MakeTypeError('not_iterable', [obj]);
index a44c3d7..3cec9cc 100644 (file)
@@ -23,7 +23,7 @@ function WeakMapConstructor(iterable) {
   var iter, adder;
 
   if (!IS_NULL_OR_UNDEFINED(iterable)) {
-    iter = GetIterator(ToObject(iterable));
+    iter = GetIterator(iterable);
     adder = this.set;
     if (!IS_SPEC_FUNCTION(adder)) {
       throw MakeTypeError('property_not_function', ['set', this]);
@@ -130,7 +130,7 @@ function WeakSetConstructor(iterable) {
   var iter, adder;
 
   if (!IS_NULL_OR_UNDEFINED(iterable)) {
-    iter = GetIterator(ToObject(iterable));
+    iter = GetIterator(iterable);
     adder = this.add;
     if (!IS_SPEC_FUNCTION(adder)) {
       throw MakeTypeError('property_not_function', ['add', this]);
index 92cd087..7f8b4a5 100644 (file)
@@ -1192,6 +1192,7 @@ function TestSetConstructorIterableValue(ctor) {
     get: function() {
       assertEquals('object', typeof this);
       return function() {
+        assertEquals('number', typeof this);
         return oneAndTwo.keys();
       };
     },
@@ -1382,6 +1383,7 @@ function TestMapConstructorIterableValue(ctor) {
     get: function() {
       assertEquals('object', typeof this);
       return function() {
+        assertEquals('number', typeof this);
         return oneAndTwo.entries();
       };
     },