Files
Toy/tests/integrations/test_variables.toy
2024-11-02 11:39:47 +11:00

71 lines
1.1 KiB
Plaintext

//declare a variable with an initial value
var answer = 42;
//declare a variable without an initial value
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;
//equality checks
print 1 == 1; //true
print 1 != 1; //false
//comparison checks
print 1 < 2; //true
print "foo" > "bar"; //true
print 1 < 2; //true
print 1 > 2; //false
print 2 <= 2; //true
print 2 >= 2; //true
print 1 <= 2; //true
print 1 >= 2; //false
//logical checks
print true && true; //true
print true && false; //false
print false && true; //false
print false && false; //false
print true || true; //true
print true || false; //true
print false || true; //true
print false || false; //false
print !true; //false
print !false; //true
//precedence
print true && false || true; //TODO: a warning is needed for this
//types
var a: int;
var b: int = 42;
a = 69;
b = 8891;
print a;
print b;
//constants
var c: int const = 42;
print c;
//TODO: type casting