mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
Gonna start unit testing to resolve issues
This commit is contained in:
31
scripts/test/arithmetic.toy
Normal file
31
scripts/test/arithmetic.toy
Normal file
@@ -0,0 +1,31 @@
|
||||
//test operators (integers)
|
||||
assert 1 + 1 == 2, "1 + 1 == 2";
|
||||
assert 1 - 1 == 0, "1 - 1 == 0";
|
||||
assert 2 * 2 == 4, "2 * 2 == 4";
|
||||
assert 1 / 2 == 0, "1 / 2 == 0"; //integer division
|
||||
assert 5 % 2 == 1, "5 % 2 == 1";
|
||||
|
||||
//test operators (floats)
|
||||
assert 1.0 + 1.0 == 2.0, "1.0 + 1.0 == 2.0";
|
||||
assert 1.0 - 1.0 == 0.0, "1.0 - 1.0 == 0.0";
|
||||
assert 2.0 * 2.0 == 4.0, "2.0 * 2.0 == 4.0";
|
||||
assert 1.0 / 2.0 == 0.5, "1.0 / 2.0 == 0.5";
|
||||
|
||||
|
||||
var a = 10;
|
||||
|
||||
a += 20;
|
||||
a -= 25;
|
||||
|
||||
assert a == 5, "+= or -= failed";
|
||||
|
||||
a *= 5;
|
||||
a /= 2;
|
||||
|
||||
assert a == 12, "*= or /= failed";
|
||||
|
||||
a %= 8;
|
||||
|
||||
assert a == 4, "%= failed";
|
||||
|
||||
print "All good";
|
||||
Reference in New Issue
Block a user