mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-17 15:54:07 +10:00
Moved tests from scripts/ to test/scripts/
This commit is contained in:
30
test/scripts/dot-chaining.toy
Normal file
30
test/scripts/dot-chaining.toy
Normal file
@@ -0,0 +1,30 @@
|
||||
//test function chaining with the dot operator
|
||||
|
||||
fn _identity(self) {
|
||||
return self;
|
||||
}
|
||||
|
||||
fn _check(self) {
|
||||
assert self == 42, "dot chaining failed";
|
||||
return self;
|
||||
}
|
||||
|
||||
var val = 42;
|
||||
|
||||
val
|
||||
.identity()
|
||||
.check()
|
||||
.identity()
|
||||
.check()
|
||||
;
|
||||
|
||||
|
||||
//test the value is actually altered
|
||||
fn _increment(self) {
|
||||
return self + 1;
|
||||
}
|
||||
|
||||
assert 3.increment().increment() == 5, "dot chaining increment failed";
|
||||
|
||||
|
||||
print "All good";
|
||||
Reference in New Issue
Block a user