mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-17 15:54:07 +10:00
63 lines
833 B
Plaintext
63 lines
833 B
Plaintext
//test basic insertion
|
|
{
|
|
var d = [:];
|
|
|
|
d["foo"] = "bar";
|
|
|
|
assert d == ["foo":"bar"], "basic insertion failed";
|
|
}
|
|
|
|
|
|
//test dot insertion
|
|
{
|
|
var d = [:];
|
|
|
|
d.foo = "bar";
|
|
|
|
assert d == ["foo":"bar"], "dot 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 dot arithmetic
|
|
{
|
|
var d = ["one":1, "two":2, "three":3];
|
|
|
|
d.three *= 3;
|
|
|
|
assert d == ["one":1, "two":2, "three":9], "index arithmetic failed";
|
|
}
|
|
|
|
|
|
//test dot calls
|
|
{
|
|
fn f() {
|
|
return 42;
|
|
}
|
|
|
|
var d = ["foo":f];
|
|
|
|
assert d.foo() == 42, "dot calls failed";
|
|
}
|
|
|
|
|
|
//test indexing with variables
|
|
{
|
|
var d = ["one":1, "two":2, "three":3];
|
|
|
|
var first = "two";
|
|
|
|
assert d[first] == 2, "indexing with variables failed";
|
|
}
|
|
|
|
print "All good";
|