mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Tested _concat() with clashing dict keys
This commit is contained in:
@@ -1,36 +1,14 @@
|
|||||||
import compound;
|
import compound;
|
||||||
|
|
||||||
//test array concat
|
|
||||||
|
//test dictionary concat with clashing keys
|
||||||
{
|
{
|
||||||
var a = [1, 2, 3];
|
var a = ["one" : 1, "two": 2, "three": 3, "random": 1];
|
||||||
var b = [4, 5, 6];
|
var b = ["four" : 4, "five": 5, "six": 6, "random": 2];
|
||||||
|
|
||||||
var c = a.concat(b).concat(b);
|
|
||||||
|
|
||||||
assert c == [1, 2, 3, 4, 5, 6, 4, 5, 6], "array.concat() failed";
|
|
||||||
}
|
|
||||||
|
|
||||||
//test dictionary concat
|
|
||||||
{
|
|
||||||
var a = ["one" : 1, "two": 2, "three": 3];
|
|
||||||
var b = ["four" : 4, "five": 5, "six": 6];
|
|
||||||
|
|
||||||
var c = a.concat(b);
|
var c = a.concat(b);
|
||||||
|
|
||||||
assert c.length() == 6, "dictionary.concat().length() failed";
|
assert c["random"] == 1, "dictionary.concat() clashing keys failed";
|
||||||
|
|
||||||
assert c == ["one" : 1, "two": 2, "three": 3, "four" : 4, "five": 5, "six": 6], "dictionary.concat() comparison failed";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//test string concat
|
|
||||||
{
|
|
||||||
var a = "foo";
|
|
||||||
var b = "bar";
|
|
||||||
|
|
||||||
var c = a.concat(b);
|
|
||||||
|
|
||||||
assert c == "foobar", "string.concat() failed";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
print "All good";
|
print "All good";
|
||||||
|
|||||||
@@ -23,6 +23,16 @@ import compound;
|
|||||||
assert c == ["one" : 1, "two": 2, "three": 3, "four" : 4, "five": 5, "six": 6], "dictionary.concat() comparison failed";
|
assert c == ["one" : 1, "two": 2, "three": 3, "four" : 4, "five": 5, "six": 6], "dictionary.concat() comparison failed";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//test dictionary concat with clashing keys
|
||||||
|
{
|
||||||
|
var a = ["one" : 1, "two": 2, "three": 3, "random": 1];
|
||||||
|
var b = ["four" : 4, "five": 5, "six": 6, "random": 2];
|
||||||
|
|
||||||
|
var c = a.concat(b);
|
||||||
|
|
||||||
|
assert c["random"] == 1, "dictionary.concat() clashing keys failed";
|
||||||
|
}
|
||||||
|
|
||||||
//test string concat
|
//test string concat
|
||||||
{
|
{
|
||||||
var a = "foo";
|
var a = "foo";
|
||||||
|
|||||||
Reference in New Issue
Block a user