65 lines
1.3 KiB
Lua
65 lines
1.3 KiB
Lua
|
|
-- Unicode comment: δ½ ε₯½δΈη ππ
|
||
|
|
|
||
|
|
-- Unicode string literals
|
||
|
|
local unicode = "γγγ«γ‘γ―δΈη"
|
||
|
|
print(unicode)
|
||
|
|
|
||
|
|
-- Null byte in string
|
||
|
|
local null_str = "hello\0world"
|
||
|
|
print("Null-str length: " .. #null_str)
|
||
|
|
|
||
|
|
-- Deeply nested tables
|
||
|
|
local deep = {
|
||
|
|
a = {
|
||
|
|
b = {
|
||
|
|
c = {
|
||
|
|
d = {
|
||
|
|
e = "deep"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
print(deep.a.b.c.d.e)
|
||
|
|
|
||
|
|
-- Very long string
|
||
|
|
local long_str = string.rep("x", 10000)
|
||
|
|
print("Long string length: " .. #long_str)
|
||
|
|
|
||
|
|
-- Metatable chains
|
||
|
|
local a = {}
|
||
|
|
local b = {}
|
||
|
|
local c = {}
|
||
|
|
setmetatable(a, {__index = b})
|
||
|
|
setmetatable(b, {__index = c})
|
||
|
|
c.value = 42
|
||
|
|
print("Metatable chain: " .. a.value)
|
||
|
|
|
||
|
|
-- Deep function nesting
|
||
|
|
local function level1()
|
||
|
|
return function()
|
||
|
|
return function()
|
||
|
|
return function()
|
||
|
|
return function()
|
||
|
|
return 42
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end
|
||
|
|
print("Deep functions: " .. level1()()()()())
|
||
|
|
|
||
|
|
-- Coroutine with deep stack
|
||
|
|
local co = coroutine.create(function()
|
||
|
|
local function recurse(n)
|
||
|
|
if n == 0 then
|
||
|
|
coroutine.yield("done")
|
||
|
|
else
|
||
|
|
return recurse(n - 1)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
recurse(100)
|
||
|
|
end)
|
||
|
|
local _, msg = coroutine.resume(co)
|
||
|
|
print("Coroutine: " .. msg)
|