Allow script arrays to hold any value type, add script engine tests, archive old rpg code

Remove the per-array type category so arrays can mix types like structs.
Add 13 passing and 125 expected-failure duskscript test fixtures with a
table-driven runner. Also includes the in-progress entity/physics and
archive moves from the working tree.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
YourWishesandClaude Sonnet 5.5 committed 2026-10-14 23:25:26 -05:00
1 parent 5c259e46e2
commit f6b884bf7f
710 files changed
+6172 -27594

No files matched your search

+131
View File
@@ -0,0 +1,131 @@
var s = "Hello, World";
// Length and indexing
assert(len(s) == 12);
assert(len("") == 0);
assert(s[0] == "H");
assert(s[11] == "d");
assert(s[4] == "o");
// Concatenation, everything turns into text next to a string
assert("a" + "b" == "ab");
assert("" + "" == "");
assert("n=" + 5 == "n=5");
assert(5 + "n" == "5n");
assert("v" + 1.5 == "v1.5");
assert("b=" + true == "b=true");
assert("b=" + false == "b=false");
assert("x=" + null == "x=null");
assert("x=" + undefined == "x=undefined");
assert("a" + 1 + 2 == "a12");
assert(1 + 2 + "a" == "3a");
assert("arr " + [1, 2] == "arr [1, 2]");
assert("arr " + ["a", 1] == "arr [\"a\", 1]");
// Equality compares text, not identity
assert("abc" == "abc");
assert("abc" != "abd");
assert("abc" != "ab");
assert("" == "");
assert("a" + "bc" == "ab" + "c");
assert("1" != 1);
// Case
assert(upcase("abc DEF 123") == "ABC DEF 123");
assert(downcase("ABC def 123") == "abc def 123");
assert(upcase("") == "");
// Trim
assert(trim(" hi ") == "hi");
assert(ltrim(" hi ") == "hi ");
assert(rtrim(" hi ") == " hi");
assert(trim("hi") == "hi");
assert(trim(" ") == "");
// Searching
assert(contains(s, "World"));
assert(!contains(s, "world"));
assert(contains(s, ""));
assert(strindex(s, "o") == 4);
assert(strindex(s, "World") == 7);
assert(strindex(s, "zzz") == -1);
assert(startswith(s, "Hello"));
assert(!startswith(s, "World"));
assert(startswith(s, ""));
assert(startswith(s, s));
assert(!startswith("ab", "abc"));
assert(endswith(s, "World"));
assert(!endswith(s, "Hello"));
assert(endswith(s, s));
assert(!endswith("bc", "abc"));
assert(indexof("hello", "l") == 2);
assert(lastindexof("hello", "l") == 3);
assert(indexof("hello", "z") == -1);
// Comparing helpers
assert(stringequals("a", "a"));
assert(!stringequals("a", "A"));
assert(stringequalsinsensitive("a", "A"));
assert(stringequalsinsensitive("Hello", "hELLO"));
assert(!stringequalsinsensitive("Hello", "Hell"));
// Slicing
assert(subarr("abcdef", 2) == "cdef");
assert(subarr("abcdef", 1, 4) == "bcd");
assert(subarr("abcdef", 0, 0) == "");
assert(subarr("abcdef", 6) == "");
assert(subarr("abcdef", 0, 6) == "abcdef");
// Split and join
var parts = split("a,b,c", ",");
assert(len(parts) == 3);
assert(parts[0] == "a");
assert(parts[2] == "c");
assert(join(parts, "-") == "a-b-c");
assert(len(split("abc", "")) == 3);
assert(split("abc", "")[1] == "b");
assert(len(split("abc", ",")) == 1);
assert(len(split("a,,b", ",")) == 3);
assert(split("a,,b", ",")[1] == "");
assert(len(split(",", ",")) == 2);
assert(join([], ",") == "");
assert(join([1, "b", true, null], "|") == "1|b|true|null");
assert(join(["x"], ",") == "x");
assert(join(split("a--b--c", "--"), "+") == "a+b+c");
// Chars
assert(chr(65) == "A");
assert(chr(97) == "a");
assert(len(chr(255)) == 1);
// Escapes
assert(len("a\nb") == 3);
assert(len("a\tb") == 3);
assert(len("\\") == 1);
assert(len("\"") == 1);
assert(len('it\'s') == 4);
assert("a\\b"[1] == "\\");
// Iterating
var total = "";
foreach(var c : "abc") {
total = c + total;
}
assert(total == "cba");
// Strings are values: the original is untouched by what was derived from it
var original = "keep";
var changed = upcase(original);
assert(original == "keep");
assert(changed == "KEEP");
// Truthiness
assert("a");
assert(!"");
// Long-ish string built in a loop
var built = "";
for(var i = 0; i < 100; i++) {
built = built + "x";
}
assert(len(built) == 100);