mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-16 07:14:07 +10:00
44 lines
609 B
Plaintext
44 lines
609 B
Plaintext
//test basic insertion
|
|
{
|
|
var d = [:];
|
|
|
|
d["foo"] = "bar";
|
|
|
|
assert d == ["foo":"bar"], "basic insertion failed";
|
|
}
|
|
|
|
|
|
//test index arithmetic
|
|
{
|
|
var d = ["one":1, "two":2, "three":3];
|
|
|
|
d["three"] *= 3;
|
|
|
|
assert d == ["one":1, "two":2, "three":9], "index arithmetic failed";
|
|
}
|
|
|
|
|
|
//test indexing with variables
|
|
{
|
|
var d = ["one":1, "two":2, "three":3];
|
|
|
|
var first = "two";
|
|
|
|
assert d[first] == 2, "indexing with variables failed";
|
|
}
|
|
|
|
|
|
//test nested indexing
|
|
{
|
|
var d = ["foo": ["bar": 0]];
|
|
|
|
d["foo"]["bar"] = 42;
|
|
|
|
print d;
|
|
|
|
assert d == ["foo": ["bar": 42]], "nested indexing failed";
|
|
}
|
|
|
|
|
|
print "All good";
|