init3.lua (2160B)
1 osprint("LuaJIT OS initialized\n") 2 3 -- Test if built-in string functions work now that we loaded the string library 4 osprint("\n=== Testing string.byte ===\n") 5 local b = string.byte("H") 6 osprint("byte('H') = ") 7 osprint(tostring(b)) 8 osprint("\n") 9 10 osprint("\n=== Testing string.char ===\n") 11 local c = string.char(72, 69, 76, 76, 79) 12 osprint("char(72, 69, 76, 76, 79) = ") 13 osprint(c) 14 osprint("\n") 15 16 osprint("\n=== Testing string.sub ===\n") 17 local s = string.sub("HELLO WORLD", 7, 11) 18 osprint("sub('HELLO WORLD', 7, 11) = ") 19 osprint(s) 20 osprint("\n") 21 22 osprint("\n=== Testing string.upper ===\n") 23 local u = string.upper("hello") 24 osprint("upper('hello') = ") 25 osprint(u) 26 osprint("\n") 27 28 osprint("\n=== Testing string.lower ===\n") 29 local l = string.lower("WORLD") 30 osprint("lower('WORLD') = ") 31 osprint(l) 32 osprint("\n") 33 34 osprint("\n=== Testing string.find ===\n") 35 local pos = string.find("hello world", "world") 36 osprint("find('hello world', 'world') = ") 37 osprint(tostring(pos)) 38 osprint("\n") 39 40 osprint("\n=== Testing string.gsub ===\n") 41 local result = string.gsub("hello world", "world", "LuaJIT") 42 osprint("gsub('hello world', 'world', 'LuaJIT') = ") 43 osprint(result) 44 osprint("\n") 45 46 osprint("\n=== Testing string.match ===\n") 47 local match = string.match("hello world", "w%w+") 48 osprint("match('hello world', 'w%%w+') = ") 49 osprint(tostring(match)) 50 osprint("\n") 51 52 osprint("\n=== Testing string.gmatch ===\n") 53 osprint("gmatch('one two three', '%%w+'):\n") 54 for word in string.gmatch("one two three", "%w+") do 55 osprint(" ") 56 osprint(word) 57 osprint("\n") 58 end 59 60 osprint("\n=== All string tests passed! ===\n") 61 62 osprint("\n=== Testing RunString ===\n") 63 local result = RunString("osprint('Hello from RunString!\\n')") 64 osprint("RunString result: ") 65 osprint(tostring(result)) 66 osprint("\n") 67 68 osprint("\n=== Testing CompileString ===\n") 69 local func, err = CompileString("return 2 + 2") 70 if func then 71 osprint("CompileString: Compilation successful\n") 72 local success, result = pcall(func) 73 if success then 74 osprint("Execution result: ") 75 osprint(tostring(result)) 76 osprint("\n") 77 end 78 end 79 80 osprint("\n=== All tests completed successfully! ===\n")