mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
changed dot operator to access global functions
This commit is contained in:
@@ -62,6 +62,16 @@ fn extra(one, two, ...rest) {
|
||||
extra("one", "two", "three", "four", "five", "six", "seven");
|
||||
|
||||
|
||||
//test underscore functions
|
||||
fn _example(self, a, b, c) {
|
||||
assert a == "a", "underscore failed (a)";
|
||||
assert b == "b", "underscore failed (b)";
|
||||
assert c == "c", "underscore failed (c)";
|
||||
return self;
|
||||
}
|
||||
|
||||
assert "hello world".example("a", "b", "c") == "hello world", "underscore call failed";
|
||||
|
||||
|
||||
|
||||
print "All good";
|
||||
|
||||
@@ -8,16 +8,6 @@
|
||||
}
|
||||
|
||||
|
||||
//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];
|
||||
@@ -28,28 +18,6 @@
|
||||
}
|
||||
|
||||
|
||||
//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];
|
||||
|
||||
Reference in New Issue
Block a user