-
-
Notifications
You must be signed in to change notification settings - Fork 667
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[java/cs] Make sure to reset old values when resizing a map
Closes #5862
- Loading branch information
Showing
8 changed files
with
143 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package unit.issues; | ||
import haxe.ds.*; | ||
#if java | ||
import java.NativeArray; | ||
#elseif cs | ||
import cs.NativeArray; | ||
#end | ||
|
||
class Issue5862 extends Test { | ||
#if (java || cs) | ||
public function test() { | ||
var imap = new IntMap(); | ||
imap.set(0, "val1"); | ||
imap.set(1, "val2"); | ||
imap.set(2, "val3"); | ||
imap.set(2, "changed_val3"); | ||
|
||
var v:Vector<Dynamic> = cast @:privateAccess imap.vals; | ||
for (i in 0...v.length) { | ||
t(v[i] != "val3"); | ||
} | ||
|
||
var smap = new StringMap(); | ||
smap.set("v1", "val1"); | ||
smap.set("v2", "val2"); | ||
smap.set("v3", "val3"); | ||
smap.set("v3", "changed_val3"); | ||
|
||
var v:Vector<Dynamic> = cast @:privateAccess smap.vals; | ||
for (i in 0...v.length) { | ||
t(v[i] != "val3"); | ||
} | ||
|
||
var omap = new ObjectMap<{}, String>(); | ||
omap.set(imap, "val1"); | ||
omap.set(smap, "val2"); | ||
omap.set(omap, "val3"); | ||
omap.set(omap, "changed_val3"); | ||
|
||
var v:Vector<Dynamic> = cast @:privateAccess omap.vals; | ||
for (i in 0...v.length) { | ||
t(v[i] != "val3"); | ||
} | ||
#if java | ||
var wmap = new WeakMap<{}, String>(); | ||
wmap.set(imap, "val1"); | ||
wmap.set(smap, "val2"); | ||
wmap.set(omap, "val3"); | ||
wmap.set(omap, "changed_val3"); | ||
|
||
var v = @:privateAccess wmap.entries; | ||
for (i in 0...v.length) { | ||
t(v[i] == null || v[i].value != "val3"); | ||
} | ||
#end | ||
|
||
var imap = new IntMap(); | ||
imap.set(0, "val1"); | ||
imap.set(1, "val2"); | ||
imap.set(2, "val3"); | ||
imap.set(2, "changed_val3"); | ||
imap.set(1, "changed_val2"); | ||
|
||
var v:Vector<Dynamic> = cast @:privateAccess imap.vals; | ||
for (i in 0...v.length) { | ||
t(v[i] != "val2"); | ||
} | ||
|
||
var smap = new StringMap(); | ||
smap.set("v1", "val1"); | ||
smap.set("v2", "val2"); | ||
smap.set("v3", "val3"); | ||
smap.set("v3", "changed_val3"); | ||
smap.set("v2", "changed_val2"); | ||
|
||
var v:Vector<Dynamic> = cast @:privateAccess smap.vals; | ||
for (i in 0...v.length) { | ||
t(v[i] != "val2"); | ||
} | ||
|
||
var omap = new ObjectMap<{}, String>(); | ||
omap.set(imap, "val1"); | ||
omap.set(smap, "val2"); | ||
omap.set(omap, "val3"); | ||
omap.set(omap, "changed_val3"); | ||
omap.set(smap, "changed_val2"); | ||
|
||
var v:Vector<Dynamic> = cast @:privateAccess omap.vals; | ||
for (i in 0...v.length) { | ||
t(v[i] != "val2"); | ||
} | ||
#if java | ||
var wmap = new WeakMap<{}, String>(); | ||
wmap.set(imap, "val1"); | ||
wmap.set(smap, "val2"); | ||
wmap.set(omap, "val3"); | ||
wmap.set(omap, "changed_val3"); | ||
wmap.set(smap, "changed_val2"); | ||
|
||
var v = @:privateAccess wmap.entries; | ||
for (i in 0...v.length) { | ||
t(v[i] == null || v[i].value != "val2"); | ||
} | ||
#end | ||
} | ||
#end | ||
} |