Lua: fix some subtle Lua-isms

This commit is contained in:
Zef Hemel
2025-03-09 15:37:38 +01:00
parent 29c2781c11
commit 242ae73078
9 changed files with 737 additions and 34 deletions
+8
View File
@@ -14,6 +14,14 @@ assert(string.sub("Hello", 2, 4) == "ell")
assert(string.upper("Hello") == "HELLO")
assert(string.lower("Hello") == "hello")
-- string.sub tests
assertEqual(string.sub("hello", 1), "hello")
assertEqual(string.sub("hello", 1, 1), "h")
-- with negative indeses
assertEqual(string.sub("hello", -1), "o")
assertEqual(string.sub("hello", -2), "lo")
assertEqual(string.sub("hello", -2, -1), "lo")
-- Invoke string metatable methods
assertEqual(("hello"):len(), 5)
assertEqual(("hello"):upper(), "HELLO")