mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
cleaning up tests
This commit is contained in:
29
scripts/test/index-arrays.toy
Normal file
29
scripts/test/index-arrays.toy
Normal file
@@ -0,0 +1,29 @@
|
||||
//test basic replacement
|
||||
{
|
||||
var week = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"];
|
||||
|
||||
week[3] = "Holiday";
|
||||
|
||||
assert week == ["monday", "tuesday", "wednesday", "Holiday", "friday", "saturday", "sunday"], "basic replacement failed";
|
||||
}
|
||||
|
||||
|
||||
//test backwards
|
||||
{
|
||||
var week = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"];
|
||||
|
||||
assert week[::-1] == ["sunday", "saturday", "friday", "thursday", "wednesday", "tuesday", "monday"], "backwards failed";
|
||||
}
|
||||
|
||||
|
||||
//test array weird manipulation
|
||||
{
|
||||
var week = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"];
|
||||
|
||||
week[::-2] = ["first", "second", "third"];
|
||||
|
||||
assert week == ["monday", "tuesday", "third", "thursday", "second", "saturday", "first"], "array weird manipulation failed";
|
||||
}
|
||||
|
||||
|
||||
print "All good";
|
||||
21
scripts/test/index-dictionaries.toy
Normal file
21
scripts/test/index-dictionaries.toy
Normal file
@@ -0,0 +1,21 @@
|
||||
//test basic insertion
|
||||
{
|
||||
var d = [:];
|
||||
|
||||
d["foo"] = "bar";
|
||||
|
||||
assert d == ["foo":"bar"], "basic insertion failed";
|
||||
}
|
||||
|
||||
|
||||
//test dot insertion
|
||||
{
|
||||
var d = [:];
|
||||
|
||||
d.foo = "bar";
|
||||
|
||||
assert d == ["foo":"bar"], "dot insertion failed";
|
||||
}
|
||||
|
||||
|
||||
print "All good";
|
||||
21
scripts/test/index-strings.toy
Normal file
21
scripts/test/index-strings.toy
Normal file
@@ -0,0 +1,21 @@
|
||||
//test basic replacement
|
||||
var greeting: string = "hello world";
|
||||
|
||||
greeting[0:4] = "goodnight";
|
||||
|
||||
assert greeting == "goodnight world", "basic replacement failed";
|
||||
|
||||
|
||||
//test backwards string
|
||||
assert greeting[::-1] == "dlrow thgindoog", "backwards string failed";
|
||||
|
||||
|
||||
//test string weird manipulation
|
||||
var numbers = "0123456789";
|
||||
|
||||
numbers[::-2] = "abc";
|
||||
|
||||
assert numbers == "01234c6b8a", "string weird manipulation failed";
|
||||
|
||||
|
||||
print "All good";
|
||||
Reference in New Issue
Block a user