Jelajahi Sumber

[flash] call hasNext when constructing a StringMap iterator (see #3908)

Simon Krajewski 10 tahun lalu
induk
melakukan
789c022088
2 mengubah file dengan 10 tambahan dan 5 penghapusan
  1. 2 2
      std/flash/_std/haxe/ds/StringMap.hx
  2. 8 3
      tests/unit/src/unitstd/Map.unit.hx

+ 2 - 2
std/flash/_std/haxe/ds/StringMap.hx

@@ -145,8 +145,8 @@ private class StringMapKeysIterator {
 		this.h = h;
 		this.rh = rh;
 		this.index = 0;
-		this.nextIndex = 0;
 		isReserved = false;
+		hasNext();
 	}
 
 	public inline function hasNext():Bool {
@@ -183,7 +183,7 @@ private class StringMapValuesIterator<T> {
 		this.h = h;
 		this.rh = rh;
 		this.index = 0;
-		this.nextIndex = 0;
+		hasNext();
 	}
 
 	public inline function hasNext():Bool {

+ 8 - 3
tests/unit/src/unitstd/Map.unit.hx

@@ -165,6 +165,11 @@ map["bar"] = map["foo"] = 9;
 map["bar"] == 9;
 map["foo"] == 9;
 
-/*
- * ['' => ''].keys().next() == '';
-*/
+#if !(java || cs)
+['' => ''].keys().next() == '';
+['' => ''].iterator().next() == '';
+[2 => 3].keys().next() == 2;
+[2 => 3].iterator().next() == 3;
+//[a => b].keys().next() == a;
+//[a => b].iterator().next() == b;
+#end