mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Implemented scopes
This commit is contained in:
19
tests/integrations/test_scopes.toy
Normal file
19
tests/integrations/test_scopes.toy
Normal file
@@ -0,0 +1,19 @@
|
||||
//shadowing
|
||||
var answer = 42;
|
||||
print answer; //42
|
||||
{
|
||||
var answer = 7;
|
||||
print answer; //7
|
||||
}
|
||||
print answer; //42
|
||||
|
||||
//rebinding
|
||||
var question = 42;
|
||||
print question; //42
|
||||
{
|
||||
var question = question;
|
||||
print question; //42
|
||||
}
|
||||
print question; //42
|
||||
|
||||
//TODO: scope test case
|
||||
@@ -7,15 +7,13 @@ var empty;
|
||||
//assign a previously existing variable
|
||||
answer = 6 * 9;
|
||||
|
||||
//access a variable
|
||||
answer = answer + 1;
|
||||
|
||||
//compound assignments
|
||||
answer += 5;
|
||||
|
||||
answer -= 5;
|
||||
|
||||
answer *= 9;
|
||||
|
||||
answer /= 2;
|
||||
|
||||
answer %= 10;
|
||||
|
||||
Reference in New Issue
Block a user