on master help sign in
wip
commit4193b5fd40259558ff43aac67603f5803d62b96c authoriko <mail@iko.soy> dateSun 28 Jul 2024, 02:24 (2 years ago) parent9b0ba75
38 files changed+5573−5972
zod/luau/TODO.md+1−1 zod/luau/lib/lua/parser.hoon+2 zod/luau/lib/lua/printer.hoon+32−10 zod/luau/res/lua/cycled/all.lua+97−108 zod/luau/res/lua/cycled/api.lua+480−609 zod/luau/res/lua/cycled/attrib.lua+173−172 zod/luau/res/lua/cycled/big.lua+32−34 zod/luau/res/lua/cycled/bitwise.lua+57−55 zod/luau/res/lua/cycled/bwcoercion.lua+14−14 zod/luau/res/lua/cycled/calls.lua+134−125 zod/luau/res/lua/cycled/closure.lua+80−62 zod/luau/res/lua/cycled/code.lua+269−259 zod/luau/res/lua/cycled/constructs.lua+114−111 zod/luau/res/lua/cycled/coroutine.lua+363−415 zod/luau/res/lua/cycled/cstack.lua+60−46 zod/luau/res/lua/cycled/db.lua+282−344 zod/luau/res/lua/cycled/errors.lua+268−385 zod/luau/res/lua/cycled/events.lua+172−164 zod/luau/res/lua/cycled/files.lua+376−444 zod/luau/res/lua/cycled/foo.lua+26−19 zod/luau/res/lua/cycled/gc.lua+233−205 zod/luau/res/lua/cycled/gengc.lua+64−54 zod/luau/res/lua/cycled/goto.lua+70−57 zod/luau/res/lua/cycled/heavy.lua+53−59 zod/luau/res/lua/cycled/literals.lua+128−240 zod/luau/res/lua/cycled/locals.lua+344−281 zod/luau/res/lua/cycled/main.lua+211−346 zod/luau/res/lua/cycled/math.lua+311−263 zod/luau/res/lua/cycled/nextvar.lua+173−142 zod/luau/res/lua/cycled/pm.lua+229−231 zod/luau/res/lua/cycled/sort.lua+67−59 zod/luau/res/lua/cycled/strings.lua+313−306 zod/luau/res/lua/cycled/tpack.lua+185−171 zod/luau/res/lua/cycled/tracegc.lua+1−1 zod/luau/res/lua/cycled/utf8.lua+78−70 zod/luau/res/lua/cycled/vararg.lua+24−24 zod/luau/res/lua/cycled/verybig.lua+15−76 zod/luau/ted/test-lua.hoon+42−10
zod/luau/TODO.md+1−1
@@ -1,6 +1,6 @@
11# Parser
22
33- [x] functioncall
4−- [ ] any string apart from the basic string with no escapes
4+- [x] any string apart from the basic string with no escapes
55- [ ] check if int fits in int or make it a float
66- [ ] should `print-blok` have `do`-`end`? This is fucked.
zod/luau/lib/lua/parser.hoon+2
@@ -756,6 +756,8 @@ apex
756756 =/ int=(unit @) ?~(int ?:(?=(~ leading-zeros) ~ `0) int)
757757 ?: ?=([~ ~ ~] [int frac exp]) ~
758758 ?: ?=([~ [~ ~]] [int frac]) ~
759+ :: If there is no fractional or exponential part it should just be an int.
760+ ?: ?=([~ ~] [frac exp]) ~
759761 %- some
760762 :*
761763 %d
zod/luau/lib/lua/printer.hoon+32−10
@@ -33,7 +33,7 @@ print
3333 %table (print-table +.expr)
3434 %string (print-string +.expr)
3535 %wildcard "..."
36− %functiondef (print-funcbody +.expr)
36+ %functiondef (zing ~["function " (print-funcbody +.expr)])
3737 %unop
3838 %- zing
3939 :~
@@ -61,7 +61,13 @@ print
6161 %- zing
6262 :~
6363 "\""
64− (trip string)
64+ ::
65+ ^- tape
66+ %- zing
67+ %+ turn (trip string)
68+ |= char=@t
69+ ^- tape
70+ :- '\\' (show-u `@`char)
6571 "\""
6672 ==
6773:: table
@@ -192,7 +198,13 @@ print
192198 ^- tape
193199 ?- -.stat
194200 %empty ";"
195− %blok (print-blok +.stat)
201+ %blok
202+ %- zing
203+ :~
204+ "do\0a"
205+ (print-blok +.stat)
206+ "\0aend"
207+ ==
196208 %asmnt
197209 %- zing
198210 :~
@@ -216,13 +228,14 @@ print
216228 (print-expr cond.stat)
217229 " do\0a"
218230 (print-blok body.stat)
231+ "\0aend"
219232 ==
220233 %repeat
221234 %- zing
222235 :~
223236 "repeat\0a"
224237 (print-blok body.stat)
225− "until "
238+ "\0auntil "
226239 (print-expr cond.stat)
227240 ==
228241 %if (print-if +.stat)
@@ -241,8 +254,12 @@ print
241254 :~
242255 "local "
243256 (print-attnamelist attnamelist.local-asmnt)
244− " = "
245− ?~ rhs.local-asmnt "" (print-explist u.rhs.local-asmnt)
257+ ?~ rhs.local-asmnt ""
258+ %- zing
259+ :~
260+ " = "
261+ (print-explist u.rhs.local-asmnt)
262+ ==
246263 ==
247264:: attnamelist
248265::
@@ -387,7 +404,7 @@ print
387404 |= [cond=expr body=blok]
388405 %- zing
389406 :~
390− "\0aelseif"
407+ "\0aelseif "
391408 (print-expr cond)
392409 " then\0a"
393410 (print-blok body)
@@ -487,7 +504,12 @@ print
487504++ show-float
488505 |= x=@rd
489506 ^- tape
490− %- r-co:co
491− %- rlyd
492− x
507+ =/ res
508+ %- r-co:co
509+ %- rlyd
510+ x
511+ :: if there is no dot then it will be interpreted as an int. add `.0` to force a float.
512+ ?: =(~ (find ~['.'] res))
513+ (weld res ".0")
514+ res
493515 --
zod/luau/res/lua/cycled/all.lua+97−108
@@ -1,14 +1,13 @@
1−local version = "Lua 5.4"
1+local version = "\76\117\97\32\53\46\52"
22if _VERSION ~= version then
3−io.stderr:write("This test suite is for ",version,", not for ",_VERSION,"
4−Exiting tests")
3+io.stderr:write("\84\104\105\115\32\116\101\115\116\32\115\117\105\116\101\32\105\115\32\102\111\114\32",version,"\44\32\110\111\116\32\102\111\114\32",_VERSION,"\10\69\120\105\116\105\110\103\32\116\101\115\116\115")
54return
65end
76_G.ARG=arg
8−_soft=rawget(_G,"_soft") or false
9−_port=rawget(_G,"_port") or false
10−_nomsg=rawget(_G,"_nomsg") or false
11−local usertests = rawget(_G,"_U")
7+_soft=rawget(_G,"\95\115\111\102\116") or false
8+_port=rawget(_G,"\95\112\111\114\116") or false
9+_nomsg=rawget(_G,"\95\110\111\109\115\103") or false
10+local usertests = rawget(_G,"\95\85")
1211if usertests then
1312_soft=true
1413_port=true
@@ -18,19 +17,19 @@ debug=nil
1817if usertests then
1918T=nil
2019else
21−T=rawget(_G,"T")
20+T=rawget(_G,"\84")
2221end
23−print("
24− Starting Tests")
22+print("\10\9\83\116\97\114\116\105\110\103\32\84\101\115\116\115")
23+do
2524local random_x,random_y = math.randomseed()
26−print(string.format("random seeds: %d, %d",random_x,random_y))
27−print("current path:
28−****" .. package.path .. "****
29−")
25+print(string.format("\114\97\110\100\111\109\32\115\101\101\100\115\58\32\37\100\44\32\37\100",random_x,random_y))
26+end
27+print("\99\117\114\114\101\110\116\32\112\97\116\104\58\10\42\42\42\42" .. package.path .. "\42\42\42\42\10")
3028local initclock = os.clock()
3129local lastclock = initclock
3230local walltime = os.time()
3331local collectgarbage = collectgarbage
32+do
3433local msgs = {}
3534function Message(m)
3635if not _nomsg then
@@ -38,51 +37,47 @@ print(m)
3837msgs[# msgs + 1]=string.sub(m,3,- 3)
3938end
4039end
41−assert(os.setlocale("C"))
40+assert(os.setlocale("\67"))
4241local T,print,format,write,assert,type,unpack,floor = T,print,string.format,io.write,assert,type,table.unpack,math.floor
4342local function F
4443(m)
4544local function round
4645(m)
4746m=m + 0.04999
48−return format("%.1f",m)
47+return format("\37\46\49\102",m)
4948end
50−if m < 1e3 then
49+if m < 1000 then
5150return m
5251else
53−m=m / 1e3
54−if m < 1e3 then
55−return round(m) .. "K"
52+m=m / 1000
53+if m < 1000 then
54+return round(m) .. "\75"
5655else
57−return round(m / 1e3) .. "M"
56+return round(m / 1000) .. "\77"
5857end
5958end
6059end
61−local Cstacklevel =
62−local showmem =
60+local Cstacklevel
61+local showmem
6362if not T then
6463local max = 0
65−showmem=()
66−local m = collectgarbage("count") * 1024
64+showmem=function ()
65+local m = collectgarbage("\99\111\117\110\116") * 1024
6766max=(m > max) and m or max
68−print(format(" ---- total memory: %s, max memory: %s ----
69−",F(m),F(max)))
67+print(format("\32\32\32\32\45\45\45\45\32\116\111\116\97\108\32\109\101\109\111\114\121\58\32\37\115\44\32\109\97\120\32\109\101\109\111\114\121\58\32\37\115\32\45\45\45\45\10",F(m),F(max)))
7068end
71−Cstacklevel=()
69+Cstacklevel=function ()
7270return 0
7371end
7472else
75−showmem=()
73+showmem=function ()
7674T.checkmemory()
7775local total,numblocks,maxmem = T.totalmem()
78−local count = collectgarbage("count")
79−print(format("
80− ---- total memory: %s (%.0fK), max use: %s, blocks: %d
81−",F(total),count,F(maxmem),numblocks))
82−print(format(" (strings: %d, tables: %d, functions: %d, " .. "
83− udata: %d, threads: %d)",T.totalmem("string"),T.totalmem("table"),T.totalmem("function"),T.totalmem("userdata"),T.totalmem("thread")))
84−end
85−Cstacklevel=()
76+local count = collectgarbage("\99\111\117\110\116")
77+print(format("\10\32\32\32\32\45\45\45\45\32\116\111\116\97\108\32\109\101\109\111\114\121\58\32\37\115\32\40\37\46\48\102\75\41\44\32\109\97\120\32\117\115\101\58\32\37\115\44\32\32\98\108\111\99\107\115\58\32\37\100\10",F(total),count,F(maxmem),numblocks))
78+print(format("\9\40\115\116\114\105\110\103\115\58\32\32\37\100\44\32\116\97\98\108\101\115\58\32\37\100\44\32\102\117\110\99\116\105\111\110\115\58\32\37\100\44\32" .. "\10\9\117\100\97\116\97\58\32\37\100\44\32\116\104\114\101\97\100\115\58\32\37\100\41",T.totalmem("\115\116\114\105\110\103"),T.totalmem("\116\97\98\108\101"),T.totalmem("\102\117\110\99\116\105\111\110"),T.totalmem("\117\115\101\114\100\97\116\97"),T.totalmem("\116\104\114\101\97\100")))
79+end
80+Cstacklevel=function ()
8681local _,_,ncalls = T.stacklevel()
8782return ncalls
8883end
@@ -90,14 +85,13 @@ end
9085local Cstack = Cstacklevel()
9186local function report
9287(n)
93−print("
94−***** FILE '" .. n .. "'*****")
88+print("\10\42\42\42\42\42\32\70\73\76\69\32\39" .. n .. "\39\42\42\42\42\42")
9589end
9690local olddofile = dofile
97−local dofile = (n,strip)
91+local dofile = function (n,strip)
9892showmem()
9993local c = os.clock()
100−print(string.format("time: %g (+%g)",c - initclock,c - lastclock))
94+print(string.format("\116\105\109\101\58\32\37\103\32\40\43\37\103\41",c - initclock,c - lastclock))
10195lastclock=c
10296report(n)
10397local f = assert(loadfile(n))
@@ -105,86 +99,84 @@ local b = string.dump(f,strip)
10599f=assert(load(b))
106100return f()
107101end
108−dofile("main.lua")
109−require("tracegc").start()
110−report("gc.lua")
111−local f = assert(loadfile("gc.lua"))
102+dofile("\109\97\105\110\46\108\117\97")
103+require("\116\114\97\99\101\103\99").start()
104+report("\103\99\46\108\117\97")
105+local f = assert(loadfile("\103\99\46\108\117\97"))
112106f()
113−dofile("db.lua")
114−assert(dofile("calls.lua") == deep and deep)
107+dofile("\100\98\46\108\117\97")
108+assert(dofile("\99\97\108\108\115\46\108\117\97") == deep and deep)
115109_G.deep=nil
116−olddofile("strings.lua")
117−olddofile("literals.lua")
118−dofile("tpack.lua")
119−assert(dofile("attrib.lua") == 27)
120−dofile("gengc.lua")
121−assert(dofile("locals.lua") == 5)
122−dofile("constructs.lua")
123−dofile("code.lua",true)
110+olddofile("\115\116\114\105\110\103\115\46\108\117\97")
111+olddofile("\108\105\116\101\114\97\108\115\46\108\117\97")
112+dofile("\116\112\97\99\107\46\108\117\97")
113+assert(dofile("\97\116\116\114\105\98\46\108\117\97") == 27)
114+dofile("\103\101\110\103\99\46\108\117\97")
115+assert(dofile("\108\111\99\97\108\115\46\108\117\97") == 5)
116+dofile("\99\111\110\115\116\114\117\99\116\115\46\108\117\97")
117+dofile("\99\111\100\101\46\108\117\97",true)
124118if not _G._soft then
125−report("big.lua")
126−local f = coroutine.wrap(assert(loadfile("big.lua")))
127−assert(f() == "b")
128−assert(f() == "a")
129−end
130−dofile("cstack.lua")
131−dofile("nextvar.lua")
132−dofile("pm.lua")
133−dofile("utf8.lua")
134−dofile("api.lua")
135−assert(dofile("events.lua") == 12)
136−dofile("vararg.lua")
137−dofile("closure.lua")
138−dofile("coroutine.lua")
139−dofile("goto.lua",true)
140−dofile("errors.lua")
141−dofile("math.lua")
142−dofile("sort.lua",true)
143−dofile("bitwise.lua")
144−assert(dofile("verybig.lua",true) == 10)
119+report("\98\105\103\46\108\117\97")
120+local f = coroutine.wrap(assert(loadfile("\98\105\103\46\108\117\97")))
121+assert(f() == "\98")
122+assert(f() == "\97")
123+end
124+dofile("\99\115\116\97\99\107\46\108\117\97")
125+dofile("\110\101\120\116\118\97\114\46\108\117\97")
126+dofile("\112\109\46\108\117\97")
127+dofile("\117\116\102\56\46\108\117\97")
128+dofile("\97\112\105\46\108\117\97")
129+assert(dofile("\101\118\101\110\116\115\46\108\117\97") == 12)
130+dofile("\118\97\114\97\114\103\46\108\117\97")
131+dofile("\99\108\111\115\117\114\101\46\108\117\97")
132+dofile("\99\111\114\111\117\116\105\110\101\46\108\117\97")
133+dofile("\103\111\116\111\46\108\117\97",true)
134+dofile("\101\114\114\111\114\115\46\108\117\97")
135+dofile("\109\97\116\104\46\108\117\97")
136+dofile("\115\111\114\116\46\108\117\97",true)
137+dofile("\98\105\116\119\105\115\101\46\108\117\97")
138+assert(dofile("\118\101\114\121\98\105\103\46\108\117\97",true) == 10)
145139;
146140collectgarbage()
147−dofile("files.lua")
141+dofile("\102\105\108\101\115\46\108\117\97")
148142if # msgs > 0 then
149−local m = table.concat(msgs,"
150− ")
151−warn("#tests not performed:
152− ",m,"
153−")
154−end
155−print("(there should be two warnings now)")
156−warn("@on")
157−warn("#This is ","an expected"," warning")
158−warn("@off")
159−warn("******** THIS WARNING SHOULD NOT APPEAR **********")
160−warn("******** THIS WARNING ALSO SHOULD NOT APPEAR **********")
161−warn("@on")
162−warn("#This is"," another one")
143+local m = table.concat(msgs,"\10\32\32")
144+warn("\35\116\101\115\116\115\32\110\111\116\32\112\101\114\102\111\114\109\101\100\58\10\32\32",m,"\10")
145+end
146+print("\40\116\104\101\114\101\32\115\104\111\117\108\100\32\98\101\32\116\119\111\32\119\97\114\110\105\110\103\115\32\110\111\119\41")
147+warn("\64\111\110")
148+warn("\35\84\104\105\115\32\105\115\32","\97\110\32\101\120\112\101\99\116\101\100","\32\119\97\114\110\105\110\103")
149+warn("\64\111\102\102")
150+warn("\42\42\42\42\42\42\42\42\32\84\72\73\83\32\87\65\82\78\73\78\71\32\83\72\79\85\76\68\32\78\79\84\32\65\80\80\69\65\82\32\42\42\42\42\42\42\42\42\42\42")
151+warn("\42\42\42\42\42\42\42\42\32\84\72\73\83\32\87\65\82\78\73\78\71\32\65\76\83\79\32\83\72\79\85\76\68\32\78\79\84\32\65\80\80\69\65\82\32\42\42\42\42\42\42\42\42\42\42")
152+warn("\64\111\110")
153+warn("\35\84\104\105\115\32\105\115","\32\97\110\111\116\104\101\114\32\111\110\101")
163154assert(debug == nil)
164−local debug = require("debug")
165−print(string.format("%d-bit integers, %d-bit floats",string.packsize("j") * 8,string.packsize("n") * 8))
166−debug.sethook((a)
167−assert(type(a) == "string")
168−end,"cr")
155+local debug = require("\100\101\98\117\103")
156+print(string.format("\37\100\45\98\105\116\32\105\110\116\101\103\101\114\115\44\32\37\100\45\98\105\116\32\102\108\111\97\116\115",string.packsize("\106") * 8,string.packsize("\110") * 8))
157+debug.sethook(function (a)
158+assert(type(a) == "\115\116\114\105\110\103")
159+end,"\99\114")
169160_G.showmem=showmem
170−assert(Cstack == Cstacklevel(),"should be at the same C-stack level it was when started the tests")
161+assert(Cstack == Cstacklevel(),"\115\104\111\117\108\100\32\98\101\32\97\116\32\116\104\101\32\115\97\109\101\32\67\45\115\116\97\99\107\32\108\101\118\101\108\32\105\116\32\119\97\115\32\119\104\101\110\32\115\116\97\114\116\101\100\32\116\104\101\32\116\101\115\116\115")
162+end
171163local _G,showmem,print,format,clock,time,difftime,assert,open,warn = _G,showmem,print,string.format,os.clock,os.time,os.difftime,assert,io.open,warn
172−local fname = T and "time-debug.txt" or "time.txt"
173−local lasttime =
164+local fname = T and "\116\105\109\101\45\100\101\98\117\103\46\116\120\116" or "\116\105\109\101\46\116\120\116"
165+local lasttime
174166if not usertests then
175167local f = io.open(fname)
176168if f then
177−lasttime=assert(tonumber(f:read("a")))
169+lasttime=assert(tonumber(f:read("\97")))
178170f:close()
179171;
180172else
181173lasttime=nil
182174end
183175end
184−print("cleaning all!!!!")
176+print("\99\108\101\97\110\105\110\103\32\97\108\108\33\33\33\33")
185177for n in pairs(_G)
186178do
187−if not ({["___Glob"] = 1,["tostring"] = 1})[n] then
179+if not ({["\95\95\95\71\108\111\98"] = 1,["\116\111\115\116\114\105\110\103"] = 1})[n] then
188180_G[n]=undef
189181end
190182end
@@ -198,17 +190,14 @@ collectgarbage()
198190showmem()
199191local clocktime = clock() - initclock
200192walltime=difftime(time(),walltime)
201−print(format("
202−
203−total time: %.2fs (wall time: %gs)
204−",clocktime,walltime))
193+print(format("\10\10\116\111\116\97\108\32\116\105\109\101\58\32\37\46\50\102\115\32\40\119\97\108\108\32\116\105\109\101\58\32\37\103\115\41\10",clocktime,walltime))
205194if not usertests then
206195lasttime=lasttime or clocktime
207196local diff = (clocktime - lasttime) / lasttime
208197local tolerance = 0.05
209198if (diff >= tolerance or diff <= - tolerance) then
210−warn(format("#time difference from previous test: %+.1f%%",diff * 100))
199+warn(format("\35\116\105\109\101\32\100\105\102\102\101\114\101\110\99\101\32\102\114\111\109\32\112\114\101\118\105\111\117\115\32\116\101\115\116\58\32\37\43\46\49\102\37\37",diff * 100))
211200end
212−assert(open(fname,"w")):write(clocktime):close()
201+assert(open(fname,"\119")):write(clocktime):close()
213202end
214−print("final OK !!!")
203+print("\102\105\110\97\108\32\79\75\32\33\33\33")
zod/luau/res/lua/cycled/api.lua+480−609
@@ -1,12 +1,10 @@
11if T == nil then
2−(Message or print)("
3− >>> testC not active: skipping API tests <<<
4−")
2+(Message or print)("\10\32\62\62\62\32\116\101\115\116\67\32\110\111\116\32\97\99\116\105\118\101\58\32\115\107\105\112\112\105\110\103\32\65\80\73\32\116\101\115\116\115\32\60\60\60\10")
53return
64end
7−local debug = require("debug")
5+local debug = require("\100\101\98\117\103")
86local pack = table.pack
9−local MEMERRMSG = "not enough memory"
7+local MEMERRMSG = "\110\111\116\32\101\110\111\117\103\104\32\109\101\109\111\114\121"
108local function tcheck
119(t1,t2)
1210assert(t1.n == (t2.n or # t2) + 1)
@@ -20,226 +18,197 @@ local function checkerr
2018local stat,err = pcall(f,...)
2119assert(not stat and string.find(err,msg))
2220end
23−print("testing C API")
24−local a = T.testC("pushvalue R; return 1")
21+print("\116\101\115\116\105\110\103\32\67\32\65\80\73")
22+local a = T.testC("\112\117\115\104\118\97\108\117\101\32\82\59\32\114\101\116\117\114\110\32\49")
2523assert(a == debug.getregistry())
26−assert(T.testC("settop 10; absindex -1; return 1") == 10)
27−assert(T.testC("settop 5; absindex -5; return 1") == 1)
28−assert(T.testC("settop 10; absindex 1; return 1") == 1)
29−assert(T.testC("settop 10; absindex R; return 1") < - 10)
30−a=T.d2s(12458954321123)
31−assert(a == string.pack("d",12458954321123))
32−assert(T.s2d(a) == 12458954321123)
33−local a,b,c = T.testC("pushnum 1; pushnum 2; pushnum 3; return 2")
24+assert(T.testC("\115\101\116\116\111\112\32\49\48\59\32\97\98\115\105\110\100\101\120\32\45\49\59\32\114\101\116\117\114\110\32\49") == 10)
25+assert(T.testC("\115\101\116\116\111\112\32\53\59\32\97\98\115\105\110\100\101\120\32\45\53\59\32\114\101\116\117\114\110\32\49") == 1)
26+assert(T.testC("\115\101\116\116\111\112\32\49\48\59\32\97\98\115\105\110\100\101\120\32\49\59\32\114\101\116\117\114\110\32\49") == 1)
27+assert(T.testC("\115\101\116\116\111\112\32\49\48\59\32\97\98\115\105\110\100\101\120\32\82\59\32\114\101\116\117\114\110\32\49") < - 10)
28+a=T.d2s(12458954321123.0)
29+assert(a == string.pack("\100",12458954321123.0))
30+assert(T.s2d(a) == 12458954321123.0)
31+local a,b,c = T.testC("\112\117\115\104\110\117\109\32\49\59\32\112\117\115\104\110\117\109\32\50\59\32\112\117\115\104\110\117\109\32\51\59\32\114\101\116\117\114\110\32\50")
3432assert(a == 2 and b == 3 and not c)
35−local f = T.makeCfunc("pushnum 1; pushnum 2; pushnum 3; return 2")
33+local f = T.makeCfunc("\112\117\115\104\110\117\109\32\49\59\32\112\117\115\104\110\117\109\32\50\59\32\112\117\115\104\110\117\109\32\51\59\32\114\101\116\117\114\110\32\50")
3634a,b,c=f()
3735assert(a == 2 and b == 3 and not c)
38−a,b,c=T.testC("pushbool 1; pushbool 2; pushbool 0; return 3")
36+a,b,c=T.testC("\112\117\115\104\98\111\111\108\32\49\59\32\112\117\115\104\98\111\111\108\32\50\59\32\112\117\115\104\98\111\111\108\32\48\59\32\114\101\116\117\114\110\32\51")
3937assert(a == b and a == true and c == false)
40−a,b,c=T.testC("pushbool 0; pushbool 10; pushnil;
41− tobool -3; tobool -3; tobool -3; return 3")
38+a,b,c=T.testC("\112\117\115\104\98\111\111\108\32\48\59\32\112\117\115\104\98\111\111\108\32\49\48\59\32\112\117\115\104\110\105\108\59\10\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\116\111\98\111\111\108\32\45\51\59\32\116\111\98\111\111\108\32\45\51\59\32\116\111\98\111\111\108\32\45\51\59\32\114\101\116\117\114\110\32\51")
4239assert(a == false and b == true and c == false)
43−a,b,c=T.testC("gettop; return 2",10,20,30,40)
40+a,b,c=T.testC("\103\101\116\116\111\112\59\32\114\101\116\117\114\110\32\50",10,20,30,40)
4441assert(a == 40 and b == 5 and not c)
45−local t = pack(T.testC("settop 5; return *",2,3))
46−tcheck(t,{["n"] = 4,2,3})
47−t=pack(T.testC("settop 0; settop 15; return 10",3,1,23))
42+local t = pack(T.testC("\115\101\116\116\111\112\32\53\59\32\114\101\116\117\114\110\32\42",2,3))
43+tcheck(t,{["\110"] = 4,2,3})
44+t=pack(T.testC("\115\101\116\116\111\112\32\48\59\32\115\101\116\116\111\112\32\49\53\59\32\114\101\116\117\114\110\32\49\48",3,1,23))
4845assert(t.n == 10 and t[1] == nil and t[10] == nil)
49−t=pack(T.testC("remove -2; return *",2,3,4))
50−tcheck(t,{["n"] = 2,2,4})
51−t=pack(T.testC("insert -1; return *",2,3))
52−tcheck(t,{["n"] = 2,2,3})
53−t=pack(T.testC("insert 3; return *",2,3,4,5))
54−tcheck(t,{["n"] = 4,2,5,3,4})
55−t=pack(T.testC("replace 2; return *",2,3,4,5))
56−tcheck(t,{["n"] = 3,5,3,4})
57−t=pack(T.testC("replace -2; return *",2,3,4,5))
58−tcheck(t,{["n"] = 3,2,3,5})
59−t=pack(T.testC("remove 3; return *",2,3,4,5))
60−tcheck(t,{["n"] = 3,2,4,5})
61−t=pack(T.testC("copy 3 4; return *",2,3,4,5))
62−tcheck(t,{["n"] = 4,2,3,3,5})
63−t=pack(T.testC("copy -3 -1; return *",2,3,4,5))
64−tcheck(t,{["n"] = 4,2,3,4,3})
46+t=pack(T.testC("\114\101\109\111\118\101\32\45\50\59\32\114\101\116\117\114\110\32\42",2,3,4))
47+tcheck(t,{["\110"] = 2,2,4})
48+t=pack(T.testC("\105\110\115\101\114\116\32\45\49\59\32\114\101\116\117\114\110\32\42",2,3))
49+tcheck(t,{["\110"] = 2,2,3})
50+t=pack(T.testC("\105\110\115\101\114\116\32\51\59\32\114\101\116\117\114\110\32\42",2,3,4,5))
51+tcheck(t,{["\110"] = 4,2,5,3,4})
52+t=pack(T.testC("\114\101\112\108\97\99\101\32\50\59\32\114\101\116\117\114\110\32\42",2,3,4,5))
53+tcheck(t,{["\110"] = 3,5,3,4})
54+t=pack(T.testC("\114\101\112\108\97\99\101\32\45\50\59\32\114\101\116\117\114\110\32\42",2,3,4,5))
55+tcheck(t,{["\110"] = 3,2,3,5})
56+t=pack(T.testC("\114\101\109\111\118\101\32\51\59\32\114\101\116\117\114\110\32\42",2,3,4,5))
57+tcheck(t,{["\110"] = 3,2,4,5})
58+t=pack(T.testC("\99\111\112\121\32\51\32\52\59\32\114\101\116\117\114\110\32\42",2,3,4,5))
59+tcheck(t,{["\110"] = 4,2,3,3,5})
60+t=pack(T.testC("\99\111\112\121\32\45\51\32\45\49\59\32\114\101\116\117\114\110\32\42",2,3,4,5))
61+tcheck(t,{["\110"] = 4,2,3,4,3})
62+do
6563local t = {10,20,30,40,50,60}
6664for i = - 6, 6
6765do
68−local s = string.format("rotate 2 %d; return 7",i)
66+local s = string.format("\114\111\116\97\116\101\32\50\32\37\100\59\32\114\101\116\117\114\110\32\55",i)
6967local t1 = pack(T.testC(s,10,20,30,40,50,60))
7068tcheck(t1,t)
7169table.insert(t,1,table.remove(t))
7270end
73−t=pack(T.testC("rotate -2 1; return *",10,20,30,40))
71+t=pack(T.testC("\114\111\116\97\116\101\32\45\50\32\49\59\32\114\101\116\117\114\110\32\42",10,20,30,40))
7472tcheck(t,{10,20,40,30})
75−t=pack(T.testC("rotate -2 -1; return *",10,20,30,40))
73+t=pack(T.testC("\114\111\116\97\116\101\32\45\50\32\45\49\59\32\114\101\116\117\114\110\32\42",10,20,30,40))
7674tcheck(t,{10,20,40,30})
77−t=pack(T.testC("rotate -1 0; return *",10,20,30,40))
75+t=pack(T.testC("\114\111\116\97\116\101\32\45\49\32\48\59\32\114\101\116\117\114\110\32\42",10,20,30,40))
7876tcheck(t,{10,20,30,40})
79−t=pack(T.testC("rotate -1 1; return *",10,20,30,40))
77+t=pack(T.testC("\114\111\116\97\116\101\32\45\49\32\49\59\32\114\101\116\117\114\110\32\42",10,20,30,40))
8078tcheck(t,{10,20,30,40})
81−t=pack(T.testC("rotate 5 -1; return *",10,20,30,40))
79+t=pack(T.testC("\114\111\116\97\116\101\32\53\32\45\49\59\32\114\101\116\117\114\110\32\42",10,20,30,40))
8280tcheck(t,{10,20,30,40})
83−T.testC(" warningC "#This shold be a"
84− warningC " single "
85− warning "warning"
86− warningC "#This should be "
87− warning "another one"
88−")
89−local f = T.makeCfunc(" getglobal error
90− pushstring bola
91− pcall 1 1 1 # call 'error' with given handler
92− pushstatus
93− return 2 # return error message and status
94− ")
81+end
82+T.testC("\32\32\119\97\114\110\105\110\103\67\32\34\35\84\104\105\115\32\115\104\111\108\100\32\98\101\32\97\34\10\32\32\119\97\114\110\105\110\103\67\32\34\32\115\105\110\103\108\101\32\34\10\32\32\119\97\114\110\105\110\103\32\34\119\97\114\110\105\110\103\34\10\32\32\119\97\114\110\105\110\103\67\32\34\35\84\104\105\115\32\115\104\111\117\108\100\32\98\101\32\34\10\32\32\119\97\114\110\105\110\103\32\34\97\110\111\116\104\101\114\32\111\110\101\34\10")
83+do
84+local f = T.makeCfunc("\32\32\32\32\103\101\116\103\108\111\98\97\108\32\101\114\114\111\114\10\32\32\32\32\112\117\115\104\115\116\114\105\110\103\32\98\111\108\97\10\32\32\32\32\112\99\97\108\108\32\49\32\49\32\49\32\32\32\35\32\99\97\108\108\32\39\101\114\114\111\114\39\32\119\105\116\104\32\103\105\118\101\110\32\104\97\110\100\108\101\114\10\32\32\32\32\112\117\115\104\115\116\97\116\117\115\10\32\32\32\32\114\101\116\117\114\110\32\50\32\32\32\32\32\35\32\114\101\116\117\114\110\32\101\114\114\111\114\32\109\101\115\115\97\103\101\32\97\110\100\32\115\116\97\116\117\115\10\32\32")
9585local msg,st = f(string.upper)
96−assert(st == "ERRRUN" and msg == "BOLA")
86+assert(st == "\69\82\82\82\85\78" and msg == "\66\79\76\65")
9787local msg,st = f(string.len)
98−assert(st == "ERRRUN" and msg == 4)
99−t=pack(T.testC("insert 3; pushvalue 3; remove 3; pushvalue 2; remove 2;
100− insert 2; pushvalue 1; remove 1; insert 1;
101− insert -2; pushvalue -2; remove -3; return *",2,3,4,5,10,40,90))
102−tcheck(t,{["n"] = 7,2,3,4,5,10,40,90})
103−t=pack(T.testC("concat 5; return *","alo",2,3,"joao",12))
104−tcheck(t,{["n"] = 1,"alo23joao12"})
105−t=pack(T.testC("call 2,-1; return *",(a,b)
88+assert(st == "\69\82\82\82\85\78" and msg == 4)
89+end
90+t=pack(T.testC("\105\110\115\101\114\116\32\51\59\32\112\117\115\104\118\97\108\117\101\32\51\59\32\114\101\109\111\118\101\32\51\59\32\112\117\115\104\118\97\108\117\101\32\50\59\32\114\101\109\111\118\101\32\50\59\32\10\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\105\110\115\101\114\116\32\50\59\32\112\117\115\104\118\97\108\117\101\32\49\59\32\114\101\109\111\118\101\32\49\59\32\105\110\115\101\114\116\32\49\59\32\10\32\32\32\32\32\32\105\110\115\101\114\116\32\45\50\59\32\112\117\115\104\118\97\108\117\101\32\45\50\59\32\114\101\109\111\118\101\32\45\51\59\32\114\101\116\117\114\110\32\42",2,3,4,5,10,40,90))
91+tcheck(t,{["\110"] = 7,2,3,4,5,10,40,90})
92+t=pack(T.testC("\99\111\110\99\97\116\32\53\59\32\114\101\116\117\114\110\32\42","\97\108\111",2,3,"\106\111\97\111",12))
93+tcheck(t,{["\110"] = 1,"\97\108\111\50\51\106\111\97\111\49\50"})
94+t=pack(T.testC("\99\97\108\108\32\50\44\45\49\59\32\114\101\116\117\114\110\32\42",function (a,b)
10695return 1,2,3,4,a,b
107−end,"alo","joao"))
108−tcheck(t,{["n"] = 6,1,2,3,4,"alo","joao"})
96+end,"\97\108\111","\106\111\97\111"))
97+tcheck(t,{["\110"] = 6,1,2,3,4,"\97\108\111","\106\111\97\111"})
98+do
10999local a = {}
110−for i = 1, 1e3
100+for i = 1, 1000
111101do
112102a[i]=true
113103end
114104;
115105a[999]=10
116−local b = T.testC("pcall 1 -1 0; pop 1; tostring -1; return 1",table.unpack,a)
117−assert(b == "10")
106+local b = T.testC("\112\99\97\108\108\32\49\32\45\49\32\48\59\32\112\111\112\32\49\59\32\116\111\115\116\114\105\110\103\32\45\49\59\32\114\101\116\117\114\110\32\49",table.unpack,a)
107+assert(b == "\49\48")
108+end
118109_G.AA=14
119110;
120−_G.BB="a31"
121−local a = {T.testC(" getglobal AA;
122− getglobal BB;
123− getglobal BB;
124− setglobal AA;
125− return *
126−")}
127−assert(a[2] == 14 and a[3] == "a31" and a[4] == nil and _G.AA == "a31")
111+_G.BB="\97\51\49"
112+local a = {T.testC("\32\32\103\101\116\103\108\111\98\97\108\32\65\65\59\10\32\32\103\101\116\103\108\111\98\97\108\32\66\66\59\10\32\32\103\101\116\103\108\111\98\97\108\32\66\66\59\10\32\32\115\101\116\103\108\111\98\97\108\32\65\65\59\10\32\32\114\101\116\117\114\110\32\42\10")}
113+assert(a[2] == 14 and a[3] == "\97\51\49" and a[4] == nil and _G.AA == "\97\51\49")
128114_G.AA,_G.BB=nil
129−assert(T.testC("pushnum 10; pushnum 20; arith /; return 1") == 0.5)
130−assert(T.testC("pushnum 10; pushnum 20; arith -; return 1") == - 10)
131−assert(T.testC("pushnum 10; pushnum -20; arith *; return 1") == - 200)
132−assert(T.testC("pushnum 10; pushnum 3; arith ^; return 1") == 1e3)
133−assert(T.testC("pushnum 10; pushstring 20; arith /; return 1") == 0.5)
134−assert(T.testC("pushstring 10; pushnum 20; arith -; return 1") == - 10)
135−assert(T.testC("pushstring 10; pushstring -20; arith *; return 1") == - 200)
136−assert(T.testC("pushstring 10; pushstring 3; arith ^; return 1") == 1e3)
137−assert(T.testC("arith /; return 1",2,0) == 10 / 0)
138−a=T.testC("pushnum 10; pushint 3; arith \; return 1")
139−assert(a == 3 and math.type(a) == "float")
140−a=T.testC("pushint 10; pushint 3; arith \; return 1")
141−assert(a == 3 and math.type(a) == "integer")
142−a=assert(T.testC("pushint 10; pushint 3; arith +; return 1"))
143−assert(a == 13 and math.type(a) == "integer")
144−a=assert(T.testC("pushnum 10; pushint 3; arith +; return 1"))
145−assert(a == 13 and math.type(a) == "float")
146−a,b,c=T.testC("pushnum 1;
147− pushstring 10; arith _;
148− pushstring 5; return 3")
149−assert(a == 1 and b == - 10 and c == "5")
150−local mt = {["__add"] = (a,b)
115+assert(T.testC("\112\117\115\104\110\117\109\32\49\48\59\32\112\117\115\104\110\117\109\32\50\48\59\32\97\114\105\116\104\32\47\59\32\114\101\116\117\114\110\32\49") == 0.5)
116+assert(T.testC("\112\117\115\104\110\117\109\32\49\48\59\32\112\117\115\104\110\117\109\32\50\48\59\32\97\114\105\116\104\32\45\59\32\114\101\116\117\114\110\32\49") == - 10)
117+assert(T.testC("\112\117\115\104\110\117\109\32\49\48\59\32\112\117\115\104\110\117\109\32\45\50\48\59\32\97\114\105\116\104\32\42\59\32\114\101\116\117\114\110\32\49") == - 200)
118+assert(T.testC("\112\117\115\104\110\117\109\32\49\48\59\32\112\117\115\104\110\117\109\32\51\59\32\97\114\105\116\104\32\94\59\32\114\101\116\117\114\110\32\49") == 1000)
119+assert(T.testC("\112\117\115\104\110\117\109\32\49\48\59\32\112\117\115\104\115\116\114\105\110\103\32\50\48\59\32\97\114\105\116\104\32\47\59\32\114\101\116\117\114\110\32\49") == 0.5)
120+assert(T.testC("\112\117\115\104\115\116\114\105\110\103\32\49\48\59\32\112\117\115\104\110\117\109\32\50\48\59\32\97\114\105\116\104\32\45\59\32\114\101\116\117\114\110\32\49") == - 10)
121+assert(T.testC("\112\117\115\104\115\116\114\105\110\103\32\49\48\59\32\112\117\115\104\115\116\114\105\110\103\32\45\50\48\59\32\97\114\105\116\104\32\42\59\32\114\101\116\117\114\110\32\49") == - 200)
122+assert(T.testC("\112\117\115\104\115\116\114\105\110\103\32\49\48\59\32\112\117\115\104\115\116\114\105\110\103\32\51\59\32\97\114\105\116\104\32\94\59\32\114\101\116\117\114\110\32\49") == 1000)
123+assert(T.testC("\97\114\105\116\104\32\47\59\32\114\101\116\117\114\110\32\49",2,0) == 10.0 / 0)
124+a=T.testC("\112\117\115\104\110\117\109\32\49\48\59\32\112\117\115\104\105\110\116\32\51\59\32\97\114\105\116\104\32\92\59\32\114\101\116\117\114\110\32\49")
125+assert(a == 3.0 and math.type(a) == "\102\108\111\97\116")
126+a=T.testC("\112\117\115\104\105\110\116\32\49\48\59\32\112\117\115\104\105\110\116\32\51\59\32\97\114\105\116\104\32\92\59\32\114\101\116\117\114\110\32\49")
127+assert(a == 3 and math.type(a) == "\105\110\116\101\103\101\114")
128+a=assert(T.testC("\112\117\115\104\105\110\116\32\49\48\59\32\112\117\115\104\105\110\116\32\51\59\32\97\114\105\116\104\32\43\59\32\114\101\116\117\114\110\32\49"))
129+assert(a == 13 and math.type(a) == "\105\110\116\101\103\101\114")
130+a=assert(T.testC("\112\117\115\104\110\117\109\32\49\48\59\32\112\117\115\104\105\110\116\32\51\59\32\97\114\105\116\104\32\43\59\32\114\101\116\117\114\110\32\49"))
131+assert(a == 13 and math.type(a) == "\102\108\111\97\116")
132+a,b,c=T.testC("\112\117\115\104\110\117\109\32\49\59\10\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\112\117\115\104\115\116\114\105\110\103\32\49\48\59\32\97\114\105\116\104\32\95\59\10\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\112\117\115\104\115\116\114\105\110\103\32\53\59\32\114\101\116\117\114\110\32\51")
133+assert(a == 1 and b == - 10 and c == "\53")
134+local mt = {["\95\95\97\100\100"] = function (a,b)
151135return setmetatable({a[1] + b[1]},mt)
152−end,["__mod"] = (a,b)
136+end,["\95\95\109\111\100"] = function (a,b)
153137return setmetatable({a[1] % b[1]},mt)
154−end,["__unm"] = (a)
138+end,["\95\95\117\110\109"] = function (a)
155139return setmetatable({a[1] * 2},mt)
156140end}
157141a,b,c=setmetatable({4},mt),setmetatable({8},mt),setmetatable({- 3},mt)
158−local x,y,z = T.testC("arith +; return 2",10,a,b)
142+local x,y,z = T.testC("\97\114\105\116\104\32\43\59\32\114\101\116\117\114\110\32\50",10,a,b)
159143assert(x == 10 and y[1] == 12 and z == nil)
160−assert(T.testC("arith %; return 1",a,c)[1] == 4 % - 3)
161−assert(T.testC("arith _; arith +; arith %; return 1",b,a,c)[1] == 8 % (4 + (- 3) * 2))
162−checkerr("divide by zero",T.testC,"arith \",10,0)
163−checkerr("%%0",T.testC,"arith %",10,0)
164−assert(T.testC("compare LT 2 5, return 1",3,2,2,4,2,2))
165−assert(T.testC("compare LE 2 5, return 1",3,2,2,4,2,2))
166−assert(not T.testC("compare LT 3 4, return 1",3,2,2,4,2,2))
167−assert(T.testC("compare LE 3 4, return 1",3,2,2,4,2,2))
168−assert(T.testC("compare LT 5 2, return 1",4,2,2,3,2,2))
169−assert(not T.testC("compare LT 2 -3, return 1","4","2","2","3","2","2"))
170−assert(not T.testC("compare LT -3 2, return 1","3","2","2","4","2","2"))
171−assert(not T.testC("compare LT 1 4, return 1"))
172−assert(not T.testC("compare LE 9 1, return 1"))
173−assert(not T.testC("compare EQ 9 9, return 1"))
174−local b = {["__lt"] = (a,b)
144+assert(T.testC("\97\114\105\116\104\32\37\59\32\114\101\116\117\114\110\32\49",a,c)[1] == 4 % - 3)
145+assert(T.testC("\97\114\105\116\104\32\95\59\32\97\114\105\116\104\32\43\59\32\97\114\105\116\104\32\37\59\32\114\101\116\117\114\110\32\49",b,a,c)[1] == 8 % (4 + (- 3) * 2))
146+checkerr("\100\105\118\105\100\101\32\98\121\32\122\101\114\111",T.testC,"\97\114\105\116\104\32\92",10,0)
147+checkerr("\37\37\48",T.testC,"\97\114\105\116\104\32\37",10,0)
148+assert(T.testC("\99\111\109\112\97\114\101\32\76\84\32\50\32\53\44\32\114\101\116\117\114\110\32\49",3,2,2,4,2,2))
149+assert(T.testC("\99\111\109\112\97\114\101\32\76\69\32\50\32\53\44\32\114\101\116\117\114\110\32\49",3,2,2,4,2,2))
150+assert(not T.testC("\99\111\109\112\97\114\101\32\76\84\32\51\32\52\44\32\114\101\116\117\114\110\32\49",3,2,2,4,2,2))
151+assert(T.testC("\99\111\109\112\97\114\101\32\76\69\32\51\32\52\44\32\114\101\116\117\114\110\32\49",3,2,2,4,2,2))
152+assert(T.testC("\99\111\109\112\97\114\101\32\76\84\32\53\32\50\44\32\114\101\116\117\114\110\32\49",4,2,2,3,2,2))
153+assert(not T.testC("\99\111\109\112\97\114\101\32\76\84\32\50\32\45\51\44\32\114\101\116\117\114\110\32\49","\52","\50","\50","\51","\50","\50"))
154+assert(not T.testC("\99\111\109\112\97\114\101\32\76\84\32\45\51\32\50\44\32\114\101\116\117\114\110\32\49","\51","\50","\50","\52","\50","\50"))
155+assert(not T.testC("\99\111\109\112\97\114\101\32\76\84\32\49\32\52\44\32\114\101\116\117\114\110\32\49"))
156+assert(not T.testC("\99\111\109\112\97\114\101\32\76\69\32\57\32\49\44\32\114\101\116\117\114\110\32\49"))
157+assert(not T.testC("\99\111\109\112\97\114\101\32\69\81\32\57\32\57\44\32\114\101\116\117\114\110\32\49"))
158+local b = {["\95\95\108\116"] = function (a,b)
175159return a[1] < b[1]
176160end}
177161local a1,a3,a4 = setmetatable({1},b),setmetatable({3},b),setmetatable({4},b)
178−assert(T.testC("compare LT 2 5, return 1",a3,2,2,a4,2,2))
179−assert(T.testC("compare LE 2 5, return 1",a3,2,2,a4,2,2))
180−assert(T.testC("compare LT 5 -6, return 1",a4,2,2,a3,2,2))
181−a,b=T.testC("compare LT 5 -6, return 2",a1,2,2,a3,2,20)
162+assert(T.testC("\99\111\109\112\97\114\101\32\76\84\32\50\32\53\44\32\114\101\116\117\114\110\32\49",a3,2,2,a4,2,2))
163+assert(T.testC("\99\111\109\112\97\114\101\32\76\69\32\50\32\53\44\32\114\101\116\117\114\110\32\49",a3,2,2,a4,2,2))
164+assert(T.testC("\99\111\109\112\97\114\101\32\76\84\32\53\32\45\54\44\32\114\101\116\117\114\110\32\49",a4,2,2,a3,2,2))
165+a,b=T.testC("\99\111\109\112\97\114\101\32\76\84\32\53\32\45\54\44\32\114\101\116\117\114\110\32\50",a1,2,2,a3,2,20)
182166assert(a == 20 and b == false)
183−a,b=T.testC("compare LE 5 -6, return 2",a1,2,2,a3,2,20)
167+a,b=T.testC("\99\111\109\112\97\114\101\32\76\69\32\53\32\45\54\44\32\114\101\116\117\114\110\32\50",a1,2,2,a3,2,20)
184168assert(a == 20 and b == false)
185−a,b=T.testC("compare LE 5 -6, return 2",a1,2,2,a1,2,20)
169+a,b=T.testC("\99\111\109\112\97\114\101\32\76\69\32\53\32\45\54\44\32\114\101\116\117\114\110\32\50",a1,2,2,a1,2,20)
186170assert(a == 20 and b == true)
187−local mt = {["__lt"] = (a,b)
171+do
172+local mt = {["\95\95\108\116"] = function (a,b)
188173return a[1] < b[1]
189−end,["__le"] = (a,b)
174+end,["\95\95\108\101"] = function (a,b)
190175return a[1] <= b[1]
191−end,["__eq"] = (a,b)
176+end,["\95\95\101\113"] = function (a,b)
192177return a[1] == b[1]
193178end}
194179local function O
195180(x)
196181return setmetatable({x},mt)
197182end
198−local a,b = T.testC("compare LT 2 3; pushint 10; return 2",O(1),O(2))
183+local a,b = T.testC("\99\111\109\112\97\114\101\32\76\84\32\50\32\51\59\32\112\117\115\104\105\110\116\32\49\48\59\32\114\101\116\117\114\110\32\50",O(1),O(2))
199184assert(a == true and b == 10)
200−local a,b = T.testC("compare LE 2 3; pushint 10; return 2",O(3),O(2))
185+local a,b = T.testC("\99\111\109\112\97\114\101\32\76\69\32\50\32\51\59\32\112\117\115\104\105\110\116\32\49\48\59\32\114\101\116\117\114\110\32\50",O(3),O(2))
201186assert(a == false and b == 10)
202−local a,b = T.testC("compare EQ 2 3; pushint 10; return 2",O(3),O(3))
187+local a,b = T.testC("\99\111\109\112\97\114\101\32\69\81\32\50\32\51\59\32\112\117\115\104\105\110\116\32\49\48\59\32\114\101\116\117\114\110\32\50",O(3),O(3))
203188assert(a == true and b == 10)
204−local t = setmetatable({["x"] = 20},{["__len"] = (t)
189+end
190+local t = setmetatable({["\120"] = 20},{["\95\95\108\101\110"] = function (t)
205191return t.x
206192end})
207−a,b,c=T.testC(" len 2;
208− Llen 2;
209− objsize 2;
210− return 3
211−",t)
193+a,b,c=T.testC("\32\32\32\108\101\110\32\50\59\10\32\32\32\76\108\101\110\32\50\59\10\32\32\32\111\98\106\115\105\122\101\32\50\59\10\32\32\32\114\101\116\117\114\110\32\51\10",t)
212194assert(a == 20 and b == 20 and c == 0)
213−t.x="234"
195+t.x="\50\51\52"
214196;
215197t[1]=20
216−a,b,c=T.testC(" len 2;
217− Llen 2;
218− objsize 2;
219− return 3
220−",t)
221−assert(a == "234" and b == 234 and c == 1)
198+a,b,c=T.testC("\32\32\32\108\101\110\32\50\59\10\32\32\32\76\108\101\110\32\50\59\10\32\32\32\111\98\106\115\105\122\101\32\50\59\10\32\32\32\114\101\116\117\114\110\32\51\10",t)
199+assert(a == "\50\51\52" and b == 234 and c == 1)
222200t.x=print
223201;
224202t[1]=20
225−a,c=T.testC(" len 2;
226− objsize 2;
227− return 2
228−",t)
203+a,c=T.testC("\32\32\32\108\101\110\32\50\59\10\32\32\32\111\98\106\115\105\122\101\32\50\59\10\32\32\32\114\101\116\117\114\110\32\50\10",t)
229204assert(a == print and c == 1)
230−a=setmetatable({["x"] = "u"},{["__concat"] = (a,b)
231−return a.x .. "." .. b.x
205+a=setmetatable({["\120"] = "\117"},{["\95\95\99\111\110\99\97\116"] = function (a,b)
206+return a.x .. "\46" .. b.x
232207end})
233−x,y=T.testC(" pushnum 5
234− pushvalue 2;
235− pushvalue 2;
236− concat 2;
237− pushvalue -2;
238− return 2;
239−",a,a)
208+x,y=T.testC("\32\32\112\117\115\104\110\117\109\32\53\10\32\32\112\117\115\104\118\97\108\117\101\32\50\59\10\32\32\112\117\115\104\118\97\108\117\101\32\50\59\10\32\32\99\111\110\99\97\116\32\50\59\10\32\32\112\117\115\104\118\97\108\117\101\32\45\50\59\10\32\32\114\101\116\117\114\110\32\50\59\10",a,a)
240209assert(x == a .. a and y == 5)
241−assert(T.testC("concat 0; return 1") == "")
242−assert(T.testC("concat 1; return 1","xuxu") == "xuxu")
210+assert(T.testC("\99\111\110\99\97\116\32\48\59\32\114\101\116\117\114\110\32\49") == "")
211+assert(T.testC("\99\111\110\99\97\116\32\49\59\32\114\101\116\117\114\110\32\49","\120\117\120\117") == "\120\117\120\117")
243212local function B
244213(x)
245214return x and 1 or 0
@@ -247,26 +216,17 @@ end
247216local function count
248217(x,n)
249218n=n or 2
250−local prog = " isnumber %d;
251− isstring %d;
252− isfunction %d;
253− iscfunction %d;
254− istable %d;
255− isuserdata %d;
256− isnil %d;
257− isnull %d;
258− return 8
259− "
219+local prog = "\32\32\32\32\105\115\110\117\109\98\101\114\32\37\100\59\10\32\32\32\32\105\115\115\116\114\105\110\103\32\37\100\59\10\32\32\32\32\105\115\102\117\110\99\116\105\111\110\32\37\100\59\10\32\32\32\32\105\115\99\102\117\110\99\116\105\111\110\32\37\100\59\10\32\32\32\32\105\115\116\97\98\108\101\32\37\100\59\10\32\32\32\32\105\115\117\115\101\114\100\97\116\97\32\37\100\59\10\32\32\32\32\105\115\110\105\108\32\37\100\59\10\32\32\32\32\105\115\110\117\108\108\32\37\100\59\10\32\32\32\32\114\101\116\117\114\110\32\56\10\32\32"
260220prog=string.format(prog,n,n,n,n,n,n,n,n)
261221local a,b,c,d,e,f,g,h = T.testC(prog,x)
262222return B(a) + B(b) + B(c) + B(d) + B(e) + B(f) + B(g) + (100 * B(h))
263223end
264224assert(count(3) == 2)
265−assert(count("alo") == 1)
266−assert(count("32") == 2)
225+assert(count("\97\108\111") == 1)
226+assert(count("\51\50") == 2)
267227assert(count({}) == 1)
268228assert(count(print) == 2)
269−assert(count(()
229+assert(count(function ()
270230
271231end) == 1)
272232assert(count(nil) == 1)
@@ -275,100 +235,88 @@ assert(count(nil,15) == 100)
275235local function to
276236(s,x,n)
277237n=n or 2
278−return T.testC(string.format("%s %d; return 1",s,n),x)
238+return T.testC(string.format("\37\115\32\37\100\59\32\114\101\116\117\114\110\32\49",s,n),x)
279239end
280240local null = T.pushuserdata(0)
281241local hfunc = string.gmatch("","")
282242assert(debug.getupvalue(hfunc,1))
283−assert(to("tostring",{}) == nil)
284−assert(to("tostring","alo") == "alo")
285−assert(to("tostring",12) == "12")
286−assert(to("tostring",12,3) == nil)
287−assert(to("objsize",{}) == 0)
288−assert(to("objsize",{1,2,3}) == 3)
289−assert(to("objsize","aloa") == 6)
290−assert(to("objsize",T.newuserdata(0)) == 0)
291−assert(to("objsize",T.newuserdata(101)) == 101)
292−assert(to("objsize",124) == 0)
293−assert(to("objsize",true) == 0)
294−assert(to("tonumber",{}) == 0)
295−assert(to("tonumber","12") == 12)
296−assert(to("tonumber","s2") == 0)
297−assert(to("tonumber",1,20) == 0)
298−assert(to("topointer",10) == null)
299−assert(to("topointer",true) == null)
300−assert(to("topointer",nil) == null)
301−assert(to("topointer","abc") ~= null)
302−assert(to("topointer",string.rep("x",10)) == to("topointer",string.rep("x",10)))
303−local s1 = string.rep("x",300)
304−local s2 = string.rep("x",300)
305−assert(to("topointer",s1) ~= to("topointer",s2))
306−assert(to("topointer",T.pushuserdata(20)) ~= null)
307−assert(to("topointer",io.read) ~= null)
308−assert(to("topointer",hfunc) ~= null)
309−assert(to("topointer",()
243+assert(to("\116\111\115\116\114\105\110\103",{}) == nil)
244+assert(to("\116\111\115\116\114\105\110\103","\97\108\111") == "\97\108\111")
245+assert(to("\116\111\115\116\114\105\110\103",12) == "\49\50")
246+assert(to("\116\111\115\116\114\105\110\103",12,3) == nil)
247+assert(to("\111\98\106\115\105\122\101",{}) == 0)
248+assert(to("\111\98\106\115\105\122\101",{1,2,3}) == 3)
249+assert(to("\111\98\106\115\105\122\101","\97\108\111\97") == 6)
250+assert(to("\111\98\106\115\105\122\101",T.newuserdata(0)) == 0)
251+assert(to("\111\98\106\115\105\122\101",T.newuserdata(101)) == 101)
252+assert(to("\111\98\106\115\105\122\101",124) == 0)
253+assert(to("\111\98\106\115\105\122\101",true) == 0)
254+assert(to("\116\111\110\117\109\98\101\114",{}) == 0)
255+assert(to("\116\111\110\117\109\98\101\114","\49\50") == 12)
256+assert(to("\116\111\110\117\109\98\101\114","\115\50") == 0)
257+assert(to("\116\111\110\117\109\98\101\114",1,20) == 0)
258+assert(to("\116\111\112\111\105\110\116\101\114",10) == null)
259+assert(to("\116\111\112\111\105\110\116\101\114",true) == null)
260+assert(to("\116\111\112\111\105\110\116\101\114",nil) == null)
261+assert(to("\116\111\112\111\105\110\116\101\114","\97\98\99") ~= null)
262+assert(to("\116\111\112\111\105\110\116\101\114",string.rep("\120",10)) == to("\116\111\112\111\105\110\116\101\114",string.rep("\120",10)))
263+do
264+local s1 = string.rep("\120",300)
265+local s2 = string.rep("\120",300)
266+assert(to("\116\111\112\111\105\110\116\101\114",s1) ~= to("\116\111\112\111\105\110\116\101\114",s2))
267+end
268+assert(to("\116\111\112\111\105\110\116\101\114",T.pushuserdata(20)) ~= null)
269+assert(to("\116\111\112\111\105\110\116\101\114",io.read) ~= null)
270+assert(to("\116\111\112\111\105\110\116\101\114",hfunc) ~= null)
271+assert(to("\116\111\112\111\105\110\116\101\114",function ()
310272
311273end) ~= null)
312−assert(to("topointer",io.stdin) ~= null)
313−assert(to("func2num",20) == 0)
314−assert(to("func2num",T.pushuserdata(10)) == 0)
315−assert(to("func2num",io.read) ~= 0)
316−assert(to("func2num",hfunc) ~= 0)
317−a=to("tocfunction",math.deg)
274+assert(to("\116\111\112\111\105\110\116\101\114",io.stdin) ~= null)
275+assert(to("\102\117\110\99\50\110\117\109",20) == 0)
276+assert(to("\102\117\110\99\50\110\117\109",T.pushuserdata(10)) == 0)
277+assert(to("\102\117\110\99\50\110\117\109",io.read) ~= 0)
278+assert(to("\102\117\110\99\50\110\117\109",hfunc) ~= 0)
279+a=to("\116\111\99\102\117\110\99\116\105\111\110",math.deg)
318280assert(a(3) == math.deg(3) and a == math.deg)
319−print("testing panic function")
320−assert(T.checkpanic("pushstring hi; error") == "hi")
321−assert(T.checkpanic("pushstring hi; error;","checkstack 5 XX
322− pushstring ' alo'
323− pushstring ' mundo'
324− concat 3") == "hi alo mundo")
325−assert(T.checkpanic("loadstring 4") == "bad argument #4 (string expected, got no value)")
326−T.totalmem(T.totalmem() + 1e4)
327−assert(T.checkpanic("newuserdata 20000") == MEMERRMSG)
281+print("\116\101\115\116\105\110\103\32\112\97\110\105\99\32\102\117\110\99\116\105\111\110")
282+do
283+assert(T.checkpanic("\112\117\115\104\115\116\114\105\110\103\32\104\105\59\32\101\114\114\111\114") == "\104\105")
284+assert(T.checkpanic("\112\117\115\104\115\116\114\105\110\103\32\104\105\59\32\101\114\114\111\114\59","\99\104\101\99\107\115\116\97\99\107\32\53\32\88\88\10\32\32\32\32\32\32\112\117\115\104\115\116\114\105\110\103\32\39\32\97\108\111\39\10\32\32\32\32\32\32\112\117\115\104\115\116\114\105\110\103\32\39\32\109\117\110\100\111\39\10\32\32\32\32\32\32\99\111\110\99\97\116\32\51") == "\104\105\32\97\108\111\32\109\117\110\100\111")
285+assert(T.checkpanic("\108\111\97\100\115\116\114\105\110\103\32\52") == "\98\97\100\32\97\114\103\117\109\101\110\116\32\35\52\32\40\115\116\114\105\110\103\32\101\120\112\101\99\116\101\100\44\32\103\111\116\32\110\111\32\118\97\108\117\101\41")
286+T.totalmem(T.totalmem() + 10000)
287+assert(T.checkpanic("\110\101\119\117\115\101\114\100\97\116\97\32\50\48\48\48\48") == MEMERRMSG)
328288T.totalmem(0)
329289if not _soft then
330−local msg = T.checkpanic(" pushstring "function f() f() end"
331− loadstring -1; call 0 0
332− getglobal f; call 0 0
333− ")
334−assert(string.find(msg,"stack overflow"))
335−end
336−assert(T.checkpanic(" pushstring "return {__close = function () Y = 'ho'; end}"
337− newtable
338− loadstring -2
339− call 0 1
340− setmetatable -2
341− toclose -1
342− pushstring "hi"
343− error
344− "," getglobal Y
345− concat 2 # concat original error with global Y
346− ") == "hiho")
290+local msg = T.checkpanic("\32\32\32\32\32\32\112\117\115\104\115\116\114\105\110\103\32\34\102\117\110\99\116\105\111\110\32\102\40\41\32\102\40\41\32\101\110\100\34\10\32\32\32\32\32\32\108\111\97\100\115\116\114\105\110\103\32\45\49\59\32\99\97\108\108\32\48\32\48\10\32\32\32\32\32\32\103\101\116\103\108\111\98\97\108\32\102\59\32\99\97\108\108\32\48\32\48\10\32\32\32\32")
291+assert(string.find(msg,"\115\116\97\99\107\32\111\118\101\114\102\108\111\119"))
292+end
293+assert(T.checkpanic("\32\32\32\32\112\117\115\104\115\116\114\105\110\103\32\34\114\101\116\117\114\110\32\123\95\95\99\108\111\115\101\32\61\32\102\117\110\99\116\105\111\110\32\40\41\32\89\32\61\32\39\104\111\39\59\32\101\110\100\125\34\10\32\32\32\32\110\101\119\116\97\98\108\101\10\32\32\32\32\108\111\97\100\115\116\114\105\110\103\32\45\50\10\32\32\32\32\99\97\108\108\32\48\32\49\10\32\32\32\32\115\101\116\109\101\116\97\116\97\98\108\101\32\45\50\10\32\32\32\32\116\111\99\108\111\115\101\32\45\49\10\32\32\32\32\112\117\115\104\115\116\114\105\110\103\32\34\104\105\34\10\32\32\32\32\101\114\114\111\114\10\32\32","\32\32\32\32\103\101\116\103\108\111\98\97\108\32\89\10\32\32\32\32\99\111\110\99\97\116\32\50\32\32\32\32\32\32\32\32\32\35\32\99\111\110\99\97\116\32\111\114\105\103\105\110\97\108\32\101\114\114\111\114\32\119\105\116\104\32\103\108\111\98\97\108\32\89\10\32\32") == "\104\105\104\111")
294+end
347295if not _soft then
348−print("testing stack overflow")
349−collectgarbage("stop")
350−checkerr("XXXX",T.testC,"checkstack 1000023 XXXX")
351−checkerr("^stack overflow$",T.testC,"checkstack 1000023 ''")
352−local s = string.rep("pushnil;checkstack 1 XX;",1e6)
353−checkerr("overflow",T.testC,s)
354−collectgarbage("restart")
355−print("+")
356−end
357−local lim = _soft and 500 or 1.2e4
358−local prog = {"checkstack " .. (lim * 2 + 100) .. "msg","newtable"}
296+print("\116\101\115\116\105\110\103\32\115\116\97\99\107\32\111\118\101\114\102\108\111\119")
297+collectgarbage("\115\116\111\112")
298+checkerr("\88\88\88\88",T.testC,"\99\104\101\99\107\115\116\97\99\107\32\49\48\48\48\48\50\51\32\88\88\88\88")
299+checkerr("\94\115\116\97\99\107\32\111\118\101\114\102\108\111\119\36",T.testC,"\99\104\101\99\107\115\116\97\99\107\32\49\48\48\48\48\50\51\32\39\39")
300+local s = string.rep("\112\117\115\104\110\105\108\59\99\104\101\99\107\115\116\97\99\107\32\49\32\88\88\59",1000000)
301+checkerr("\111\118\101\114\102\108\111\119",T.testC,s)
302+collectgarbage("\114\101\115\116\97\114\116")
303+print("\43")
304+end
305+local lim = _soft and 500 or 12000
306+local prog = {"\99\104\101\99\107\115\116\97\99\107\32" .. (lim * 2 + 100) .. "\109\115\103","\110\101\119\116\97\98\108\101"}
359307for i = 1, lim
360308do
361−prog[# prog + 1]="pushnum " .. i
362−prog[# prog + 1]="pushnum " .. i * 10
309+prog[# prog + 1]="\112\117\115\104\110\117\109\32" .. i
310+prog[# prog + 1]="\112\117\115\104\110\117\109\32" .. i * 10
363311end
364−prog[# prog + 1]="rawgeti R 2"
365−prog[# prog + 1]="insert " .. - (2 * lim + 2)
312+prog[# prog + 1]="\114\97\119\103\101\116\105\32\82\32\50"
313+prog[# prog + 1]="\105\110\115\101\114\116\32" .. - (2 * lim + 2)
366314for i = 1, lim
367315do
368−prog[# prog + 1]="settable " .. - (2 * (lim - i + 1) + 1)
316+prog[# prog + 1]="\115\101\116\116\97\98\108\101\32" .. - (2 * (lim - i + 1) + 1)
369317end
370−prog[# prog + 1]="return 2"
371−prog=table.concat(prog,";")
318+prog[# prog + 1]="\114\101\116\117\114\110\32\50"
319+prog=table.concat(prog,"\59")
372320local g,t = T.testC(prog)
373321assert(g == _G)
374322for i = 1, lim
@@ -379,16 +327,12 @@ t[i]=undef
379327end
380328assert(next(t) == nil)
381329prog,g,t=nil
382−a=T.testC(" loadstring 2; pcall 0 1 0;
383− pushvalue 3; insert -2; pcall 1 1 0;
384− pcall 0 0 0;
385− return 1
386−","XX=150",(a)
330+a=T.testC("\32\32\108\111\97\100\115\116\114\105\110\103\32\50\59\32\112\99\97\108\108\32\48\32\49\32\48\59\10\32\32\112\117\115\104\118\97\108\117\101\32\51\59\32\105\110\115\101\114\116\32\45\50\59\32\112\99\97\108\108\32\49\32\49\32\48\59\10\32\32\112\99\97\108\108\32\48\32\48\32\48\59\10\32\32\114\101\116\117\114\110\32\49\10","\88\88\61\49\53\48",function (a)
387331assert(a == nil)
388332;
389333return 3
390334end)
391−assert(type(a) == "string" and XX == 150)
335+assert(type(a) == "\115\116\114\105\110\103" and XX == 150)
392336_G.XX=nil
393337local function check3
394338(p, ...)
@@ -396,160 +340,168 @@ local arg = {...}
396340assert(# arg == 3)
397341assert(string.find(arg[3],p))
398342end
399−check3(":1:",T.testC("loadstring 2; return *","x="))
400−check3("%.",T.testC("loadfile 2; return *","."))
401−check3("xxxx",T.testC("loadfile 2; return *","xxxx"))
343+check3("\58\49\58",T.testC("\108\111\97\100\115\116\114\105\110\103\32\50\59\32\114\101\116\117\114\110\32\42","\120\61"))
344+check3("\37\46",T.testC("\108\111\97\100\102\105\108\101\32\50\59\32\114\101\116\117\114\110\32\42","\46"))
345+check3("\120\120\120\120",T.testC("\108\111\97\100\102\105\108\101\32\50\59\32\114\101\116\117\114\110\32\42","\120\120\120\120"))
402346local function checkerrnopro
403347(code,msg)
404−local th = coroutine.create(()
348+local th = coroutine.create(function ()
405349
406350end)
407351local stt,err = pcall(T.testC,th,code)
408352assert(not stt and string.find(err,msg))
409353end
410354if not _soft then
411−collectgarbage("stop")
412−checkerrnopro("pushnum 3; call 0 0","attempt to call")
413−print("testing stack overflow in unprotected thread")
355+collectgarbage("\115\116\111\112")
356+checkerrnopro("\112\117\115\104\110\117\109\32\51\59\32\99\97\108\108\32\48\32\48","\97\116\116\101\109\112\116\32\116\111\32\99\97\108\108")
357+print("\116\101\115\116\105\110\103\32\115\116\97\99\107\32\111\118\101\114\102\108\111\119\32\105\110\32\117\110\112\114\111\116\101\99\116\101\100\32\116\104\114\101\97\100")
414358function F()
415359F()
416360end
417−checkerrnopro("getglobal 'F'; call 0 0;","stack overflow")
361+checkerrnopro("\103\101\116\103\108\111\98\97\108\32\39\70\39\59\32\99\97\108\108\32\48\32\48\59","\115\116\97\99\107\32\111\118\101\114\102\108\111\119")
418362F=nil
419−collectgarbage("restart")
363+collectgarbage("\114\101\115\116\97\114\116")
420364end
421−print("+")
365+print("\43")
366+do
422367local a = {}
423−local a1 = T.testC("rawsetp 2 1; return 1",a,20)
368+local a1 = T.testC("\114\97\119\115\101\116\112\32\50\32\49\59\32\114\101\116\117\114\110\32\49",a,20)
424369assert(a == a1)
425370assert(a[T.pushuserdata(1)] == 20)
426−local a1,res = T.testC("rawgetp -1 1; return 2",a)
371+local a1,res = T.testC("\114\97\119\103\101\116\112\32\45\49\32\49\59\32\114\101\116\117\114\110\32\50",a)
427372assert(a == a1 and res == 20)
373+end
374+do
428375local a = {}
429376a[a]=10
430−local prog = "gettable -1; return *"
377+local prog = "\103\101\116\116\97\98\108\101\32\45\49\59\32\114\101\116\117\114\110\32\42"
431378local res = {T.testC(prog,a)}
432379assert(# res == 2 and res[1] == prog and res[2] == 10)
433−local prog = "settable -2; return *"
380+local prog = "\115\101\116\116\97\98\108\101\32\45\50\59\32\114\101\116\117\114\110\32\42"
434381local res = {T.testC(prog,a,20)}
435382assert(a[a] == 20)
436383assert(# res == 1 and res[1] == prog)
437384a[a]=10
438−local prog = "rawget -1; return *"
385+local prog = "\114\97\119\103\101\116\32\45\49\59\32\114\101\116\117\114\110\32\42"
439386local res = {T.testC(prog,a)}
440387assert(# res == 2 and res[1] == prog and res[2] == 10)
441−local prog = "rawset -2; return *"
388+local prog = "\114\97\119\115\101\116\32\45\50\59\32\114\101\116\117\114\110\32\42"
442389local res = {T.testC(prog,a,20)}
443390assert(a[a] == 20)
444391assert(# res == 1 and res[1] == prog)
445−local prog = "rawset -1; return *"
392+local prog = "\114\97\119\115\101\116\32\45\49\59\32\114\101\116\117\114\110\32\42"
446393local res = {T.testC(prog,30,a)}
447394assert(a[30] == a)
448395assert(# res == 1 and res[1] == prog)
449−local prog = "settable -1; return *"
396+local prog = "\115\101\116\116\97\98\108\101\32\45\49\59\32\114\101\116\117\114\110\32\42"
450397local res = {T.testC(prog,40,a)}
451398assert(a[40] == a)
452399assert(# res == 1 and res[1] == prog)
453−local prog = "rawseti -1 100; return *"
400+local prog = "\114\97\119\115\101\116\105\32\45\49\32\49\48\48\59\32\114\101\116\117\114\110\32\42"
454401local res = {T.testC(prog,a)}
455402assert(a[100] == a)
456403assert(# res == 1 and res[1] == prog)
457−local prog = "seti -1 200; return *"
404+local prog = "\115\101\116\105\32\45\49\32\50\48\48\59\32\114\101\116\117\114\110\32\42"
458405local res = {T.testC(prog,a)}
459406assert(a[200] == a)
460407assert(# res == 1 and res[1] == prog)
461−a={["x"] = 0,["y"] = 12}
462−x,y=T.testC("gettable 2; pushvalue 4; gettable 2; return 2",a,3,"y",4,"x")
408+end
409+a={["\120"] = 0,["\121"] = 12}
410+x,y=T.testC("\103\101\116\116\97\98\108\101\32\50\59\32\112\117\115\104\118\97\108\117\101\32\52\59\32\103\101\116\116\97\98\108\101\32\50\59\32\114\101\116\117\114\110\32\50",a,3,"\121",4,"\120")
463411assert(x == 0 and y == 12)
464−T.testC("settable -5",a,3,4,"x",15)
412+T.testC("\115\101\116\116\97\98\108\101\32\45\53",a,3,4,"\120",15)
465413assert(a.x == 15)
466414a[a]=print
467−x=T.testC("gettable 2; return 1",a)
415+x=T.testC("\103\101\116\116\97\98\108\101\32\50\59\32\114\101\116\117\114\110\32\49",a)
468416assert(x == print)
469−T.testC("settable 2",a,"x")
470−assert(a[a] == "x")
471−b=setmetatable({["p"] = a},{})
472−getmetatable(b).__index=(t,i)
417+T.testC("\115\101\116\116\97\98\108\101\32\50",a,"\120")
418+assert(a[a] == "\120")
419+b=setmetatable({["\112"] = a},{})
420+getmetatable(b).__index=function (t,i)
473421return t.p[i]
474422end
475−local k,x = T.testC("gettable 3, return 2",4,b,20,35,"x")
423+local k,x = T.testC("\103\101\116\116\97\98\108\101\32\51\44\32\114\101\116\117\114\110\32\50",4,b,20,35,"\120")
476424assert(x == 15 and k == 35)
477−k=T.testC("getfield 2 y, return 1",b)
425+k=T.testC("\103\101\116\102\105\101\108\100\32\50\32\121\44\32\114\101\116\117\114\110\32\49",b)
478426assert(k == 12)
479−getmetatable(b).__index=(t,i)
427+getmetatable(b).__index=function (t,i)
480428return a[i]
481429end
482−getmetatable(b).__newindex=(t,i,v)
430+getmetatable(b).__newindex=function (t,i,v)
483431a[i]=v
484432end
485−y=T.testC("insert 2; gettable -5; return 1",2,3,4,"y",b)
433+y=T.testC("\105\110\115\101\114\116\32\50\59\32\103\101\116\116\97\98\108\101\32\45\53\59\32\114\101\116\117\114\110\32\49",2,3,4,"\121",b)
486434assert(y == 12)
487−k=T.testC("settable -5, return 1",b,3,4,"x",16)
435+k=T.testC("\115\101\116\116\97\98\108\101\32\45\53\44\32\114\101\116\117\114\110\32\49",b,3,4,"\120",16)
488436assert(a.x == 16 and k == 4)
489−a[b]="xuxu"
490−y=T.testC("gettable 2, return 1",b)
491−assert(y == "xuxu")
492−T.testC("settable 2",b,19)
437+a[b]="\120\117\120\117"
438+y=T.testC("\103\101\116\116\97\98\108\101\32\50\44\32\114\101\116\117\114\110\32\49",b)
439+assert(y == "\120\117\120\117")
440+T.testC("\115\101\116\116\97\98\108\101\32\50",b,19)
493441assert(a[b] == 19)
494−local t = {["_012345678901234567890123456789012345678901234567890123456789"] = 32}
495−local a = T.testC(" getfield 2 _012345678901234567890123456789012345678901234567890123456789
496− return 1
497− ",t)
442+do
443+local t = {["\95\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57"] = 32}
444+local a = T.testC("\32\32\32\32\103\101\116\102\105\101\108\100\32\50\32\95\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\10\32\32\32\32\114\101\116\117\114\110\32\49\10\32\32",t)
498445assert(a == 32)
499−local a = T.testC(" pushnum 33
500− setglobal _012345678901234567890123456789012345678901234567890123456789
501− ")
446+local a = T.testC("\32\32\32\32\112\117\115\104\110\117\109\32\51\51\10\32\32\32\32\115\101\116\103\108\111\98\97\108\32\95\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\10\32\32")
502447assert(_012345678901234567890123456789012345678901234567890123456789 == 33)
503448_012345678901234567890123456789012345678901234567890123456789=nil
449+end
504450a={}
505−t=pack(T.testC("next; return *",a,nil))
506−tcheck(t,{["n"] = 1,a})
507−a={["a"] = 3}
508−t=pack(T.testC("next; return *",a,nil))
509−tcheck(t,{["n"] = 3,a,"a",3})
510−t=pack(T.testC("next; pop 1; next; return *",a,nil))
511−tcheck(t,{["n"] = 1,a})
512−local A = T.testC(" pushnum 10; pushnum 20; pushcclosure 2; return 1")
513−t,b,c=A("pushvalue U0; pushvalue U1; pushvalue U2; return 3")
514−assert(b == 10 and c == 20 and type(t) == "table")
515−a,b=A("tostring U3; tonumber U4; return 2")
451+t=pack(T.testC("\110\101\120\116\59\32\114\101\116\117\114\110\32\42",a,nil))
452+tcheck(t,{["\110"] = 1,a})
453+a={["\97"] = 3}
454+t=pack(T.testC("\110\101\120\116\59\32\114\101\116\117\114\110\32\42",a,nil))
455+tcheck(t,{["\110"] = 3,a,"\97",3})
456+t=pack(T.testC("\110\101\120\116\59\32\112\111\112\32\49\59\32\110\101\120\116\59\32\114\101\116\117\114\110\32\42",a,nil))
457+tcheck(t,{["\110"] = 1,a})
458+do
459+local A = T.testC("\32\112\117\115\104\110\117\109\32\49\48\59\32\112\117\115\104\110\117\109\32\50\48\59\32\112\117\115\104\99\99\108\111\115\117\114\101\32\50\59\32\114\101\116\117\114\110\32\49")
460+t,b,c=A("\112\117\115\104\118\97\108\117\101\32\85\48\59\32\112\117\115\104\118\97\108\117\101\32\85\49\59\32\112\117\115\104\118\97\108\117\101\32\85\50\59\32\114\101\116\117\114\110\32\51")
461+assert(b == 10 and c == 20 and type(t) == "\116\97\98\108\101")
462+a,b=A("\116\111\115\116\114\105\110\103\32\85\51\59\32\116\111\110\117\109\98\101\114\32\85\52\59\32\114\101\116\117\114\110\32\50")
516463assert(a == nil and b == 0)
517−A("pushnum 100; pushnum 200; replace U2; replace U1")
518−b,c=A("pushvalue U1; pushvalue U2; return 2")
464+A("\112\117\115\104\110\117\109\32\49\48\48\59\32\112\117\115\104\110\117\109\32\50\48\48\59\32\114\101\112\108\97\99\101\32\85\50\59\32\114\101\112\108\97\99\101\32\85\49")
465+b,c=A("\112\117\115\104\118\97\108\117\101\32\85\49\59\32\112\117\115\104\118\97\108\117\101\32\85\50\59\32\114\101\116\117\114\110\32\50")
519466assert(b == 100 and c == 200)
520−A("replace U2; replace U1",{["x"] = 1},{["x"] = 2})
521−b,c=A("pushvalue U1; pushvalue U2; return 2")
467+A("\114\101\112\108\97\99\101\32\85\50\59\32\114\101\112\108\97\99\101\32\85\49",{["\120"] = 1},{["\120"] = 2})
468+b,c=A("\112\117\115\104\118\97\108\117\101\32\85\49\59\32\112\117\115\104\118\97\108\117\101\32\85\50\59\32\114\101\116\117\114\110\32\50")
522469assert(b.x == 1 and c.x == 2)
523470T.checkmemory()
524−assert(T.testC("isnull U1; return 1") == true)
525−assert(T.testC("isnull U100; return 1") == true)
526−assert(T.testC("pushvalue U1; return 1") == nil)
527−local f = T.testC(" pushnum 10; pushnum 20; pushcclosure 2; return 1")
471+end
472+assert(T.testC("\105\115\110\117\108\108\32\85\49\59\32\114\101\116\117\114\110\32\49") == true)
473+assert(T.testC("\105\115\110\117\108\108\32\85\49\48\48\59\32\114\101\116\117\114\110\32\49") == true)
474+assert(T.testC("\112\117\115\104\118\97\108\117\101\32\85\49\59\32\114\101\116\117\114\110\32\49") == nil)
475+local f = T.testC("\32\112\117\115\104\110\117\109\32\49\48\59\32\112\117\115\104\110\117\109\32\50\48\59\32\112\117\115\104\99\99\108\111\115\117\114\101\32\50\59\32\114\101\116\117\114\110\32\49")
528476assert(T.upvalue(f,1) == 10 and T.upvalue(f,2) == 20 and T.upvalue(f,3) == nil)
529−T.upvalue(f,2,"xuxu")
530−assert(T.upvalue(f,2) == "xuxu")
531−local A = "checkstack 300 msg;" .. string.rep("pushnum 10;",255) .. "pushcclosure 255; return 1"
477+T.upvalue(f,2,"\120\117\120\117")
478+assert(T.upvalue(f,2) == "\120\117\120\117")
479+do
480+local A = "\99\104\101\99\107\115\116\97\99\107\32\51\48\48\32\109\115\103\59" .. string.rep("\112\117\115\104\110\117\109\32\49\48\59",255) .. "\112\117\115\104\99\99\108\111\115\117\114\101\32\50\53\53\59\32\114\101\116\117\114\110\32\49"
532481A=T.testC(A)
533482for i = 1, 255
534483do
535−assert(A(("pushvalue U%d; return 1"):format(i)) == 10)
484+assert(A(("\112\117\115\104\118\97\108\117\101\32\85\37\100\59\32\114\101\116\117\114\110\32\49"):format(i)) == 10)
485+end
486+assert(A("\105\115\110\117\108\108\32\85\50\53\54\59\32\114\101\116\117\114\110\32\49"))
487+assert(not A("\105\115\110\105\108\32\85\50\53\54\59\32\114\101\116\117\114\110\32\49"))
536488end
537−assert(A("isnull U256; return 1"))
538−assert(not A("isnil U256; return 1"))
539−checkerr("got number",debug.setuservalue,3,{})
540−checkerr("got nil",debug.setuservalue,nil,{})
541−checkerr("got light userdata",debug.setuservalue,T.pushuserdata(1),{})
489+checkerr("\103\111\116\32\110\117\109\98\101\114",debug.setuservalue,3,{})
490+checkerr("\103\111\116\32\110\105\108",debug.setuservalue,nil,{})
491+checkerr("\103\111\116\32\108\105\103\104\116\32\117\115\101\114\100\97\116\97",debug.setuservalue,T.pushuserdata(1),{})
542492local b = T.newuserdata(0,10)
543493for i = 1, 10
544494do
545495local v,p = debug.getuservalue(b,i)
546496assert(v == nil and p)
547497end
498+do
548499local v,p = debug.getuservalue(b,- 2)
549500assert(v == nil and not p)
550501local v,p = debug.getuservalue(b,11)
551502assert(v == nil and not p)
552−local t = {true,false,4.56,print,{},b,"XYZ"}
503+end
504+local t = {true,false,4.56,print,{},b,"\88\89\90"}
553505for k,v in ipairs(t)
554506do
555507debug.setuservalue(b,v,k)
@@ -560,7 +512,7 @@ local v1,p = debug.getuservalue(b,k)
560512assert(v1 == v and p)
561513end
562514assert(not debug.getuservalue(4))
563−debug.setuservalue(b,()
515+debug.setuservalue(b,function ()
564516return 10
565517end,10)
566518collectgarbage()
@@ -568,21 +520,23 @@ assert(debug.getuservalue(b,10)() == 10)
568520debug.setuservalue(b,134)
569521collectgarbage()
570522assert(debug.getuservalue(b) == 134)
571−local oldmode = collectgarbage("incremental")
572−T.gcstate("atomic")
573−assert(T.gccolor(b) == "black")
574−debug.setuservalue(b,{["x"] = 100})
575−T.gcstate("pause")
523+do
524+local oldmode = collectgarbage("\105\110\99\114\101\109\101\110\116\97\108")
525+T.gcstate("\97\116\111\109\105\99")
526+assert(T.gccolor(b) == "\98\108\97\99\107")
527+debug.setuservalue(b,{["\120"] = 100})
528+T.gcstate("\112\97\117\115\101")
576529assert(debug.getuservalue(b).x == 100)
577530collectgarbage(oldmode)
578−for i = 1, 1e3
531+end
532+for i = 1, 1000
579533do
580534local bb = T.newuserdata(0,1)
581535debug.setuservalue(bb,b)
582536b=bb
583537end
584538collectgarbage()
585−for i = 1, 1e3
539+for i = 1, 1000
586540do
587541b=debug.getuservalue(b)
588542end
@@ -607,9 +561,9 @@ T.unref(Arr[i])
607561end
608562local function printlocks
609563()
610−local f = T.makeCfunc("gettable R; return 1")
611−local n = f("n")
612−print("n",n)
564+local f = T.makeCfunc("\103\101\116\116\97\98\108\101\32\82\59\32\114\101\116\117\114\110\32\49")
565+local n = f("\110")
566+print("\110",n)
613567for i = 0, n
614568do
615569print(i,f(i))
@@ -623,28 +577,28 @@ for i = 1, Lim, 2
623577do
624578T.unref(Arr[i])
625579end
626−assert(type(T.getref(Arr[2])) == "table")
580+assert(type(T.getref(Arr[2])) == "\116\97\98\108\101")
627581assert(T.getref(- 1) == nil)
628582a=T.ref({})
629583collectgarbage()
630−assert(type(T.getref(a)) == "table")
584+assert(type(T.getref(a)) == "\116\97\98\108\101")
631585local tt = {}
632−local cl = {["n"] = 0}
586+local cl = {["\110"] = 0}
633587A=nil
634588;
635589B=nil
636−local F =
637−F=(x)
590+local F
591+F=function (x)
638592local udval = T.udataval(x)
639593table.insert(cl,udval)
640594local d = T.newuserdata(100)
641595d=nil
642596assert(debug.getmetatable(x).__gc == F)
643−assert(load("table.insert({}, {})"))()
597+assert(load("\116\97\98\108\101\46\105\110\115\101\114\116\40\123\125\44\32\123\125\41"))()
644598assert(not collectgarbage())
645599local dummy = {}
646600if A ~= nil then
647−assert(type(A) == "userdata")
601+assert(type(A) == "\117\115\101\114\100\97\116\97")
648602assert(T.udataval(A) == B)
649603debug.getmetatable(A)
650604end
@@ -653,45 +607,47 @@ B=udval
653607return 1,2,3
654608end
655609tt.__gc=F
610+do
656611collectgarbage()
657612;
658613collectgarbage()
659614;
660−local x = collectgarbage("count")
615+local x = collectgarbage("\99\111\117\110\116")
661616;
662617local a = T.newuserdata(5001)
663−assert(T.testC("objsize 2; return 1",a) == 5001)
664−assert(collectgarbage("count") >= x + 4)
618+assert(T.testC("\111\98\106\115\105\122\101\32\50\59\32\114\101\116\117\114\110\32\49",a) == 5001)
619+assert(collectgarbage("\99\111\117\110\116") >= x + 4)
665620a=nil
666621collectgarbage()
667622;
668−assert(collectgarbage("count") <= x + 1)
669−x=collectgarbage("count")
670−collectgarbage("stop")
671−for i = 1, 1e3
623+assert(collectgarbage("\99\111\117\110\116") <= x + 1)
624+x=collectgarbage("\99\111\117\110\116")
625+collectgarbage("\115\116\111\112")
626+for i = 1, 1000
672627do
673628T.newuserdata(0)
674629end
675−assert(collectgarbage("count") > x + 10)
630+assert(collectgarbage("\99\111\117\110\116") > x + 10)
676631collectgarbage()
677−assert(collectgarbage("count") <= x + 1)
632+assert(collectgarbage("\99\111\117\110\116") <= x + 1)
678633collectgarbage()
679−x=collectgarbage("count")
680−collectgarbage("stop")
681−a={["__gc"] = ()
634+x=collectgarbage("\99\111\117\110\116")
635+collectgarbage("\115\116\111\112")
636+a={["\95\95\103\99"] = function ()
682637
683638end}
684−for i = 1, 1e3
639+for i = 1, 1000
685640do
686641debug.setmetatable(T.newuserdata(0),a)
687642end
688−assert(collectgarbage("count") >= x + 10)
643+assert(collectgarbage("\99\111\117\110\116") >= x + 10)
689644collectgarbage()
690−assert(collectgarbage("count") >= x + 10)
645+assert(collectgarbage("\99\111\117\110\116") >= x + 10)
691646collectgarbage()
692−assert(collectgarbage("count") <= x + 1)
693−collectgarbage("restart")
694−collectgarbage("stop")
647+assert(collectgarbage("\99\111\117\110\116") <= x + 1)
648+collectgarbage("\114\101\115\116\97\114\116")
649+end
650+collectgarbage("\115\116\111\112")
695651a=T.newuserdata(0)
696652;
697653debug.setmetatable(a,tt)
@@ -709,8 +665,8 @@ debug.setmetatable(c,tt)
709665local nc = T.udataval(c)
710666x=T.newuserdata(4)
711667y=T.newuserdata(0)
712−checkerr("FILE%* expected, got userdata",io.input,a)
713−checkerr("FILE%* expected, got userdata",io.input,x)
668+checkerr("\70\73\76\69\37\42\32\101\120\112\101\99\116\101\100\44\32\103\111\116\32\117\115\101\114\100\97\116\97",io.input,a)
669+checkerr("\70\73\76\69\37\42\32\101\120\112\101\99\116\101\100\44\32\103\111\116\32\117\115\101\114\100\97\116\97",io.input,x)
714670assert(debug.getmetatable(x) == nil and debug.getmetatable(y) == nil)
715671local d = T.ref(a)
716672;
@@ -732,7 +688,7 @@ T.unref(f)
732688collectgarbage()
733689assert(# cl == 1 and cl[1] == nc)
734690x=T.getref(d)
735−assert(type(x) == "userdata" and debug.getmetatable(x) == tt)
691+assert(type(x) == "\117\115\101\114\100\97\116\97" and debug.getmetatable(x) == tt)
736692x=nil
737693tt.b=b
738694tt=nil
@@ -741,17 +697,17 @@ b=nil
741697T.unref(d)
742698;
743699local n5 = T.newuserdata(0)
744−debug.setmetatable(n5,{["__gc"] = F})
700+debug.setmetatable(n5,{["\95\95\103\99"] = F})
745701n5=T.udataval(n5)
746702collectgarbage()
747703assert(# cl == 4)
748704assert(cl[2] == n5 and cl[3] == nb and cl[4] == na)
749−collectgarbage("restart")
705+collectgarbage("\114\101\115\116\97\114\116")
750706a,na={},{}
751707for i = 30, 1, - 1
752708do
753709a[i]=T.newuserdata(0)
754−debug.setmetatable(a[i],{["__gc"] = F})
710+debug.setmetatable(a[i],{["\95\95\103\99"] = F})
755711na[i]=T.udataval(a[i])
756712end
757713cl={}
@@ -770,8 +726,8 @@ T.unref(Arr[i])
770726end
771727x=T.newuserdata(41)
772728;
773−debug.setmetatable(x,{["__gc"] = F})
774−assert(T.testC("objsize 2; return 1",x) == 41)
729+debug.setmetatable(x,{["\95\95\103\99"] = F})
730+assert(T.testC("\111\98\106\115\105\122\101\32\50\59\32\114\101\116\117\114\110\32\49",x) == 41)
775731cl={}
776732a={[x] = 1}
777733x=T.udataval(x)
@@ -783,14 +739,15 @@ a[n]=undef
783739end
784740collectgarbage()
785741assert(# cl == 1 and cl[1] == x)
786−assert(T.testC("compare EQ 2 4; return 1",print,1,print,20))
787−assert(T.testC("compare EQ 3 2; return 1","alo","alo"))
788−assert(T.testC("compare EQ 2 3; return 1",nil,nil))
789−assert(not T.testC("compare EQ 2 3; return 1",{},{}))
790−assert(not T.testC("compare EQ 2 3; return 1"))
791−assert(not T.testC("compare EQ 2 3; return 1",3))
742+assert(T.testC("\99\111\109\112\97\114\101\32\69\81\32\50\32\52\59\32\114\101\116\117\114\110\32\49",print,1,print,20))
743+assert(T.testC("\99\111\109\112\97\114\101\32\69\81\32\51\32\50\59\32\114\101\116\117\114\110\32\49","\97\108\111","\97\108\111"))
744+assert(T.testC("\99\111\109\112\97\114\101\32\69\81\32\50\32\51\59\32\114\101\116\117\114\110\32\49",nil,nil))
745+assert(not T.testC("\99\111\109\112\97\114\101\32\69\81\32\50\32\51\59\32\114\101\116\117\114\110\32\49",{},{}))
746+assert(not T.testC("\99\111\109\112\97\114\101\32\69\81\32\50\32\51\59\32\114\101\116\117\114\110\32\49"))
747+assert(not T.testC("\99\111\109\112\97\114\101\32\69\81\32\50\32\51\59\32\114\101\116\117\114\110\32\49",3))
748+do
792749local map = {}
793−local t = {["__eq"] = (a,b)
750+local t = {["\95\95\101\113"] = function (a,b)
794751return map[a] == map[b]
795752end}
796753local function f
@@ -802,18 +759,14 @@ return u
802759end
803760assert(f(10) == f(10))
804761assert(f(10) ~= f(11))
805−assert(T.testC("compare EQ 2 3; return 1",f(10),f(10)))
806−assert(not T.testC("compare EQ 2 3; return 1",f(10),f(20)))
762+assert(T.testC("\99\111\109\112\97\114\101\32\69\81\32\50\32\51\59\32\114\101\116\117\114\110\32\49",f(10),f(10)))
763+assert(not T.testC("\99\111\109\112\97\114\101\32\69\81\32\50\32\51\59\32\114\101\116\117\114\110\32\49",f(10),f(20)))
807764t.__eq=nil
808765assert(f(10) ~= f(10))
809−print("+")
766+end
767+print("\43")
810768_G.TT={}
811−T.sethook(" # set a line hook after 3 count hooks
812− sethook 4 0 '
813− getglobal TT;
814− pushvalue -3; append -2
815− pushvalue -2; append -2
816− '","c",3)
769+T.sethook("\32\32\35\32\115\101\116\32\97\32\108\105\110\101\32\104\111\111\107\32\97\102\116\101\114\32\51\32\99\111\117\110\116\32\104\111\111\107\115\10\32\32\115\101\116\104\111\111\107\32\52\32\48\32\39\10\32\32\32\32\103\101\116\103\108\111\98\97\108\32\84\84\59\10\32\32\32\32\112\117\115\104\118\97\108\117\101\32\45\51\59\32\97\112\112\101\110\100\32\45\50\10\32\32\32\32\112\117\115\104\118\97\108\117\101\32\45\50\59\32\97\112\112\101\110\100\32\45\50\10\32\32\39","\99",3)
817770local a = 1
818771a=1
819772a=1
@@ -821,14 +774,15 @@ a=1
821774a=1
822775debug.sethook()
823776local t = _G.TT
824−assert(t[1] == "line")
777+assert(t[1] == "\108\105\110\101")
825778local line = t[2]
826−assert(t[3] == "line" and t[4] == line + 1)
827−assert(t[5] == "line" and t[6] == line + 2)
779+assert(t[3] == "\108\105\110\101" and t[4] == line + 1)
780+assert(t[5] == "\108\105\110\101" and t[6] == line + 2)
828781assert(t[7] == nil)
829782_G.TT=nil
830−warn("@off")
831−collectgarbage("stop")
783+do
784+warn("\64\111\102\102")
785+collectgarbage("\115\116\111\112")
832786local a = {}
833787for i = 1, 20
834788do
@@ -836,23 +790,25 @@ a[i]=T.newuserdata(i)
836790end
837791for i = 1, 20, 2
838792do
839−debug.setmetatable(a[i],{["__gc"] = (x)
840−error("@expected error in gc")
793+debug.setmetatable(a[i],{["\95\95\103\99"] = function (x)
794+error("\64\101\120\112\101\99\116\101\100\32\101\114\114\111\114\32\105\110\32\103\99")
841795end})
842796end
843797for i = 2, 20, 2
844798do
845−debug.setmetatable(a[i],{["__gc"] = (x)
846−load("A=A+1")()
799+debug.setmetatable(a[i],{["\95\95\103\99"] = function (x)
800+load("\65\61\65\43\49")()
847801end})
848802end
849803a=nil
850804_G.A=0
851805collectgarbage()
852806assert(A == 10)
853−collectgarbage("restart")
854−warn("@on")
807+collectgarbage("\114\101\115\116\97\114\116")
808+warn("\64\111\110")
809+end
855810_G.A=nil
811+do
856812local a = {}
857813;
858814local lim = 30
@@ -876,47 +832,40 @@ for i = 0, lim
876832do
877833a[T.pushuserdata(i)]=i
878834end
879−assert(type(tostring(a[1])) == "string")
835+assert(type(tostring(a[1])) == "\115\116\114\105\110\103")
836+end
880837T.closestate(T.newstate())
881838;
882839L1=T.newstate()
883840assert(L1)
884−assert(T.doremote(L1,"X='a'; return 'a'") == "a")
885−assert(# pack(T.doremote(L1,"function f () return 'alo', 3 end; f()")) == 0)
886−a,b=T.doremote(L1,"return f()")
887−assert(a == "alo" and b == "3")
888−T.doremote(L1,"_ERRORMESSAGE = nil")
889−a,b,c=T.doremote(L1,"return sin(1)")
841+assert(T.doremote(L1,"\88\61\39\97\39\59\32\114\101\116\117\114\110\32\39\97\39") == "\97")
842+assert(# pack(T.doremote(L1,"\102\117\110\99\116\105\111\110\32\102\32\40\41\32\114\101\116\117\114\110\32\39\97\108\111\39\44\32\51\32\101\110\100\59\32\102\40\41")) == 0)
843+a,b=T.doremote(L1,"\114\101\116\117\114\110\32\102\40\41")
844+assert(a == "\97\108\111" and b == "\51")
845+T.doremote(L1,"\95\69\82\82\79\82\77\69\83\83\65\71\69\32\61\32\110\105\108")
846+a,b,c=T.doremote(L1,"\114\101\116\117\114\110\32\115\105\110\40\49\41")
890847assert(a == nil and c == 2)
891−a,b,c=T.doremote(L1,"return a+")
892−assert(a == nil and c == 3 and type(b) == "string")
848+a,b,c=T.doremote(L1,"\114\101\116\117\114\110\32\97\43")
849+assert(a == nil and c == 3 and type(b) == "\115\116\114\105\110\103")
893850T.loadlib(L1)
894−a,b,c=T.doremote(L1," string = require'string'
895− a = require'_G'; assert(a == _G and require("_G") == a)
896− io = require'io'; assert(type(io.read) == "function")
897− assert(require("io") == io)
898− a = require'table'; assert(type(a.insert) == "function")
899− a = require'debug'; assert(type(a.getlocal) == "function")
900− a = require'math'; assert(type(a.sin) == "function")
901− return string.sub('okinama', 1, 2)
902−")
903−assert(a == "ok")
851+a,b,c=T.doremote(L1,"\32\32\115\116\114\105\110\103\32\61\32\114\101\113\117\105\114\101\39\115\116\114\105\110\103\39\10\32\32\97\32\61\32\114\101\113\117\105\114\101\39\95\71\39\59\32\97\115\115\101\114\116\40\97\32\61\61\32\95\71\32\97\110\100\32\114\101\113\117\105\114\101\40\34\95\71\34\41\32\61\61\32\97\41\10\32\32\105\111\32\61\32\114\101\113\117\105\114\101\39\105\111\39\59\32\97\115\115\101\114\116\40\116\121\112\101\40\105\111\46\114\101\97\100\41\32\61\61\32\34\102\117\110\99\116\105\111\110\34\41\10\32\32\97\115\115\101\114\116\40\114\101\113\117\105\114\101\40\34\105\111\34\41\32\61\61\32\105\111\41\10\32\32\97\32\61\32\114\101\113\117\105\114\101\39\116\97\98\108\101\39\59\32\97\115\115\101\114\116\40\116\121\112\101\40\97\46\105\110\115\101\114\116\41\32\61\61\32\34\102\117\110\99\116\105\111\110\34\41\10\32\32\97\32\61\32\114\101\113\117\105\114\101\39\100\101\98\117\103\39\59\32\97\115\115\101\114\116\40\116\121\112\101\40\97\46\103\101\116\108\111\99\97\108\41\32\61\61\32\34\102\117\110\99\116\105\111\110\34\41\10\32\32\97\32\61\32\114\101\113\117\105\114\101\39\109\97\116\104\39\59\32\97\115\115\101\114\116\40\116\121\112\101\40\97\46\115\105\110\41\32\61\61\32\34\102\117\110\99\116\105\111\110\34\41\10\32\32\114\101\116\117\114\110\32\115\116\114\105\110\103\46\115\117\98\40\39\111\107\105\110\97\109\97\39\44\32\49\44\32\50\41\10")
852+assert(a == "\111\107")
904853T.closestate(L1)
905854;
906855L1=T.newstate()
907856T.loadlib(L1)
908−T.doremote(L1,"a = {}")
909−T.testC(L1,"getglobal "a"; pushstring "x"; pushint 1;
910− settable -3")
911−assert(T.doremote(L1,"return a.x") == "1")
857+T.doremote(L1,"\97\32\61\32\123\125")
858+T.testC(L1,"\103\101\116\103\108\111\98\97\108\32\34\97\34\59\32\112\117\115\104\115\116\114\105\110\103\32\34\120\34\59\32\112\117\115\104\105\110\116\32\49\59\10\32\32\32\32\32\32\32\32\32\32\32\32\32\115\101\116\116\97\98\108\101\32\45\51")
859+assert(T.doremote(L1,"\114\101\116\117\114\110\32\97\46\120") == "\49")
912860T.closestate(L1)
913861L1=nil
914−print("+")
915−print("testing to-be-closed variables")
862+print("\43")
863+print("\116\101\115\116\105\110\103\32\116\111\45\98\101\45\99\108\111\115\101\100\32\118\97\114\105\97\98\108\101\115")
864+do
916865local openresource = {}
917866local function newresource
918867()
919−local x = setmetatable({10},{["__close"] = (y)
868+local x = setmetatable({10},{["\95\95\99\108\111\115\101"] = function (y)
920869assert(openresource[# openresource] == y)
921870openresource[# openresource]=nil
922871y[1]=y[1] + 1
@@ -924,85 +873,33 @@ end})
924873openresource[# openresource + 1]=x
925874return x
926875end
927−local a,b = T.testC(" call 0 1 # create resource
928− pushnil
929− toclose -2 # mark call result to be closed
930− toclose -1 # mark nil to be closed (will be ignored)
931− return 2
932− ",newresource)
876+local a,b = T.testC("\32\32\32\32\99\97\108\108\32\48\32\49\32\32\32\35\32\99\114\101\97\116\101\32\114\101\115\111\117\114\99\101\10\32\32\32\32\112\117\115\104\110\105\108\10\32\32\32\32\116\111\99\108\111\115\101\32\45\50\32\32\35\32\109\97\114\107\32\99\97\108\108\32\114\101\115\117\108\116\32\116\111\32\98\101\32\99\108\111\115\101\100\10\32\32\32\32\116\111\99\108\111\115\101\32\45\49\32\32\35\32\109\97\114\107\32\110\105\108\32\116\111\32\98\101\32\99\108\111\115\101\100\32\40\119\105\108\108\32\98\101\32\105\103\110\111\114\101\100\41\10\32\32\32\32\114\101\116\117\114\110\32\50\10\32\32",newresource)
933877assert(a[1] == 11 and b == nil)
934878assert(# openresource == 0)
935−local a = {T.testC(" call 0 1 # create resource
936− toclose 2 # mark it to be closed
937− return 2
938− ",newresource)}
939−assert(type(a[1]) == "string" and a[2][1] == 11)
879+local a = {T.testC("\32\32\32\32\99\97\108\108\32\48\32\49\32\32\32\35\32\99\114\101\97\116\101\32\114\101\115\111\117\114\99\101\10\32\32\32\32\116\111\99\108\111\115\101\32\50\32\35\32\109\97\114\107\32\105\116\32\116\111\32\98\101\32\99\108\111\115\101\100\10\32\32\32\32\114\101\116\117\114\110\32\50\10\32\32",newresource)}
880+assert(type(a[1]) == "\115\116\114\105\110\103" and a[2][1] == 11)
940881assert(# openresource == 0)
941−local a,b = pcall(T.makeCfunc(" call 0 1 # create resource
942− toclose -1 # mark it to be closed
943− error # resource is the error object
944− "),newresource)
882+local a,b = pcall(T.makeCfunc("\32\32\32\32\99\97\108\108\32\48\32\49\32\32\32\35\32\99\114\101\97\116\101\32\114\101\115\111\117\114\99\101\10\32\32\32\32\116\111\99\108\111\115\101\32\45\49\32\35\32\109\97\114\107\32\105\116\32\116\111\32\98\101\32\99\108\111\115\101\100\10\32\32\32\32\101\114\114\111\114\32\32\32\32\32\32\32\35\32\114\101\115\111\117\114\99\101\32\105\115\32\116\104\101\32\101\114\114\111\114\32\111\98\106\101\99\116\10\32\32"),newresource)
945883assert(a == false and b[1] == 11)
946884assert(# openresource == 0)
947−local a,b = pcall(T.makeCfunc(" newtable # create non-closable object
948− toclose -1 # mark it to be closed (should raise an error)
949− abort # will not be executed
950− "))
951−assert(a == false and string.find(b,"non%-closable value"))
885+local a,b = pcall(T.makeCfunc("\32\32\32\32\110\101\119\116\97\98\108\101\32\32\32\35\32\99\114\101\97\116\101\32\110\111\110\45\99\108\111\115\97\98\108\101\32\111\98\106\101\99\116\10\32\32\32\32\116\111\99\108\111\115\101\32\45\49\32\35\32\109\97\114\107\32\105\116\32\116\111\32\98\101\32\99\108\111\115\101\100\32\40\115\104\111\117\108\100\32\114\97\105\115\101\32\97\110\32\101\114\114\111\114\41\10\32\32\32\32\97\98\111\114\116\32\32\35\32\119\105\108\108\32\110\111\116\32\98\101\32\101\120\101\99\117\116\101\100\10\32\32"))
886+assert(a == false and string.find(b,"\110\111\110\37\45\99\108\111\115\97\98\108\101\32\118\97\108\117\101"))
952887local function check
953888(n)
954889assert(# openresource == n)
955890end
956891_ENV.xxx=true
957−local a = T.testC(" pushvalue 2 # stack: S, NR, CH, NR
958− call 0 1 # create resource; stack: S, NR, CH, R
959− toclose -1 # mark it to be closed
960− pushvalue 2 # stack: S, NR, CH, R, NR
961− call 0 1 # create another resource; stack: S, NR, CH, R, R
962− toclose -1 # mark it to be closed
963− pushvalue 3 # stack: S, NR, CH, R, R, CH
964− pushint 2 # there should be two open resources
965− call 1 0 # stack: S, NR, CH, R, R
966− closeslot -1 # close second resource
967− pushvalue 3 # stack: S, NR, CH, R, R, CH
968− pushint 1 # there should be one open resource
969− call 1 0 # stack: S, NR, CH, R, R
970− closeslot 4
971− setglobal "xxx" # previous op. erased the slot
972− pop 1 # pop other resource from the stack
973− pushint *
974− return 1 # return stack size
975− ",newresource,check)
892+local a = T.testC("\32\32\32\32\112\117\115\104\118\97\108\117\101\32\50\32\32\35\32\115\116\97\99\107\58\32\83\44\32\78\82\44\32\67\72\44\32\78\82\10\32\32\32\32\99\97\108\108\32\48\32\49\32\32\32\35\32\99\114\101\97\116\101\32\114\101\115\111\117\114\99\101\59\32\115\116\97\99\107\58\32\83\44\32\78\82\44\32\67\72\44\32\82\10\32\32\32\32\116\111\99\108\111\115\101\32\45\49\32\35\32\109\97\114\107\32\105\116\32\116\111\32\98\101\32\99\108\111\115\101\100\10\32\32\32\32\112\117\115\104\118\97\108\117\101\32\50\32\32\35\32\32\115\116\97\99\107\58\32\83\44\32\78\82\44\32\67\72\44\32\82\44\32\78\82\10\32\32\32\32\99\97\108\108\32\48\32\49\32\32\32\35\32\99\114\101\97\116\101\32\97\110\111\116\104\101\114\32\114\101\115\111\117\114\99\101\59\32\115\116\97\99\107\58\32\83\44\32\78\82\44\32\67\72\44\32\82\44\32\82\10\32\32\32\32\116\111\99\108\111\115\101\32\45\49\32\35\32\109\97\114\107\32\105\116\32\116\111\32\98\101\32\99\108\111\115\101\100\10\32\32\32\32\112\117\115\104\118\97\108\117\101\32\51\32\32\35\32\115\116\97\99\107\58\32\83\44\32\78\82\44\32\67\72\44\32\82\44\32\82\44\32\67\72\10\32\32\32\32\112\117\115\104\105\110\116\32\50\32\32\32\35\32\116\104\101\114\101\32\115\104\111\117\108\100\32\98\101\32\116\119\111\32\111\112\101\110\32\114\101\115\111\117\114\99\101\115\10\32\32\32\32\99\97\108\108\32\49\32\48\32\32\35\32\32\115\116\97\99\107\58\32\83\44\32\78\82\44\32\67\72\44\32\82\44\32\82\10\32\32\32\32\99\108\111\115\101\115\108\111\116\32\45\49\32\32\32\35\32\99\108\111\115\101\32\115\101\99\111\110\100\32\114\101\115\111\117\114\99\101\10\32\32\32\32\112\117\115\104\118\97\108\117\101\32\51\32\32\35\32\115\116\97\99\107\58\32\83\44\32\78\82\44\32\67\72\44\32\82\44\32\82\44\32\67\72\10\32\32\32\32\112\117\115\104\105\110\116\32\49\32\32\32\35\32\116\104\101\114\101\32\115\104\111\117\108\100\32\98\101\32\111\110\101\32\111\112\101\110\32\114\101\115\111\117\114\99\101\10\32\32\32\32\99\97\108\108\32\49\32\48\32\32\35\32\115\116\97\99\107\58\32\83\44\32\78\82\44\32\67\72\44\32\82\44\32\82\10\32\32\32\32\99\108\111\115\101\115\108\111\116\32\52\10\32\32\32\32\115\101\116\103\108\111\98\97\108\32\34\120\120\120\34\32\32\35\32\112\114\101\118\105\111\117\115\32\111\112\46\32\101\114\97\115\101\100\32\116\104\101\32\115\108\111\116\10\32\32\32\32\112\111\112\32\49\32\32\32\32\32\32\32\35\32\112\111\112\32\111\116\104\101\114\32\114\101\115\111\117\114\99\101\32\102\114\111\109\32\116\104\101\32\115\116\97\99\107\10\32\32\32\32\112\117\115\104\105\110\116\32\42\10\32\32\32\32\114\101\116\117\114\110\32\49\32\32\32\32\35\32\114\101\116\117\114\110\32\115\116\97\99\107\32\115\105\122\101\10\32\32",newresource,check)
976893assert(a == 3 and _ENV.xxx == nil)
977−local a = T.testC(" pushvalue 2 # stack: S, NR, CH, NR
978− call 0 1 # create resource; stack: S, NR, CH, R
979− toclose -1 # mark it to be closed
980− pushvalue 2 # stack: S, NR, CH, R, NR
981− call 0 1 # create another resource; stack: S, NR, CH, R, R
982− toclose -1 # mark it to be closed
983− pushvalue 3 # stack: S, NR, CH, R, R, CH
984− pushint 2 # there should be two open resources
985− call 1 0 # stack: S, NR, CH, R, R
986− pop 1 # pop second resource
987− pushvalue 3 # stack: S, NR, CH, R, CH
988− pushint 1 # there should be one open resource
989− call 1 0 # stack: S, NR, CH, R
990− pop 1 # pop other resource from the stack
991− pushvalue 3 # stack: S, NR, CH, CH
992− pushint 0 # there should be no open resources
993− call 1 0 # stack: S, NR, CH
994− pushint *
995− return 1 # return stack size
996− ",newresource,check)
894+local a = T.testC("\32\32\32\32\112\117\115\104\118\97\108\117\101\32\50\32\32\35\32\115\116\97\99\107\58\32\83\44\32\78\82\44\32\67\72\44\32\78\82\10\32\32\32\32\99\97\108\108\32\48\32\49\32\32\32\35\32\99\114\101\97\116\101\32\114\101\115\111\117\114\99\101\59\32\115\116\97\99\107\58\32\83\44\32\78\82\44\32\67\72\44\32\82\10\32\32\32\32\116\111\99\108\111\115\101\32\45\49\32\35\32\109\97\114\107\32\105\116\32\116\111\32\98\101\32\99\108\111\115\101\100\10\32\32\32\32\112\117\115\104\118\97\108\117\101\32\50\32\32\35\32\32\115\116\97\99\107\58\32\83\44\32\78\82\44\32\67\72\44\32\82\44\32\78\82\10\32\32\32\32\99\97\108\108\32\48\32\49\32\32\32\35\32\99\114\101\97\116\101\32\97\110\111\116\104\101\114\32\114\101\115\111\117\114\99\101\59\32\115\116\97\99\107\58\32\83\44\32\78\82\44\32\67\72\44\32\82\44\32\82\10\32\32\32\32\116\111\99\108\111\115\101\32\45\49\32\35\32\109\97\114\107\32\105\116\32\116\111\32\98\101\32\99\108\111\115\101\100\10\32\32\32\32\112\117\115\104\118\97\108\117\101\32\51\32\32\35\32\115\116\97\99\107\58\32\83\44\32\78\82\44\32\67\72\44\32\82\44\32\82\44\32\67\72\10\32\32\32\32\112\117\115\104\105\110\116\32\50\32\32\32\35\32\116\104\101\114\101\32\115\104\111\117\108\100\32\98\101\32\116\119\111\32\111\112\101\110\32\114\101\115\111\117\114\99\101\115\10\32\32\32\32\99\97\108\108\32\49\32\48\32\32\35\32\32\115\116\97\99\107\58\32\83\44\32\78\82\44\32\67\72\44\32\82\44\32\82\10\32\32\32\32\112\111\112\32\49\32\32\32\35\32\112\111\112\32\115\101\99\111\110\100\32\114\101\115\111\117\114\99\101\10\32\32\32\32\112\117\115\104\118\97\108\117\101\32\51\32\32\35\32\115\116\97\99\107\58\32\83\44\32\78\82\44\32\67\72\44\32\82\44\32\67\72\10\32\32\32\32\112\117\115\104\105\110\116\32\49\32\32\32\35\32\116\104\101\114\101\32\115\104\111\117\108\100\32\98\101\32\111\110\101\32\111\112\101\110\32\114\101\115\111\117\114\99\101\10\32\32\32\32\99\97\108\108\32\49\32\48\32\32\35\32\115\116\97\99\107\58\32\83\44\32\78\82\44\32\67\72\44\32\82\10\32\32\32\32\112\111\112\32\49\32\32\32\32\32\32\32\35\32\112\111\112\32\111\116\104\101\114\32\114\101\115\111\117\114\99\101\32\102\114\111\109\32\116\104\101\32\115\116\97\99\107\10\32\32\32\32\112\117\115\104\118\97\108\117\101\32\51\32\32\35\32\115\116\97\99\107\58\32\83\44\32\78\82\44\32\67\72\44\32\67\72\10\32\32\32\32\112\117\115\104\105\110\116\32\48\32\32\32\35\32\116\104\101\114\101\32\115\104\111\117\108\100\32\98\101\32\110\111\32\111\112\101\110\32\114\101\115\111\117\114\99\101\115\10\32\32\32\32\99\97\108\108\32\49\32\48\32\32\35\32\115\116\97\99\107\58\32\83\44\32\78\82\44\32\67\72\10\32\32\32\32\112\117\115\104\105\110\116\32\42\10\32\32\32\32\114\101\116\117\114\110\32\49\32\32\32\32\35\32\114\101\116\117\114\110\32\115\116\97\99\107\32\115\105\122\101\10\32\32",newresource,check)
997895assert(a == 3)
998−local a,b = pcall(T.makeCfunc(" pushint 32
999− toclose -1
1000− "))
1001−assert(not a and string.find(b,"(C temporary)"))
1002−print("memory-allocation errors")
1003−checkerr("block too big",T.newuserdata,math.maxinteger)
896+local a,b = pcall(T.makeCfunc("\32\32\32\32\112\117\115\104\105\110\116\32\51\50\10\32\32\32\32\116\111\99\108\111\115\101\32\45\49\10\32\32"))
897+assert(not a and string.find(b,"\40\67\32\116\101\109\112\111\114\97\114\121\41"))
898+end
899+print("\109\101\109\111\114\121\45\97\108\108\111\99\97\116\105\111\110\32\101\114\114\111\114\115")
900+checkerr("\98\108\111\99\107\32\116\111\111\32\98\105\103",T.newuserdata,math.maxinteger)
1004901collectgarbage()
1005−local f = load("local a={}; for i=1,100000 do a[i]=i end")
902+local f = load("\108\111\99\97\108\32\97\61\123\125\59\32\102\111\114\32\105\61\49\44\49\48\48\48\48\48\32\100\111\32\97\91\105\93\61\105\32\101\110\100")
1006903T.alloccount(10)
1007904checkerr(MEMERRMSG,f)
1008905T.alloccount()
@@ -1017,16 +914,17 @@ collectgarbage()
1017914;
1018915collectgarbage()
1019916T.totalmem(M)
1020−a,b=T.testC("pcall 0 1 0; pushstatus; return 2",f)
917+a,b=T.testC("\112\99\97\108\108\32\48\32\49\32\48\59\32\112\117\115\104\115\116\97\116\117\115\59\32\114\101\116\117\114\110\32\50",f)
1021918T.totalmem(0)
1022−if a and b == "OK" then
919+if a and b == "\79\75" then
1023920break
1024921end
1025−if b ~= "OK" and b ~= MEMERRMSG then
922+if b ~= "\79\75" and b ~= MEMERRMSG then
1026923error(a,0)
1027924end
1028925M=M + 7
1029−print(string.format("minimum memory for %s: %d bytes",s,M - oldM))
926+end
927+print(string.format("\109\105\110\105\109\117\109\32\109\101\109\111\114\121\32\102\111\114\32\37\115\58\32\37\100\32\98\121\116\101\115",s,M - oldM))
1030928return a
1031929end
1032930local function testalloc
@@ -1039,16 +937,17 @@ collectgarbage()
1039937;
1040938collectgarbage()
1041939T.alloccount(M)
1042−a,b=T.testC("pcall 0 1 0; pushstatus; return 2",f)
940+a,b=T.testC("\112\99\97\108\108\32\48\32\49\32\48\59\32\112\117\115\104\115\116\97\116\117\115\59\32\114\101\116\117\114\110\32\50",f)
1043941T.alloccount()
1044−if a and b == "OK" then
942+if a and b == "\79\75" then
1045943break
1046944end
1047−if b ~= "OK" and b ~= MEMERRMSG then
945+if b ~= "\79\75" and b ~= MEMERRMSG then
1048946error(a,0)
1049947end
1050948M=M + 1
1051−print(string.format("minimum allocations for %s: %d allocations",s,M))
949+end
950+print(string.format("\109\105\110\105\109\117\109\32\97\108\108\111\99\97\116\105\111\110\115\32\102\111\114\32\37\115\58\32\37\100\32\97\108\108\111\99\97\116\105\111\110\115",s,M))
1052951return a
1053952end
1054953local function testamem
@@ -1056,88 +955,83 @@ local function testamem
1056955testalloc(s,f)
1057956return testbytes(s,f)
1058957end
1059−b=testamem("doing nothing",()
958+b=testamem("\100\111\105\110\103\32\110\111\116\104\105\110\103",function ()
1060959return 10
1061960end)
1062961assert(b == 10)
1063−testamem("state creation",()
962+testamem("\115\116\97\116\101\32\99\114\101\97\116\105\111\110",function ()
1064963local st = T.newstate()
1065964if st then
1066965T.closestate(st)
1067966end
1068967return st
1069968end)
1070−testamem("empty-table creation",()
969+testamem("\101\109\112\116\121\45\116\97\98\108\101\32\99\114\101\97\116\105\111\110",function ()
1071970return {}
1072971end)
1073−testamem("string creation",()
1074−return "XXX" .. "YYY"
972+testamem("\115\116\114\105\110\103\32\99\114\101\97\116\105\111\110",function ()
973+return "\88\88\88" .. "\89\89\89"
1075974end)
1076−testamem("coroutine creation",()
975+testamem("\99\111\114\111\117\116\105\110\101\32\99\114\101\97\116\105\111\110",function ()
1077976return coroutine.create(print)
1078977end)
1079−testamem("to-be-closed variables",()
1080−local flag =
1081−local x <close> = setmetatable({},{["__close"] = ()
978+testamem("\116\111\45\98\101\45\99\108\111\115\101\100\32\118\97\114\105\97\98\108\101\115",function ()
979+local flag
980+do
981+local x <close> = setmetatable({},{["\95\95\99\108\111\115\101"] = function ()
1082982flag=true
1083983end})
1084984flag=false
1085985local x = {}
986+end
1086987return flag
1087988end)
1088−local mt = T.testC("rawgeti R 1; return 1")
1089−assert(type(mt) == "thread" and coroutine.running() == mt)
989+local mt = T.testC("\114\97\119\103\101\116\105\32\82\32\49\59\32\114\101\116\117\114\110\32\49")
990+assert(type(mt) == "\116\104\114\101\97\100" and coroutine.running() == mt)
1090991local function expand
1091992(n,s)
1092993if n == 0 then
1093994return ""
1094995end
1095−local e = string.rep("=",n)
1096−return string.format("T.doonnewstack([%s[ %s;
1097− collectgarbage(); %s]%s])
1098−",e,s,expand(n - 1,s),e)
996+local e = string.rep("\61",n)
997+return string.format("\84\46\100\111\111\110\110\101\119\115\116\97\99\107\40\91\37\115\91\32\37\115\59\10\32\99\111\108\108\101\99\116\103\97\114\98\97\103\101\40\41\59\32\37\115\93\37\115\93\41\10",e,s,expand(n - 1,s),e)
1099998end
1100999G=0
11011000;
11021001collectgarbage()
11031002;
1104−a=collectgarbage("count")
1105−load(expand(20,"G=G+1"))()
1003+a=collectgarbage("\99\111\117\110\116")
1004+load(expand(20,"\71\61\71\43\49"))()
11061005assert(G == 20)
11071006;
11081007collectgarbage()
11091008;
11101009G=nil
1111−testamem("running code on new thread",()
1112−return T.doonnewstack("local x=1") == 0
1010+testamem("\114\117\110\110\105\110\103\32\99\111\100\101\32\111\110\32\110\101\119\32\116\104\114\101\97\100",function ()
1011+return T.doonnewstack("\108\111\99\97\108\32\120\61\49") == 0
11131012end)
1114−testamem("loadstring",()
1115−return load("x=1")
1013+testamem("\108\111\97\100\115\116\114\105\110\103",function ()
1014+return load("\120\61\49")
11161015end)
1117−local testprog = "local function foo () return end
1118−local t = {"x"}
1119−AA = "aaa"
1120−for i = 1, #t do AA = AA .. t[i] end
1121−return true
1122−"
1016+local testprog = "\108\111\99\97\108\32\102\117\110\99\116\105\111\110\32\102\111\111\32\40\41\32\114\101\116\117\114\110\32\101\110\100\10\108\111\99\97\108\32\116\32\61\32\123\34\120\34\125\10\65\65\32\61\32\34\97\97\97\34\10\102\111\114\32\105\32\61\32\49\44\32\35\116\32\100\111\32\65\65\32\61\32\65\65\32\46\46\32\116\91\105\93\32\101\110\100\10\114\101\116\117\114\110\32\116\114\117\101\10"
11231017_G.AA=nil
11241018local t = os.tmpname()
1125−local f = assert(io.open(t,"w"))
1019+local f = assert(io.open(t,"\119"))
11261020f:write(testprog)
11271021f:close()
1128−testamem("dofile",()
1022+testamem("\100\111\102\105\108\101",function ()
11291023local a = loadfile(t)
11301024return a and a()
11311025end)
11321026assert(os.remove(t))
1133−assert(_G.AA == "aaax")
1134−testamem("gsub",()
1135−local a,b = string.gsub("alo alo","(a)",(x)
1136−return x .. "b"
1027+assert(_G.AA == "\97\97\97\120")
1028+testamem("\103\115\117\98",function ()
1029+local a,b = string.gsub("\97\108\111\32\97\108\111","\40\97\41",function (x)
1030+return x .. "\98"
11371031end)
1138−return (a == "ablo ablo")
1032+return (a == "\97\98\108\111\32\97\98\108\111")
11391033end)
1140−testamem("dump/undump",()
1034+testamem("\100\117\109\112\47\117\110\100\117\109\112",function ()
11411035local a = load(testprog)
11421036local b = a and string.dump(a)
11431037a=b and load(b)
@@ -1145,57 +1039,59 @@ return a and a()
11451039end)
11461040_G.AA=nil
11471041local t = os.tmpname()
1148−testamem("file creation",()
1149−local f = assert(io.open(t,"w"))
1150−assert(not io.open("nomenaoexistente"))
1042+testamem("\102\105\108\101\32\99\114\101\97\116\105\111\110",function ()
1043+local f = assert(io.open(t,"\119"))
1044+assert(not io.open("\110\111\109\101\110\97\111\101\120\105\115\116\101\110\116\101"))
11511045io.close(f)
11521046;
1153−return not loadfile("nomenaoexistente")
1047+return not loadfile("\110\111\109\101\110\97\111\101\120\105\115\116\101\110\116\101")
11541048end)
11551049assert(os.remove(t))
1156−testamem("table creation",()
1050+testamem("\116\97\98\108\101\32\99\114\101\97\116\105\111\110",function ()
11571051local a,lim = {},10
11581052for i = 1, lim
11591053do
11601054a[i]=i
11611055;
1162−a[i .. "a"]={}
1056+a[i .. "\97"]={}
11631057end
1164−return (type(a[lim .. "a"]) == "table" and a[lim] == lim)
1058+return (type(a[lim .. "\97"]) == "\116\97\98\108\101" and a[lim] == lim)
11651059end)
1166−testamem("constructors",()
1167−local a = {10,20,30,40,50,["a"] = 1,["b"] = 2,["c"] = 3,["d"] = 4,["e"] = 5}
1168−return (type(a) == "table" and a.e == 5)
1060+testamem("\99\111\110\115\116\114\117\99\116\111\114\115",function ()
1061+local a = {10,20,30,40,50,["\97"] = 1,["\98"] = 2,["\99"] = 3,["\100"] = 4,["\101"] = 5}
1062+return (type(a) == "\116\97\98\108\101" and a.e == 5)
11691063end)
11701064local a = 1
11711065local close = nil
1172−testamem("closure creation",()
1066+testamem("\99\108\111\115\117\114\101\32\99\114\101\97\116\105\111\110",function ()
11731067function close(b)
1174−return (x)
1068+return function (x)
11751069return b + x
11761070end
11771071end
11781072return (close(2)(4) == 6)
11791073end)
1180−testamem("using coroutines",()
1181−local a = coroutine.wrap(()
1182−coroutine.yield(string.rep("a",10))
1074+testamem("\117\115\105\110\103\32\99\111\114\111\117\116\105\110\101\115",function ()
1075+local a = coroutine.wrap(function ()
1076+coroutine.yield(string.rep("\97",10))
11831077return {}
11841078end)
11851079assert(string.len(a()) == 10)
11861080return a()
11871081end)
1082+do
11881083local lim = 100
11891084local a = {}
11901085;
11911086for i = 1, lim
11921087do
1193−a[i]="01234567890123456789"
1088+a[i]="\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57"
11941089end
1195−testamem("auxiliary buffer",()
1196−return (# table.concat(a,",") == 20 * lim + lim - 1)
1090+testamem("\97\117\120\105\108\105\97\114\121\32\98\117\102\102\101\114",function ()
1091+return (# table.concat(a,"\44") == 20 * lim + lim - 1)
11971092end)
1198−testamem("growing stack",()
1093+end
1094+testamem("\103\114\111\119\105\110\103\32\115\116\97\99\107",function ()
11991095local function foo
12001096(n)
12011097if n == 0 then
@@ -1206,91 +1102,66 @@ end
12061102end
12071103return foo(100)
12081104end)
1209−local res = T.testC("rawcheckstack 500000; return 1")
1105+do
1106+local res = T.testC("\114\97\119\99\104\101\99\107\115\116\97\99\107\32\53\48\48\48\48\48\59\32\114\101\116\117\114\110\32\49")
12101107assert(res == false)
12111108local L = T.newstate()
12121109T.alloccount(0)
1213−res=T.testC(L,"rawcheckstack 5000; return 1")
1110+res=T.testC(L,"\114\97\119\99\104\101\99\107\115\116\97\99\107\32\53\48\48\48\59\32\114\101\116\117\114\110\32\49")
12141111T.alloccount()
12151112T.closestate(L)
12161113assert(res == false)
1114+end
1115+do
12171116local L = T.newstate()
12181117T.alloccount(0)
12191118T.closestate(L)
12201119T.alloccount()
1120+end
1121+do
12211122local L = T.newstate()
12221123T.loadlib(L)
1223−local res = (T.doremote(L," _ENV = require"_G"
1224− local T = require"T"
1225− local a = {}
1226− for i = 1, 1000 do a[i] = 'i' .. i end -- grow string table
1227− local stsize, stuse = T.querystr()
1228− assert(stuse > 1000)
1229− local function foo (n)
1230− if n > 0 then foo(n - 1) end
1231− end
1232− foo(180) -- grow stack
1233− local _, stksize = T.stacklevel()
1234− assert(stksize > 180)
1235− a = nil
1236− T.alloccount(0)
1237− collectgarbage()
1238− T.alloccount()
1239− -- stack and string table could not be reallocated,
1240− -- so they kept their sizes (without errors)
1241− assert(select(2, T.stacklevel()) == stksize)
1242− assert(T.querystr() == stsize)
1243− return 'ok'
1244− "))
1245−assert(res == "ok")
1124+local res = (T.doremote(L,"\32\32\32\32\95\69\78\86\32\61\32\114\101\113\117\105\114\101\34\95\71\34\10\32\32\32\32\108\111\99\97\108\32\84\32\61\32\114\101\113\117\105\114\101\34\84\34\10\32\32\32\32\108\111\99\97\108\32\97\32\61\32\123\125\10\32\32\32\32\102\111\114\32\105\32\61\32\49\44\32\49\48\48\48\32\100\111\32\97\91\105\93\32\61\32\39\105\39\32\46\46\32\105\32\101\110\100\32\32\32\32\45\45\32\103\114\111\119\32\115\116\114\105\110\103\32\116\97\98\108\101\10\32\32\32\32\108\111\99\97\108\32\115\116\115\105\122\101\44\32\115\116\117\115\101\32\61\32\84\46\113\117\101\114\121\115\116\114\40\41\10\32\32\32\32\97\115\115\101\114\116\40\115\116\117\115\101\32\62\32\49\48\48\48\41\10\32\32\32\32\108\111\99\97\108\32\102\117\110\99\116\105\111\110\32\102\111\111\32\40\110\41\10\32\32\32\32\32\32\105\102\32\110\32\62\32\48\32\116\104\101\110\32\102\111\111\40\110\32\45\32\49\41\32\101\110\100\10\32\32\32\32\101\110\100\10\32\32\32\32\102\111\111\40\49\56\48\41\32\32\32\32\45\45\32\103\114\111\119\32\115\116\97\99\107\10\32\32\32\32\108\111\99\97\108\32\95\44\32\115\116\107\115\105\122\101\32\61\32\84\46\115\116\97\99\107\108\101\118\101\108\40\41\10\32\32\32\32\97\115\115\101\114\116\40\115\116\107\115\105\122\101\32\62\32\49\56\48\41\10\32\32\32\32\97\32\61\32\110\105\108\10\32\32\32\32\84\46\97\108\108\111\99\99\111\117\110\116\40\48\41\10\32\32\32\32\99\111\108\108\101\99\116\103\97\114\98\97\103\101\40\41\10\32\32\32\32\84\46\97\108\108\111\99\99\111\117\110\116\40\41\10\32\32\32\32\45\45\32\115\116\97\99\107\32\97\110\100\32\115\116\114\105\110\103\32\116\97\98\108\101\32\99\111\117\108\100\32\110\111\116\32\98\101\32\114\101\97\108\108\111\99\97\116\101\100\44\10\32\32\32\32\45\45\32\115\111\32\116\104\101\121\32\107\101\112\116\32\116\104\101\105\114\32\115\105\122\101\115\32\40\119\105\116\104\111\117\116\32\101\114\114\111\114\115\41\10\32\32\32\32\97\115\115\101\114\116\40\115\101\108\101\99\116\40\50\44\32\84\46\115\116\97\99\107\108\101\118\101\108\40\41\41\32\61\61\32\115\116\107\115\105\122\101\41\10\32\32\32\32\97\115\115\101\114\116\40\84\46\113\117\101\114\121\115\116\114\40\41\32\61\61\32\115\116\115\105\122\101\41\10\32\32\32\32\114\101\116\117\114\110\32\39\111\107\39\10\32\32"))
1125+assert(res == "\111\107")
12461126T.closestate(L)
1247−print("+")
1127+end
1128+print("\43")
12481129local function gsub
12491130(a,b,c)
1250−a,b=T.testC("gsub 2 3 4; gettop; return 2",a,b,c)
1131+a,b=T.testC("\103\115\117\98\32\50\32\51\32\52\59\32\103\101\116\116\111\112\59\32\114\101\116\117\114\110\32\50",a,b,c)
12511132assert(b == 5)
12521133return a
12531134end
1254−assert(gsub("alo.alo.uhuh.",".","//") == "alo//alo//uhuh//")
1255−assert(gsub("alo.alo.uhuh.","alo","//") == "//.//.uhuh.")
1256−assert(gsub("","alo","//") == "")
1257−assert(gsub("...",".","/.") == "/././.")
1258−assert(gsub("...","...","") == "")
1259−local mt_xuxu,res,top = T.testC("newmetatable xuxu; gettop; return 3")
1260−assert(type(mt_xuxu) == "table" and res and top == 3)
1261−local d,res,top = T.testC("newmetatable xuxu; gettop; return 3")
1135+assert(gsub("\97\108\111\46\97\108\111\46\117\104\117\104\46","\46","\47\47") == "\97\108\111\47\47\97\108\111\47\47\117\104\117\104\47\47")
1136+assert(gsub("\97\108\111\46\97\108\111\46\117\104\117\104\46","\97\108\111","\47\47") == "\47\47\46\47\47\46\117\104\117\104\46")
1137+assert(gsub("","\97\108\111","\47\47") == "")
1138+assert(gsub("\46\46\46","\46","\47\46") == "\47\46\47\46\47\46")
1139+assert(gsub("\46\46\46","\46\46\46","") == "")
1140+local mt_xuxu,res,top = T.testC("\110\101\119\109\101\116\97\116\97\98\108\101\32\120\117\120\117\59\32\103\101\116\116\111\112\59\32\114\101\116\117\114\110\32\51")
1141+assert(type(mt_xuxu) == "\116\97\98\108\101" and res and top == 3)
1142+local d,res,top = T.testC("\110\101\119\109\101\116\97\116\97\98\108\101\32\120\117\120\117\59\32\103\101\116\116\111\112\59\32\114\101\116\117\114\110\32\51")
12621143assert(mt_xuxu == d and not res and top == 3)
1263−d,res,top=T.testC("newmetatable xuxu1; gettop; return 3")
1144+d,res,top=T.testC("\110\101\119\109\101\116\97\116\97\98\108\101\32\120\117\120\117\49\59\32\103\101\116\116\111\112\59\32\114\101\116\117\114\110\32\51")
12641145assert(mt_xuxu ~= d and res and top == 3)
12651146x=T.newuserdata(0)
12661147;
12671148y=T.newuserdata(0)
12681149;
1269−T.testC("pushstring xuxu; gettable R; setmetatable 2",x)
1150+T.testC("\112\117\115\104\115\116\114\105\110\103\32\120\117\120\117\59\32\103\101\116\116\97\98\108\101\32\82\59\32\115\101\116\109\101\116\97\116\97\98\108\101\32\50",x)
12701151assert(getmetatable(x) == mt_xuxu)
1271−local res1,res2,top = T.testC("testudata -1 xuxu
1272− testudata 2 xuxu
1273− gettop
1274− return 3",x)
1152+local res1,res2,top = T.testC("\116\101\115\116\117\100\97\116\97\32\45\49\32\120\117\120\117\10\32\32\32\9\32\9\9\9\32\32\116\101\115\116\117\100\97\116\97\32\50\32\120\117\120\117\10\9\9\9\9\32\32\103\101\116\116\111\112\10\9\9\9\9\32\32\114\101\116\117\114\110\32\51",x)
12751153assert(res1 and res2 and top == 4)
1276−res1,res2,top=T.testC("testudata -1 xuxu1
1277− testudata 2 xuxu1
1278− gettop
1279− return 3",x)
1154+res1,res2,top=T.testC("\116\101\115\116\117\100\97\116\97\32\45\49\32\120\117\120\117\49\10\9\9\9\32\32\32\32\116\101\115\116\117\100\97\116\97\32\50\32\120\117\120\117\49\10\9\9\9\32\32\32\32\103\101\116\116\111\112\10\9\9\9\32\32\32\32\114\101\116\117\114\110\32\51",x)
12801155assert(not res1 and not res2 and top == 4)
1281−res1,res2,top=T.testC("testudata -1 xuxu2
1282− testudata 2 xuxu2
1283− gettop
1284− return 3",x)
1156+res1,res2,top=T.testC("\116\101\115\116\117\100\97\116\97\32\45\49\32\120\117\120\117\50\10\9\9\9\32\32\32\32\116\101\115\116\117\100\97\116\97\32\50\32\120\117\120\117\50\10\9\9\9\32\32\32\32\103\101\116\116\111\112\10\9\9\9\32\32\32\32\114\101\116\117\114\110\32\51",x)
12851157assert(not res1 and not res2 and top == 4)
1286−res1,res2,top=T.testC("testudata -1 xuxu
1287− testudata 2 xuxu
1288− gettop
1289− return 3",y)
1158+res1,res2,top=T.testC("\116\101\115\116\117\100\97\116\97\32\45\49\32\120\117\120\117\10\9\9\9\32\32\32\32\116\101\115\116\117\100\97\116\97\32\50\32\120\117\120\117\10\9\9\9\32\32\32\32\103\101\116\116\111\112\10\9\9\9\32\32\32\32\114\101\116\117\114\110\32\51",y)
12901159assert(not res1 and not res2 and top == 4)
1160+do
12911161local r = debug.getregistry()
12921162assert(r.xuxu == mt_xuxu and r.xuxu1 == d)
12931163r.xuxu=nil
12941164;
12951165r.xuxu1=nil
1296−print("OK")
1166+end
1167+print("\79\75")
zod/luau/res/lua/cycled/attrib.lua+173−172
@@ -1,65 +1,62 @@
1−print("testing require")
2−assert(require("string") == string)
3−assert(require("math") == math)
4−assert(require("table") == table)
5−assert(require("io") == io)
6−assert(require("os") == os)
7−assert(require("coroutine") == coroutine)
8−assert(type(package.path) == "string")
9−assert(type(package.cpath) == "string")
10−assert(type(package.loaded) == "table")
11−assert(type(package.preload) == "table")
12−assert(type(package.config) == "string")
13−print("package config: " .. string.gsub(package.config,"
14−","|"))
15−local max = _soft and 100 or 2e3
1+print("\116\101\115\116\105\110\103\32\114\101\113\117\105\114\101")
2+assert(require("\115\116\114\105\110\103") == string)
3+assert(require("\109\97\116\104") == math)
4+assert(require("\116\97\98\108\101") == table)
5+assert(require("\105\111") == io)
6+assert(require("\111\115") == os)
7+assert(require("\99\111\114\111\117\116\105\110\101") == coroutine)
8+assert(type(package.path) == "\115\116\114\105\110\103")
9+assert(type(package.cpath) == "\115\116\114\105\110\103")
10+assert(type(package.loaded) == "\116\97\98\108\101")
11+assert(type(package.preload) == "\116\97\98\108\101")
12+assert(type(package.config) == "\115\116\114\105\110\103")
13+print("\112\97\99\107\97\103\101\32\99\111\110\102\105\103\58\32" .. string.gsub(package.config,"\10","\124"))
14+do
15+local max = _soft and 100 or 2000
1616local t = {}
1717for i = 1, max
1818do
19−t[i]=string.rep("?",i % 10 + 1)
20−end
21−t[# t + 1]=";"
22−local path = table.concat(t,";")
23−local s,err = package.searchpath("xuxu",path)
24−assert(not s and string.find(err,string.rep("xuxu",10)) and # string.gsub(err,"[^
25−]","") >= max)
26−local path = string.rep("?",max)
27−local s,err = package.searchpath("xuxu",path)
28−assert(not s and string.find(err,string.rep("xuxu",max)))
19+t[i]=string.rep("\63",i % 10 + 1)
20+end
21+t[# t + 1]="\59"
22+local path = table.concat(t,"\59")
23+local s,err = package.searchpath("\120\117\120\117",path)
24+assert(not s and string.find(err,string.rep("\120\117\120\117",10)) and # string.gsub(err,"\91\94\10\93","") >= max)
25+local path = string.rep("\63",max)
26+local s,err = package.searchpath("\120\117\120\117",path)
27+assert(not s and string.find(err,string.rep("\120\117\120\117",max)))
28+end
29+do
2930local oldpath = package.path
3031package.path={}
31−local s,err = pcall(require,"no-such-file")
32−assert(not s and string.find(err,"package.path"))
32+local s,err = pcall(require,"\110\111\45\115\117\99\104\45\102\105\108\101")
33+assert(not s and string.find(err,"\112\97\99\107\97\103\101\46\112\97\116\104"))
3334package.path=oldpath
34−print("testing 'require' message")
35+end
36+do
37+print("\116\101\115\116\105\110\103\32\39\114\101\113\117\105\114\101\39\32\109\101\115\115\97\103\101")
3538local oldpath = package.path
3639local oldcpath = package.cpath
37−package.path="?.lua;?/?"
38−package.cpath="?.so;?/init"
39−local st,msg = pcall(require,"XXX")
40−local expected = "module 'XXX' not found:
41− no field package.preload['XXX']
42− no file 'XXX.lua'
43− no file 'XXX/XXX'
44− no file 'XXX.so'
45− no file 'XXX/init'"
40+package.path="\63\46\108\117\97\59\63\47\63"
41+package.cpath="\63\46\115\111\59\63\47\105\110\105\116"
42+local st,msg = pcall(require,"\88\88\88")
43+local expected = "\109\111\100\117\108\101\32\39\88\88\88\39\32\110\111\116\32\102\111\117\110\100\58\10\9\110\111\32\102\105\101\108\100\32\112\97\99\107\97\103\101\46\112\114\101\108\111\97\100\91\39\88\88\88\39\93\10\9\110\111\32\102\105\108\101\32\39\88\88\88\46\108\117\97\39\10\9\110\111\32\102\105\108\101\32\39\88\88\88\47\88\88\88\39\10\9\110\111\32\102\105\108\101\32\39\88\88\88\46\115\111\39\10\9\110\111\32\102\105\108\101\32\39\88\88\88\47\105\110\105\116\39"
4644assert(msg == expected)
4745package.path=oldpath
4846package.cpath=oldcpath
49−print("+")
47+end
48+print("\43")
5049if not _port then
51−local dirsep = string.match(package.config,"^([^
52−]+)
53−")
54−local DIR = "libs" .. dirsep
50+local dirsep = string.match(package.config,"\94\40\91\94\10\93\43\41\10")
51+local DIR = "\108\105\98\115" .. dirsep
5552local function D
5653(x)
57−local x = string.gsub(x,"/",dirsep)
54+local x = string.gsub(x,"\47",dirsep)
5855return DIR .. x
5956end
6057local function DC
6158(x)
62−local ext = (dirsep == "\") and ".dll" or ".so"
59+local ext = (dirsep == "\92") and "\46\100\108\108" or "\46\115\111"
6360return D(x .. ext)
6461end
6562local function createfiles
@@ -80,22 +77,19 @@ do
8077os.remove(D(n))
8178end
8279end
83−local files = {["names.lua"] = "do return {...} end
84−",["err.lua"] = "B = 15; a = a + 1;",["synerr.lua"] = "B =",["A.lua"] = "",["B.lua"] = "assert(...=='B');require 'A'",["A.lc"] = "",["A"] = "",["L"] = "",["XXxX"] = "",["C.lua"] = "package.loaded[...] = 25; require'C'"}
80+local files = {["\110\97\109\101\115\46\108\117\97"] = "\100\111\32\114\101\116\117\114\110\32\123\46\46\46\125\32\101\110\100\10",["\101\114\114\46\108\117\97"] = "\66\32\61\32\49\53\59\32\97\32\61\32\97\32\43\32\49\59",["\115\121\110\101\114\114\46\108\117\97"] = "\66\32\61",["\65\46\108\117\97"] = "",["\66\46\108\117\97"] = "\97\115\115\101\114\116\40\46\46\46\61\61\39\66\39\41\59\114\101\113\117\105\114\101\32\39\65\39",["\65\46\108\99"] = "",["\65"] = "",["\76"] = "",["\88\88\120\88"] = "",["\67\46\108\117\97"] = "\112\97\99\107\97\103\101\46\108\111\97\100\101\100\91\46\46\46\93\32\61\32\50\53\59\32\114\101\113\117\105\114\101\39\67\39"}
8581AA=nil
86−local extras = "NAME = '%s'
87−REQUIRED = ...
88−return AA"
82+local extras = "\78\65\77\69\32\61\32\39\37\115\39\10\82\69\81\85\73\82\69\68\32\61\32\46\46\46\10\114\101\116\117\114\110\32\65\65"
8983createfiles(files,"",extras)
90−assert(package.searchpath("C.lua",D("?"),"","") == D("C.lua"))
91−assert(package.searchpath("C.lua",D("?"),".",".") == D("C.lua"))
92−assert(package.searchpath("--x-",D("?"),"-","X") == D("XXxX"))
93−assert(package.searchpath("---xX",D("?"),"---","XX") == D("XXxX"))
94−assert(package.searchpath(D("C.lua"),"?",dirsep) == D("C.lua"))
95−assert(package.searchpath(".\C.lua",D("?"),"\") == D("./C.lua"))
84+assert(package.searchpath("\67\46\108\117\97",D("\63"),"","") == D("\67\46\108\117\97"))
85+assert(package.searchpath("\67\46\108\117\97",D("\63"),"\46","\46") == D("\67\46\108\117\97"))
86+assert(package.searchpath("\45\45\120\45",D("\63"),"\45","\88") == D("\88\88\120\88"))
87+assert(package.searchpath("\45\45\45\120\88",D("\63"),"\45\45\45","\88\88") == D("\88\88\120\88"))
88+assert(package.searchpath(D("\67\46\108\117\97"),"\63",dirsep) == D("\67\46\108\117\97"))
89+assert(package.searchpath("\46\92\67\46\108\117\97",D("\63"),"\92") == D("\46\47\67\46\108\117\97"))
9690local oldpath = package.path
97−package.path=string.gsub("D/?.lua;D/?.lc;D/?;D/??x?;D/L","D/",DIR)
98−local try = (p,n,r,ext)
91+package.path=string.gsub("\68\47\63\46\108\117\97\59\68\47\63\46\108\99\59\68\47\63\59\68\47\63\63\120\63\59\68\47\76","\68\47",DIR)
92+local try = function (p,n,r,ext)
9993NAME=nil
10094local rr,x = require(p)
10195assert(NAME == n)
@@ -103,141 +97,139 @@ assert(REQUIRED == p)
10397assert(rr == r)
10498assert(ext == x)
10599end
106−local a = require("names")
107−assert(a[1] == "names" and a[2] == D("names.lua"))
108−local st,msg = pcall(require,"err")
109−assert(not st and string.find(msg,"arithmetic") and B == 15)
110−st,msg=pcall(require,"synerr")
111−assert(not st and string.find(msg,"error loading module"))
112−assert(package.searchpath("C",package.path) == D("C.lua"))
113−assert(require("C") == 25)
114−assert(require("C") == 25)
100+local a = require("\110\97\109\101\115")
101+assert(a[1] == "\110\97\109\101\115" and a[2] == D("\110\97\109\101\115\46\108\117\97"))
102+local st,msg = pcall(require,"\101\114\114")
103+assert(not st and string.find(msg,"\97\114\105\116\104\109\101\116\105\99") and B == 15)
104+st,msg=pcall(require,"\115\121\110\101\114\114")
105+assert(not st and string.find(msg,"\101\114\114\111\114\32\108\111\97\100\105\110\103\32\109\111\100\117\108\101"))
106+assert(package.searchpath("\67",package.path) == D("\67\46\108\117\97"))
107+assert(require("\67") == 25)
108+assert(require("\67") == 25)
115109AA=nil
116−try("B","B.lua",true,"libs/B.lua")
110+try("\66","\66\46\108\117\97",true,"\108\105\98\115\47\66\46\108\117\97")
117111assert(package.loaded.B)
118−assert(require("B") == true)
112+assert(require("\66") == true)
119113assert(package.loaded.A)
120−assert(require("C") == 25)
114+assert(require("\67") == 25)
121115package.loaded.A=nil
122−try("B",nil,true,nil)
123−try("A","A.lua",true,"libs/A.lua")
116+try("\66",nil,true,nil)
117+try("\65","\65\46\108\117\97",true,"\108\105\98\115\47\65\46\108\117\97")
124118package.loaded.A=nil
125−os.remove(D("A.lua"))
119+os.remove(D("\65\46\108\117\97"))
126120AA={}
127−try("A","A.lc",AA,"libs/A.lc")
128−assert(package.searchpath("A",package.path) == D("A.lc"))
129−assert(require("A") == AA)
121+try("\65","\65\46\108\99",AA,"\108\105\98\115\47\65\46\108\99")
122+assert(package.searchpath("\65",package.path) == D("\65\46\108\99"))
123+assert(require("\65") == AA)
130124AA=false
131−try("K","L",false,"libs/L")
132−try("K","L",false,"libs/L")
133−assert(rawget(_G,"_REQUIREDNAME") == nil)
134−AA="x"
135−try("X","XXxX",AA,"libs/XXxX")
125+try("\75","\76",false,"\108\105\98\115\47\76")
126+try("\75","\76",false,"\108\105\98\115\47\76")
127+assert(rawget(_G,"\95\82\69\81\85\73\82\69\68\78\65\77\69") == nil)
128+AA="\120"
129+try("\88","\88\88\120\88",AA,"\108\105\98\115\47\88\88\120\88")
136130removefiles(files)
137131NAME,REQUIRED,AA,B=nil
138132local _G = _G
139−package.path=string.gsub("D/?.lua;D/?/init.lua","D/",DIR)
140−files={["P1/init.lua"] = "AA = 10",["P1/xuxu.lua"] = "AA = 20"}
141−createfiles(files,"_ENV = {}
142−","
143−return _ENV
144−")
133+package.path=string.gsub("\68\47\63\46\108\117\97\59\68\47\63\47\105\110\105\116\46\108\117\97","\68\47",DIR)
134+files={["\80\49\47\105\110\105\116\46\108\117\97"] = "\65\65\32\61\32\49\48",["\80\49\47\120\117\120\117\46\108\117\97"] = "\65\65\32\61\32\50\48"}
135+createfiles(files,"\95\69\78\86\32\61\32\123\125\10","\10\114\101\116\117\114\110\32\95\69\78\86\10")
145136AA=0
146−local m,ext = assert(require("P1"))
147−assert(ext == "libs/P1/init.lua")
137+local m,ext = assert(require("\80\49"))
138+assert(ext == "\108\105\98\115\47\80\49\47\105\110\105\116\46\108\117\97")
148139assert(AA == 0 and m.AA == 10)
149−assert(require("P1") == m)
150−assert(require("P1") == m)
151−assert(package.searchpath("P1.xuxu",package.path) == D("P1/xuxu.lua"))
152−m.xuxu,ext=assert(require("P1.xuxu"))
140+assert(require("\80\49") == m)
141+assert(require("\80\49") == m)
142+assert(package.searchpath("\80\49\46\120\117\120\117",package.path) == D("\80\49\47\120\117\120\117\46\108\117\97"))
143+m.xuxu,ext=assert(require("\80\49\46\120\117\120\117"))
153144assert(AA == 0 and m.xuxu.AA == 20)
154−assert(ext == "libs/P1/xuxu.lua")
155−assert(require("P1.xuxu") == m.xuxu)
156−assert(require("P1.xuxu") == m.xuxu)
157−assert(require("P1") == m and m.AA == 10)
145+assert(ext == "\108\105\98\115\47\80\49\47\120\117\120\117\46\108\117\97")
146+assert(require("\80\49\46\120\117\120\117") == m.xuxu)
147+assert(require("\80\49\46\120\117\120\117") == m.xuxu)
148+assert(require("\80\49") == m and m.AA == 10)
158149removefiles(files)
159150AA=nil
160151package.path=""
161−assert(not pcall(require,"file_does_not_exist"))
162−package.path="???"
163−assert(not pcall(require,"file_does_not_exist1"))
152+assert(not pcall(require,"\102\105\108\101\95\100\111\101\115\95\110\111\116\95\101\120\105\115\116"))
153+package.path="\63\63\63"
154+assert(not pcall(require,"\102\105\108\101\95\100\111\101\115\95\110\111\116\95\101\120\105\115\116\49"))
164155package.path=oldpath
165−local fname = "file_does_not_exist2"
156+local fname = "\102\105\108\101\95\100\111\101\115\95\110\111\116\95\101\120\105\115\116\50"
166157local m,err = pcall(require,fname)
167−for t in string.gmatch(package.path .. ";" .. package.cpath,"[^;]+")
158+for t in string.gmatch(package.path .. "\59" .. package.cpath,"\91\94\59\93\43")
168159do
169−t=string.gsub(t,"?",fname)
160+t=string.gsub(t,"\63",fname)
170161assert(string.find(err,t,1,true))
171162end
163+do
172164local searchers = package.searchers
173165package.searchers=3
174−local st,msg = pcall(require,"a")
175−assert(not st and string.find(msg,"must be a table"))
166+local st,msg = pcall(require,"\97")
167+assert(not st and string.find(msg,"\109\117\115\116\32\98\101\32\97\32\116\97\98\108\101"))
176168package.searchers=searchers
169+end
177170local function import
178171(...)
179172local f = {...}
180−return (m)
173+return function (m)
181174for i = 1, # f
182175do
183176m[f[i]]=_G[f[i]]
184177end
185178end
186179end
187−assert(not pcall(module,"XUXU"))
180+assert(not pcall(module,"\88\85\88\85"))
188181local p = ""
189−local st,err,when = package.loadlib(DC("lib1"),"*")
182+local st,err,when = package.loadlib(DC("\108\105\98\49"),"\42")
190183if not st then
191−local f,err,when = package.loadlib("donotexist",p .. "xuxu")
192−assert(not f and type(err) == "string" and when == "absent")
184+local f,err,when = package.loadlib("\100\111\110\111\116\101\120\105\115\116",p .. "\120\117\120\117")
185+assert(not f and type(err) == "\115\116\114\105\110\103" and when == "\97\98\115\101\110\116")
193186;
194−(Message or print)("
195− >>> cannot load dynamic library <<<
196−")
187+(Message or print)("\10\32\62\62\62\32\99\97\110\110\111\116\32\108\111\97\100\32\100\121\110\97\109\105\99\32\108\105\98\114\97\114\121\32\60\60\60\10")
197188print(err,when)
198189else
199−local f = assert(package.loadlib(DC("lib1"),p .. "onefunction"))
190+local f = assert(package.loadlib(DC("\108\105\98\49"),p .. "\111\110\101\102\117\110\99\116\105\111\110"))
200191local a,b = f(15,25)
201192assert(a == 25 and b == 15)
202−f=assert(package.loadlib(DC("lib1"),p .. "anotherfunc"))
203−assert(f(10,20) == "10%20
204−")
205−local f,err,when = package.loadlib(DC("lib1"),p .. "xuxu")
206−assert(not f and type(err) == "string" and when == "init")
207−f,err,when=package.loadlib("donotexist",p .. "xuxu")
208−assert(not f and type(err) == "string" and when == "open")
209−f=assert(package.loadlib(DC("lib11"),p .. "luaopen_lib11"))
210−assert(f() == "exported")
211−package.cpath=DC("?")
212−local lib2,ext = require("lib2-v2")
213−assert(string.find(ext,"libs/lib2-v2",1,true))
214−assert(_ENV.x == "lib2-v2" and _ENV.y == DC("lib2-v2"))
215−assert(lib2.id("x") == true)
216−local fs,ext = require("lib1.sub")
217−assert(_ENV.x == "lib1.sub" and _ENV.y == DC("lib1"))
218−assert(string.find(ext,"libs/lib1",1,true))
193+f=assert(package.loadlib(DC("\108\105\98\49"),p .. "\97\110\111\116\104\101\114\102\117\110\99"))
194+assert(f(10,20) == "\49\48\37\50\48\10")
195+local f,err,when = package.loadlib(DC("\108\105\98\49"),p .. "\120\117\120\117")
196+assert(not f and type(err) == "\115\116\114\105\110\103" and when == "\105\110\105\116")
197+f,err,when=package.loadlib("\100\111\110\111\116\101\120\105\115\116",p .. "\120\117\120\117")
198+assert(not f and type(err) == "\115\116\114\105\110\103" and when == "\111\112\101\110")
199+f=assert(package.loadlib(DC("\108\105\98\49\49"),p .. "\108\117\97\111\112\101\110\95\108\105\98\49\49"))
200+assert(f() == "\101\120\112\111\114\116\101\100")
201+package.cpath=DC("\63")
202+local lib2,ext = require("\108\105\98\50\45\118\50")
203+assert(string.find(ext,"\108\105\98\115\47\108\105\98\50\45\118\50",1,true))
204+assert(_ENV.x == "\108\105\98\50\45\118\50" and _ENV.y == DC("\108\105\98\50\45\118\50"))
205+assert(lib2.id("\120") == true)
206+local fs,ext = require("\108\105\98\49\46\115\117\98")
207+assert(_ENV.x == "\108\105\98\49\46\115\117\98" and _ENV.y == DC("\108\105\98\49"))
208+assert(string.find(ext,"\108\105\98\115\47\108\105\98\49",1,true))
219209assert(fs.id(45) == 45)
220210_ENV.x,_ENV.y=nil
221211end
222212_ENV=_G
213+do
223214local p = package
224215package={}
225−p.preload.pl=(...)
216+p.preload.pl=function (...)
226217local _ENV = {...}
227218function xuxu(x)
228219return x + 20
229220end
230221return _ENV
231222end
232−local pl,ext = require("pl")
233−assert(require("pl") == pl)
223+local pl,ext = require("\112\108")
224+assert(require("\112\108") == pl)
234225assert(pl.xuxu(10) == 30)
235−assert(pl[1] == "pl" and pl[2] == ":preload:" and ext == ":preload:")
226+assert(pl[1] == "\112\108" and pl[2] == "\58\112\114\101\108\111\97\100\58" and ext == "\58\112\114\101\108\111\97\100\58")
236227package=p
237−assert(type(package.path) == "string")
238−print("+")
228+assert(type(package.path) == "\115\116\114\105\110\103")
239229end
240−print("testing assignments, logical operators, and constructors")
230+print("\43")
231+end
232+print("\116\101\115\116\105\110\103\32\97\115\115\105\103\110\109\101\110\116\115\44\32\108\111\103\105\99\97\108\32\111\112\101\114\97\116\111\114\115\44\32\97\110\100\32\99\111\110\115\116\114\117\99\116\111\114\115")
241233local res,res2 = 27
242234local a,b = 1,2 + 3
243235assert(a == 1 and b == 5)
@@ -248,9 +240,10 @@ return 10,11,12
248240end
249241a.x,b,a[1]=1,2,f()
250242assert(a.x == 1 and b == 2 and a[1] == 10)
251−a[f()],b,a[f() + 3]=f(),a,"x"
252−assert(a[10] == 10 and b == a and a[13] == "x")
253−local f = (n)
243+a[f()],b,a[f() + 3]=f(),a,"\120"
244+assert(a[10] == 10 and b == a and a[13] == "\120")
245+do
246+local f = function (n)
254247local x = {}
255248;
256249for i = 1, n
@@ -261,7 +254,7 @@ end
261254return table.unpack(x)
262255end
263256;
264−local a,b,c =
257+local a,b,c
265258a,b=0,f(1)
266259assert(a == 0 and b == 1)
267260a,b=0,f(1)
@@ -270,6 +263,7 @@ a,b,c=0,5,f(4)
270263assert(a == 0 and b == 5 and c == 1)
271264a,b,c=0,5,f(0)
272265assert(a == 0 and b == 5 and c == nil)
266+end
273267local a,b,c,d = 1 and nil,1 or nil,(1 and (nil or 1)),6
274268assert(not a and b and c and d == 6)
275269d=20
@@ -282,7 +276,7 @@ assert((10 and 2) == 2)
282276assert((10 or 2) == 10)
283277assert((10 or assert(nil)) == 10)
284278assert(not (nil and assert(nil)))
285−assert((nil or "alo") == "alo")
279+assert((nil or "\97\108\111") == "\97\108\111")
286280assert((nil and 10) == nil)
287281assert((false and 10) == false)
288282assert((true or 10) == true)
@@ -299,9 +293,9 @@ assert(not not (nil and true) == false)
299293assert(not 10 == false)
300294assert(not {} == false)
301295assert(not 0.5 == false)
302−assert(not "x" == false)
296+assert(not "\120" == false)
303297assert({} ~= {})
304−print("+")
298+print("\43")
305299a={}
306300a[true]=20
307301a[false]=10
@@ -310,18 +304,18 @@ function f(a)
310304return a
311305end
312306local a = {}
313−for i = 3e3, - 3e3, - 1
307+for i = 3000, - 3000, - 1
314308do
315−a[i + 0]=i
309+a[i + 0.0]=i
316310;
317311end
318−a[1e31]="alo"
312+a[1e31.0]="\97\108\111"
319313;
320314a[true]=10
321315;
322316a[false]=20
323−assert(a[1e31] == "alo" and a[not 1] == 20 and a[10 < 20] == 10)
324−for i = 3e3, - 3e3, - 1
317+assert(a[1e31.0] == "\97\108\111" and a[not 1] == 20 and a[10 < 20] == 10)
318+for i = 3000, - 3000, - 1
325319do
326320assert(a[i] == i)
327321;
@@ -331,21 +325,21 @@ a[f]=print
331325a[a]=a
332326assert(a[a][a][a][a][print] == assert)
333327a[print](a[a[f]] == a[print])
334−assert(not pcall(()
328+assert(not pcall(function ()
335329local a = {}
336330;
337331a[nil]=10
338332end))
339−assert(not pcall(()
333+assert(not pcall(function ()
340334local a = {[nil] = 10}
341335end))
342336assert(a[nil] == undef)
343337a=nil
344−local a,b,c =
345−a={10,9,8,7,6,5,4,3,2,[- 3] = "a",[f] = print,["a"] = "a",["b"] = "ab"}
338+local a,b,c
339+a={10,9,8,7,6,5,4,3,2,[- 3] = "\97",[f] = print,["\97"] = "\97",["\98"] = "\97\98"}
346340a,a.x,a.y=a,a[- 3]
347−assert(a[1] == 10 and a[- 3] == a.a and a[f] == print and a.x == "a" and not a.y)
348−a[1],f(a)[2],b,c={["alo"] = assert},10,a[1],a[f],6,10,23,f(a),2
341+assert(a[1] == 10 and a[- 3] == a.a and a[f] == print and a.x == "\97" and not a.y)
342+a[1],f(a)[2],b,c={["\97\108\111"] = assert},10,a[1],a[f],6,10,23,f(a),2
349343a[1].alo(a[2] == 10 and b == 10 and c == print)
350344a.aVeryLongName012345678901234567890123456789012345678901234567890123456789=10
351345local function foo
@@ -353,33 +347,37 @@ local function foo
353347return a.aVeryLongName012345678901234567890123456789012345678901234567890123456789
354348end
355349assert(foo() == 10 and a.aVeryLongName012345678901234567890123456789012345678901234567890123456789 == 10)
350+do
356351local function foo
357352()
358353local _ENV <const> = 11
359−X="hi"
354+X="\104\105"
360355end
361356local st,msg = pcall(foo)
362−assert(not st and string.find(msg,"number"))
357+assert(not st and string.find(msg,"\110\117\109\98\101\114"))
358+end
363359local maxint = math.maxinteger
364−while maxint ~= (maxint + 0) or (maxint - 1) ~= (maxint - 1) do
360+while maxint ~= (maxint + 0.0) or (maxint - 1) ~= (maxint - 1.0) do
365361maxint=maxint // 2
366−local maxintF = maxint + 0
367−assert(maxintF == maxint and math.type(maxintF) == "float" and maxintF >= 2 ^ 14)
362+end
363+local maxintF = maxint + 0.0
364+assert(maxintF == maxint and math.type(maxintF) == "\102\108\111\97\116" and maxintF >= 2.0 ^ 14)
368365a[maxintF]=10
369366;
370−a[maxintF - 1]=11
367+a[maxintF - 1.0]=11
371368;
372369a[- maxintF]=12
373370;
374−a[- maxintF + 1]=13
371+a[- maxintF + 1.0]=13
375372;
376373assert(a[maxint] == 10 and a[maxint - 1] == 11 and a[- maxint] == 12 and a[- maxint + 1] == 13)
377374a[maxint]=20
378375a[- maxint]=22
379−assert(a[maxintF] == 20 and a[maxintF - 1] == 11 and a[- maxintF] == 22 and a[- maxintF + 1] == 13)
376+assert(a[maxintF] == 20 and a[maxintF - 1.0] == 11 and a[- maxintF] == 22 and a[- maxintF + 1.0] == 13)
380377a=nil
381−local a,i,j,b =
382−a={"a","b"}
378+do
379+local a,i,j,b
380+a={"\97","\98"}
383381;
384382i=1
385383;
@@ -395,8 +393,10 @@ b,a.x,a=a,10,20
395393end
396394foo()
397395assert(a == 20 and b.x == 10)
398−local a,i,j,b =
399−a={"a","b"}
396+end
397+do
398+local a,i,j,b
399+a={"\97","\98"}
400400;
401401i=1
402402;
@@ -410,21 +410,22 @@ end
410410foo()
411411assert(i == 2 and b[1] == 1 and a == 1 and j == b and b[2] == 2 and b[3] == 1)
412412local t = {}
413−((a)
413+(function (a)
414414t[a],a=10,20
415415end)(1)
416416;
417417assert(t[1] == 10)
418+end
418419local function foo
419420()
420−local a =
421−return ()
422−local b =
421+local a
422+return function ()
423+local b
423424a,b=3,14
424425return a,b
425426end
426427end
427428local a,b = foo()()
428429assert(a == 3 and b == 14)
429−print("OK")
430+print("\79\75")
430431return res
zod/luau/res/lua/cycled/big.lua+32−34
@@ -1,22 +1,20 @@
11if _soft then
2−return "a"
2+return "\97"
33end
4−print("testing large tables")
5−local debug = require("debug")
6−local lim = 2 ^ 18 + 1e3
7−local prog = {"local y = {0"}
4+print("\116\101\115\116\105\110\103\32\108\97\114\103\101\32\116\97\98\108\101\115")
5+local debug = require("\100\101\98\117\103")
6+local lim = 2 ^ 18 + 1000
7+local prog = {"\108\111\99\97\108\32\121\32\61\32\123\48"}
88for i = 1, lim
99do
1010prog[# prog + 1]=i
1111end
12−prog[# prog + 1]="}
13−"
14−prog[# prog + 1]="X = y
15−"
16−prog[# prog + 1]=("assert(X[%d] == %d)"):format(lim - 1,lim - 2)
17−prog[# prog + 1]="return 0"
18−prog=table.concat(prog,";")
19−local env = {["string"] = string,["assert"] = assert}
12+prog[# prog + 1]="\125\10"
13+prog[# prog + 1]="\88\32\61\32\121\10"
14+prog[# prog + 1]=("\97\115\115\101\114\116\40\88\91\37\100\93\32\61\61\32\37\100\41"):format(lim - 1,lim - 2)
15+prog[# prog + 1]="\114\101\116\117\114\110\32\48"
16+prog=table.concat(prog,"\59")
17+local env = {["\115\116\114\105\110\103"] = string,["\97\115\115\101\114\116"] = assert}
2018local f = assert(load(prog,nil,nil,env))
2119f()
2220assert(env.X[lim] == lim - 1 and env.X[lim + 1] == lim)
@@ -24,46 +22,46 @@ for k in pairs(env)
2422do
2523env[k]=undef
2624end
27−setmetatable(env,{["__index"] = (t,n)
28−coroutine.yield("g")
25+setmetatable(env,{["\95\95\105\110\100\101\120"] = function (t,n)
26+coroutine.yield("\103")
2927;
3028return _G[n]
31−end,["__newindex"] = (t,n,v)
32−coroutine.yield("s")
29+end,["\95\95\110\101\119\105\110\100\101\120"] = function (t,n,v)
30+coroutine.yield("\115")
3331;
3432_G[n]=v
3533end})
3634X=nil
3735local co = coroutine.wrap(f)
38−assert(co() == "s")
39−assert(co() == "g")
40−assert(co() == "g")
36+assert(co() == "\115")
37+assert(co() == "\103")
38+assert(co() == "\103")
4139assert(co() == 0)
4240assert(X[lim] == lim - 1 and X[lim + 1] == lim)
43−getmetatable(env).__index=()
41+getmetatable(env).__index=function ()
4442
4543end
46−getmetatable(env).__newindex=()
44+getmetatable(env).__newindex=function ()
4745
4846end
4947local e,m = pcall(f)
50−assert(not e and m:find("global 'X'"))
51−getmetatable(env).__newindex=()
52−error("hi")
48+assert(not e and m:find("\103\108\111\98\97\108\32\39\88\39"))
49+getmetatable(env).__newindex=function ()
50+error("\104\105")
5351end
5452local e,m = xpcall(f,debug.traceback)
55−assert(not e and m:find("'newindex'"))
53+assert(not e and m:find("\39\110\101\119\105\110\100\101\120\39"))
5654f,X=nil
57−coroutine.yield("b")
55+coroutine.yield("\98")
5856if 2 ^ 32 == 0 then
59−print("testing string length overflow")
57+print("\116\101\115\116\105\110\103\32\115\116\114\105\110\103\32\108\101\110\103\116\104\32\111\118\101\114\102\108\111\119")
6058local repstrings = 192
61−local ssize = math.ceil(2 ^ 32 / repstrings) + 1
62−assert(repstrings * ssize > 2 ^ 32)
59+local ssize = math.ceil(2.0 ^ 32 / repstrings) + 1
60+assert(repstrings * ssize > 2.0 ^ 32)
6361local longs = string.rep("",ssize)
64−local rep = assert(load("local a = ...; return " .. string.rep("a",repstrings,"..")))
62+local rep = assert(load("\108\111\99\97\108\32\97\32\61\32\46\46\46\59\32\114\101\116\117\114\110\32" .. string.rep("\97",repstrings,"\46\46")))
6563local a,b = pcall(rep,longs)
66−assert(not a and string.find(b,"overflow"))
64+assert(not a and string.find(b,"\111\118\101\114\102\108\111\119"))
6765end
68−print("OK")
69−return "a"
66+print("\79\75")
67+return "\97"
zod/luau/res/lua/cycled/bitwise.lua+57−55
@@ -1,9 +1,9 @@
1−print("testing bitwise operations")
2−require("bwcoercion")
3−local numbits = string.packsize("j") * 8
1+print("\116\101\115\116\105\110\103\32\98\105\116\119\105\115\101\32\111\112\101\114\97\116\105\111\110\115")
2+require("\98\119\99\111\101\114\99\105\111\110")
3+local numbits = string.packsize("\106") * 8
44assert(~ 0 == - 1)
55assert((1 << (numbits - 1)) == math.mininteger)
6−local a,b,c,d =
6+local a,b,c,d
77a=18446744073709551615
88assert(a == - 1 and a & - 1 == a and a & 35 == 35)
99a=17361641481138401520
@@ -18,13 +18,13 @@ c=170
1818;
1919d=253
2020assert(a | b ~ c & d == 244)
21−a=240
21+a=240.0
2222;
23−b=204
23+b=204.0
2424;
25−c="0xAA.0"
25+c="\48\120\65\65\46\48"
2626;
27−d="0xFD.0"
27+d="\48\120\70\68\46\48"
2828assert(a | b ~ c & d == 244)
2929a=4026531840
3030;
@@ -41,14 +41,16 @@ c=c << 32
4141d=d << 32
4242assert(a | b ~ c & d == 4093640704 << 32)
4343assert(~ ~ a == a and ~ a == - 1 ~ a and - d == ~ d + 1)
44−local code = string.format("return -1 >> %d",math.maxinteger)
44+do
45+local code = string.format("\114\101\116\117\114\110\32\45\49\32\62\62\32\37\100",math.maxinteger)
4546assert(load(code)() == 0)
46−local code = string.format("return -1 >> %d",math.mininteger)
47+local code = string.format("\114\101\116\117\114\110\32\45\49\32\62\62\32\37\100",math.mininteger)
4748assert(load(code)() == 0)
48−local code = string.format("return -1 << %d",math.maxinteger)
49+local code = string.format("\114\101\116\117\114\110\32\45\49\32\60\60\32\37\100",math.maxinteger)
4950assert(load(code)() == 0)
50−local code = string.format("return -1 << %d",math.mininteger)
51+local code = string.format("\114\101\116\117\114\110\32\45\49\32\60\60\32\37\100",math.mininteger)
5152assert(load(code)() == 0)
53+end
5254assert(- 1 >> 1 == (1 << (numbits - 1)) - 1 and 1 << 31 == 2147483648)
5355assert(- 1 >> (numbits - 1) == 1)
5456assert(- 1 >> numbits == 0 and - 1 >> - numbits == 0 and - 1 << numbits == 0 and - 1 << - numbits == 0)
@@ -58,35 +60,35 @@ assert(1 << math.mininteger == 0)
5860assert(1 << math.maxinteger == 0)
5961assert((2 ^ 30 - 1) << 2 ^ 30 == 0)
6062assert((2 ^ 30 - 1) >> 2 ^ 30 == 0)
61−assert(1 >> - 3 == 1 << 3 and 1e3 >> 5 == 1e3 << - 5)
62−assert("0xffffffffffffffff" | 0 == - 1)
63−assert("0xfffffffffffffffe" & "-1" == - 2)
64−assert(" -0xfffffffffffffffe
65− " & "-1" == 2)
66−assert("
67− -45 " >> " -2 " == - 45 * 4)
68−assert("1234.0" << "5.0" == 1234 * 32)
69−assert("0xffff.0" ~ "0xAAAA" == 21845)
70−assert(~ "0x0.000p4" == - 1)
71−assert(("7" .. 3) << 1 == 146)
72−assert(4294967295 >> (1 .. "9") == 8191)
73−assert(10 | (1 .. "9") == 27)
74−local st,msg = pcall(()
75−return 4 & "a"
63+assert(1 >> - 3 == 1 << 3 and 1000 >> 5 == 1000 << - 5)
64+assert("\48\120\102\102\102\102\102\102\102\102\102\102\102\102\102\102\102\102" | 0 == - 1)
65+assert("\48\120\102\102\102\102\102\102\102\102\102\102\102\102\102\102\102\101" & "\45\49" == - 2)
66+assert("\32\9\45\48\120\102\102\102\102\102\102\102\102\102\102\102\102\102\102\102\101\10\9" & "\45\49" == 2)
67+assert("\32\32\32\10\32\32\45\52\53\32\32\9\32" >> "\32\32\45\50\32\32" == - 45 * 4)
68+assert("\49\50\51\52\46\48" << "\53\46\48" == 1234 * 32)
69+assert("\48\120\102\102\102\102\46\48" ~ "\48\120\65\65\65\65" == 21845)
70+assert(~ "\48\120\48\46\48\48\48\112\52" == - 1)
71+assert(("\55" .. 3) << 1 == 146)
72+assert(4294967295 >> (1 .. "\57") == 8191)
73+assert(10 | (1 .. "\57") == 27)
74+do
75+local st,msg = pcall(function ()
76+return 4 & "\97"
7677end)
77−assert(string.find(msg,"'band'"))
78−local st,msg = pcall(()
79−return ~ "a"
78+assert(string.find(msg,"\39\98\97\110\100\39"))
79+local st,msg = pcall(function ()
80+return ~ "\97"
8081end)
81−assert(string.find(msg,"'bnot'"))
82−assert(not pcall(()
83−return "0xffffffffffffffff.0" | 0
82+assert(string.find(msg,"\39\98\110\111\116\39"))
83+end
84+assert(not pcall(function ()
85+return "\48\120\102\102\102\102\102\102\102\102\102\102\102\102\102\102\102\102\46\48" | 0
8486end))
85−assert(not pcall(()
86−return "0xffffffffffffffff" | 0
87+assert(not pcall(function ()
88+return "\48\120\102\102\102\102\102\102\102\102\102\102\102\102\102\102\102\102" | 0
8789end))
88−print("+")
89−package.preload.bit32=()
90+print("\43")
91+package.preload.bit32=function ()
9092local bit = {}
9193function bit.bnot(a)
9294return ~ a & 4294967295
@@ -159,9 +161,9 @@ end
159161local function checkfield
160162(f,w)
161163w=w or 1
162−assert(f >= 0,"field cannot be negative")
163−assert(w > 0,"width must be positive")
164−assert(f + w <= 32,"trying to access non-existent bits")
164+assert(f >= 0,"\102\105\101\108\100\32\99\97\110\110\111\116\32\98\101\32\110\101\103\97\116\105\118\101")
165+assert(w > 0,"\119\105\100\116\104\32\109\117\115\116\32\98\101\32\112\111\115\105\116\105\118\101")
166+assert(f + w <= 32,"\116\114\121\105\110\103\32\116\111\32\97\99\99\101\115\115\32\110\111\110\45\101\120\105\115\116\101\110\116\32\98\105\116\115")
165167return f,~ (- 1 << w)
166168end
167169function bit.extract(a,f,w)
@@ -176,8 +178,8 @@ return a & 4294967295
176178end
177179return bit
178180end
179−print("testing bitwise library")
180−local bit32 = require("bit32")
181+print("\116\101\115\116\105\110\103\32\98\105\116\119\105\115\101\32\108\105\98\114\97\114\121")
182+local bit32 = require("\98\105\116\51\50")
181183assert(bit32.band() == bit32.bnot(0))
182184assert(bit32.btest() == true)
183185assert(bit32.bor() == 0)
@@ -234,7 +236,7 @@ assert(305419896 >> 4 == 19088743)
234236assert(305419896 >> 8 == 1193046)
235237assert(305419896 >> 32 == 0)
236238assert(305419896 >> - 32 == 1311768464867721216)
237−print("+")
239+print("\43")
238240local c = {0,1,2,3,10,2147483648,2863311530,1431655765,4294967295,2147483647}
239241for _,b in pairs(c)
240242do
@@ -270,16 +272,16 @@ do
270272for i = - 40, 40
271273do
272274local x = bit32.lshift(b,i)
273−local y = math.floor(math.fmod(b * 2 ^ i,2 ^ 32))
274−assert(math.fmod(x - y,2 ^ 32) == 0)
275+local y = math.floor(math.fmod(b * 2.0 ^ i,2.0 ^ 32))
276+assert(math.fmod(x - y,2.0 ^ 32) == 0)
275277end
276278end
277279assert(not pcall(bit32.band,{}))
278−assert(not pcall(bit32.bnot,"a"))
280+assert(not pcall(bit32.bnot,"\97"))
279281assert(not pcall(bit32.lshift,45))
280282assert(not pcall(bit32.lshift,45,print))
281283assert(not pcall(bit32.rshift,45,print))
282−print("+")
284+print("\43")
283285assert(bit32.extract(305419896,0,4) == 8)
284286assert(bit32.extract(305419896,4,4) == 7)
285287assert(bit32.extract(2684358929,28,4) == 10)
@@ -296,12 +298,12 @@ assert(bit32.replace(0,1,2) == 2 ^ 2)
296298assert(bit32.replace(0,- 1,4) == 2 ^ 4)
297299assert(bit32.replace(- 1,0,31) == (1 << 31) - 1)
298300assert(bit32.replace(- 1,0,1,2) == (1 << 32) - 7)
299−assert(bit32.bor(3) == 3)
300−assert(bit32.bor(- 4) == 4294967292)
301−if 2 ^ 50 < 2 ^ 50 + 1 and 2 ^ 50 < (- 1 >> 1) then
302−assert(bit32.bor(2 ^ 32 - 5) == 4294967291)
303−assert(bit32.bor(- 2 ^ 32 - 6) == 4294967290)
304−assert(bit32.bor(2 ^ 48 - 5) == 4294967291)
305−assert(bit32.bor(- 2 ^ 48 - 6) == 4294967290)
301+assert(bit32.bor(3.0) == 3)
302+assert(bit32.bor(- 4.0) == 4294967292)
303+if 2.0 ^ 50 < 2.0 ^ 50 + 1.0 and 2.0 ^ 50 < (- 1 >> 1) then
304+assert(bit32.bor(2.0 ^ 32 - 5.0) == 4294967291)
305+assert(bit32.bor(- 2.0 ^ 32 - 6.0) == 4294967290)
306+assert(bit32.bor(2.0 ^ 48 - 5.0) == 4294967291)
307+assert(bit32.bor(- 2.0 ^ 48 - 6.0) == 4294967290)
306308end
307−print("OK")
309+print("\79\75")
zod/luau/res/lua/cycled/bwcoercion.lua+14−14
@@ -13,14 +13,14 @@ return tointeger(x)
1313end
1414local function trymt
1515(x,y,mtname)
16−if type(y) ~= "string" then
16+if type(y) ~= "\115\116\114\105\110\103" then
1717local mt = getmetatable(y)
1818local mm = mt and rawget(mt,mtname)
1919if mm then
2020return mm(x,y)
2121end
2222end
23−error("attempt to '" .. strsub(mtname,3) .. "' a " .. type(x) .. " with a " .. type(y),4)
23+error("\97\116\116\101\109\112\116\32\116\111\32\39" .. strsub(mtname,3) .. "\39\32\97\32" .. type(x) .. "\32\119\105\116\104\32\97\32" .. type(y),4)
2424end
2525local function checkargs
2626(x,y,mtname)
@@ -33,27 +33,27 @@ return trymt(x,y,mtname),nil
3333end
3434end
3535local smt = getmetatable("")
36−smt.__band=(x,y)
37−local x,y = checkargs(x,y,"__band")
36+smt.__band=function (x,y)
37+local x,y = checkargs(x,y,"\95\95\98\97\110\100")
3838return y and x & y or x
3939end
40−smt.__bor=(x,y)
41−local x,y = checkargs(x,y,"__bor")
40+smt.__bor=function (x,y)
41+local x,y = checkargs(x,y,"\95\95\98\111\114")
4242return y and x | y or x
4343end
44−smt.__bxor=(x,y)
45−local x,y = checkargs(x,y,"__bxor")
44+smt.__bxor=function (x,y)
45+local x,y = checkargs(x,y,"\95\95\98\120\111\114")
4646return y and x ~ y or x
4747end
48−smt.__shl=(x,y)
49−local x,y = checkargs(x,y,"__shl")
48+smt.__shl=function (x,y)
49+local x,y = checkargs(x,y,"\95\95\115\104\108")
5050return y and x << y or x
5151end
52−smt.__shr=(x,y)
53−local x,y = checkargs(x,y,"__shr")
52+smt.__shr=function (x,y)
53+local x,y = checkargs(x,y,"\95\95\115\104\114")
5454return y and x >> y or x
5555end
56−smt.__bnot=(x)
57−local x,y = checkargs(x,x,"__bnot")
56+smt.__bnot=function (x)
57+local x,y = checkargs(x,x,"\95\95\98\110\111\116")
5858return y and ~ x or x
5959end
zod/luau/res/lua/cycled/calls.lua+134−125
@@ -1,16 +1,17 @@
1−print("testing functions and calls")
2−local debug = require("debug")
3−assert(type(1 < 2) == "boolean")
4−assert(type(true) == "boolean" and type(false) == "boolean")
5−assert(type(nil) == "nil" and type(- 3) == "number" and type("x") == "string" and type({}) == "table" and type(type) == "function")
1+print("\116\101\115\116\105\110\103\32\102\117\110\99\116\105\111\110\115\32\97\110\100\32\99\97\108\108\115")
2+local debug = require("\100\101\98\117\103")
3+assert(type(1 < 2) == "\98\111\111\108\101\97\110")
4+assert(type(true) == "\98\111\111\108\101\97\110" and type(false) == "\98\111\111\108\101\97\110")
5+assert(type(nil) == "\110\105\108" and type(- 3) == "\110\117\109\98\101\114" and type("\120") == "\115\116\114\105\110\103" and type({}) == "\116\97\98\108\101" and type(type) == "\102\117\110\99\116\105\111\110")
66assert(type(assert) == type(print))
77local function f
88(x)
99return a:x(x)
1010end
11−assert(type(f) == "function")
11+assert(type(f) == "\102\117\110\99\116\105\111\110")
1212assert(not pcall(type))
1313fact=false
14+do
1415local res = 1
1516local function fact
1617(n)
@@ -21,9 +22,10 @@ return n * fact(n - 1)
2122end
2223end
2324assert(fact(5) == 120)
25+end
2426assert(fact == false)
2527fact=nil
26−local a = {["i"] = 10}
28+local a = {["\105"] = 10}
2729local self = 20
2830function a:x(x)
2931return x + self.i
@@ -32,19 +34,21 @@ function a.y(x)
3234return x + self
3335end
3436assert(a:x(1) + 10 == a.y(1))
35−a.t={["i"] = - 100}
36−a["t"].x=(self,a,b)
37+a.t={["\105"] = - 100}
38+a["\116"].x=function (self,a,b)
3739return self.i + a + b
3840end
3941assert(a.t:x(2,3) == - 95)
40−local a = {["x"] = 0}
42+do
43+local a = {["\120"] = 0}
4144function a:add(x)
4245self.x,a.y=self.x + x,20
4346;
4447return self
4548end
4649assert(a:add(10):add(20):add(30).x == 60 and a.y == 20)
47−local a = {["b"] = {["c"] = {}}}
50+end
51+local a = {["\98"] = {["\99"] = {}}}
4852function a.b.c.f1(x)
4953return x + 1
5054end
@@ -52,34 +56,34 @@ function a.b.c:f2(x,y)
5256self[x]=y
5357end
5458assert(a.b.c.f1(4) == 5)
55−a.b.c:f2("k",12)
59+a.b.c:f2("\107",12)
5660;
5761assert(a.b.c.k == 12)
58−print("+")
62+print("\43")
5963t=nil
6064function f(a,b,c)
61−local d = "a"
65+local d = "\97"
6266;
6367t={a,b,c,d}
6468end
6569f(1,2)
66−assert(t[1] == 1 and t[2] == 2 and t[3] == nil and t[4] == "a")
70+assert(t[1] == 1 and t[2] == 2 and t[3] == nil and t[4] == "\97")
6771f(1,2,3,4)
68−assert(t[1] == 1 and t[2] == 2 and t[3] == 3 and t[4] == "a")
72+assert(t[1] == 1 and t[2] == 2 and t[3] == 3 and t[4] == "\97")
6973t=nil
7074function fat(x)
7175if x <= 1 then
7276return 1
7377else
74−return x * load("return fat(" .. x - 1 .. ")","")()
78+return x * load("\114\101\116\117\114\110\32\102\97\116\40" .. x - 1 .. "\41","")()
7579end
7680end
77−assert(load("load 'assert(fat(6)==720)' () "))()
78−a=load("return fat(5), 3")
81+assert(load("\108\111\97\100\32\39\97\115\115\101\114\116\40\102\97\116\40\54\41\61\61\55\50\48\41\39\32\40\41\32"))()
82+a=load("\114\101\116\117\114\110\32\102\97\116\40\53\41\44\32\51")
7983local a,b = a()
8084assert(a == 120 and b == 3)
8185fat=nil
82−print("+")
86+print("\43")
8387local function err_on_n
8488(n)
8589if n == 0 then
@@ -94,6 +98,7 @@ exit(1)
9498;
9599end
96100end
101+do
97102local function dummy
98103(n)
99104if n > 0 then
@@ -102,6 +107,7 @@ dummy(n - 1)
102107end
103108end
104109dummy(10)
110+end
105111_G.deep=nil
106112function deep(n)
107113if n > 0 then
@@ -110,7 +116,7 @@ end
110116end
111117deep(10)
112118deep(180)
113−print("testing tail calls")
119+print("\116\101\115\116\105\110\103\32\116\97\105\108\32\99\97\108\108\115")
114120function deep(n)
115121if n > 0 then
116122return deep(n - 1)
@@ -118,7 +124,7 @@ else
118124return 101
119125end
120126end
121−assert(deep(3e4) == 101)
127+assert(deep(30000) == 101)
122128a={}
123129function a:deep(n)
124130if n > 0 then
@@ -127,7 +133,8 @@ else
127133return 101
128134end
129135end
130−assert(a:deep(3e4) == 101)
136+assert(a:deep(30000) == 101)
137+do
131138local function foo
132139(x, ...)
133140local a = {...}
@@ -140,18 +147,18 @@ return foo(10,x,x + 1)
140147end
141148local a,b,c = foo1(- 2)
142149assert(a == 10 and b == - 2 and c == - 1)
143−local t = setmetatable({},{["__call"] = foo})
150+local t = setmetatable({},{["\95\95\99\97\108\108"] = foo})
144151local function foo2
145152(x)
146153return t(10,x)
147154end
148155a,b,c=foo2(100)
149156assert(a == t and b == 10 and c == 100)
150−a,b=(()
157+a,b=(function ()
151158return foo()
152159end)()
153160assert(a == nil and b == nil)
154−local X,Y,A =
161+local X,Y,A
155162local function foo
156163(x,y, ...)
157164X=x
@@ -172,13 +179,17 @@ a,b,c=foo1(10,20)
172179assert(X == 10 and Y == 20 and # A == 0)
173180a,b,c=foo1(10,20,30)
174181assert(X == 10 and Y == 20 and # A == 1 and A[1] == 30)
182+end
183+do
175184local function loop
176185()
177186assert(pcall(loop))
178187end
179188local err,msg = xpcall(loop,loop)
180−assert(not err and string.find(msg,"error"))
181−local n = 1e4
189+assert(not err and string.find(msg,"\101\114\114\111\114"))
190+end
191+do
192+local n = 10000
182193local function foo
183194()
184195if n == 0 then
@@ -191,43 +202,46 @@ end
191202end
192203for i = 1, 100
193204do
194−foo=setmetatable({},{["__call"] = foo})
205+foo=setmetatable({},{["\95\95\99\97\108\108"] = foo})
195206end
196−assert(coroutine.wrap(()
207+assert(coroutine.wrap(function ()
197208return foo()
198209end)() == 1023)
199−print("+")
210+end
211+print("\43")
212+do
200213local N = 20
201214local u = table.pack
202215for i = 1, N
203216do
204−u=setmetatable({i},{["__call"] = u})
217+u=setmetatable({i},{["\95\95\99\97\108\108"] = u})
205218end
206−local Res = u("a","b","c")
219+local Res = u("\97","\98","\99")
207220assert(Res.n == N + 3)
208221for i = 1, N
209222do
210223assert(Res[i][1] == i)
211224end
212−assert(Res[N + 1] == "a" and Res[N + 2] == "b" and Res[N + 3] == "c")
225+assert(Res[N + 1] == "\97" and Res[N + 2] == "\98" and Res[N + 3] == "\99")
226+end
213227a=nil
214−((x)
228+(function (x)
215229a=x
216230end)(23)
217−assert(a == 23 and ((x)
231+assert(a == 23 and (function (x)
218232return x * 2
219233end)(20) == 40)
220−local Z = (le)
234+local Z = function (le)
221235local function a
222236(f)
223−return le((x)
237+return le(function (x)
224238return f(f)(x)
225239end)
226240end
227241return a(a)
228242end
229−local F = (f)
230−return (n)
243+local F = function (f)
244+return function (n)
231245if n == 0 then
232246return 1
233247else
@@ -241,7 +255,7 @@ local function g
241255(z)
242256local function f
243257(a,b,c,d)
244−return (x,y)
258+return function (x,y)
245259return a + b + c + d + a + x + y + z
246260end
247261end
@@ -249,7 +263,7 @@ return f(z,z + 1,z + 2,z + 3)
249263end
250264local f = g(10)
251265assert(f(9,16) == 10 + 11 + 12 + 13 + 10 + 9 + 16 + 10)
252−print("+")
266+print("\43")
253267local function unlpack
254268(t,i)
255269i=i or 1
@@ -265,7 +279,7 @@ do
265279assert(t1[i] == t2[i])
266280end
267281end
268−local pack = (...)
282+local pack = function (...)
269283return (table.pack(...))
270284end
271285local function f
@@ -278,7 +292,7 @@ return a,b
278292end
279293local a,b,c,d = unlpack({1,2,3})
280294assert(a == 1 and b == 2 and c == 3 and d == nil)
281−a={1,2,3,4,false,10,"alo",false,assert}
295+a={1,2,3,4,false,10,"\97\108\111",false,assert}
282296equaltab(pack(unlpack(a)),a)
283297equaltab(pack(unlpack(a),- 1),{1,- 1})
284298a,b,c,d=ret2(f()),ret2(f())
@@ -287,23 +301,19 @@ a,b,c,d=unlpack(pack(ret2(f()),ret2(f())))
287301assert(a == 1 and b == 1 and c == 2 and d == nil)
288302a,b,c,d=unlpack(pack(ret2(f()),(ret2(f()))))
289303assert(a == 1 and b == 1 and c == nil and d == nil)
290−a=ret2({unlpack({1,2,3}),unlpack({3,2,1}),unlpack({"a","b"})})
291−assert(a[1] == 1 and a[2] == 3 and a[3] == "a" and a[4] == "b")
292−rawget({},"x",1)
293−rawset({},"x",1,2)
304+a=ret2({unlpack({1,2,3}),unlpack({3,2,1}),unlpack({"\97","\98"})})
305+assert(a[1] == 1 and a[2] == 3 and a[3] == "\97" and a[4] == "\98")
306+rawget({},"\120",1)
307+rawset({},"\120",1,2)
294308assert(math.sin(1,2) == math.sin(1))
295−table.sort({10,9,8,4,19,23,0,0},(a,b)
309+table.sort({10,9,8,4,19,23,0,0},function (a,b)
296310return a < b
297−end,"extra arg")
298−local x = "-- a comment
299− x = 10 +
300−23;
301− local a = function () x = 'hi' end;
302− return ''"
311+end,"\101\120\116\114\97\32\97\114\103")
312+local x = "\45\45\32\97\32\99\111\109\109\101\110\116\10\32\32\120\32\61\32\49\48\32\43\32\10\50\51\59\32\10\32\32\32\32\32\108\111\99\97\108\32\97\32\61\32\102\117\110\99\116\105\111\110\32\40\41\32\120\32\61\32\39\104\105\39\32\101\110\100\59\32\10\32\32\32\32\32\114\101\116\117\114\110\32\39\39"
303313local function read1
304314(x)
305315local i = 0
306−return ()
316+return function ()
307317collectgarbage()
308318i=i + 1
309319return string.sub(x,i,i)
@@ -313,46 +323,48 @@ local function cannotload
313323(msg,a,b)
314324assert(not a and string.find(b,msg))
315325end
316−a=assert(load(read1(x),"modname","t",_G))
326+a=assert(load(read1(x),"\109\111\100\110\97\109\101","\116",_G))
317327assert(a() == "" and _G.x == 33)
318−assert(debug.getinfo(a).source == "modname")
319−cannotload("attempt to load a text chunk",load(read1(x),"modname","b",{}))
320−cannotload("attempt to load a text chunk",load(x,"modname","b"))
321−a=assert(load(()
328+assert(debug.getinfo(a).source == "\109\111\100\110\97\109\101")
329+cannotload("\97\116\116\101\109\112\116\32\116\111\32\108\111\97\100\32\97\32\116\101\120\116\32\99\104\117\110\107",load(read1(x),"\109\111\100\110\97\109\101","\98",{}))
330+cannotload("\97\116\116\101\109\112\116\32\116\111\32\108\111\97\100\32\97\32\116\101\120\116\32\99\104\117\110\107",load(x,"\109\111\100\110\97\109\101","\98"))
331+a=assert(load(function ()
322332return nil
323333end))
324334a()
325−assert(not load(()
335+assert(not load(function ()
326336return true
327337end))
328−local t = {nil,"return ","3"}
329−f,msg=load(()
338+local t = {nil,"\114\101\116\117\114\110\32","\51"}
339+f,msg=load(function ()
330340return table.remove(t,1)
331341end)
332342assert(f() == nil)
333−f=load(string.dump(()
343+f=load(string.dump(function ()
334344return 1
335−end),nil,"b",{})
336−assert(type(f) == "function" and f() == 1)
337−local f = string.dump(()
338−return "01234567890123456789012345678901234567890123456789"
345+end),nil,"\98",{})
346+assert(type(f) == "\102\117\110\99\116\105\111\110" and f() == 1)
347+do
348+local f = string.dump(function ()
349+return "\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57"
339350end)
340351f=load(read1(f))
341−assert(f() == "01234567890123456789012345678901234567890123456789")
342−x=string.dump(load("x = 1; return x"))
343−a=assert(load(read1(x),nil,"b"))
352+assert(f() == "\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57")
353+end
354+x=string.dump(load("\120\32\61\32\49\59\32\114\101\116\117\114\110\32\120"))
355+a=assert(load(read1(x),nil,"\98"))
344356assert(a() == 1 and _G.x == 1)
345−cannotload("attempt to load a binary chunk",load(read1(x),nil,"t"))
346−cannotload("attempt to load a binary chunk",load(x,nil,"t"))
357+cannotload("\97\116\116\101\109\112\116\32\116\111\32\108\111\97\100\32\97\32\98\105\110\97\114\121\32\99\104\117\110\107",load(read1(x),nil,"\116"))
358+cannotload("\97\116\116\101\109\112\116\32\116\111\32\108\111\97\100\32\97\32\98\105\110\97\114\121\32\99\104\117\110\107",load(x,nil,"\116"))
347359_G.x=nil
348360assert(not pcall(string.dump,print))
349−cannotload("unexpected symbol",load(read1("*a = 123")))
350−cannotload("unexpected symbol",load("*a = 123"))
351−cannotload("hhi",load(()
352−error("hhi")
361+cannotload("\117\110\101\120\112\101\99\116\101\100\32\115\121\109\98\111\108",load(read1("\42\97\32\61\32\49\50\51")))
362+cannotload("\117\110\101\120\112\101\99\116\101\100\32\115\121\109\98\111\108",load("\42\97\32\61\32\49\50\51"))
363+cannotload("\104\104\105",load(function ()
364+error("\104\104\105")
353365end))
354−assert(load("return _ENV",nil,nil,123)() == 123)
355−local x =
366+assert(load("\114\101\116\117\114\110\32\95\69\78\86",nil,nil,123)() == 123)
367+local x
356368;
357369XX=123
358370local function h
@@ -361,70 +373,64 @@ local y = x
361373return XX
362374end
363375local d = string.dump(h)
364−x=load(d,"","b")
365−assert(debug.getupvalue(x,2) == "_ENV")
376+x=load(d,"","\98")
377+assert(debug.getupvalue(x,2) == "\95\69\78\86")
366378debug.setupvalue(x,2,_G)
367379assert(x() == 123)
368−assert(assert(load("return XX + ...",nil,nil,{["XX"] = 13}))(4) == 17)
380+assert(assert(load("\114\101\116\117\114\110\32\88\88\32\43\32\46\46\46",nil,nil,{["\88\88"] = 13}))(4) == 17)
369381XX=nil
370−x=" return function (x)
371− return function (y)
372− return function (z)
373− return x+y+z
374− end
375− end
376− end
377−"
378−a=assert(load(read1(x),"read","t"))
382+x="\32\32\114\101\116\117\114\110\32\102\117\110\99\116\105\111\110\32\40\120\41\10\32\32\32\32\114\101\116\117\114\110\32\102\117\110\99\116\105\111\110\32\40\121\41\10\32\32\32\32\32\114\101\116\117\114\110\32\102\117\110\99\116\105\111\110\32\40\122\41\10\32\32\32\32\32\32\32\114\101\116\117\114\110\32\120\43\121\43\122\10\32\32\32\32\32\101\110\100\10\32\32\32\101\110\100\10\32\32\101\110\100\10"
383+a=assert(load(read1(x),"\114\101\97\100","\116"))
379384assert(a()(2)(3)(10) == 15)
380385x=string.dump(a)
381−a=assert(load(read1(x),"read","b"))
386+a=assert(load(read1(x),"\114\101\97\100","\98"))
382387assert(a()(2)(3)(10) == 15)
383388local a,b = 20,30
384−x=load(string.dump((x)
385−if x == "set" then
389+x=load(string.dump(function (x)
390+if x == "\115\101\116" then
386391a=10 + b
387392;
388393b=b + 1
389394else
390395return a
391396end
392−end),"","b",nil)
397+end),"","\98",nil)
393398assert(x() == nil)
394−assert(debug.setupvalue(x,1,"hi") == "a")
395−assert(x() == "hi")
396−assert(debug.setupvalue(x,2,13) == "b")
399+assert(debug.setupvalue(x,1,"\104\105") == "\97")
400+assert(x() == "\104\105")
401+assert(debug.setupvalue(x,2,13) == "\98")
397402assert(not debug.setupvalue(x,3,10))
398−x("set")
403+x("\115\101\116")
399404assert(x() == 23)
400−x("set")
405+x("\115\101\116")
401406assert(x() == 24)
407+do
402408local nup = 200
403−local prog = {"local a1"}
409+local prog = {"\108\111\99\97\108\32\97\49"}
404410for i = 2, nup
405411do
406−prog[# prog + 1]=", a" .. i
412+prog[# prog + 1]="\44\32\97" .. i
407413end
408−prog[# prog + 1]=" = 1"
414+prog[# prog + 1]="\32\61\32\49"
409415for i = 2, nup
410416do
411−prog[# prog + 1]=", " .. i
417+prog[# prog + 1]="\44\32" .. i
412418end
413419local sum = 1
414−prog[# prog + 1]="; return function () return a1"
420+prog[# prog + 1]="\59\32\114\101\116\117\114\110\32\102\117\110\99\116\105\111\110\32\40\41\32\114\101\116\117\114\110\32\97\49"
415421for i = 2, nup
416422do
417−prog[# prog + 1]=" + a" .. i
423+prog[# prog + 1]="\32\43\32\97" .. i
418424;
419425sum=sum + i
420426end
421−prog[# prog + 1]=" end"
427+prog[# prog + 1]="\32\101\110\100"
422428prog=table.concat(prog)
423429local f = assert(load(prog))()
424430assert(f() == sum)
425431f=load(string.dump(f))
426432local a = 10
427−local h = ()
433+local h = function ()
428434return a
429435end
430436for i = 1, nup
@@ -432,41 +438,43 @@ do
432438debug.upvaluejoin(f,i,h,1)
433439end
434440assert(f() == 10 * nup)
435−local t = {["x"] = 1}
441+end
442+do
443+local t = {["\120"] = 1}
436444function t:_012345678901234567890123456789012345678901234567890123456789()
437445return self.x
438446end
439447assert(t:_012345678901234567890123456789012345678901234567890123456789() == 1)
440−assert((()
448+end
449+assert((function ()
441450return nil
442451end)(4) == nil)
443−assert((()
444−local a =
452+assert((function ()
453+local a
445454;
446455return a
447456end)(4) == nil)
448−assert(((a)
457+assert((function (a)
449458return a
450459end)() == nil)
451−print("testing binary chunks")
452−local header = string.pack("c4BBc6BBB","Lua",84,0,"�
453−
454−",4,string.packsize("j"),string.packsize("n"))
455−local c = string.dump(()
460+print("\116\101\115\116\105\110\103\32\98\105\110\97\114\121\32\99\104\117\110\107\115")
461+do
462+local header = string.pack("\99\52\66\66\99\54\66\66\66","\27\76\117\97",84,0,"\25\147\13\10\26\10",4,string.packsize("\106"),string.packsize("\110"))
463+local c = string.dump(function ()
456464local a = 1
457465;
458466local b = 3
459467;
460−local f = ()
468+local f = function ()
461469return a + b + _ENV.c
462470end
463−local s1 = "a constant"
464−local s2 = "another constant"
471+local s1 = "\97\32\99\111\110\115\116\97\110\116"
472+local s2 = "\97\110\111\116\104\101\114\32\99\111\110\115\116\97\110\116"
465473return a + b * 3
466474end)
467475assert(assert(load(c))() == 10)
468476assert(string.sub(c,1,# header) == header)
469−local ci,cn = string.unpack("jn",c,# header + 1)
477+local ci,cn = string.unpack("\106\110",c,# header + 1)
470478assert(ci == 22136 and cn == 370.5)
471479for i = 1, # header
472480do
@@ -477,7 +485,8 @@ end
477485for i = 1, # c - 1
478486do
479487local st,msg = load(string.sub(c,1,i))
480−assert(not st and string.find(msg,"truncated"))
488+assert(not st and string.find(msg,"\116\114\117\110\99\97\116\101\100"))
489+end
481490end
482−print("OK")
491+print("\79\75")
483492return deep
zod/luau/res/lua/cycled/closure.lua+80−62
@@ -1,12 +1,13 @@
1−print("testing closures")
2−local A,B = 0,{["g"] = 10}
1+print("\116\101\115\116\105\110\103\32\99\108\111\115\117\114\101\115")
2+local A,B = 0,{["\103"] = 10}
33local function f
44(x)
55local a = {}
6−for i = 1, 1e3
6+for i = 1, 1000
77do
88local y = 0
9−a[i]=()
9+do
10+a[i]=function ()
1011B.g=B.g + 1
1112;
1213y=y + x
@@ -14,7 +15,8 @@ y=y + x
1415return y + A
1516end
1617end
17−local dummy = ()
18+end
19+local dummy = function ()
1820return a[A]
1921end
2022collectgarbage()
@@ -32,10 +34,11 @@ return a
3234end
3335local a = f(10)
3436local x = {[1] = {}}
35−setmetatable(x,{["__mode"] = "kv"})
37+setmetatable(x,{["\95\95\109\111\100\101"] = "\107\118"})
3638while x[1] do
3739local a = A .. A .. A .. A
3840A=A + 1
41+end
3942assert(a[1]() == 20 + A)
4043assert(a[1]() == 30 + A)
4144assert(a[2]() == 10 + A)
@@ -44,17 +47,18 @@ assert(a[2]() == 20 + A)
4447assert(a[2]() == 30 + A)
4548assert(a[3]() == 20 + A)
4649assert(a[8]() == 10 + A)
47−assert(getmetatable(x).__mode == "kv")
50+assert(getmetatable(x).__mode == "\107\118")
4851assert(B.g == 19)
4952a={}
5053for i = 1, 5
5154do
52−a[i]=(x)
55+a[i]=function (x)
5356return i + a + _ENV
5457end
5558end
5659assert(a[3] ~= a[4] and a[4] ~= a[5])
57−local a = (x)
60+do
61+local a = function (x)
5862return math.sin(_ENV[x])
5963end
6064local function f
@@ -62,12 +66,13 @@ local function f
6266return a
6367end
6468assert(f() == f())
69+end
6570a={}
6671for i = 1, 10
6772do
68−a[i]={["set"] = (x)
73+a[i]={["\115\101\116"] = function (x)
6974i=x
70−end,["get"] = ()
75+end,["\103\101\116"] = function ()
7176return i
7277end}
7378if i == 3 then
@@ -77,19 +82,19 @@ end
7782assert(a[4] == undef)
7883a[1].set(10)
7984assert(a[2].get() == 2)
80−a[2].set("a")
85+a[2].set("\97")
8186assert(a[3].get() == 3)
82−assert(a[2].get() == "a")
87+assert(a[2].get() == "\97")
8388a={}
84−local t = {"a","b"}
89+local t = {"\97","\98"}
8590for i = 1, # t
8691do
8792local k = t[i]
88−a[i]={["set"] = (x,y)
93+a[i]={["\115\101\116"] = function (x,y)
8994i=x
9095;
9196k=y
92−end,["get"] = ()
97+end,["\103\101\116"] = function ()
9398return i,k
9499end}
95100if i == 2 then
@@ -98,16 +103,16 @@ end
98103end
99104a[1].set(10,20)
100105local r,s = a[2].get()
101−assert(r == 2 and s == "b")
106+assert(r == 2 and s == "\98")
102107r,s=a[1].get()
103108assert(r == 10 and s == 20)
104−a[2].set("a","b")
109+a[2].set("\97","\98")
105110r,s=a[2].get()
106−assert(r == "a" and s == "b")
107−local f =
111+assert(r == "\97" and s == "\98")
112+local f
108113for i = 1, 3
109114do
110−f=()
115+f=function ()
111116return i
112117end
113118break
@@ -116,31 +121,33 @@ assert(f() == 1)
116121for k = 1, # t
117122do
118123local v = t[k]
119−f=()
124+f=function ()
120125return k,v
121126end
122127break
123128end
124129assert(({f()})[1] == 1)
125−assert(({f()})[2] == "a")
126−local b =
130+assert(({f()})[2] == "\97")
131+local b
127132function f(x)
128133local first = 1
129134while 1 do
130135if x == 3 and not first then
131136return
132137end
133−local a = "xuxu"
134−b=(op,y)
135−if op == "set" then
138+local a = "\120\117\120\117"
139+b=function (op,y)
140+if op == "\115\101\116" then
136141a=x + y
137142else
138143return a
139144end
140145end
141146if x == 1 then
147+do
142148break
143−elseifx == 2 then
149+end
150+elseif x == 2 then
144151return
145152else
146153if x ~= 3 then
@@ -149,25 +156,26 @@ end
149156end
150157first=nil
151158end
159+end
152160for i = 1, 3
153161do
154162f(i)
155−assert(b("get") == "xuxu")
156−b("set",10)
163+assert(b("\103\101\116") == "\120\117\120\117")
164+b("\115\101\116",10)
157165;
158−assert(b("get") == 10 + i)
166+assert(b("\103\101\116") == 10 + i)
159167b=nil
160168end
161169pcall(f,4)
162170;
163−assert(b("get") == "xuxu")
164−b("set",10)
171+assert(b("\103\101\116") == "\120\117\120\117")
172+b("\115\101\116",10)
165173;
166−assert(b("get") == 14)
167−local y,w =
174+assert(b("\103\101\116") == 14)
175+local y,w
168176function f(x)
169−return (y)
170−return (z)
177+return function (y)
178+return function (z)
171179return w + x + y + z
172180end
173181end
@@ -175,66 +183,72 @@ end
175183y=f(10)
176184w=1.345
177185assert(y(20)(30) == 60 + w)
178−local X,Y =
186+do
187+local X,Y
179188local a = math.sin(0)
180189while a do
181190local b = 10
182−X=()
191+X=function ()
183192return b
184193end
185194if a then
186195break
187196end
197+end
198+do
188199local b = 20
189−Y=()
200+Y=function ()
190201return b
191202end
203+end
192204assert(X() == 10 and Y() == 20)
205+end
193206local a = {}
194207local i = 1
195208repeat
196209local x = i
197−a[i]=()
210+a[i]=function ()
198211i=x + 1
199212;
200213return x
201−enduntil i > 10 or a[i]() ~= x
214+end
215+until i > 10 or a[i]() ~= x
202216assert(i == 11 and a[1]() == 1 and a[3]() == 3 and i == 4)
203217a={}
204218for i = 1, 10
205219do
206220if i % 3 == 0 then
207221local y = 0
208−a[i]=(x)
222+a[i]=function (x)
209223local t = y
210224;
211225y=x
212226;
213227return t
214228end
215−elseifi % 3 == 1 then
229+elseif i % 3 == 1 then
216230goto L1
217−error("not here")
231+error("\110\111\116\32\104\101\114\101")
218232::L1::
219233local y = 1
220−a[i]=(x)
234+a[i]=function (x)
221235local t = y
222236;
223237y=x
224238;
225239return t
226240end
227−elseifi % 3 == 2 then
228−local t =
241+elseif i % 3 == 2 then
242+local t
229243goto l4
230244::l4a::
231245a[i]=t
232246;
233247goto l4b
234−error("should never be here!")
248+error("\115\104\111\117\108\100\32\110\101\118\101\114\32\98\101\32\104\101\114\101\33")
235249::l4::
236250local y = 2
237−t=(x)
251+t=function (x)
238252local t = y
239253;
240254y=x
@@ -242,7 +256,7 @@ y=x
242256return t
243257end
244258goto l4a
245−error("should never be here!")
259+error("\115\104\111\117\108\100\32\110\101\118\101\114\32\98\101\32\104\101\114\101\33")
246260::l4b::
247261end
248262end
@@ -250,39 +264,43 @@ for i = 1, 10
250264do
251265assert(a[i](i * 10) == i % 3 and a[i]() == i * 10)
252266end
253−print("+")
267+print("\43")
254268local function t
255269()
256270local function c
257271(a,b)
258−assert(a == "test" and b == "OK")
272+assert(a == "\116\101\115\116" and b == "\79\75")
259273end
260274local function v
261275(f, ...)
262−c("test",f() ~= 1 and "FAILED" or "OK")
276+c("\116\101\115\116",f() ~= 1 and "\70\65\73\76\69\68" or "\79\75")
263277end
264278local x = 1
265−return v(()
279+return v(function ()
266280return x
267281end)
268282end
269283t()
270−local debug = require("debug")
271−local foo1,foo2,foo3 =
284+local debug = require("\100\101\98\117\103")
285+local foo1,foo2,foo3
286+do
272287local a,b,c = 3,5,7
273−foo1=()
288+foo1=function ()
274289return a + b
275290end
276291;
277−foo2=()
292+foo2=function ()
278293return b + a
279294end
280295;
296+do
281297local a = 10
282−foo3=()
298+foo3=function ()
283299return a + b
284300end
285301;
302+end
303+end
286304assert(debug.upvalueid(foo1,1))
287305assert(debug.upvalueid(foo1,2))
288306assert(not debug.upvalueid(foo1,3))
@@ -291,7 +309,7 @@ assert(debug.upvalueid(foo1,2) == debug.upvalueid(foo2,1))
291309assert(debug.upvalueid(foo3,1))
292310assert(debug.upvalueid(foo1,1) ~= debug.upvalueid(foo3,1))
293311assert(debug.upvalueid(foo1,2) == debug.upvalueid(foo3,2))
294−assert(debug.upvalueid(string.gmatch("x","x"),1) ~= nil)
312+assert(debug.upvalueid(string.gmatch("\120","\120"),1) ~= nil)
295313assert(foo1() == 3 + 5 and foo2() == 5 + 3)
296314debug.upvaluejoin(foo1,2,foo2,2)
297315assert(foo1() == 3 + 3 and foo2() == 5 + 3)
@@ -306,4 +324,4 @@ assert(not pcall(debug.upvaluejoin,foo1,0,foo2,1))
306324assert(not pcall(debug.upvaluejoin,print,1,foo2,1))
307325assert(not pcall(debug.upvaluejoin,{},1,foo2,1))
308326assert(not pcall(debug.upvaluejoin,foo1,1,print,1))
309−print("OK")
327+print("\79\75")
zod/luau/res/lua/cycled/code.lua+269−259
@@ -1,10 +1,8 @@
11if T == nil then
2−(Message or print)("
3− >>> testC not active: skipping opcode tests <<<
4−")
2+(Message or print)("\10\32\62\62\62\32\116\101\115\116\67\32\110\111\116\32\97\99\116\105\118\101\58\32\115\107\105\112\112\105\110\103\32\111\112\99\111\100\101\32\116\101\115\116\115\32\60\60\60\10")
53return
64end
7−print("testing code generation and optimizations")
5+print("\116\101\115\116\105\110\103\32\99\111\100\101\32\103\101\110\101\114\97\116\105\111\110\32\97\110\100\32\111\112\116\105\109\105\122\97\116\105\111\110\115")
86local k0aux <const> = 0
97local k0 <const> = k0aux
108local k1 <const> = 1
@@ -14,15 +12,17 @@ local kFF0 <const> = 4080
1412local k3_78 <const> = 3.78
1513local x,k3_78_4 <const> = 10,k3_78 / 4
1614assert(x == 10)
17−local kx <const> = "x"
15+local kx <const> = "\120"
1816local kTrue <const> = true
1917local kFalse <const> = false
2018local kNil <const> = nil
19+do
2120local function f
2221(a)
2322for k,v,w in a
2423do
2524
25+end
2626end
2727end
2828local function checkKlist
@@ -36,12 +36,12 @@ end
3636end
3737local function foo
3838()
39−local a =
39+local a
4040a=k3
4141;
4242a=0
4343;
44−a=0
44+a=0.0
4545;
4646a=- 7 + 7
4747a=k3_78 / 4
@@ -54,61 +54,61 @@ a=k3_78 / 4
5454a=- 3.78 / 4
5555a=- 3.79 / 4
5656;
57−a=0
57+a=0.0
5858;
5959a=- 0
6060;
6161a=k3
6262;
63−a=3
63+a=3.0
6464;
6565a=3
6666;
67−a=3
67+a=3.0
6868end
6969checkKlist(foo,{3.78 / 4,- 3.78 / 4,- 3.79 / 4})
70−foo=(f,a)
71−f(100 * 1e3)
72−f(100 * 1e3)
73−f(- 100 * 1e3)
74−f(- 100 * 1e3)
75−f(1e5)
76−f(1e5)
77−f(- 1e5)
78−f(- 1e5)
79−end
80−checkKlist(foo,{1e5,1e5,- 1e5,- 1e5})
81−foo=(t,a)
70+foo=function (f,a)
71+f(100 * 1000)
72+f(100.0 * 1000)
73+f(- 100 * 1000)
74+f(- 100 * 1e3.0)
75+f(100000)
76+f(1e5.0)
77+f(- 100000)
78+f(- 1e5.0)
79+end
80+checkKlist(foo,{100000,1e5.0,- 100000,- 1e5.0})
81+foo=function (t,a)
8282t[a]=1
8383;
84−t[a]=1
84+t[a]=1.0
8585t[a]=1
8686;
87−t[a]=1
87+t[a]=1.0
8888t[a]=2
8989;
90−t[a]=2
90+t[a]=2.0
9191t[a]=0
9292;
93−t[a]=0
93+t[a]=0.0
9494t[a]=1
9595;
96−t[a]=1
96+t[a]=1.0
9797t[a]=2
9898;
99−t[a]=2
99+t[a]=2.0
100100t[a]=0
101101;
102−t[a]=0
102+t[a]=0.0
103103end
104−checkKlist(foo,{1,1,2,2,0,0})
104+checkKlist(foo,{1,1.0,2,2.0,0,0.0})
105105local function check
106106(f, ...)
107107local arg = {...}
108108local c = T.listcode(f)
109109for i = 1, # arg
110110do
111−local opcode = string.match(c[i],"%u%w+")
111+local opcode = string.match(c[i],"\37\117\37\119\43")
112112assert(arg[i] == opcode)
113113end
114114assert(c[# arg + 2] == undef)
@@ -126,29 +126,29 @@ b=T.listcode(b)
126126assert(# a == # b)
127127for i = 1, # a
128128do
129−a[i]=string.gsub(a[i],"%b()","")
130−b[i]=string.gsub(b[i],"%b()","")
129+a[i]=string.gsub(a[i],"\37\98\40\41","")
130+b[i]=string.gsub(b[i],"\37\98\40\41","")
131131assert(a[i] == b[i])
132132end
133133end
134−check(()
135−(()
134+check(function ()
135+(function ()
136136
137137end)({f()})
138−end,"CLOSURE","NEWTABLE","EXTRAARG","GETTABUP","CALL","SETLIST","CALL","RETURN0")
139−check((x)
140−(()
138+end,"\67\76\79\83\85\82\69","\78\69\87\84\65\66\76\69","\69\88\84\82\65\65\82\71","\71\69\84\84\65\66\85\80","\67\65\76\76","\83\69\84\76\73\83\84","\67\65\76\76","\82\69\84\85\82\78\48")
139+check(function (x)
140+(function ()
141141return x
142142end)({f()})
143−end,"CLOSURE","NEWTABLE","EXTRAARG","GETTABUP","CALL","SETLIST","CALL","RETURN")
144−check(()
143+end,"\67\76\79\83\85\82\69","\78\69\87\84\65\66\76\69","\69\88\84\82\65\65\82\71","\71\69\84\84\65\66\85\80","\67\65\76\76","\83\69\84\76\73\83\84","\67\65\76\76","\82\69\84\85\82\78")
144+check(function ()
145145local kNil <const> = nil
146−local a,b,c =
147−local d =
146+local a,b,c
147+local d
148148;
149−local e =
149+local e
150150;
151−local f,g,h =
151+local f,g,h
152152;
153153d=nil
154154;
@@ -160,8 +160,8 @@ a=kNil
160160;
161161c=nil
162162;
163−end,"LOADNIL","RETURN0")
164−check(()
163+end,"\76\79\65\68\78\73\76","\82\69\84\85\82\78\48")
164+check(function ()
165165local a,b,c,d = 1,1,1,1
166166d=nil
167167;
@@ -170,7 +170,8 @@ c=nil
170170b=nil
171171;
172172a=nil
173−end,"LOADI","LOADI","LOADI","LOADI","LOADNIL","RETURN0")
173+end,"\76\79\65\68\73","\76\79\65\68\73","\76\79\65\68\73","\76\79\65\68\73","\76\79\65\68\78\73\76","\82\69\84\85\82\78\48")
174+do
174175local a,b,c,d = 1,1,1,1
175176d=nil
176177;
@@ -180,389 +181,397 @@ b=nil
180181;
181182a=nil
182183assert(a == nil and b == nil and c == nil and d == nil)
183−check((a,b,c)
184+end
185+check(function (a,b,c)
184186return a
185−end,"RETURN1")
186−check(()
187+end,"\82\69\84\85\82\78\49")
188+check(function ()
187189while kTrue do
188190local a = - 1
189−end,"LOADI","JMP","RETURN0")
190−check(()
191+end
192+end,"\76\79\65\68\73","\74\77\80","\82\69\84\85\82\78\48")
193+check(function ()
191194while 1 do
192195local a = - 1
193−end,"LOADI","JMP","RETURN0")
194−check(()
196+end
197+end,"\76\79\65\68\73","\74\77\80","\82\69\84\85\82\78\48")
198+check(function ()
195199repeat
196−local x = 1until true
197−end,"LOADI","RETURN0")
198−check((a,b,c,d)
200+local x = 1
201+until true
202+end,"\76\79\65\68\73","\82\69\84\85\82\78\48")
203+check(function (a,b,c,d)
199204return a .. b .. c .. d
200−end,"MOVE","MOVE","MOVE","MOVE","CONCAT","RETURN1")
201−check(()
205+end,"\77\79\86\69","\77\79\86\69","\77\79\86\69","\77\79\86\69","\67\79\78\67\65\84","\82\69\84\85\82\78\49")
206+check(function ()
202207return not not nil
203−end,"LOADFALSE","RETURN1")
204−check(()
208+end,"\76\79\65\68\70\65\76\83\69","\82\69\84\85\82\78\49")
209+check(function ()
205210return not not kFalse
206−end,"LOADFALSE","RETURN1")
207−check(()
211+end,"\76\79\65\68\70\65\76\83\69","\82\69\84\85\82\78\49")
212+check(function ()
208213return not not true
209−end,"LOADTRUE","RETURN1")
210−check(()
214+end,"\76\79\65\68\84\82\85\69","\82\69\84\85\82\78\49")
215+check(function ()
211216return not not k3
212−end,"LOADTRUE","RETURN1")
213−check(()
214−local a,b,c,d =
217+end,"\76\79\65\68\84\82\85\69","\82\69\84\85\82\78\49")
218+check(function ()
219+local a,b,c,d
215220a=b * a
216221c.x,a[b]=- ((a + d / b - a[b]) ^ a.x),b
217−end,"LOADNIL","MUL","MMBIN","DIV","MMBIN","ADD","MMBIN","GETTABLE","SUB","MMBIN","GETFIELD","POW","MMBIN","UNM","SETTABLE","SETFIELD","RETURN0")
218−check(()
219−local a,b =
222+end,"\76\79\65\68\78\73\76","\77\85\76","\77\77\66\73\78","\68\73\86","\77\77\66\73\78","\65\68\68","\77\77\66\73\78","\71\69\84\84\65\66\76\69","\83\85\66","\77\77\66\73\78","\71\69\84\70\73\69\76\68","\80\79\87","\77\77\66\73\78","\85\78\77","\83\69\84\84\65\66\76\69","\83\69\84\70\73\69\76\68","\82\69\84\85\82\78\48")
223+check(function ()
224+local a,b
220225local c = kNil
221226a[kx]=3.2
222227a.x=b
223−a[b]="x"
224−end,"LOADNIL","SETFIELD","SETFIELD","SETTABLE","RETURN0")
225−check((a)
228+a[b]="\120"
229+end,"\76\79\65\68\78\73\76","\83\69\84\70\73\69\76\68","\83\69\84\70\73\69\76\68","\83\69\84\84\65\66\76\69","\82\69\84\85\82\78\48")
230+check(function (a)
226231local k255 <const> = 255
227232a[1]=a[100]
228233a[k255]=a[256]
229234a[256]=5
230−end,"GETI","SETI","LOADI","GETTABLE","SETI","LOADI","SETTABLE","RETURN0")
231−check(()
232−local a,b =
235+end,"\71\69\84\73","\83\69\84\73","\76\79\65\68\73","\71\69\84\84\65\66\76\69","\83\69\84\73","\76\79\65\68\73","\83\69\84\84\65\66\76\69","\82\69\84\85\82\78\48")
236+check(function ()
237+local a,b
233238a=a - a
234239b=a / a
235240b=5 - 4
236−end,"LOADNIL","SUB","MMBIN","DIV","MMBIN","LOADI","RETURN0")
237−check(()
238−local a,b =
241+end,"\76\79\65\68\78\73\76","\83\85\66","\77\77\66\73\78","\68\73\86","\77\77\66\73\78","\76\79\65\68\73","\82\69\84\85\82\78\48")
242+check(function ()
243+local a,b
239244a[kTrue]=false
240−end,"LOADNIL","LOADTRUE","SETTABLE","RETURN0")
241−checkR((a)
245+end,"\76\79\65\68\78\73\76","\76\79\65\68\84\82\85\69","\83\69\84\84\65\66\76\69","\82\69\84\85\82\78\48")
246+checkR(function (a)
242247if a == 1 then
243248return 2
244249end
245−end,1,2,"EQI","JMP","LOADI","RETURN1")
246−checkR((a)
247−if - 4 == a then
250+end,1,2,"\69\81\73","\74\77\80","\76\79\65\68\73","\82\69\84\85\82\78\49")
251+checkR(function (a)
252+if - 4.0 == a then
248253return 2
249254end
250−end,- 4,2,"EQI","JMP","LOADI","RETURN1")
251−checkR((a)
252−if a == "hi" then
255+end,- 4,2,"\69\81\73","\74\77\80","\76\79\65\68\73","\82\69\84\85\82\78\49")
256+checkR(function (a)
257+if a == "\104\105" then
253258return 2
254259end
255−end,10,nil,"EQK","JMP","LOADI","RETURN1")
256−checkR((a)
257−if a == 1e4 then
260+end,10,nil,"\69\81\75","\74\77\80","\76\79\65\68\73","\82\69\84\85\82\78\49")
261+checkR(function (a)
262+if a == 10000 then
258263return 2
259264end
260−end,1,nil,"EQK","JMP","LOADI","RETURN1")
261−checkR((a)
262−if - 1e4 == a then
265+end,1,nil,"\69\81\75","\74\77\80","\76\79\65\68\73","\82\69\84\85\82\78\49")
266+checkR(function (a)
267+if - 10000 == a then
263268return 2
264269end
265−end,- 1e4,2,"EQK","JMP","LOADI","RETURN1")
266−checkR((a)
270+end,- 10000,2,"\69\81\75","\74\77\80","\76\79\65\68\73","\82\69\84\85\82\78\49")
271+checkR(function (a)
267272if - 10 <= a then
268273return 2
269274end
270−end,- 10,2,"GEI","JMP","LOADI","RETURN1")
271−checkR((a)
272−if 128 > a then
275+end,- 10,2,"\71\69\73","\74\77\80","\76\79\65\68\73","\82\69\84\85\82\78\49")
276+checkR(function (a)
277+if 128.0 > a then
273278return 2
274279end
275−end,129,nil,"LTI","JMP","LOADI","RETURN1")
276−checkR((a)
277−if - 127 < a then
280+end,129,nil,"\76\84\73","\74\77\80","\76\79\65\68\73","\82\69\84\85\82\78\49")
281+checkR(function (a)
282+if - 127.0 < a then
278283return 2
279284end
280−end,- 127,nil,"GTI","JMP","LOADI","RETURN1")
281−checkR((a)
285+end,- 127,nil,"\71\84\73","\74\77\80","\76\79\65\68\73","\82\69\84\85\82\78\49")
286+checkR(function (a)
282287if 10 < a then
283288return 2
284289end
285−end,11,2,"GTI","JMP","LOADI","RETURN1")
286−checkR((a)
290+end,11,2,"\71\84\73","\74\77\80","\76\79\65\68\73","\82\69\84\85\82\78\49")
291+checkR(function (a)
287292if 129 < a then
288293return 2
289294end
290−end,130,2,"LOADI","LT","JMP","LOADI","RETURN1")
291−checkR((a)
292−if a >= 23 then
295+end,130,2,"\76\79\65\68\73","\76\84","\74\77\80","\76\79\65\68\73","\82\69\84\85\82\78\49")
296+checkR(function (a)
297+if a >= 23.0 then
293298return 2
294299end
295−end,25,2,"GEI","JMP","LOADI","RETURN1")
296−checkR((a)
300+end,25,2,"\71\69\73","\74\77\80","\76\79\65\68\73","\82\69\84\85\82\78\49")
301+checkR(function (a)
297302if a >= 23.1 then
298303return 2
299304end
300−end,0,nil,"LOADK","LE","JMP","LOADI","RETURN1")
301−checkR((a)
302−if a > 2300 then
305+end,0,nil,"\76\79\65\68\75","\76\69","\74\77\80","\76\79\65\68\73","\82\69\84\85\82\78\49")
306+checkR(function (a)
307+if a > 2300.0 then
303308return 2
304309end
305−end,0,nil,"LOADF","LT","JMP","LOADI","RETURN1")
310+end,0,nil,"\76\79\65\68\70","\76\84","\74\77\80","\76\79\65\68\73","\82\69\84\85\82\78\49")
306311local function checkK
307312(func,val)
308−check(func,"LOADK","RETURN1")
313+check(func,"\76\79\65\68\75","\82\69\84\85\82\78\49")
309314checkKlist(func,{val})
310315assert(func() == val)
311316end
312317local function checkI
313318(func,val)
314−check(func,"LOADI","RETURN1")
319+check(func,"\76\79\65\68\73","\82\69\84\85\82\78\49")
315320checkKlist(func,{})
316321assert(func() == val)
317322end
318323local function checkF
319324(func,val)
320−check(func,"LOADF","RETURN1")
325+check(func,"\76\79\65\68\70","\82\69\84\85\82\78\49")
321326checkKlist(func,{})
322327assert(func() == val)
323328end
324−checkF(()
325−return 0
326−end,0)
327−checkI(()
329+checkF(function ()
330+return 0.0
331+end,0.0)
332+checkI(function ()
328333return k0
329334end,0)
330−checkI(()
335+checkI(function ()
331336return - k0 // 1
332337end,0)
333−checkK(()
338+checkK(function ()
334339return 3 ^ - 1
335340end,1 / 3)
336−checkK(()
341+checkK(function ()
337342return (1 + 1) ^ (50 + 50)
338343end,2 ^ 100)
339−checkK(()
344+checkK(function ()
340345return (- 2) ^ (31 - 2)
341−end,- 536870912 + 0)
342−checkF(()
343−return (- k3 ^ 0 + 5) // 3
344−end,1)
345−checkI(()
346+end,- 536870912 + 0.0)
347+checkF(function ()
348+return (- k3 ^ 0 + 5) // 3.0
349+end,1.0)
350+checkI(function ()
346351return - k3 % 5
347352end,2)
348−checkF(()
349−return - ((2 ^ 8 + - (- 1)) % 8) / 2 * 4 - 3
350−end,- 5)
351−checkF(()
353+checkF(function ()
354+return - ((2.0 ^ 8 + - (- 1)) % 8) / 2 * 4 - 3
355+end,- 5.0)
356+checkF(function ()
352357return - ((2 ^ 8 + - (- 1)) % 8) // 2 * 4 - 3
353−end,- 7)
354−checkI(()
355−return 240 | 204 ~ 170 & 253
358+end,- 7.0)
359+checkI(function ()
360+return 240.0 | 204.0 ~ 170 & 253
356361end,244)
357−checkI(()
362+checkI(function ()
358363return ~ (~ kFF0 | kFF0)
359364end,0)
360−checkI(()
361−return ~ ~ - 1024
365+checkI(function ()
366+return ~ ~ - 1024.0
362367end,- 1024)
363−checkI(()
368+checkI(function ()
364369return ((100 << k6) << - 4) >> 2
365370end,100)
366371local a = 17
367372;
368373local sbx = ((1 << a) - 1) >> 1
369374local border <const> = 65535
370−checkI(()
375+checkI(function ()
371376return border
372377end,sbx)
373−checkI(()
378+checkI(function ()
374379return - border
375380end,- sbx)
376−checkI(()
381+checkI(function ()
377382return border + 1
378383end,sbx + 1)
379−checkK(()
384+checkK(function ()
380385return border + 2
381386end,sbx + 2)
382−checkK(()
387+checkK(function ()
383388return - (border + 1)
384389end,- (sbx + 1))
385−local border <const> = 65535
386−checkF(()
390+local border <const> = 65535.0
391+checkF(function ()
387392return border
388−end,sbx + 0)
389−checkF(()
393+end,sbx + 0.0)
394+checkF(function ()
390395return - border
391−end,- sbx + 0)
392−checkF(()
396+end,- sbx + 0.0)
397+checkF(function ()
393398return border + 1
394−end,(sbx + 1))
395−checkK(()
399+end,(sbx + 1.0))
400+checkK(function ()
396401return border + 2
397−end,(sbx + 2))
398−checkK(()
402+end,(sbx + 2.0))
403+checkK(function ()
399404return - (border + 1)
400−end,- (sbx + 1))
401−checkR((x)
405+end,- (sbx + 1.0))
406+checkR(function (x)
402407return x + k1
403−end,10,11,"ADDI","MMBINI","RETURN1")
404−checkR((x)
408+end,10,11,"\65\68\68\73","\77\77\66\73\78\73","\82\69\84\85\82\78\49")
409+checkR(function (x)
405410return x - 127
406−end,10,- 117,"ADDI","MMBINI","RETURN1")
407−checkR((x)
411+end,10,- 117,"\65\68\68\73","\77\77\66\73\78\73","\82\69\84\85\82\78\49")
412+checkR(function (x)
408413return 128 + x
409−end,0,128,"ADDI","MMBINI","RETURN1")
410−checkR((x)
414+end,0.0,128.0,"\65\68\68\73","\77\77\66\73\78\73","\82\69\84\85\82\78\49")
415+checkR(function (x)
411416return x * - 127
412−end,- 1,127,"MULK","MMBINK","RETURN1")
413−checkR((x)
417+end,- 1.0,127.0,"\77\85\76\75","\77\77\66\73\78\75","\82\69\84\85\82\78\49")
418+checkR(function (x)
414419return 20 * x
415−end,2,40,"MULK","MMBINK","RETURN1")
416−checkR((x)
420+end,2,40,"\77\85\76\75","\77\77\66\73\78\75","\82\69\84\85\82\78\49")
421+checkR(function (x)
417422return x ^ - 2
418−end,2,0.25,"POWK","MMBINK","RETURN1")
419−checkR((x)
423+end,2,0.25,"\80\79\87\75","\77\77\66\73\78\75","\82\69\84\85\82\78\49")
424+checkR(function (x)
420425return x / 40
421−end,40,1,"DIVK","MMBINK","RETURN1")
422−checkR((x)
426+end,40,1.0,"\68\73\86\75","\77\77\66\73\78\75","\82\69\84\85\82\78\49")
427+checkR(function (x)
423428return x // 1
424−end,10,10,"IDIVK","MMBINK","RETURN1")
425−checkR((x)
429+end,10.0,10.0,"\73\68\73\86\75","\77\77\66\73\78\75","\82\69\84\85\82\78\49")
430+checkR(function (x)
426431return x % (100 - 10)
427−end,91,1,"MODK","MMBINK","RETURN1")
428−checkR((x)
432+end,91,1,"\77\79\68\75","\77\77\66\73\78\75","\82\69\84\85\82\78\49")
433+checkR(function (x)
429434return k1 << x
430−end,3,8,"SHLI","MMBINI","RETURN1")
431−checkR((x)
435+end,3,8,"\83\72\76\73","\77\77\66\73\78\73","\82\69\84\85\82\78\49")
436+checkR(function (x)
432437return x << 127
433−end,10,0,"SHRI","MMBINI","RETURN1")
434−checkR((x)
438+end,10,0,"\83\72\82\73","\77\77\66\73\78\73","\82\69\84\85\82\78\49")
439+checkR(function (x)
435440return x << - 127
436−end,10,0,"SHRI","MMBINI","RETURN1")
437−checkR((x)
441+end,10,0,"\83\72\82\73","\77\77\66\73\78\73","\82\69\84\85\82\78\49")
442+checkR(function (x)
438443return x >> 128
439−end,8,0,"SHRI","MMBINI","RETURN1")
440−checkR((x)
444+end,8,0,"\83\72\82\73","\77\77\66\73\78\73","\82\69\84\85\82\78\49")
445+checkR(function (x)
441446return x >> - 127
442−end,8,0,"SHRI","MMBINI","RETURN1")
443−checkR((x)
447+end,8,0,"\83\72\82\73","\77\77\66\73\78\73","\82\69\84\85\82\78\49")
448+checkR(function (x)
444449return x & 1
445−end,9,1,"BANDK","MMBINK","RETURN1")
446−checkR((x)
450+end,9,1,"\66\65\78\68\75","\77\77\66\73\78\75","\82\69\84\85\82\78\49")
451+checkR(function (x)
447452return 10 | x
448−end,1,11,"BORK","MMBINK","RETURN1")
449−checkR((x)
453+end,1,11,"\66\79\82\75","\77\77\66\73\78\75","\82\69\84\85\82\78\49")
454+checkR(function (x)
450455return - 10 ~ x
451−end,- 1,9,"BXORK","MMBINK","RETURN1")
452−checkR((x)
453−return x + 0
454−end,1,1,"ADDK","MMBINK","RETURN1")
455−checkR((x)
456−return x * - 1e4
457−end,2,- 2e4,"MULK","MMBINK","RETURN1")
458−checkR((x)
456+end,- 1,9,"\66\88\79\82\75","\77\77\66\73\78\75","\82\69\84\85\82\78\49")
457+checkR(function (x)
458+return x + 0.0
459+end,1,1.0,"\65\68\68\75","\77\77\66\73\78\75","\82\69\84\85\82\78\49")
460+checkR(function (x)
461+return x * - 10000
462+end,2,- 20000,"\77\85\76\75","\77\77\66\73\78\75","\82\69\84\85\82\78\49")
463+checkR(function (x)
459464return x ^ 0.5
460−end,4,2,"POWK","MMBINK","RETURN1")
461−checkR((x)
462−return x / 2
463−end,4,2,"DIVK","MMBINK","RETURN1")
464−checkR((x)
465−return x // 1e4
466−end,1e4,1,"IDIVK","MMBINK","RETURN1")
467−checkR((x)
468−return x % (100 - 10)
469−end,91,1,"MODK","MMBINK","RETURN1")
470−check(()
471−return - 0
472−end,"LOADF","UNM","RETURN1")
473−check(()
465+end,4,2.0,"\80\79\87\75","\77\77\66\73\78\75","\82\69\84\85\82\78\49")
466+checkR(function (x)
467+return x / 2.0
468+end,4,2.0,"\68\73\86\75","\77\77\66\73\78\75","\82\69\84\85\82\78\49")
469+checkR(function (x)
470+return x // 10000
471+end,10000,1,"\73\68\73\86\75","\77\77\66\73\78\75","\82\69\84\85\82\78\49")
472+checkR(function (x)
473+return x % (100.0 - 10)
474+end,91,1.0,"\77\79\68\75","\77\77\66\73\78\75","\82\69\84\85\82\78\49")
475+check(function ()
476+return - 0.0
477+end,"\76\79\65\68\70","\85\78\77","\82\69\84\85\82\78\49")
478+check(function ()
474479return k3 / 0
475−end,"LOADI","DIVK","MMBINK","RETURN1")
476−check(()
480+end,"\76\79\65\68\73","\68\73\86\75","\77\77\66\73\78\75","\82\69\84\85\82\78\49")
481+check(function ()
477482return 0 % 0
478−end,"LOADI","MODK","MMBINK","RETURN1")
479−check(()
483+end,"\76\79\65\68\73","\77\79\68\75","\77\77\66\73\78\75","\82\69\84\85\82\78\49")
484+check(function ()
480485return - 4 // 0
481−end,"LOADI","IDIVK","MMBINK","RETURN1")
482−check((x)
483−return x >> 2
484−end,"LOADF","SHR","MMBIN","RETURN1")
485−check((x)
486+end,"\76\79\65\68\73","\73\68\73\86\75","\77\77\66\73\78\75","\82\69\84\85\82\78\49")
487+check(function (x)
488+return x >> 2.0
489+end,"\76\79\65\68\70","\83\72\82","\77\77\66\73\78","\82\69\84\85\82\78\49")
490+check(function (x)
486491return x << 128
487−end,"LOADI","SHL","MMBIN","RETURN1")
488−check((x)
489−return x & 2
490−end,"LOADF","BAND","MMBIN","RETURN1")
491−check(()
492+end,"\76\79\65\68\73","\83\72\76","\77\77\66\73\78","\82\69\84\85\82\78\49")
493+check(function (x)
494+return x & 2.0
495+end,"\76\79\65\68\70","\66\65\78\68","\77\77\66\73\78","\82\69\84\85\82\78\49")
496+check(function ()
492497for i = - 10, 10.5
493498do
494499
495500end
496−end,"LOADI","LOADK","LOADI","FORPREP","FORLOOP","RETURN0")
497−check(()
498−for i = 268435455, 10, 1
501+end,"\76\79\65\68\73","\76\79\65\68\75","\76\79\65\68\73","\70\79\82\80\82\69\80","\70\79\82\76\79\79\80","\82\69\84\85\82\78\48")
502+check(function ()
503+for i = 268435455, 10.0, 1
499504do
500505
501506end
502−end,"LOADK","LOADF","LOADI","FORPREP","FORLOOP","RETURN0")
503−check(()
507+end,"\76\79\65\68\75","\76\79\65\68\70","\76\79\65\68\73","\70\79\82\80\82\69\80","\70\79\82\76\79\79\80","\82\69\84\85\82\78\48")
508+check(function ()
504509return - nil
505−end,"LOADNIL","UNM","RETURN1")
506−check(()
507−local a,b,c =
510+end,"\76\79\65\68\78\73\76","\85\78\77","\82\69\84\85\82\78\49")
511+check(function ()
512+local a,b,c
508513b[c],a=c,b
509514b[a],a=c,b
510515a,b=c,a
511516a=a
512−end,"LOADNIL","MOVE","MOVE","SETTABLE","MOVE","MOVE","MOVE","SETTABLE","MOVE","MOVE","MOVE","RETURN0")
513−local t =
514−check(()
517+end,"\76\79\65\68\78\73\76","\77\79\86\69","\77\79\86\69","\83\69\84\84\65\66\76\69","\77\79\86\69","\77\79\86\69","\77\79\86\69","\83\69\84\84\65\66\76\69","\77\79\86\69","\77\79\86\69","\77\79\86\69","\82\69\84\85\82\78\48")
518+do
519+local t
520+check(function ()
515521t[kx]=t.y
516−end,"GETTABUP","SETTABUP")
517−check((a)
522+end,"\71\69\84\84\65\66\85\80","\83\69\84\84\65\66\85\80")
523+check(function (a)
518524t[a()]=t[a()]
519−end,"MOVE","CALL","GETUPVAL","MOVE","CALL","GETUPVAL","GETTABLE","SETTABLE")
520−checkequal(()
521−local a =
525+end,"\77\79\86\69","\67\65\76\76","\71\69\84\85\80\86\65\76","\77\79\86\69","\67\65\76\76","\71\69\84\85\80\86\65\76","\71\69\84\84\65\66\76\69","\83\69\84\84\65\66\76\69")
526+end
527+checkequal(function ()
528+local a
522529;
523530if not (a or b) then
524531b=a
525532end
526−end,()
527−local a =
533+end,function ()
534+local a
528535;
529536if (not a and not b) then
530537b=a
531538end
532539end)
533−checkequal((l)
534−local a =
540+checkequal(function (l)
541+local a
535542;
536543return 0 <= a and a <= l
537−end,(l)
538−local a =
544+end,function (l)
545+local a
539546;
540547return not (not (a >= 0) or not (a <= l))
541548end)
542−check((a,b)
549+check(function (a,b)
543550while a do
544551if b then
545552break
546553else
547554a=a + 1
548555end
549−end,"TEST","JMP","TEST","JMP","ADDI","MMBINI","JMP","RETURN0")
550−checkequal(()
556+end
557+end,"\84\69\83\84","\74\77\80","\84\69\83\84","\74\77\80","\65\68\68\73","\77\77\66\73\78\73","\74\77\80","\82\69\84\85\82\78\48")
558+checkequal(function ()
551559return 6 or true or nil
552−end,()
560+end,function ()
553561return k6 or kTrue or kNil
554562end)
555−checkequal(()
563+checkequal(function ()
556564return 6 and true or nil
557−end,()
565+end,function ()
558566return k6 and kTrue or kNil
559567end)
560−local k0 <const> = "00000000000000000000000000000000000000000000000000"
568+do
569+local k0 <const> = "\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48"
561570local function f1
562571()
563572local k <const> = k0
564−return ()
565−return ()
573+return function ()
574+return function ()
566575return k
567576end
568577end
@@ -573,4 +582,5 @@ assert(f3() == k0)
573582checkK(f3,k0)
574583assert(T.listk(f1)[1] == nil)
575584assert(T.listk(f2)[1] == nil)
576−print("OK")
585+end
586+print("\79\75")
zod/luau/res/lua/cycled/constructs.lua+114−111
@@ -1,22 +1,26 @@
11;
22;
3−print("testing syntax")
3+print("\116\101\115\116\105\110\103\32\115\121\110\116\97\120")
44;
55;
6−local debug = require("debug")
6+local debug = require("\100\101\98\117\103")
77local function checkload
88(s,msg)
99assert(string.find(select(2,load(s)),msg))
1010end
11−local a =
11+local a
12+do
1213;
1314;
1415;
16+end
1517;
18+do
1619;
1720a=3
1821;
1922assert(a == 3)
23+end
2024;
2125;
2226if false then
@@ -28,7 +32,7 @@ assert(2 ^ 3 ^ 2 == 2 ^ (3 ^ 2))
2832;
2933assert(2 ^ 3 * 4 == (2 ^ 3) * 4)
3034;
31−assert(2 ^ - 2 == 1 / 4 and - 2 ^ - - 2 == - - - 4)
35+assert(2.0 ^ - 2 == 1 / 4 and - 2 ^ - - 2 == - - - 4)
3236;
3337assert(not nil and 2 and not (2 > 3 or 3 < 2))
3438;
@@ -37,9 +41,9 @@ assert(- 3 - 1 - 5 == 0 + 0 - 9)
3741assert(- 2 ^ 2 == - 4 and (- 2) ^ 2 == 4 and 2 * 2 - 3 - 1 == 0)
3842;
3943assert(- 3 % 5 == 2 and - 3 + 5 == 2)
40−assert(2 * 1 + 3 / 3 == 3 and 1 + 2 .. 3 * 1 == "33")
44+assert(2 * 1 + 3 / 3 == 3 and 1 + 2 .. 3 * 1 == "\51\51")
4145;
42−assert(not (2 + 1 > 3 * 1) and "a" .. "b" > "a")
46+assert(not (2 + 1 > 3 * 1) and "\97" .. "\98" > "\97")
4347;
4448assert(240 | 204 ~ 170 & 253 == 244)
4549assert(253 & 170 ~ 204 | 240 == 244)
@@ -70,14 +74,13 @@ x,y=2,1
7074;
7175assert((x > y) and x or y == 2)
7276;
73−assert(1234567890 == tonumber("1234567890") and 1234567890 + 1 == 1234567891)
74−local operand = {3,100,5,- 10,- 5,1e4,- 1e4}
75−local operator = {"+","-","*","/","//","%","^","&","|","^","<<",">>","==","~=","<",">","<=",">="}
77+assert(1234567890 == tonumber("\49\50\51\52\53\54\55\56\57\48") and 1234567890 + 1 == 1234567891)
78+do
79+local operand = {3,100,5.0,- 10,- 5.0,10000,- 10000}
80+local operator = {"\43","\45","\42","\47","\47\47","\37","\94","\38","\124","\94","\60\60","\62\62","\61\61","\126\61","\60","\62","\60\61","\62\61"}
7681for _,op in ipairs(operator)
7782do
78−local f = assert(load(string.format("return function (x,y)
79− return x %s y
80− end",op)))()
83+local f = assert(load(string.format("\114\101\116\117\114\110\32\102\117\110\99\116\105\111\110\32\40\120\44\121\41\10\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\114\101\116\117\114\110\32\120\32\37\115\32\121\10\32\32\32\32\32\32\32\32\32\32\32\32\32\32\101\110\100",op)))()
8184;
8285for _,o1 in ipairs(operand)
8386do
@@ -85,48 +88,56 @@ for _,o2 in ipairs(operand)
8588do
8689local gab = f(o1,o2)
8790_ENV.XX=o1
88−local code = string.format("return XX %s %s",op,o2)
91+local code = string.format("\114\101\116\117\114\110\32\88\88\32\37\115\32\37\115",op,o2)
8992local res = assert(load(code))()
9093assert(res == gab)
9194_ENV.XX=o2
92−code=string.format("return (%s) %s XX",o1,op)
95+code=string.format("\114\101\116\117\114\110\32\40\37\115\41\32\37\115\32\88\88",o1,op)
9396res=assert(load(code))()
9497assert(res == gab)
95−code=string.format("return (%s) %s %s",o1,op,o2)
98+code=string.format("\114\101\116\117\114\110\32\40\37\115\41\32\37\115\32\37\115",o1,op,o2)
9699res=assert(load(code))()
97100assert(res == gab)
98101end
99102end
100103end
101104_ENV.XX=nil
105+end
102106repeat
107+
103108until 1
104109;
105110repeat
111+
106112until true
107113;
108114while false do
109115
116+end
110117;
111118while nil do
112119
120+end
113121;
114−local a =
122+do
123+local a
115124;
116125local function f
117126(x)
118−x={["a"] = 1}
127+x={["\97"] = 1}
119128;
120−x={["x"] = 1}
129+x={["\120"] = 1}
121130;
122−x={["G"] = 1}
131+x={["\71"] = 1}
123132end
124−local code = {"local x = {"}
133+end
134+do
135+local code = {"\108\111\99\97\108\32\120\32\61\32\123"}
125136for i = 1, 257
126137do
127−code[# code + 1]=i .. ".1,"
138+code[# code + 1]=i .. "\46\49\44"
128139end
129−code[# code + 1]="};"
140+code[# code + 1]="\125\59"
130141code=table.concat(code)
131142local function check
132143(ret,val)
@@ -134,14 +145,15 @@ local code = code .. ret
134145code=load(code)
135146assert(code() == val)
136147end
137−check("return (1 ~ (2 or 3))",1 ~ 2)
138−check("return (1 | (2 or 3))",1 | 2)
139−check("return (1 + (2 or 3))",1 + 2)
140−check("return (1 << (2 or 3))",1 << 2)
148+check("\114\101\116\117\114\110\32\40\49\32\126\32\40\50\32\111\114\32\51\41\41",1 ~ 2)
149+check("\114\101\116\117\114\110\32\40\49\32\124\32\40\50\32\111\114\32\51\41\41",1 | 2)
150+check("\114\101\116\117\114\110\32\40\49\32\43\32\40\50\32\111\114\32\51\41\41",1 + 2)
151+check("\114\101\116\117\114\110\32\40\49\32\60\60\32\40\50\32\111\114\32\51\41\41",1 << 2)
152+end
141153local function f
142154(i)
143−if type(i) ~= "number" then
144−return i,"jojo"
155+if type(i) ~= "\110\117\109\98\101\114" then
156+return i,"\106\111\106\111"
145157end
146158;
147159if i > 0 then
@@ -154,27 +166,27 @@ x={f(3),f(5),f(10)}
154166assert(x[1] == 3 and x[2] == 5 and x[3] == 10 and x[4] == 9 and x[12] == 1)
155167;
156168assert(x[nil] == nil)
157−x={f("alo"),f("xixi"),nil}
169+x={f("\97\108\111"),f("\120\105\120\105"),nil}
158170;
159−assert(x[1] == "alo" and x[2] == "xixi" and x[3] == nil)
171+assert(x[1] == "\97\108\111" and x[2] == "\120\105\120\105" and x[3] == nil)
160172;
161−x={f("alo") .. "xixi"}
173+x={f("\97\108\111") .. "\120\105\120\105"}
162174;
163−assert(x[1] == "aloxixi")
175+assert(x[1] == "\97\108\111\120\105\120\105")
164176x={f({})}
165−assert(x[2] == "jojo" and type(x[1]) == "table")
166−local f = (i)
177+assert(x[2] == "\106\111\106\111" and type(x[1]) == "\116\97\98\108\101")
178+local f = function (i)
167179if i < 10 then
168−return "a"
169−elseifi < 20 then
170−return "b"
171−elseifi < 30 then
172−return "c"
180+return "\97"
181+elseif i < 20 then
182+return "\98"
183+elseif i < 30 then
184+return "\99"
173185end
174186;
175187end
176−assert(f(3) == "a" and f(12) == "b" and f(26) == "c" and f(100) == nil)
177−for i = 1, 1e3
188+assert(f(3) == "\97" and f(12) == "\98" and f(26) == "\99" and f(100) == nil)
189+for i = 1, 1000
178190do
179191break
180192;
@@ -202,6 +214,7 @@ end
202214;
203215end
204216;
217+end
205218assert(a == n * (n + 1) / 2 and i == 3)
206219;
207220assert(t[1] and t[n] and not t[0] and not t[n + 1])
@@ -209,7 +222,7 @@ function f(b)
209222local x = 1
210223;
211224repeat
212−local a =
225+local a
213226;
214227if b == 1 then
215228local b = 1
@@ -217,12 +230,12 @@ local b = 1
217230x=10
218231;
219232break
220−elseifb == 2 then
233+elseif b == 2 then
221234x=20
222235;
223236break
224237;
225−elseifb == 3 then
238+elseif b == 3 then
226239x=30
227240;
228241else
@@ -230,30 +243,31 @@ local a,b,c,d = math.sin(1)
230243;
231244x=x + 1
232245;
233−enduntil x >= 12
246+end
247+until x >= 12
234248;
235249return x
236250end
237251;
238252assert(f(1) == 10 and f(2) == 20 and f(3) == 30 and f(4) == 12)
239−local f = (i)
253+local f = function (i)
240254if i < 10 then
241−return "a"
242−elseifi < 20 then
243−return "b"
244−elseifi < 30 then
245−return "c"
255+return "\97"
256+elseif i < 20 then
257+return "\98"
258+elseif i < 30 then
259+return "\99"
246260else
247261return 8
248262end
249263end
250−assert(f(3) == "a" and f(12) == "b" and f(26) == "c" and f(100) == 8)
264+assert(f(3) == "\97" and f(12) == "\98" and f(26) == "\99" and f(100) == 8)
251265local a,b = nil,23
252266x={f(100) * 2 + 3 or a,a or b + 2}
253267assert(x[1] == 19 and x[2] == 25)
254−x={["f"] = 2 + 3 or a,["a"] = b + 2}
268+x={["\102"] = 2 + 3 or a,["\97"] = b + 2}
255269assert(x.f == 5 and x.a == 25)
256−a={["y"] = 1}
270+a={["\121"] = 1}
257271x={a.y}
258272assert(x[1] == 1)
259273local function f
@@ -266,6 +280,7 @@ else
266280return
267281end
268282;
283+end
269284;
270285end
271286;
@@ -278,10 +293,12 @@ else
278293return
279294end
280295end
296+end
281297f(10)
282298;
283299g(10)
284300;
301+do
285302function f()
286303return 1,2,3
287304end
@@ -291,6 +308,7 @@ assert(a == 1 and b == 2 and c == 3)
291308a,b,c=(f())
292309;
293310assert(a == 1 and b == nil and c == nil)
311+end
294312local a,b = 3 and f()
295313;
296314assert(a == 1 and b == nil)
@@ -306,29 +324,17 @@ return nil or f()
306324end
307325a,b=g()
308326assert(a == 1 and b == nil)
309−print("+")
310−;
311−local prog <const> = "local x <XXX> = 10"
312−checkload(prog,"unknown attribute 'XXX'")
313−checkload("local xxx <const> = 20; xxx = 10",":1: attempt to assign to const variable 'xxx'")
314−checkload(" local xx;
315− local xxx <const> = 20;
316− local yyy;
317− local function foo ()
318− local abc = xx + yyy + xxx;
319− return function () return function () xxx = yyy end end
320− end
321− ",":6: attempt to assign to const variable 'xxx'")
322−checkload(" local x <close> = nil
323− x = io.open()
324− ",":2: attempt to assign to const variable 'x'")
325−f="return function ( a , b , c , d , e )
326− local x = a >= b or c or ( d and e ) or nil
327− return x
328−end , { a = 1 , b = 2 >= 1 , } or { 1 };
329−"
330−f=string.gsub(f,"%s+","
331−")
327+print("\43")
328+;
329+do
330+local prog <const> = "\108\111\99\97\108\32\120\32\60\88\88\88\62\32\61\32\49\48"
331+checkload(prog,"\117\110\107\110\111\119\110\32\97\116\116\114\105\98\117\116\101\32\39\88\88\88\39")
332+checkload("\108\111\99\97\108\32\120\120\120\32\60\99\111\110\115\116\62\32\61\32\50\48\59\32\120\120\120\32\61\32\49\48","\58\49\58\32\97\116\116\101\109\112\116\32\116\111\32\97\115\115\105\103\110\32\116\111\32\99\111\110\115\116\32\118\97\114\105\97\98\108\101\32\39\120\120\120\39")
333+checkload("\32\32\32\32\108\111\99\97\108\32\120\120\59\10\32\32\32\32\108\111\99\97\108\32\120\120\120\32\60\99\111\110\115\116\62\32\61\32\50\48\59\10\32\32\32\32\108\111\99\97\108\32\121\121\121\59\10\32\32\32\32\108\111\99\97\108\32\102\117\110\99\116\105\111\110\32\102\111\111\32\40\41\10\32\32\32\32\32\32\108\111\99\97\108\32\97\98\99\32\61\32\120\120\32\43\32\121\121\121\32\43\32\120\120\120\59\10\32\32\32\32\32\32\114\101\116\117\114\110\32\102\117\110\99\116\105\111\110\32\40\41\32\114\101\116\117\114\110\32\102\117\110\99\116\105\111\110\32\40\41\32\120\120\120\32\61\32\121\121\121\32\101\110\100\32\101\110\100\10\32\32\32\32\101\110\100\10\32\32","\58\54\58\32\97\116\116\101\109\112\116\32\116\111\32\97\115\115\105\103\110\32\116\111\32\99\111\110\115\116\32\118\97\114\105\97\98\108\101\32\39\120\120\120\39")
334+checkload("\32\32\32\32\108\111\99\97\108\32\120\32\60\99\108\111\115\101\62\32\61\32\110\105\108\10\32\32\32\32\120\32\61\32\105\111\46\111\112\101\110\40\41\10\32\32","\58\50\58\32\97\116\116\101\109\112\116\32\116\111\32\97\115\115\105\103\110\32\116\111\32\99\111\110\115\116\32\118\97\114\105\97\98\108\101\32\39\120\39")
335+end
336+f="\114\101\116\117\114\110\32\102\117\110\99\116\105\111\110\32\40\32\97\32\44\32\98\32\44\32\99\32\44\32\100\32\44\32\101\32\41\10\32\32\108\111\99\97\108\32\120\32\61\32\97\32\62\61\32\98\32\111\114\32\99\32\111\114\32\40\32\100\32\97\110\100\32\101\32\41\32\111\114\32\110\105\108\10\32\32\114\101\116\117\114\110\32\120\10\101\110\100\32\44\32\123\32\97\32\61\32\49\32\44\32\98\32\61\32\50\32\62\61\32\49\32\44\32\125\32\111\114\32\123\32\49\32\125\59\10"
337+f=string.gsub(f,"\37\115\43","\10")
332338;
333339f,a=load(f)()
334340;
@@ -345,25 +351,27 @@ local function h
345351(a,b,c,d,e)
346352while (a >= b or c or (d and e) or nil) do
347353return 1
354+end
348355;
349356return 0
350357end
351358;
352359assert(f(2,1) == true and g(2,1) == 1 and h(2,1) == 1)
353−assert(f(1,2,"a") == "a" and g(1,2,"a") == 1 and h(1,2,"a") == 1)
354−assert(f(1,2,"a") ~= nil,"")
355−assert(f(1,2,"a") == "a" and g(1,2,"a") == 1 and h(1,2,"a") == 1)
356−assert(f(1,2,nil,1,"x") == "x" and g(1,2,nil,1,"x") == 1 and h(1,2,nil,1,"x") == 1)
357−assert(f(1,2,nil,nil,"x") == nil and g(1,2,nil,nil,"x") == 0 and h(1,2,nil,nil,"x") == 0)
360+assert(f(1,2,"\97") == "\97" and g(1,2,"\97") == 1 and h(1,2,"\97") == 1)
361+assert(f(1,2,"\97") ~= nil,"")
362+assert(f(1,2,"\97") == "\97" and g(1,2,"\97") == 1 and h(1,2,"\97") == 1)
363+assert(f(1,2,nil,1,"\120") == "\120" and g(1,2,nil,1,"\120") == 1 and h(1,2,nil,1,"\120") == 1)
364+assert(f(1,2,nil,nil,"\120") == nil and g(1,2,nil,nil,"\120") == 0 and h(1,2,nil,nil,"\120") == 0)
358365assert(f(1,2,nil,1,nil) == nil and g(1,2,nil,1,nil) == 0 and h(1,2,nil,1,nil) == 0)
359−assert(1 and 2 < 3 == true and 2 < 3 and "a" < "b" == true)
366+assert(1 and 2 < 3 == true and 2 < 3 and "\97" < "\98" == true)
360367x=2 < 3 and not 3
361368;
362369assert(x == false)
363−x=2 < 1 or (2 > 1 and "a")
370+x=2 < 1 or (2 > 1 and "\97")
364371;
365−assert(x == "a")
366−local a =
372+assert(x == "\97")
373+do
374+local a
367375;
368376if nil then
369377a=1
@@ -374,9 +382,10 @@ a=2
374382end
375383;
376384assert(a == 2)
385+end
377386local function F
378387(a)
379−assert(debug.getinfo(1,"n").name == "F")
388+assert(debug.getinfo(1,"\110").name == "\70")
380389return a,2,3
381390end
382391a,b=F(1) ~= nil
@@ -387,29 +396,23 @@ a,b=F(nil) == nil
387396;
388397assert(a == true and b == nil)
389398_ENV.GLOB1=math.random(0,1)
390−local basiccases = {{"nil",nil},{"false",false},{"true",true},{"10",10},{"(0==_ENV.GLOB1)",0 == _ENV.GLOB1}}
391−local prog =
399+local basiccases = {{"\110\105\108",nil},{"\102\97\108\115\101",false},{"\116\114\117\101",true},{"\49\48",10},{"\40\48\61\61\95\69\78\86\46\71\76\79\66\49\41",0 == _ENV.GLOB1}}
400+local prog
392401if _ENV.GLOB1 == 0 then
393−basiccases[2][1]="F"
394−prog=" local F <const> = false
395− if %s then IX = true end
396− return %s
397−"
402+basiccases[2][1]="\70"
403+prog="\32\32\32\32\108\111\99\97\108\32\70\32\60\99\111\110\115\116\62\32\61\32\102\97\108\115\101\10\32\32\32\32\105\102\32\37\115\32\116\104\101\110\32\73\88\32\61\32\116\114\117\101\32\101\110\100\10\32\32\32\32\114\101\116\117\114\110\32\37\115\10"
398404else
399−basiccases[4][1]="k10"
400−prog=" local k10 <const> = 10
401− if %s then IX = true end
402− return %s
403− "
404−end
405−print("testing short-circuit optimizations (" .. _ENV.GLOB1 .. ")")
406−local binops <const> = {{" and ",(a,b)
405+basiccases[4][1]="\107\49\48"
406+prog="\32\32\32\32\108\111\99\97\108\32\107\49\48\32\60\99\111\110\115\116\62\32\61\32\49\48\10\32\32\32\32\105\102\32\37\115\32\116\104\101\110\32\73\88\32\61\32\116\114\117\101\32\101\110\100\10\32\32\32\32\114\101\116\117\114\110\32\37\115\10\32\32"
407+end
408+print("\116\101\115\116\105\110\103\32\115\104\111\114\116\45\99\105\114\99\117\105\116\32\111\112\116\105\109\105\122\97\116\105\111\110\115\32\40" .. _ENV.GLOB1 .. "\41")
409+local binops <const> = {{"\32\97\110\100\32",function (a,b)
407410if not a then
408411return a
409412else
410413return b
411414end
412−end},{" or ",(a,b)
415+end},{"\32\111\114\32",function (a,b)
413416if a then
414417return a
415418else
@@ -428,9 +431,9 @@ for _,v2 in ipairs(cases[n - i])
428431do
429432for _,op in ipairs(binops)
430433do
431−local t = {"(" .. v1[1] .. op[1] .. v2[1] .. ")",op[2](v1[2],v2[2])}
434+local t = {"\40" .. v1[1] .. op[1] .. v2[1] .. "\41",op[2](v1[2],v2[2])}
432435res[# res + 1]=t
433−res[# res + 1]={"not" .. t[1],not t[2]}
436+res[# res + 1]={"\110\111\116" .. t[1],not t[2]}
434437end
435438end
436439end
@@ -443,7 +446,7 @@ for i = 2, level
443446do
444447cases[i]=createcases(i)
445448end
446−print("+")
449+print("\43")
447450local i = 0
448451for n = 1, level
449452do
@@ -454,13 +457,13 @@ local p = load(string.format(prog,s,s),"")
454457IX=false
455458assert(p() == v[2] and IX == not not v[2])
456459i=i + 1
457−if i % 6e4 == 0 then
458−print("+")
460+if i % 60000 == 0 then
461+print("\43")
459462end
460463end
461464end
462465IX=nil
463466_G.GLOB1=nil
464−checkload("for x do","expected")
465−checkload("x:call","expected")
466−print("OK")
467+checkload("\102\111\114\32\120\32\100\111","\101\120\112\101\99\116\101\100")
468+checkload("\120\58\99\97\108\108","\101\120\112\101\99\116\101\100")
469+print("\79\75")
zod/luau/res/lua/cycled/coroutine.lua+363−415
@@ -1,8 +1,8 @@
1−print("testing coroutines")
2−local debug = require("debug")
3−local f =
1+print("\116\101\115\116\105\110\103\32\99\111\114\111\117\116\105\110\101\115")
2+local debug = require("\100\101\98\117\103")
3+local f
44local main,ismain = coroutine.running()
5−assert(type(main) == "thread" and ismain)
5+assert(type(main) == "\116\104\114\101\97\100" and ismain)
66assert(not coroutine.resume(main))
77assert(not coroutine.isyieldable(main) and not coroutine.isyieldable())
88assert(not pcall(coroutine.yield))
@@ -24,7 +24,7 @@ local function foo
2424local x,y = coroutine.running()
2525assert(x == f and y == false)
2626assert(coroutine.resume(f) == false)
27−assert(coroutine.status(f) == "running")
27+assert(coroutine.status(f) == "\114\117\110\110\105\110\103")
2828local arg = {...}
2929assert(coroutine.isyieldable(x))
3030for i = 1, # arg
@@ -35,36 +35,36 @@ return table.unpack(a)
3535end
3636f=coroutine.create(foo)
3737assert(coroutine.isyieldable(f))
38−assert(type(f) == "thread" and coroutine.status(f) == "suspended")
39−assert(string.find(tostring(f),"thread"))
40−local s,a,b,c,d =
41−s,a,b,c,d=coroutine.resume(f,{1,2,3},{},{1},{"a","b","c"})
38+assert(type(f) == "\116\104\114\101\97\100" and coroutine.status(f) == "\115\117\115\112\101\110\100\101\100")
39+assert(string.find(tostring(f),"\116\104\114\101\97\100"))
40+local s,a,b,c,d
41+s,a,b,c,d=coroutine.resume(f,{1,2,3},{},{1},{"\97","\98","\99"})
4242assert(coroutine.isyieldable(f))
43−assert(s and a == nil and coroutine.status(f) == "suspended")
43+assert(s and a == nil and coroutine.status(f) == "\115\117\115\112\101\110\100\101\100")
4444s,a,b,c,d=coroutine.resume(f)
4545eqtab(_G.x,{})
4646assert(s and a == 1 and b == nil)
4747assert(coroutine.isyieldable(f))
4848s,a,b,c,d=coroutine.resume(f,1,2,3)
4949eqtab(_G.x,{1,2,3})
50−assert(s and a == "a" and b == "b" and c == "c" and d == nil)
51−s,a,b,c,d=coroutine.resume(f,"xuxu")
52−eqtab(_G.x,{"xuxu"})
50+assert(s and a == "\97" and b == "\98" and c == "\99" and d == nil)
51+s,a,b,c,d=coroutine.resume(f,"\120\117\120\117")
52+eqtab(_G.x,{"\120\117\120\117"})
5353assert(s and a == 1 and b == 2 and c == 3 and d == nil)
54−assert(coroutine.status(f) == "dead")
55−s,a=coroutine.resume(f,"xuxu")
56−assert(not s and string.find(a,"dead") and coroutine.status(f) == "dead")
54+assert(coroutine.status(f) == "\100\101\97\100")
55+s,a=coroutine.resume(f,"\120\117\120\117")
56+assert(not s and string.find(a,"\100\101\97\100") and coroutine.status(f) == "\100\101\97\100")
5757_G.f=nil
5858local function foo
5959(i)
6060return coroutine.yield(i)
6161end
62−local f = coroutine.wrap(()
62+local f = coroutine.wrap(function ()
6363for i = 1, 10
6464do
6565assert(foo(i) == _G.x)
6666end
67−return "a"
67+return "\97"
6868end)
6969for i = 1, 10
7070do
@@ -72,9 +72,9 @@ _G.x=i
7272;
7373assert(f(i) == i)
7474end
75−_G.x="xuxu"
75+_G.x="\120\117\120\117"
7676;
77−assert(f("xuxu") == "a")
77+assert(f("\120\117\120\117") == "\97")
7878_G.x=nil
7979local function pf
8080(n,i)
@@ -90,7 +90,7 @@ s=s * i
9090end
9191local function gen
9292(n)
93−return coroutine.wrap(()
93+return coroutine.wrap(function ()
9494for i = 2, n
9595do
9696coroutine.yield(i)
@@ -99,7 +99,7 @@ end)
9999end
100100local function filter
101101(p,g)
102−return coroutine.wrap(()
102+return coroutine.wrap(function ()
103103while 1 do
104104local n = g()
105105if n == nil then
@@ -108,6 +108,7 @@ end
108108if math.fmod(n,p) ~= 0 then
109109coroutine.yield(n)
110110end
111+end
111112end)
112113end
113114local x = gen(80)
@@ -119,31 +120,34 @@ break
119120end
120121table.insert(a,n)
121122x=filter(n,x)
123+end
122124assert(# a == 22 and a[# a] == 79)
123125x,a=nil
124−print("to-be-closed variables in coroutines")
126+print("\116\111\45\98\101\45\99\108\111\115\101\100\32\118\97\114\105\97\98\108\101\115\32\105\110\32\99\111\114\111\117\116\105\110\101\115")
125127local function func2close
126128(f)
127−return setmetatable({},{["__close"] = f})
129+return setmetatable({},{["\95\95\99\108\111\115\101"] = f})
128130end
131+do
129132local co = coroutine.create(print)
130−assert(coroutine.resume(co,"testing 'coroutine.close'"))
131−assert(coroutine.status(co) == "dead")
133+assert(coroutine.resume(co,"\116\101\115\116\105\110\103\32\39\99\111\114\111\117\116\105\110\101\46\99\108\111\115\101\39"))
134+assert(coroutine.status(co) == "\100\101\97\100")
132135local st,msg = coroutine.close(co)
133136assert(st and msg == nil)
134137st,msg=coroutine.close(co)
135138assert(st and msg == nil)
136139local st,msg = pcall(coroutine.close,coroutine.running())
137−assert(not st and string.find(msg,"running"))
140+assert(not st and string.find(msg,"\114\117\110\110\105\110\103"))
138141local main = coroutine.running()
139142;
140−(coroutine.wrap(()
143+(coroutine.wrap(function ()
141144local st,msg = pcall(coroutine.close,main)
142−assert(not st and string.find(msg,"normal"))
145+assert(not st and string.find(msg,"\110\111\114\109\97\108"))
143146end))()
144−local co =
145−co=coroutine.create(()
146−local x <close> = func2close(()
147+do
148+local co
149+co=coroutine.create(function ()
150+local x <close> = func2close(function ()
147151coroutine.close(co)
148152end)
149153coroutine.yield(20)
@@ -151,8 +155,9 @@ end)
151155local st,msg = coroutine.resume(co)
152156assert(st and msg == 20)
153157st,msg=coroutine.close(co)
154−assert(not st and string.find(msg,"running coroutine"))
155−local X =
158+assert(not st and string.find(msg,"\114\117\110\110\105\110\103\32\99\111\114\111\117\116\105\110\101"))
159+end
160+local X
156161local co = coroutine.create(error)
157162local st,msg = coroutine.resume(co,100)
158163assert(not st and msg == 100)
@@ -160,8 +165,8 @@ st,msg=coroutine.close(co)
160165assert(not st and msg == 100)
161166st,msg=coroutine.close(co)
162167assert(st and msg == nil)
163−co=coroutine.create(()
164−local x <close> = func2close((self,err)
168+co=coroutine.create(function ()
169+local x <close> = func2close(function (self,err)
165170assert(err == nil)
166171;
167172X=false
@@ -172,15 +177,15 @@ end)
172177coroutine.resume(co)
173178assert(X)
174179assert(coroutine.close(co))
175−assert(not X and coroutine.status(co) == "dead")
180+assert(not X and coroutine.status(co) == "\100\101\97\100")
176181local x = 0
177−co=coroutine.create(()
178−local y <close> = func2close((self,err)
182+co=coroutine.create(function ()
183+local y <close> = func2close(function (self,err)
179184assert(err == 111)
180185x=200
181186error(200)
182187end)
183−local x <close> = func2close((self,err)
188+local x <close> = func2close(function (self,err)
184189assert(err == nil)
185190;
186191error(111)
@@ -190,26 +195,28 @@ end)
190195coroutine.resume(co)
191196assert(x == 0)
192197local st,msg = coroutine.close(co)
193−assert(st == false and coroutine.status(co) == "dead" and msg == 200)
198+assert(st == false and coroutine.status(co) == "\100\101\97\100" and msg == 200)
194199assert(x == 200)
195200st,msg=coroutine.close(co)
196201assert(st and msg == nil)
202+end
203+do
197204local X = false
198205local Y = false
199206local function foo
200207()
201−local x <close> = func2close((self,err)
208+local x <close> = func2close(function (self,err)
202209Y=debug.getinfo(2)
203210X=err
204211end)
205212error(43)
206213end
207−local co = coroutine.create(()
214+local co = coroutine.create(function ()
208215return pcall(foo)
209216end)
210217local st1,st2,err = coroutine.resume(co)
211218assert(st1 and not st2 and err == 43)
212−assert(X == 43 and Y.what == "C")
219+assert(X == 43 and Y.what == "\67")
213220local track = {}
214221local function h
215222(o)
@@ -218,20 +225,20 @@ return 1
218225end
219226local function foo
220227()
221−local x <close> = func2close((_,msg)
228+local x <close> = func2close(function (_,msg)
222229track[# track + 1]=msg or false
223230error(20)
224231end)
225−local y <close> = func2close((_,msg)
232+local y <close> = func2close(function (_,msg)
226233track[# track + 1]=msg or false
227−return 1e3
234+return 1000
228235end)
229−local z <close> = func2close((_,msg)
236+local z <close> = func2close(function (_,msg)
230237track[# track + 1]=msg or false
231238error(10)
232239end)
233240coroutine.yield(1)
234−h(func2close((_,msg)
241+h(func2close(function (_,msg)
235242track[# track + 1]=msg or false
236243error(2)
237244end))
@@ -240,10 +247,11 @@ local co = coroutine.create(pcall)
240247local st,res = coroutine.resume(co,foo)
241248assert(st and res == 1)
242249local st,res1,res2 = coroutine.resume(co)
243−assert(coroutine.status(co) == "dead")
250+assert(coroutine.status(co) == "\100\101\97\100")
244251assert(st and not res1 and res2 == 20)
245252assert(track[1] == false and track[2] == 2 and track[3] == 10 and track[4] == 10)
246−local co = coroutine.wrap(()
253+end
254+local co = coroutine.wrap(function ()
247255assert(not pcall(table.sort,{1,2,3},coroutine.yield))
248256assert(coroutine.isyieldable())
249257coroutine.yield(20)
@@ -251,17 +259,17 @@ return 30
251259end)
252260assert(co() == 20)
253261assert(co() == 30)
254−local f = (s,i)
262+local f = function (s,i)
255263return coroutine.yield(i)
256264end
257−local f1 = coroutine.wrap(()
258−return xpcall(pcall,(...)
265+local f1 = coroutine.wrap(function ()
266+return xpcall(pcall,function (...)
259267return ...
260−end,()
268+end,function ()
261269local s = 0
262270for i in f,nil,1
263271do
264−pcall(()
272+pcall(function ()
265273s=s + i
266274end)
267275end
@@ -285,25 +293,28 @@ local function g
285293(x)
286294return x[1] * 2
287295end
288−co=coroutine.wrap(()
296+co=coroutine.wrap(function ()
289297coroutine.yield(xpcall(f,g,10,20))
290298end)
291299assert(co() == 10)
292300local r,msg = co(100)
293301assert(not r and msg == 240)
302+do
294303local function f
295304(c)
296305assert(not coroutine.isyieldable())
297306return c .. c
298307end
299−local co = coroutine.wrap((c)
308+local co = coroutine.wrap(function (c)
300309assert(coroutine.isyieldable())
301−local s = string.gsub("a",".",f)
310+local s = string.gsub("\97","\46",f)
302311return s
303312end)
304−assert(co() == "aa")
305−local X =
306−local co = coroutine.create(()
313+assert(co() == "\97\97")
314+end
315+do
316+local X
317+local co = coroutine.create(function ()
307318coroutine.yield(10)
308319return 20
309320end)
@@ -312,15 +323,17 @@ local function dotrace
312323(event)
313324trace[# trace + 1]=event
314325end
315−debug.sethook(co,dotrace,"clr")
326+debug.sethook(co,dotrace,"\99\108\114")
316327repeat
328+
317329until not coroutine.resume(co)
318−local correcttrace = {"call","line","call","return","line","return"}
330+local correcttrace = {"\99\97\108\108","\108\105\110\101","\99\97\108\108","\114\101\116\117\114\110","\108\105\110\101","\114\101\116\117\114\110"}
319331assert(# trace == # correcttrace)
320332for k,v in pairs(trace)
321333do
322334assert(v == correcttrace[k])
323335end
336+end
324337function foo()
325338assert(debug.getinfo(1).currentline == debug.getinfo(foo).linedefined + 1)
326339assert(debug.getinfo(2).currentline == debug.getinfo(goo).linedefined)
@@ -338,9 +351,9 @@ x=coroutine.create(goo)
338351a,b=coroutine.resume(x)
339352assert(a and b == 3)
340353a,b=coroutine.resume(x)
341−assert(not a and b == foo and coroutine.status(x) == "dead")
354+assert(not a and b == foo and coroutine.status(x) == "\100\101\97\100")
342355a,b=coroutine.resume(x)
343−assert(not a and string.find(b,"dead") and coroutine.status(x) == "dead")
356+assert(not a and string.find(b,"\100\101\97\100") and coroutine.status(x) == "\100\101\97\100")
344357goo=nil
345358local function all
346359(a,n,k)
@@ -355,7 +368,7 @@ end
355368end
356369end
357370local a = 0
358−for t in coroutine.wrap(()
371+for t in coroutine.wrap(function ()
359372all({},5,4)
360373end)
361374do
@@ -364,8 +377,8 @@ end
364377assert(a == 5 ^ 4)
365378local C = {}
366379;
367−setmetatable(C,{["__mode"] = "kv"})
368−local x = coroutine.wrap(()
380+setmetatable(C,{["\95\95\109\111\100\101"] = "\107\118"})
381+local x = coroutine.wrap(function ()
369382local a = 10
370383local function f
371384()
@@ -376,6 +389,7 @@ end
376389while true do
377390a=a + 1
378391coroutine.yield(f)
392+end
379393end)
380394C[1]=x
381395;
@@ -403,24 +417,27 @@ a,b=coroutine.resume(co,co)
403417assert(a == true and b == 10)
404418assert(coroutine.resume(co,co) == false)
405419assert(coroutine.resume(co,co) == false)
420+do
406421local A = coroutine.running()
407−local B = coroutine.create(()
422+local B = coroutine.create(function ()
408423return coroutine.resume(A)
409424end)
410425local st,res = coroutine.resume(B)
411426assert(st == true and res == false)
412427local X = false
413−A=coroutine.wrap(()
414−local _ <close> = func2close(()
428+A=coroutine.wrap(function ()
429+local _ <close> = func2close(function ()
415430X=true
416431end)
417432return pcall(A,1)
418433end)
419434st,res=A()
420−assert(not st and string.find(res,"non%-suspended") and X == true)
421−local co =
422−co=coroutine.wrap(()
423−local x <close> = func2close(()
435+assert(not st and string.find(res,"\110\111\110\37\45\115\117\115\112\101\110\100\101\100") and X == true)
436+end
437+do
438+local co
439+co=coroutine.wrap(function ()
440+local x <close> = func2close(function ()
424441return pcall(co)
425442end)
426443error(111)
@@ -428,32 +445,33 @@ end)
428445local st,errobj = pcall(co)
429446assert(not st and errobj == 111)
430447st,errobj=pcall(co)
431−assert(not st and string.find(errobj,"dead coroutine"))
432−local co1,co2 =
433−co1=coroutine.create(()
448+assert(not st and string.find(errobj,"\100\101\97\100\32\99\111\114\111\117\116\105\110\101"))
449+end
450+local co1,co2
451+co1=coroutine.create(function ()
434452return co2()
435453end)
436−co2=coroutine.wrap(()
437−assert(coroutine.status(co1) == "normal")
454+co2=coroutine.wrap(function ()
455+assert(coroutine.status(co1) == "\110\111\114\109\97\108")
438456assert(not coroutine.resume(co1))
439457coroutine.yield(3)
440458end)
441459a,b=coroutine.resume(co1)
442460assert(a and b == 3)
443−assert(coroutine.status(co1) == "dead")
444−a=(a)
461+assert(coroutine.status(co1) == "\100\101\97\100")
462+a=function (a)
445463coroutine.wrap(a)(a)
446464end
447465assert(not pcall(a,a))
448466a=nil
449−local x = coroutine.create(()
467+local x = coroutine.create(function ()
450468local a = 10
451−_G.F=()
469+_G.F=function ()
452470a=a + 1
453471;
454472return a
455473end
456−error("x")
474+error("\120")
457475end)
458476assert(not coroutine.resume(x))
459477assert(not coroutine.resume(x,1,1,1,1,1,1,1))
@@ -461,12 +479,10 @@ assert(_G.F() == 11)
461479assert(_G.F() == 12)
462480_G.F=nil
463481if not T then
464−(Message or print)("
465− >>> testC not active: skipping coroutine API tests <<<
466−")
482+(Message or print)("\10\32\62\62\62\32\116\101\115\116\67\32\110\111\116\32\97\99\116\105\118\101\58\32\115\107\105\112\112\105\110\103\32\99\111\114\111\117\116\105\110\101\32\65\80\73\32\116\101\115\116\115\32\60\60\60\10")
467483else
468−print("testing yields inside hooks")
469−local turn =
484+print("\116\101\115\116\105\110\103\32\121\105\101\108\100\115\32\105\110\115\105\100\101\32\104\111\111\107\115")
485+local turn
470486local function fact
471487(t,x)
472488assert(turn == t)
@@ -477,39 +493,41 @@ return x * fact(t,x - 1)
477493end
478494end
479495local A,B = 0,0
480−local x = coroutine.create(()
481−T.sethook("yield 0","",2)
482−A=fact("A",6)
496+local x = coroutine.create(function ()
497+T.sethook("\121\105\101\108\100\32\48","",2)
498+A=fact("\65",6)
483499end)
484−local y = coroutine.create(()
485−T.sethook("yield 0","",3)
486−B=fact("B",7)
500+local y = coroutine.create(function ()
501+T.sethook("\121\105\101\108\100\32\48","",3)
502+B=fact("\66",7)
487503end)
488504while A == 0 or B == 0 do
489505if A == 0 then
490−turn="A"
506+turn="\65"
491507;
492508assert(T.resume(x))
493509end
494510if B == 0 then
495−turn="B"
511+turn="\66"
496512;
497513assert(T.resume(y))
498514end
499515debug.traceback(x)
500516debug.traceback(y)
517+end
501518assert(B // A == 7)
502−local done =
519+do
520+local done
503521local function test
504522(n)
505523done=false
506−return coroutine.wrap(()
524+return coroutine.wrap(function ()
507525local a = {}
508526for i = 1, n
509527do
510528a[i]=i
511529end
512−T.sethook("pushint 10; yield 0","",1)
530+T.sethook("\112\117\115\104\105\110\116\32\49\48\59\32\121\105\101\108\100\32\48","",1)
513531local a1 = {table.unpack(a)}
514532assert(# a1 == n)
515533for i = 1, n
@@ -523,27 +541,32 @@ local co = test(0)
523541;
524542while not done do
525543co(30)
544+end
526545co=test(1)
527546;
528547while not done do
529548co(20,10)
549+end
530550co=test(3)
531551;
532552while not done do
533553co()
554+end
534555co=test(100)
535556;
536557while not done do
537558co()
538−local line = debug.getinfo(1,"l").currentline + 2
559+end
560+end
561+local line = debug.getinfo(1,"\108").currentline + 2
539562local function foo
540563()
541564local x = 10
542565x=x + 10
543566_G.XX=x
544567end
545−local co = coroutine.wrap(()
546−T.sethook("setglobal X; yield 0","l",0)
568+local co = coroutine.wrap(function ()
569+T.sethook("\115\101\116\103\108\111\98\97\108\32\88\59\32\121\105\101\108\100\32\48","\108",0)
547570;
548571foo()
549572;
@@ -573,8 +596,8 @@ co()
573596assert(_G.X == line + 3 and _G.XX == 20)
574597assert(co() == 10)
575598_G.X=nil
576−co=coroutine.wrap(()
577−T.sethook("yield 0","",1)
599+co=coroutine.wrap(function ()
600+T.sethook("\121\105\101\108\100\32\48","",1)
578601;
579602foo()
580603;
@@ -586,10 +609,11 @@ local c = 0
586609repeat
587610c=c + 1
588611;
589−local a = co()until a == 10
612+local a = co()
613+until a == 10
590614assert(_G.XX == 20 and c >= 5)
591−co=coroutine.wrap(()
592−T.sethook("yield 0","",2)
615+co=coroutine.wrap(function ()
616+T.sethook("\121\105\101\108\100\32\48","",2)
593617;
594618foo()
595619;
@@ -601,122 +625,84 @@ local c = 0
601625repeat
602626c=c + 1
603627;
604−local a = co()until a == 10
628+local a = co()
629+until a == 10
605630assert(_G.XX == 20 and c >= 5)
606631_G.X=nil
607632;
608633_G.XX=nil
609−c=coroutine.create((a, ...)
610−T.sethook("yield 0","l")
634+do
635+c=coroutine.create(function (a, ...)
636+T.sethook("\121\105\101\108\100\32\48","\108")
611637local b = a
612638return ...
613639end)
614640assert(coroutine.resume(c,1,2,3))
615641local n,v = debug.getlocal(c,0,1)
616−assert(n == "a" and v == 1 and debug.getlocal(c,0,2) ~= "b")
642+assert(n == "\97" and v == 1 and debug.getlocal(c,0,2) ~= "\98")
617643assert(debug.setlocal(c,0,1,10))
618644local t = debug.getinfo(c,0)
619645assert(t.currentline == t.linedefined + 2)
620646assert(not debug.getinfo(c,1))
621647assert(coroutine.resume(c))
622648local n,v = debug.getlocal(c,0,2)
623−assert(n == "b" and v == 10)
649+assert(n == "\98" and v == 10)
624650v={coroutine.resume(c)}
625651assert(v[1] == true and v[2] == 2 and v[3] == 3 and v[4] == undef)
626652assert(not coroutine.resume(c))
627−local c = coroutine.create(()
628−T.testC("yield 1",10,20)
653+end
654+do
655+local c = coroutine.create(function ()
656+T.testC("\121\105\101\108\100\32\49",10,20)
629657end)
630658local a,b = coroutine.resume(c)
631659assert(a and b == 20)
632660assert(debug.getinfo(c,0).linedefined == - 1)
633661a,b=debug.getlocal(c,0,2)
634662assert(b == 10)
635−print("testing coroutine API")
636−assert(T.testC(" newthread # create thread
637− pushvalue 2 # push body
638− pushstring 'a a a' # push argument
639− xmove 0 3 2 # move values to new thread
640− resume -1, 1 # call it first time
641− pushstatus
642− xmove 3 0 0 # move results back to stack
643− setglobal X # result
644− setglobal Y # status
645− pushvalue 2 # push body (to call it again)
646− pushstring 'b b b'
647− xmove 0 3 2
648− resume -1, 1 # call it again
649− pushstatus
650− xmove 3 0 0
651− return 1 # return result
652− ",(...)
663+end
664+print("\116\101\115\116\105\110\103\32\99\111\114\111\117\116\105\110\101\32\65\80\73")
665+assert(T.testC("\32\32\32\32\110\101\119\116\104\114\101\97\100\32\32\32\32\32\32\35\32\99\114\101\97\116\101\32\116\104\114\101\97\100\10\32\32\32\32\112\117\115\104\118\97\108\117\101\32\50\32\32\32\32\35\32\112\117\115\104\32\98\111\100\121\10\32\32\32\32\112\117\115\104\115\116\114\105\110\103\32\39\97\32\97\32\97\39\32\32\35\32\112\117\115\104\32\97\114\103\117\109\101\110\116\10\32\32\32\32\120\109\111\118\101\32\48\32\51\32\50\32\32\32\35\32\109\111\118\101\32\118\97\108\117\101\115\32\116\111\32\110\101\119\32\116\104\114\101\97\100\10\32\32\32\32\114\101\115\117\109\101\32\45\49\44\32\49\32\32\32\32\35\32\99\97\108\108\32\105\116\32\102\105\114\115\116\32\116\105\109\101\10\32\32\32\32\112\117\115\104\115\116\97\116\117\115\10\32\32\32\32\120\109\111\118\101\32\51\32\48\32\48\32\32\32\35\32\109\111\118\101\32\114\101\115\117\108\116\115\32\98\97\99\107\32\116\111\32\115\116\97\99\107\10\32\32\32\32\115\101\116\103\108\111\98\97\108\32\88\32\32\32\32\35\32\114\101\115\117\108\116\10\32\32\32\32\115\101\116\103\108\111\98\97\108\32\89\32\32\32\32\35\32\115\116\97\116\117\115\10\32\32\32\32\112\117\115\104\118\97\108\117\101\32\50\32\32\32\32\32\35\32\112\117\115\104\32\98\111\100\121\32\40\116\111\32\99\97\108\108\32\105\116\32\97\103\97\105\110\41\10\32\32\32\32\112\117\115\104\115\116\114\105\110\103\32\39\98\32\98\32\98\39\10\32\32\32\32\120\109\111\118\101\32\48\32\51\32\50\10\32\32\32\32\114\101\115\117\109\101\32\45\49\44\32\49\32\32\32\32\35\32\99\97\108\108\32\105\116\32\97\103\97\105\110\10\32\32\32\32\112\117\115\104\115\116\97\116\117\115\10\32\32\32\32\120\109\111\118\101\32\51\32\48\32\48\10\32\32\32\32\114\101\116\117\114\110\32\49\32\32\32\32\32\32\32\32\35\32\114\101\116\117\114\110\32\114\101\115\117\108\116\10\32\32",function (...)
653666return ...
654−end) == "b b b")
655−assert(X == "a a a" and Y == "OK")
667+end) == "\98\32\98\32\98")
668+assert(X == "\97\32\97\32\97" and Y == "\79\75")
656669X,Y=nil
657−C=coroutine.create(()
658−return T.testC(" pushnum 10;
659− pushnum 20;
660− resume -3 2;
661− pushstatus
662− gettop;
663− return 3",C)
670+C=coroutine.create(function ()
671+return T.testC("\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\112\117\115\104\110\117\109\32\49\48\59\10\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\112\117\115\104\110\117\109\32\50\48\59\10\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\114\101\115\117\109\101\32\45\51\32\50\59\10\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\112\117\115\104\115\116\97\116\117\115\10\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\103\101\116\116\111\112\59\10\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\114\101\116\117\114\110\32\51",C)
664672end)
665673local a,b,c,d = coroutine.resume(C)
666−assert(a == true and string.find(b,"non%-suspended") and c == "ERRRUN" and d == 4)
667−a,b,c,d=T.testC(" rawgeti R 1 # get main thread
668− pushnum 10;
669− pushnum 20;
670− resume -3 2;
671− pushstatus
672− gettop;
673− return 4")
674−assert(a == coroutine.running() and string.find(b,"non%-suspended") and c == "ERRRUN" and d == 4)
674+assert(a == true and string.find(b,"\110\111\110\37\45\115\117\115\112\101\110\100\101\100") and c == "\69\82\82\82\85\78" and d == 4)
675+a,b,c,d=T.testC("\32\32\32\32\114\97\119\103\101\116\105\32\82\32\49\32\32\32\32\35\32\103\101\116\32\109\97\105\110\32\116\104\114\101\97\100\10\32\32\32\32\112\117\115\104\110\117\109\32\49\48\59\10\32\32\32\32\112\117\115\104\110\117\109\32\50\48\59\10\32\32\32\32\114\101\115\117\109\101\32\45\51\32\50\59\10\32\32\32\32\112\117\115\104\115\116\97\116\117\115\10\32\32\32\32\103\101\116\116\111\112\59\10\32\32\32\32\114\101\116\117\114\110\32\52")
676+assert(a == coroutine.running() and string.find(b,"\110\111\110\37\45\115\117\115\112\101\110\100\101\100") and c == "\69\82\82\82\85\78" and d == 4)
675677local state = T.newstate()
676−assert(T.testC(state,"newthread; isyieldable -1; remove 1; return 1"))
677−assert(not T.testC(state,"rawgeti R 1; isyieldable -1; remove 1; return 1"))
678−T.testC(state,"settop 0")
678+assert(T.testC(state,"\110\101\119\116\104\114\101\97\100\59\32\105\115\121\105\101\108\100\97\98\108\101\32\45\49\59\32\114\101\109\111\118\101\32\49\59\32\114\101\116\117\114\110\32\49"))
679+assert(not T.testC(state,"\114\97\119\103\101\116\105\32\82\32\49\59\32\105\115\121\105\101\108\100\97\98\108\101\32\45\49\59\32\114\101\109\111\118\101\32\49\59\32\114\101\116\117\114\110\32\49"))
680+T.testC(state,"\115\101\116\116\111\112\32\48")
679681T.loadlib(state)
680−assert(T.doremote(state," coroutine = require'coroutine';
681− X = function (x) coroutine.yield(x, 'BB'); return 'CC' end;
682− return 'ok'"))
683−local t = table.pack(T.testC(state," rawgeti R 1 # get main thread
684− pushstring 'XX'
685− getglobal X # get function for body
686− pushstring AA # arg
687− resume 1 1 # 'resume' shadows previous stack!
688− gettop
689− setglobal T # top
690− setglobal B # second yielded value
691− setglobal A # fist yielded value
692− rawgeti R 1 # get main thread
693− pushnum 5 # arg (noise)
694− resume 1 1 # after coroutine ends, previous stack is back
695− pushstatus
696− return *
697− "))
698−assert(t.n == 4 and t[2] == "XX" and t[3] == "CC" and t[4] == "OK")
699−assert(T.doremote(state,"return T") == "2")
700−assert(T.doremote(state,"return A") == "AA")
701−assert(T.doremote(state,"return B") == "BB")
682+assert(T.doremote(state,"\32\32\32\32\99\111\114\111\117\116\105\110\101\32\61\32\114\101\113\117\105\114\101\39\99\111\114\111\117\116\105\110\101\39\59\10\32\32\32\32\88\32\61\32\102\117\110\99\116\105\111\110\32\40\120\41\32\99\111\114\111\117\116\105\110\101\46\121\105\101\108\100\40\120\44\32\39\66\66\39\41\59\32\114\101\116\117\114\110\32\39\67\67\39\32\101\110\100\59\10\32\32\32\32\114\101\116\117\114\110\32\39\111\107\39"))
683+local t = table.pack(T.testC(state,"\32\32\32\32\114\97\119\103\101\116\105\32\82\32\49\32\32\32\32\32\35\32\103\101\116\32\109\97\105\110\32\116\104\114\101\97\100\10\32\32\32\32\112\117\115\104\115\116\114\105\110\103\32\39\88\88\39\10\32\32\32\32\103\101\116\103\108\111\98\97\108\32\88\32\32\32\32\35\32\103\101\116\32\102\117\110\99\116\105\111\110\32\102\111\114\32\98\111\100\121\10\32\32\32\32\112\117\115\104\115\116\114\105\110\103\32\65\65\32\32\32\32\32\32\35\32\97\114\103\10\32\32\32\32\114\101\115\117\109\101\32\49\32\49\32\32\32\32\32\32\35\32\39\114\101\115\117\109\101\39\32\115\104\97\100\111\119\115\32\112\114\101\118\105\111\117\115\32\115\116\97\99\107\33\10\32\32\32\32\103\101\116\116\111\112\10\32\32\32\32\115\101\116\103\108\111\98\97\108\32\84\32\32\32\32\35\32\116\111\112\10\32\32\32\32\115\101\116\103\108\111\98\97\108\32\66\32\32\32\32\35\32\115\101\99\111\110\100\32\121\105\101\108\100\101\100\32\118\97\108\117\101\10\32\32\32\32\115\101\116\103\108\111\98\97\108\32\65\32\32\32\32\35\32\102\105\115\116\32\121\105\101\108\100\101\100\32\118\97\108\117\101\10\32\32\32\32\114\97\119\103\101\116\105\32\82\32\49\32\32\32\32\32\35\32\103\101\116\32\109\97\105\110\32\116\104\114\101\97\100\10\32\32\32\32\112\117\115\104\110\117\109\32\53\32\32\32\32\32\32\32\35\32\97\114\103\32\40\110\111\105\115\101\41\10\32\32\32\32\114\101\115\117\109\101\32\49\32\49\32\32\32\32\32\32\35\32\97\102\116\101\114\32\99\111\114\111\117\116\105\110\101\32\101\110\100\115\44\32\112\114\101\118\105\111\117\115\32\115\116\97\99\107\32\105\115\32\98\97\99\107\10\32\32\32\32\112\117\115\104\115\116\97\116\117\115\10\32\32\32\32\114\101\116\117\114\110\32\42\10\32\32"))
684+assert(t.n == 4 and t[2] == "\88\88" and t[3] == "\67\67" and t[4] == "\79\75")
685+assert(T.doremote(state,"\114\101\116\117\114\110\32\84") == "\50")
686+assert(T.doremote(state,"\114\101\116\117\114\110\32\65") == "\65\65")
687+assert(T.doremote(state,"\114\101\116\117\114\110\32\66") == "\66\66")
702688T.closestate(state)
703−print("+")
689+print("\43")
704690end
705−_G.TO_SURVIVE=coroutine.wrap(()
691+_G.TO_SURVIVE=coroutine.wrap(function ()
706692local a = 10
707−local x = ()
693+local x = function ()
708694a=a + 1
709695end
710696coroutine.yield()
711697end)
712698_G.TO_SURVIVE()
713699if not _soft then
714−local lim = 1e6
700+local lim = 1000000
715701local t = {lim - 10,lim - 5,lim - 1,lim,lim + 1,lim + 5}
716702for i = 1, # t
717703do
718704local j = t[i]
719−local co = coroutine.create(()
705+local co = coroutine.create(function ()
720706return table.unpack({},1,j)
721707end)
722708local r,msg = coroutine.resume(co)
@@ -724,103 +710,103 @@ assert(j < lim or not r)
724710end
725711end
726712assert(coroutine.running() == main)
727−print("+")
728−print("testing yields inside metamethods")
713+print("\43")
714+print("\116\101\115\116\105\110\103\32\121\105\101\108\100\115\32\105\110\115\105\100\101\32\109\101\116\97\109\101\116\104\111\100\115")
729715local function val
730716(x)
731−if type(x) == "table" then
717+if type(x) == "\116\97\98\108\101" then
732718return x.x
733719else
734720return x
735721end
736722end
737−local mt = {["__eq"] = (a,b)
738−coroutine.yield(nil,"eq")
723+local mt = {["\95\95\101\113"] = function (a,b)
724+coroutine.yield(nil,"\101\113")
739725;
740726return val(a) == val(b)
741−end,["__lt"] = (a,b)
742−coroutine.yield(nil,"lt")
727+end,["\95\95\108\116"] = function (a,b)
728+coroutine.yield(nil,"\108\116")
743729;
744730return val(a) < val(b)
745−end,["__le"] = (a,b)
746−coroutine.yield(nil,"le")
731+end,["\95\95\108\101"] = function (a,b)
732+coroutine.yield(nil,"\108\101")
747733;
748734return a - b <= 0
749−end,["__add"] = (a,b)
750−coroutine.yield(nil,"add")
735+end,["\95\95\97\100\100"] = function (a,b)
736+coroutine.yield(nil,"\97\100\100")
751737;
752738return val(a) + val(b)
753−end,["__sub"] = (a,b)
754−coroutine.yield(nil,"sub")
739+end,["\95\95\115\117\98"] = function (a,b)
740+coroutine.yield(nil,"\115\117\98")
755741;
756742return val(a) - val(b)
757−end,["__mul"] = (a,b)
758−coroutine.yield(nil,"mul")
743+end,["\95\95\109\117\108"] = function (a,b)
744+coroutine.yield(nil,"\109\117\108")
759745;
760746return val(a) * val(b)
761−end,["__div"] = (a,b)
762−coroutine.yield(nil,"div")
747+end,["\95\95\100\105\118"] = function (a,b)
748+coroutine.yield(nil,"\100\105\118")
763749;
764750return val(a) / val(b)
765−end,["__idiv"] = (a,b)
766−coroutine.yield(nil,"idiv")
751+end,["\95\95\105\100\105\118"] = function (a,b)
752+coroutine.yield(nil,"\105\100\105\118")
767753;
768754return val(a) // val(b)
769−end,["__pow"] = (a,b)
770−coroutine.yield(nil,"pow")
755+end,["\95\95\112\111\119"] = function (a,b)
756+coroutine.yield(nil,"\112\111\119")
771757;
772758return val(a) ^ val(b)
773−end,["__mod"] = (a,b)
774−coroutine.yield(nil,"mod")
759+end,["\95\95\109\111\100"] = function (a,b)
760+coroutine.yield(nil,"\109\111\100")
775761;
776762return val(a) % val(b)
777−end,["__unm"] = (a,b)
778−coroutine.yield(nil,"unm")
763+end,["\95\95\117\110\109"] = function (a,b)
764+coroutine.yield(nil,"\117\110\109")
779765;
780766return - val(a)
781−end,["__bnot"] = (a,b)
782−coroutine.yield(nil,"bnot")
767+end,["\95\95\98\110\111\116"] = function (a,b)
768+coroutine.yield(nil,"\98\110\111\116")
783769;
784770return ~ val(a)
785−end,["__shl"] = (a,b)
786−coroutine.yield(nil,"shl")
771+end,["\95\95\115\104\108"] = function (a,b)
772+coroutine.yield(nil,"\115\104\108")
787773;
788774return val(a) << val(b)
789−end,["__shr"] = (a,b)
790−coroutine.yield(nil,"shr")
775+end,["\95\95\115\104\114"] = function (a,b)
776+coroutine.yield(nil,"\115\104\114")
791777;
792778return val(a) >> val(b)
793−end,["__band"] = (a,b)
794−coroutine.yield(nil,"band")
779+end,["\95\95\98\97\110\100"] = function (a,b)
780+coroutine.yield(nil,"\98\97\110\100")
795781return val(a) & val(b)
796−end,["__bor"] = (a,b)
797−coroutine.yield(nil,"bor")
782+end,["\95\95\98\111\114"] = function (a,b)
783+coroutine.yield(nil,"\98\111\114")
798784;
799785return val(a) | val(b)
800−end,["__bxor"] = (a,b)
801−coroutine.yield(nil,"bxor")
786+end,["\95\95\98\120\111\114"] = function (a,b)
787+coroutine.yield(nil,"\98\120\111\114")
802788;
803789return val(a) ~ val(b)
804−end,["__concat"] = (a,b)
805−coroutine.yield(nil,"concat")
790+end,["\95\95\99\111\110\99\97\116"] = function (a,b)
791+coroutine.yield(nil,"\99\111\110\99\97\116")
806792;
807793return val(a) .. val(b)
808−end,["__index"] = (t,k)
809−coroutine.yield(nil,"idx")
794+end,["\95\95\105\110\100\101\120"] = function (t,k)
795+coroutine.yield(nil,"\105\100\120")
810796;
811797return t.k[k]
812−end,["__newindex"] = (t,k,v)
813−coroutine.yield(nil,"nidx")
798+end,["\95\95\110\101\119\105\110\100\101\120"] = function (t,k,v)
799+coroutine.yield(nil,"\110\105\100\120")
814800;
815801t.k[k]=v
816802end}
817803local function new
818804(x)
819−return setmetatable({["x"] = x,["k"] = {}},mt)
805+return setmetatable({["\120"] = x,["\107"] = {}},mt)
820806end
821807local a = new(10)
822808local b = new(12)
823−local c = new("hello")
809+local c = new("\104\101\108\108\111")
824810local function run
825811(f,t)
826812local i = 1
@@ -835,162 +821,165 @@ end
835821assert(stat == t[i])
836822i=i + 1
837823end
838−assert(run(()
824+end
825+assert(run(function ()
839826if (a >= b) then
840−return ">="
827+return "\62\61"
841828else
842−return "<"
829+return "\60"
843830end
844−end,{"le","sub"}) == "<")
845−assert(run(()
831+end,{"\108\101","\115\117\98"}) == "\60")
832+assert(run(function ()
846833if (a <= b) then
847−return "<="
834+return "\60\61"
848835else
849−return ">"
836+return "\62"
850837end
851−end,{"le","sub"}) == "<=")
852−assert(run(()
838+end,{"\108\101","\115\117\98"}) == "\60\61")
839+assert(run(function ()
853840if (a == b) then
854−return "=="
841+return "\61\61"
855842else
856−return "~="
843+return "\126\61"
857844end
858−end,{"eq"}) == "~=")
859−assert(run(()
845+end,{"\101\113"}) == "\126\61")
846+assert(run(function ()
860847return a & b + a
861−end,{"add","band"}) == 2)
862−assert(run(()
848+end,{"\97\100\100","\98\97\110\100"}) == 2)
849+assert(run(function ()
863850return 1 + a
864−end,{"add"}) == 11)
865−assert(run(()
851+end,{"\97\100\100"}) == 11)
852+assert(run(function ()
866853return a - 25
867−end,{"sub"}) == - 15)
868−assert(run(()
854+end,{"\115\117\98"}) == - 15)
855+assert(run(function ()
869856return 2 * a
870−end,{"mul"}) == 20)
871−assert(run(()
857+end,{"\109\117\108"}) == 20)
858+assert(run(function ()
872859return a ^ 2
873−end,{"pow"}) == 100)
874−assert(run(()
860+end,{"\112\111\119"}) == 100)
861+assert(run(function ()
875862return a / 2
876−end,{"div"}) == 5)
877−assert(run(()
863+end,{"\100\105\118"}) == 5)
864+assert(run(function ()
878865return a % 6
879−end,{"mod"}) == 4)
880−assert(run(()
866+end,{"\109\111\100"}) == 4)
867+assert(run(function ()
881868return a // 3
882−end,{"idiv"}) == 3)
883−assert(run(()
869+end,{"\105\100\105\118"}) == 3)
870+assert(run(function ()
884871return a + b
885−end,{"add"}) == 22)
886−assert(run(()
872+end,{"\97\100\100"}) == 22)
873+assert(run(function ()
887874return a - b
888−end,{"sub"}) == - 2)
889−assert(run(()
875+end,{"\115\117\98"}) == - 2)
876+assert(run(function ()
890877return a * b
891−end,{"mul"}) == 120)
892−assert(run(()
878+end,{"\109\117\108"}) == 120)
879+assert(run(function ()
893880return a ^ b
894−end,{"pow"}) == 10 ^ 12)
895−assert(run(()
881+end,{"\112\111\119"}) == 10 ^ 12)
882+assert(run(function ()
896883return a / b
897−end,{"div"}) == 10 / 12)
898−assert(run(()
884+end,{"\100\105\118"}) == 10 / 12)
885+assert(run(function ()
899886return a % b
900−end,{"mod"}) == 10)
901−assert(run(()
887+end,{"\109\111\100"}) == 10)
888+assert(run(function ()
902889return a // b
903−end,{"idiv"}) == 0)
904−local a1000 = new(1e3)
905−assert(run(()
906−return a1000 + 1e3
907−end,{"add"}) == 2e3)
908−assert(run(()
909−return a1000 - 2.5e4
910−end,{"sub"}) == - 2.4e4)
911−assert(run(()
912−return 2e3 * a
913−end,{"mul"}) == 2e4)
914−assert(run(()
915−return a1000 / 1e3
916−end,{"div"}) == 1)
917−assert(run(()
890+end,{"\105\100\105\118"}) == 0)
891+local a1000 = new(1000)
892+assert(run(function ()
893+return a1000 + 1000
894+end,{"\97\100\100"}) == 2000)
895+assert(run(function ()
896+return a1000 - 25000
897+end,{"\115\117\98"}) == - 24000)
898+assert(run(function ()
899+return 2000 * a
900+end,{"\109\117\108"}) == 20000)
901+assert(run(function ()
902+return a1000 / 1000
903+end,{"\100\105\118"}) == 1)
904+assert(run(function ()
918905return a1000 % 600
919−end,{"mod"}) == 400)
920−assert(run(()
906+end,{"\109\111\100"}) == 400)
907+assert(run(function ()
921908return a1000 // 500
922−end,{"idiv"}) == 2)
923−assert(run(()
909+end,{"\105\100\105\118"}) == 2)
910+assert(run(function ()
924911return a % b
925−end,{"mod"}) == 10)
926−assert(run(()
912+end,{"\109\111\100"}) == 10)
913+assert(run(function ()
927914return ~ a & b
928−end,{"bnot","band"}) == ~ 10 & 12)
929−assert(run(()
915+end,{"\98\110\111\116","\98\97\110\100"}) == ~ 10 & 12)
916+assert(run(function ()
930917return a | b
931−end,{"bor"}) == 10 | 12)
932−assert(run(()
918+end,{"\98\111\114"}) == 10 | 12)
919+assert(run(function ()
933920return a ~ b
934−end,{"bxor"}) == 10 ~ 12)
935−assert(run(()
921+end,{"\98\120\111\114"}) == 10 ~ 12)
922+assert(run(function ()
936923return a << b
937−end,{"shl"}) == 10 << 12)
938−assert(run(()
924+end,{"\115\104\108"}) == 10 << 12)
925+assert(run(function ()
939926return a >> b
940−end,{"shr"}) == 10 >> 12)
941−assert(run(()
927+end,{"\115\104\114"}) == 10 >> 12)
928+assert(run(function ()
942929return 10 & b
943−end,{"band"}) == 10 & 12)
944−assert(run(()
930+end,{"\98\97\110\100"}) == 10 & 12)
931+assert(run(function ()
945932return a | 2
946−end,{"bor"}) == 10 | 2)
947−assert(run(()
933+end,{"\98\111\114"}) == 10 | 2)
934+assert(run(function ()
948935return a ~ 2
949−end,{"bxor"}) == 10 ~ 2)
950−assert(run(()
936+end,{"\98\120\111\114"}) == 10 ~ 2)
937+assert(run(function ()
951938return a >> 2
952−end,{"shr"}) == 10 >> 2)
953−assert(run(()
939+end,{"\115\104\114"}) == 10 >> 2)
940+assert(run(function ()
954941return 1 >> a
955−end,{"shr"}) == 1 >> 10)
956−assert(run(()
942+end,{"\115\104\114"}) == 1 >> 10)
943+assert(run(function ()
957944return a << 2
958−end,{"shl"}) == 10 << 2)
959−assert(run(()
945+end,{"\115\104\108"}) == 10 << 2)
946+assert(run(function ()
960947return 1 << a
961−end,{"shl"}) == 1 << 10)
962−assert(run(()
948+end,{"\115\104\108"}) == 1 << 10)
949+assert(run(function ()
963950return 2 ~ a
964−end,{"bxor"}) == 2 ~ 10)
965−assert(run(()
951+end,{"\98\120\111\114"}) == 2 ~ 10)
952+assert(run(function ()
966953return a .. b
967−end,{"concat"}) == "1012")
968−assert(run(()
954+end,{"\99\111\110\99\97\116"}) == "\49\48\49\50")
955+assert(run(function ()
969956return a .. b .. c .. a
970−end,{"concat","concat","concat"}) == "1012hello10")
971−assert(run(()
972−return "a" .. "b" .. a .. "c" .. c .. b .. "x"
973−end,{"concat","concat","concat"}) == "ab10chello12x")
974−local mt1 = {["__le"] = (a,b)
957+end,{"\99\111\110\99\97\116","\99\111\110\99\97\116","\99\111\110\99\97\116"}) == "\49\48\49\50\104\101\108\108\111\49\48")
958+assert(run(function ()
959+return "\97" .. "\98" .. a .. "\99" .. c .. b .. "\120"
960+end,{"\99\111\110\99\97\116","\99\111\110\99\97\116","\99\111\110\99\97\116"}) == "\97\98\49\48\99\104\101\108\108\111\49\50\120")
961+do
962+local mt1 = {["\95\95\108\101"] = function (a,b)
975963coroutine.yield(10)
976964return (val(a) <= val(b))
977−end,["__lt"] = (a,b)
965+end,["\95\95\108\116"] = function (a,b)
978966coroutine.yield(10)
979967return val(a) < val(b)
980968end}
981−local mt2 = {["__lt"] = mt1.__lt,["__le"] = mt1.__le}
969+local mt2 = {["\95\95\108\116"] = mt1.__lt,["\95\95\108\101"] = mt1.__le}
982970local function run
983971(f)
984972local co = coroutine.wrap(f)
985−local res =
973+local res
986974repeat
987−res=co()until res ~= 10
975+res=co()
976+until res ~= 10
988977return res
989978end
990979local function test
991980()
992−local a1 = setmetatable({["x"] = 1},mt1)
993−local a2 = setmetatable({["x"] = 2},mt2)
981+local a1 = setmetatable({["\120"] = 1},mt1)
982+local a2 = setmetatable({["\120"] = 2},mt2)
994983assert(a1 < a2)
995984assert(a1 <= a2)
996985assert(1 < a2)
@@ -1000,70 +989,68 @@ assert(2 >= a2)
1000989return true
1001990end
1002991run(test)
1003−assert(run(()
992+end
993+assert(run(function ()
1004994a.BB=print
1005995return a.BB
1006−end,{"nidx","idx"}) == print)
996+end,{"\110\105\100\120","\105\100\120"}) == print)
997+do
1007998local _ENV = _ENV
1008−f=()
999+f=function ()
10091000AAA=BBB + 1
10101001;
10111002return AAA
10121003end
1004+end
10131005local g = new(10)
10141006;
10151007g.k.BBB=10
10161008;
10171009debug.setupvalue(f,1,g)
1018−assert(run(f,{"idx","nidx","idx"}) == 11)
1010+assert(run(f,{"\105\100\120","\110\105\100\120","\105\100\120"}) == 11)
10191011assert(g.k.AAA == 11)
1020−print("+")
1021−print("testing yields inside 'for' iterators")
1022−local f = (s,i)
1012+print("\43")
1013+print("\116\101\115\116\105\110\103\32\121\105\101\108\100\115\32\105\110\115\105\100\101\32\39\102\111\114\39\32\105\116\101\114\97\116\111\114\115")
1014+local f = function (s,i)
10231015if i % 2 == 0 then
1024−coroutine.yield(nil,"for")
1016+coroutine.yield(nil,"\102\111\114")
10251017end
10261018if i < s then
10271019return i + 1
10281020end
10291021end
1030−assert(run(()
1022+assert(run(function ()
10311023local s = 0
10321024for i in f,4,0
10331025do
10341026s=s + i
10351027end
10361028return s
1037−end,{"for","for","for"}) == 10)
1029+end,{"\102\111\114","\102\111\114","\102\111\114"}) == 10)
10381030if T == nil then
1039−(Message or print)("
1040− >>> testC not active: skipping coroutine API tests <<<
1041−")
1042−print("OK")
1031+(Message or print)("\10\32\62\62\62\32\116\101\115\116\67\32\110\111\116\32\97\99\116\105\118\101\58\32\115\107\105\112\112\105\110\103\32\99\111\114\111\117\116\105\110\101\32\65\80\73\32\116\101\115\116\115\32\60\60\60\10")
1032+print("\79\75")
10431033;
10441034return
10451035end
1046−print("testing coroutine API")
1036+print("\116\101\115\116\105\110\103\32\99\111\114\111\117\116\105\110\101\32\65\80\73")
10471037local function apico
10481038(...)
10491039local x = {...}
1050−return coroutine.wrap(()
1040+return coroutine.wrap(function ()
10511041return T.testC(table.unpack(x))
10521042end)
10531043end
1054−local a = {apico(" pushstring errorcode
1055− pcallk 1 0 2;
1056− invalid command (should not arrive here)
1057−","return *","stackmark",error)()}
1058−assert(# a == 4 and a[3] == "stackmark" and a[4] == "errorcode" and _G.status == "ERRRUN" and _G.ctx == 2)
1059−local co = apico("pushvalue 2; pushnum 10; pcallk 1 2 3; invalid command;",coroutine.yield,"getglobal status; getglobal ctx; pushvalue 2; pushstring a; pcallk 1 0 4; invalid command","getglobal status; getglobal ctx; return *")
1044+local a = {apico("\32\32\112\117\115\104\115\116\114\105\110\103\32\101\114\114\111\114\99\111\100\101\10\32\32\112\99\97\108\108\107\32\49\32\48\32\50\59\10\32\32\105\110\118\97\108\105\100\32\99\111\109\109\97\110\100\32\40\115\104\111\117\108\100\32\110\111\116\32\97\114\114\105\118\101\32\104\101\114\101\41\10","\114\101\116\117\114\110\32\42","\115\116\97\99\107\109\97\114\107",error)()}
1045+assert(# a == 4 and a[3] == "\115\116\97\99\107\109\97\114\107" and a[4] == "\101\114\114\111\114\99\111\100\101" and _G.status == "\69\82\82\82\85\78" and _G.ctx == 2)
1046+local co = apico("\112\117\115\104\118\97\108\117\101\32\50\59\32\112\117\115\104\110\117\109\32\49\48\59\32\112\99\97\108\108\107\32\49\32\50\32\51\59\32\105\110\118\97\108\105\100\32\99\111\109\109\97\110\100\59",coroutine.yield,"\103\101\116\103\108\111\98\97\108\32\115\116\97\116\117\115\59\32\103\101\116\103\108\111\98\97\108\32\99\116\120\59\32\112\117\115\104\118\97\108\117\101\32\50\59\32\112\117\115\104\115\116\114\105\110\103\32\97\59\32\112\99\97\108\108\107\32\49\32\48\32\52\59\32\105\110\118\97\108\105\100\32\99\111\109\109\97\110\100","\103\101\116\103\108\111\98\97\108\32\115\116\97\116\117\115\59\32\103\101\116\103\108\111\98\97\108\32\99\116\120\59\32\114\101\116\117\114\110\32\42")
10601047assert(co() == 10)
1061−assert(co(20,30) == "a")
1048+assert(co(20,30) == "\97")
10621049a={co()}
1063−assert(# a == 10 and a[2] == coroutine.yield and a[5] == 20 and a[6] == 30 and a[7] == "YIELD" and a[8] == 3 and a[9] == "YIELD" and a[10] == 4)
1050+assert(# a == 10 and a[2] == coroutine.yield and a[5] == 20 and a[6] == 30 and a[7] == "\89\73\69\76\68" and a[8] == 3 and a[9] == "\89\73\69\76\68" and a[10] == 4)
10641051assert(not pcall(co))
1065−f=T.makeCfunc("pushnum 3; pushnum 5; yield 1;")
1066−co=coroutine.wrap(()
1052+f=T.makeCfunc("\112\117\115\104\110\117\109\32\51\59\32\112\117\115\104\110\117\109\32\53\59\32\121\105\101\108\100\32\49\59")
1053+co=coroutine.wrap(function ()
10671054assert(f() == 23)
10681055;
10691056assert(f() == 23)
@@ -1073,34 +1060,15 @@ end)
10731060assert(co(23,16) == 5)
10741061assert(co(23,16) == 5)
10751062assert(co(23,16) == 10)
1076−f=T.makeCfunc(" pushnum 102
1077− yieldk 1 U2
1078− cannot be here!
1079−"," # continuation
1080− pushvalue U3 # accessing upvalues inside a continuation
1081− pushvalue U4
1082− return *
1083−",23,"huu")
1063+f=T.makeCfunc("\32\32\32\32\32\32\32\32\112\117\115\104\110\117\109\32\49\48\50\10\9\121\105\101\108\100\107\9\49\32\85\50\10\9\99\97\110\110\111\116\32\98\101\32\104\101\114\101\33\10","\32\32\32\32\32\32\35\32\99\111\110\116\105\110\117\97\116\105\111\110\10\9\112\117\115\104\118\97\108\117\101\32\85\51\32\32\32\35\32\97\99\99\101\115\115\105\110\103\32\117\112\118\97\108\117\101\115\32\105\110\115\105\100\101\32\97\32\99\111\110\116\105\110\117\97\116\105\111\110\10\32\32\32\32\32\32\32\32\112\117\115\104\118\97\108\117\101\32\85\52\10\9\114\101\116\117\114\110\32\42\10",23,"\104\117\117")
10841064x=coroutine.wrap(f)
10851065assert(x() == 102)
1086−eqtab({x()},{23,"huu"})
1087−f=T.makeCfunc("pushstring 'a'; pushnum 102; yield 2; ")
1088−a,b,c,d=T.testC("newthread; pushvalue 2; xmove 0 3 1; resume 3 0;
1089− pushstatus; xmove 3 0 0; resume 3 0; pushstatus;
1090− return 4; ",f)
1091−assert(a == "YIELD" and b == "a" and c == 102 and d == "OK")
1066+eqtab({x()},{23,"\104\117\117"})
1067+f=T.makeCfunc("\112\117\115\104\115\116\114\105\110\103\32\39\97\39\59\32\112\117\115\104\110\117\109\32\49\48\50\59\32\121\105\101\108\100\32\50\59\32")
1068+a,b,c,d=T.testC("\110\101\119\116\104\114\101\97\100\59\32\112\117\115\104\118\97\108\117\101\32\50\59\32\120\109\111\118\101\32\48\32\51\32\49\59\32\114\101\115\117\109\101\32\51\32\48\59\10\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\112\117\115\104\115\116\97\116\117\115\59\32\120\109\111\118\101\32\51\32\48\32\48\59\32\32\114\101\115\117\109\101\32\51\32\48\59\32\112\117\115\104\115\116\97\116\117\115\59\10\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\114\101\116\117\114\110\32\52\59\32",f)
1069+assert(a == "\89\73\69\76\68" and b == "\97" and c == 102 and d == "\79\75")
10921070local count = 3
1093−f=T.makeCfunc(" remove 1; # remove argument
1094− pushvalue U3; # get selection function
1095− call 0 1; # call it (result is 'f' or 'yield')
1096− pushstring hello # single argument for selected function
1097− pushupvalueindex 2; # index of continuation program
1098− callk 1 -1 .; # call selected function
1099− errorerror # should never arrive here
1100−"," # continuation program
1101− pushnum 34 # return value
1102− return * # return all results
1103−",()
1071+f=T.makeCfunc("\32\32\114\101\109\111\118\101\32\49\59\32\32\32\32\32\32\32\32\32\32\32\32\32\35\32\114\101\109\111\118\101\32\97\114\103\117\109\101\110\116\10\32\32\112\117\115\104\118\97\108\117\101\32\85\51\59\32\32\32\32\32\32\32\32\32\35\32\103\101\116\32\115\101\108\101\99\116\105\111\110\32\102\117\110\99\116\105\111\110\10\32\32\99\97\108\108\32\48\32\49\59\32\32\32\32\32\32\32\32\32\32\32\32\32\35\32\99\97\108\108\32\105\116\32\32\40\114\101\115\117\108\116\32\105\115\32\39\102\39\32\111\114\32\39\121\105\101\108\100\39\41\10\32\32\112\117\115\104\115\116\114\105\110\103\32\104\101\108\108\111\32\32\32\32\32\32\35\32\115\105\110\103\108\101\32\97\114\103\117\109\101\110\116\32\102\111\114\32\115\101\108\101\99\116\101\100\32\102\117\110\99\116\105\111\110\10\32\32\112\117\115\104\117\112\118\97\108\117\101\105\110\100\101\120\32\50\59\32\32\32\35\32\105\110\100\101\120\32\111\102\32\99\111\110\116\105\110\117\97\116\105\111\110\32\112\114\111\103\114\97\109\10\32\32\99\97\108\108\107\32\49\32\45\49\32\46\59\9\9\35\32\99\97\108\108\32\115\101\108\101\99\116\101\100\32\102\117\110\99\116\105\111\110\10\32\32\101\114\114\111\114\101\114\114\111\114\9\9\35\32\115\104\111\117\108\100\32\110\101\118\101\114\32\97\114\114\105\118\101\32\104\101\114\101\10","\32\32\35\32\99\111\110\116\105\110\117\97\116\105\111\110\32\112\114\111\103\114\97\109\10\32\32\112\117\115\104\110\117\109\32\51\52\9\35\32\114\101\116\117\114\110\32\118\97\108\117\101\10\32\32\114\101\116\117\114\110\32\42\32\32\32\32\32\35\32\114\101\116\117\114\110\32\97\108\108\32\114\101\115\117\108\116\115\10",function ()
11041072count=count - 1
11051073if count == 0 then
11061074return coroutine.yield
@@ -1108,64 +1076,44 @@ else
11081076return f
11091077end
11101078end)
1111−co=coroutine.wrap(()
1079+co=coroutine.wrap(function ()
11121080return f(nil)
11131081end)
1114−assert(co() == "hello")
1082+assert(co() == "\104\101\108\108\111")
11151083a={co()}
11161084assert(# a == 3 and a[1] == a[2] and a[2] == a[3] and a[3] == 34)
1117−local y =
1118−co=coroutine.wrap((...)
1119−return T.testC(" # initial function
1120− yieldk 1 2
1121− cannot be here!
1122− "," # 1st continuation
1123− yieldk 0 3
1124− cannot be here!
1125− "," # 2nd continuation
1126− yieldk 0 4
1127− cannot be here!
1128− "," # 3th continuation
1129− pushvalue 6 # function which is last arg. to 'testC' here
1130− pushnum 10; pushnum 20;
1131− pcall 2 0 0 # call should throw an error and return to next line
1132− pop 1 # remove error message
1133− pushvalue 6
1134− getglobal status; getglobal ctx
1135− pcallk 2 2 5 # call should throw an error and jump to continuation
1136− cannot be here!
1137− "," # 4th (and last) continuation
1138− return *
1139− ",(a,b)
1085+local y
1086+co=coroutine.wrap(function (...)
1087+return T.testC("\32\35\32\105\110\105\116\105\97\108\32\102\117\110\99\116\105\111\110\10\32\32\32\32\32\32\32\32\32\32\121\105\101\108\100\107\32\49\32\50\10\32\32\32\32\32\32\32\32\32\32\99\97\110\110\111\116\32\98\101\32\104\101\114\101\33\10\32\32\32\32\32\32\32","\32\32\35\32\49\115\116\32\99\111\110\116\105\110\117\97\116\105\111\110\10\32\32\32\32\32\32\32\32\32\121\105\101\108\100\107\32\48\32\51\32\10\32\32\32\32\32\32\32\32\32\99\97\110\110\111\116\32\98\101\32\104\101\114\101\33\10\32\32\32\32\32\32\32","\32\32\35\32\50\110\100\32\99\111\110\116\105\110\117\97\116\105\111\110\10\32\32\32\32\32\32\32\32\32\121\105\101\108\100\107\32\48\32\52\32\10\32\32\32\32\32\32\32\32\32\99\97\110\110\111\116\32\98\101\32\104\101\114\101\33\10\32\32\32\32\32\32\32","\32\32\35\32\51\116\104\32\99\111\110\116\105\110\117\97\116\105\111\110\10\32\32\32\32\32\32\32\32\32\32\112\117\115\104\118\97\108\117\101\32\54\32\32\32\35\32\102\117\110\99\116\105\111\110\32\119\104\105\99\104\32\105\115\32\108\97\115\116\32\97\114\103\46\32\116\111\32\39\116\101\115\116\67\39\32\104\101\114\101\10\32\32\32\32\32\32\32\32\32\32\112\117\115\104\110\117\109\32\49\48\59\32\112\117\115\104\110\117\109\32\50\48\59\10\32\32\32\32\32\32\32\32\32\32\112\99\97\108\108\32\50\32\48\32\48\32\32\32\35\32\99\97\108\108\32\115\104\111\117\108\100\32\116\104\114\111\119\32\97\110\32\101\114\114\111\114\32\97\110\100\32\114\101\116\117\114\110\32\116\111\32\110\101\120\116\32\108\105\110\101\10\32\32\32\32\32\32\32\32\32\32\112\111\112\32\49\9\9\35\32\114\101\109\111\118\101\32\101\114\114\111\114\32\109\101\115\115\97\103\101\10\32\32\32\32\32\32\32\32\32\32\112\117\115\104\118\97\108\117\101\32\54\10\32\32\32\32\32\32\32\32\32\32\103\101\116\103\108\111\98\97\108\32\115\116\97\116\117\115\59\32\103\101\116\103\108\111\98\97\108\32\99\116\120\10\32\32\32\32\32\32\32\32\32\32\112\99\97\108\108\107\32\50\32\50\32\53\32\32\35\32\99\97\108\108\32\115\104\111\117\108\100\32\116\104\114\111\119\32\97\110\32\101\114\114\111\114\32\97\110\100\32\106\117\109\112\32\116\111\32\99\111\110\116\105\110\117\97\116\105\111\110\10\32\32\32\32\32\32\32\32\32\32\99\97\110\110\111\116\32\98\101\32\104\101\114\101\33\10\32\32\32\32\32\32\32","\32\32\35\32\52\116\104\32\40\97\110\100\32\108\97\115\116\41\32\99\111\110\116\105\110\117\97\116\105\111\110\10\32\32\32\32\32\32\32\32\32\114\101\116\117\114\110\32\42\10\32\32\32\32\32\32\32",function (a,b)
11401088x=a
11411089;
11421090y=b
11431091;
1144−error("errmsg")
1092+error("\101\114\114\109\115\103")
11451093end,...)
11461094end)
11471095local a = {co(3,4,6)}
11481096assert(a[1] == 6 and a[2] == undef)
11491097a={co()}
11501098;
1151−assert(a[1] == undef and _G.status == "YIELD" and _G.ctx == 2)
1099+assert(a[1] == undef and _G.status == "\89\73\69\76\68" and _G.ctx == 2)
11521100a={co()}
11531101;
1154−assert(a[1] == undef and _G.status == "YIELD" and _G.ctx == 3)
1102+assert(a[1] == undef and _G.status == "\89\73\69\76\68" and _G.ctx == 3)
11551103a={co(7,8)}
11561104;
1157−assert(type(a[1]) == "string" and type(a[2]) == "string" and type(a[3]) == "string" and type(a[4]) == "string" and type(a[5]) == "string" and type(a[6]) == "function")
1105+assert(type(a[1]) == "\115\116\114\105\110\103" and type(a[2]) == "\115\116\114\105\110\103" and type(a[3]) == "\115\116\114\105\110\103" and type(a[4]) == "\115\116\114\105\110\103" and type(a[5]) == "\115\116\114\105\110\103" and type(a[6]) == "\102\117\110\99\116\105\111\110")
11581106assert(a[7] == 3 and a[8] == 4)
11591107assert(a[9] == 7 and a[10] == 8)
1160−assert(a[11]:find("errmsg") and # a == 11)
1161−assert(x == "YIELD" and y == 4)
1108+assert(a[11]:find("\101\114\114\109\115\103") and # a == 11)
1109+assert(x == "\89\73\69\76\68" and y == 4)
11621110assert(not pcall(co))
11631111_G.ctx=nil
11641112_G.status=nil
1165−local co = coroutine.wrap(()
1166−local a = {pcall(pcall,pcall,pcall,pcall,pcall,pcall,pcall,error,"hi")}
1113+local co = coroutine.wrap(function ()
1114+local a = {pcall(pcall,pcall,pcall,pcall,pcall,pcall,pcall,error,"\104\105")}
11671115return pcall(assert,table.unpack(a))
11681116end)
11691117local a = {co()}
1170−assert(a[10] == "hi")
1171−print("OK")
1118+assert(a[10] == "\104\105")
1119+print("\79\75")
zod/luau/res/lua/cycled/cstack.lua+60−46
@@ -1,11 +1,12 @@
1−local tracegc = require("tracegc")
2−print("testing stack overflow detection")
1+local tracegc = require("\116\114\97\99\101\103\99")
2+print("\116\101\115\116\105\110\103\32\115\116\97\99\107\32\111\118\101\114\102\108\111\119\32\100\101\116\101\99\116\105\111\110")
33local function checkerror
44(msg,f, ...)
55local s,err = pcall(f,...)
66assert(not s and string.find(err,msg))
77end
8−print("testing stack overflow in message handling")
8+do
9+print("\116\101\115\116\105\110\103\32\115\116\97\99\107\32\111\118\101\114\102\108\111\119\32\105\110\32\109\101\115\115\97\103\101\32\104\97\110\100\108\105\110\103")
910local count = 0
1011local function loop
1112(x,y,z)
@@ -15,63 +16,71 @@ end
1516tracegc.stop()
1617local res,msg = xpcall(loop,loop)
1718tracegc.start()
18−assert(msg == "error in error handling")
19−print("final count: ",count)
20−print("testing recursion inside pattern matching")
19+assert(msg == "\101\114\114\111\114\32\105\110\32\101\114\114\111\114\32\104\97\110\100\108\105\110\103")
20+print("\102\105\110\97\108\32\99\111\117\110\116\58\32",count)
21+end
22+do
23+print("\116\101\115\116\105\110\103\32\114\101\99\117\114\115\105\111\110\32\105\110\115\105\100\101\32\112\97\116\116\101\114\110\32\109\97\116\99\104\105\110\103")
2124local function f
2225(size)
23−local s = string.rep("a",size)
24−local p = string.rep(".?",size)
26+local s = string.rep("\97",size)
27+local p = string.rep("\46\63",size)
2528return string.match(s,p)
2629end
2730local m = f(80)
2831assert(# m == 80)
29−checkerror("too complex",f,2e3)
30−print("testing stack-overflow in recursive 'gsub'")
32+checkerror("\116\111\111\32\99\111\109\112\108\101\120",f,2000)
33+end
34+do
35+print("\116\101\115\116\105\110\103\32\115\116\97\99\107\45\111\118\101\114\102\108\111\119\32\105\110\32\114\101\99\117\114\115\105\118\101\32\39\103\115\117\98\39")
3136local count = 0
3237local function foo
3338()
3439count=count + 1
35−string.gsub("a",".",foo)
40+string.gsub("\97","\46",foo)
3641end
37−checkerror("stack overflow",foo)
38−print("final count: ",count)
39−print("testing stack-overflow in recursive 'gsub' with metatables")
42+checkerror("\115\116\97\99\107\32\111\118\101\114\102\108\111\119",foo)
43+print("\102\105\110\97\108\32\99\111\117\110\116\58\32",count)
44+print("\116\101\115\116\105\110\103\32\115\116\97\99\107\45\111\118\101\114\102\108\111\119\32\105\110\32\114\101\99\117\114\115\105\118\101\32\39\103\115\117\98\39\32\119\105\116\104\32\109\101\116\97\116\97\98\108\101\115")
4045local count = 0
41−local t = setmetatable({},{["__index"] = foo})
42−foo=()
46+local t = setmetatable({},{["\95\95\105\110\100\101\120"] = foo})
47+foo=function ()
4348count=count + 1
44−string.gsub("a",".",t)
49+string.gsub("\97","\46",t)
50+end
51+checkerror("\115\116\97\99\107\32\111\118\101\114\102\108\111\119",foo)
52+print("\102\105\110\97\108\32\99\111\117\110\116\58\32",count)
4553end
46−checkerror("stack overflow",foo)
47−print("final count: ",count)
48−print("testing limits in coroutines inside deep calls")
54+do
55+print("\116\101\115\116\105\110\103\32\108\105\109\105\116\115\32\105\110\32\99\111\114\111\117\116\105\110\101\115\32\105\110\115\105\100\101\32\100\101\101\112\32\99\97\108\108\115")
4956local count = 0
50−local lim = 1e3
57+local lim = 1000
5158local function stack
5259(n)
5360if n > 0 then
5461return stack(n - 1) + 1
5562else
56−coroutine.wrap(()
63+coroutine.wrap(function ()
5764count=count + 1
5865stack(lim)
5966end)()
6067end
6168end
62−local st,msg = xpcall(stack,()
63−return "ok"
69+local st,msg = xpcall(stack,function ()
70+return "\111\107"
6471end,lim)
65−assert(not st and msg == "ok")
66−print("final count: ",count)
72+assert(not st and msg == "\111\107")
73+print("\102\105\110\97\108\32\99\111\117\110\116\58\32",count)
74+end
75+do
6776local count = 0
68−print("chain of 'coroutine.close'")
77+print("\99\104\97\105\110\32\111\102\32\39\99\111\114\111\117\116\105\110\101\46\99\108\111\115\101\39")
6978local coro = false
70−for i = 1, 1e3
79+for i = 1, 1000
7180do
7281local previous = coro
73−coro=coroutine.create(()
74−local cc <close> = setmetatable({},{["__close"] = ()
82+coro=coroutine.create(function ()
83+local cc <close> = setmetatable({},{["\95\95\99\108\111\115\101"] = function ()
7584count=count + 1
7685if previous then
7786assert(coroutine.close(previous))
@@ -82,9 +91,11 @@ end)
8291assert(coroutine.resume(coro))
8392end
8493local st,msg = coroutine.close(coro)
85−assert(not st and string.find(msg,"C stack overflow"))
86−print("final count: ",count)
87−print("nesting of resuming yielded coroutines")
94+assert(not st and string.find(msg,"\67\32\115\116\97\99\107\32\111\118\101\114\102\108\111\119"))
95+print("\102\105\110\97\108\32\99\111\117\110\116\58\32",count)
96+end
97+do
98+print("\110\101\115\116\105\110\103\32\111\102\32\114\101\115\117\109\105\110\103\32\121\105\101\108\100\101\100\32\99\111\114\111\117\116\105\110\101\115")
8899local count = 0
89100local function body
90101()
@@ -98,8 +109,10 @@ end
98109local f = coroutine.wrap(body)
99110f()
100111assert(not pcall(f))
101−print("final count: ",count)
102−print("nesting coroutines running after recoverable errors")
112+print("\102\105\110\97\108\32\99\111\117\110\116\58\32",count)
113+end
114+do
115+print("\110\101\115\116\105\110\103\32\99\111\114\111\117\116\105\110\101\115\32\114\117\110\110\105\110\103\32\97\102\116\101\114\32\114\101\99\111\118\101\114\97\98\108\101\32\101\114\114\111\114\115")
103116local count = 0
104117local function foo
105118()
@@ -107,17 +120,18 @@ count=count + 1
107120pcall(1)
108121coroutine.wrap(foo)()
109122end
110−checkerror("C stack overflow",foo)
111−print("final count: ",count)
123+checkerror("\67\32\115\116\97\99\107\32\111\118\101\114\102\108\111\119",foo)
124+print("\102\105\110\97\108\32\99\111\117\110\116\58\32",count)
125+end
112126if T then
113−print("testing stack recovery")
127+print("\116\101\115\116\105\110\103\32\115\116\97\99\107\32\114\101\99\111\118\101\114\121")
114128local N = 0
115129local LIM = - 1
116−local stack1 =
117−local dummy =
130+local stack1
131+local dummy
118132local function err
119133(msg)
120−assert(string.find(msg,"stack overflow"))
134+assert(string.find(msg,"\115\116\97\99\107\32\111\118\101\114\102\108\111\119"))
121135local _,stacknow = T.stacklevel()
122136assert(stacknow == stack1 + 200)
123137end
@@ -133,20 +147,20 @@ end
133147N=N + 1
134148f()
135149end
136−local topB,sizeB =
137−local topA,sizeA =
150+local topB,sizeB
151+local topA,sizeA
138152topB,sizeB=T.stacklevel()
139153tracegc.stop()
140154xpcall(f,err)
141155tracegc.start()
142156topA,sizeA=T.stacklevel()
143157assert(topA == topB and sizeA < sizeB * 2)
144−print(string.format("maximum stack size: %d",stack1))
158+print(string.format("\109\97\120\105\109\117\109\32\115\116\97\99\107\32\115\105\122\101\58\32\37\100",stack1))
145159LIM=N
146160N=0
147161tracegc.stop()
148162f()
149163tracegc.start()
150−print("+")
164+print("\43")
151165end
152−print("OK")
166+print("\79\75")
zod/luau/res/lua/cycled/db.lua+282−344
@@ -1,10 +1,12 @@
1−local debug = require("debug")
1+local debug = require("\100\101\98\117\103")
22local function dostring
33(s)
44return assert(load(s))()
55end
6−print("testing debug library and debug information")
6+print("\116\101\115\116\105\110\103\32\100\101\98\117\103\32\108\105\98\114\97\114\121\32\97\110\100\32\100\101\98\117\103\32\105\110\102\111\114\109\97\116\105\111\110")
7+do
78local a = 1
9+end
810assert(not debug.gethook())
911local testline = 19
1012local function test
@@ -12,87 +14,87 @@ local function test
1214collectgarbage()
1315local function f
1416(event,line)
15−assert(event == "line")
17+assert(event == "\108\105\110\101")
1618local l = table.remove(l,1)
1719if p then
1820print(l,line)
1921end
20−assert(l == line,"wrong trace!!")
22+assert(l == line,"\119\114\111\110\103\32\116\114\97\99\101\33\33")
2123end
22−debug.sethook(f,"l")
24+debug.sethook(f,"\108")
2325;
2426load(s)()
2527;
2628debug.sethook()
2729assert(# l == 0)
2830end
29−assert(not pcall(debug.getinfo,print,"X"))
30−assert(not pcall(debug.getinfo,0,">"))
31−assert(not debug.getinfo(1e3))
31+do
32+assert(not pcall(debug.getinfo,print,"\88"))
33+assert(not pcall(debug.getinfo,0,"\62"))
34+assert(not debug.getinfo(1000))
3235assert(not debug.getinfo(- 1))
3336local a = debug.getinfo(print)
34−assert(a.what == "C" and a.short_src == "[C]")
35−a=debug.getinfo(print,"L")
37+assert(a.what == "\67" and a.short_src == "\91\67\93")
38+a=debug.getinfo(print,"\76")
3639assert(a.activelines == nil)
37−local b = debug.getinfo(test,"SfL")
38−assert(b.name == nil and b.what == "Lua" and b.linedefined == testline and b.lastlinedefined == b.linedefined + 10 and b.func == test and not string.find(b.short_src,"%["))
40+local b = debug.getinfo(test,"\83\102\76")
41+assert(b.name == nil and b.what == "\76\117\97" and b.linedefined == testline and b.lastlinedefined == b.linedefined + 10 and b.func == test and not string.find(b.short_src,"\37\91"))
3942assert(b.activelines[b.linedefined + 1] and b.activelines[b.lastlinedefined])
4043assert(not b.activelines[b.linedefined] and not b.activelines[b.lastlinedefined + 1])
41−local func = load(string.dump(load("print(10)"),true))
42−local actl = debug.getinfo(func,"L").activelines
44+end
45+do
46+local func = load(string.dump(load("\112\114\105\110\116\40\49\48\41"),true))
47+local actl = debug.getinfo(func,"\76").activelines
4348assert(# actl == 0)
44−local a = "function f () end"
49+end
50+local a = "\102\117\110\99\116\105\111\110\32\102\32\40\41\32\101\110\100"
4551local function dostring
4652(s,x)
4753return load(s,x)()
4854end
4955dostring(a)
50−assert(debug.getinfo(f).short_src == string.format("[string "%s"]",a))
51−dostring(a .. string.format("; %s
52−=1",string.rep("p",400)))
53−assert(string.find(debug.getinfo(f).short_src,"^%[string [^
54−]*%.%.%."%]$"))
55−dostring(a .. string.format("; %s=1",string.rep("p",400)))
56−assert(string.find(debug.getinfo(f).short_src,"^%[string [^
57−]*%.%.%."%]$"))
58−dostring("
59−" .. a)
60−assert(debug.getinfo(f).short_src == "[string "..."]")
56+assert(debug.getinfo(f).short_src == string.format("\91\115\116\114\105\110\103\32\34\37\115\34\93",a))
57+dostring(a .. string.format("\59\32\37\115\10\61\49",string.rep("\112",400)))
58+assert(string.find(debug.getinfo(f).short_src,"\94\37\91\115\116\114\105\110\103\32\91\94\10\93\42\37\46\37\46\37\46\34\37\93\36"))
59+dostring(a .. string.format("\59\32\37\115\61\49",string.rep("\112",400)))
60+assert(string.find(debug.getinfo(f).short_src,"\94\37\91\115\116\114\105\110\103\32\91\94\10\93\42\37\46\37\46\37\46\34\37\93\36"))
61+dostring("\10" .. a)
62+assert(debug.getinfo(f).short_src == "\91\115\116\114\105\110\103\32\34\46\46\46\34\93")
6163dostring(a,"")
62−assert(debug.getinfo(f).short_src == "[string ""]")
63−dostring(a,"@xuxu")
64−assert(debug.getinfo(f).short_src == "xuxu")
65−dostring(a,"@" .. string.rep("p",1e3) .. "t")
66−assert(string.find(debug.getinfo(f).short_src,"^%.%.%.p*t$"))
67−dostring(a,"=xuxu")
68−assert(debug.getinfo(f).short_src == "xuxu")
69−dostring(a,string.format("=%s",string.rep("x",500)))
70−assert(string.find(debug.getinfo(f).short_src,"^x*$"))
71−dostring(a,"=")
64+assert(debug.getinfo(f).short_src == "\91\115\116\114\105\110\103\32\34\34\93")
65+dostring(a,"\64\120\117\120\117")
66+assert(debug.getinfo(f).short_src == "\120\117\120\117")
67+dostring(a,"\64" .. string.rep("\112",1000) .. "\116")
68+assert(string.find(debug.getinfo(f).short_src,"\94\37\46\37\46\37\46\112\42\116\36"))
69+dostring(a,"\61\120\117\120\117")
70+assert(debug.getinfo(f).short_src == "\120\117\120\117")
71+dostring(a,string.format("\61\37\115",string.rep("\120",500)))
72+assert(string.find(debug.getinfo(f).short_src,"\94\120\42\36"))
73+dostring(a,"\61")
7274assert(debug.getinfo(f).short_src == "")
7375_G.a=nil
7476;
7577_G.f=nil
7678;
77−_G[string.rep("p",400)]=nil
79+_G[string.rep("\112",400)]=nil
7880repeat
79−local g = {["x"] = ()
81+local g = {["\120"] = function ()
8082local a = debug.getinfo(2)
81−assert(a.name == "f" and a.namewhat == "local")
83+assert(a.name == "\102" and a.namewhat == "\108\111\99\97\108")
8284a=debug.getinfo(1)
83−assert(a.name == "x" and a.namewhat == "field")
84−return "xixi"
85+assert(a.name == "\120" and a.namewhat == "\102\105\101\108\100")
86+return "\120\105\120\105"
8587end}
86−local f = ()
88+local f = function ()
8789return 1 + 1 and (not 1 or g.x())
8890end
89−assert(f() == "xixi")
91+assert(f() == "\120\105\120\105")
9092g=debug.getinfo(f)
91−assert(g.what == "Lua" and g.func == f and g.namewhat == "" and not g.name)
93+assert(g.what == "\76\117\97" and g.func == f and g.namewhat == "" and not g.name)
9294function f(x,name)
93−name=name or "f"
95+name=name or "\102"
9496local a = debug.getinfo(1)
95−assert(a.name == name and a.namewhat == "local")
97+assert(a.name == name and a.namewhat == "\108\111\99\97\108")
9698return x
9799end
98100if 3 > 4 then
@@ -111,6 +113,7 @@ while 1 do
111113local x = 10
112114;
113115break
116+end
114117;
115118f()
116119local b = 1
@@ -134,7 +137,8 @@ else
134137break
135138end
136139;
137−f()until 1
140+f()
141+until 1
138142g={}
139143f(g).x=f(2) and f(10) + f(9)
140144assert(g.x == f(19))
@@ -142,84 +146,41 @@ function g(x)
142146if not x then
143147return 3
144148end
145−return (x("a","x"))
149+return (x("\97","\120"))
146150end
147−assert(g(f) == "a")until 1
148−test("if
149−math.sin(1)
150−then
151− a=1
152−else
153− a=2
154−end
155−",{2,3,4,7})
156−test("local function foo()
157−end
158−foo()
159−A = 1
160−A = 2
161−A = 3
162−",{2,3,2,4,5,6})
151+assert(g(f) == "\97")
152+until 1
153+test("\105\102\10\109\97\116\104\46\115\105\110\40\49\41\10\116\104\101\110\10\32\32\97\61\49\10\101\108\115\101\10\32\32\97\61\50\10\101\110\100\10",{2,3,4,7})
154+test("\108\111\99\97\108\32\102\117\110\99\116\105\111\110\32\102\111\111\40\41\10\101\110\100\10\102\111\111\40\41\10\65\32\61\32\49\10\65\32\61\32\50\10\65\32\61\32\51\10",{2,3,2,4,5,6})
163155_G.A=nil
164−test("--
165−if nil then
166− a=1
167−else
168− a=2
169−end
170−",{2,5,6})
171−test("a=1
172−repeat
173− a=a+1
174−until a==3
175−",{1,3,4,3,4})
176−test(" do
177− return
178−end
179−",{2})
180−test("local a
181−a=1
182−while a<=3 do
183− a=a+1
184−end
185−",{1,2,3,4,3,4,3,4,3,5})
186−test("while math.sin(1) do
187− if math.sin(1)
188− then break
189− end
190−end
191−a=1",{1,2,3,6})
192−test("for i=1,3 do
193− a=i
194−end
195−",{1,2,1,2,1,2,1,3})
196−test("for i,v in pairs{'a','b'} do
197− a=tostring(i) .. v
198−end
199−",{1,2,1,2,1,3})
200−test("for i=1,4 do a=1 end",{1,1,1,1})
156+test("\45\45\10\105\102\32\110\105\108\32\116\104\101\110\10\32\32\97\61\49\10\101\108\115\101\10\32\32\97\61\50\10\101\110\100\10",{2,5,6})
157+test("\97\61\49\10\114\101\112\101\97\116\10\32\32\97\61\97\43\49\10\117\110\116\105\108\32\97\61\61\51\10",{1,3,4,3,4})
158+test("\32\100\111\10\32\32\114\101\116\117\114\110\10\101\110\100\10",{2})
159+test("\108\111\99\97\108\32\97\10\97\61\49\10\119\104\105\108\101\32\97\60\61\51\32\100\111\10\32\32\97\61\97\43\49\10\101\110\100\10",{1,2,3,4,3,4,3,4,3,5})
160+test("\119\104\105\108\101\32\109\97\116\104\46\115\105\110\40\49\41\32\100\111\10\32\32\105\102\32\109\97\116\104\46\115\105\110\40\49\41\10\32\32\116\104\101\110\32\98\114\101\97\107\10\32\32\101\110\100\10\101\110\100\10\97\61\49",{1,2,3,6})
161+test("\102\111\114\32\105\61\49\44\51\32\100\111\10\32\32\97\61\105\10\101\110\100\10",{1,2,1,2,1,2,1,3})
162+test("\102\111\114\32\105\44\118\32\105\110\32\112\97\105\114\115\123\39\97\39\44\39\98\39\125\32\100\111\10\32\32\97\61\116\111\115\116\114\105\110\103\40\105\41\32\46\46\32\118\10\101\110\100\10",{1,2,1,2,1,3})
163+test("\102\111\114\32\105\61\49\44\52\32\100\111\32\97\61\49\32\101\110\100",{1,1,1,1})
201164_G.a=nil
202−local a = {1,2,3,10,124,125,126,127,128,129,130,255,256,257,500,1e3}
203−local s = " local b = {10}
204− a = b[1] X + Y b[1]
205− b = 4
206− "
165+do
166+local a = {1,2,3,10,124,125,126,127,128,129,130,255,256,257,500,1000}
167+local s = "\32\32\32\32\32\108\111\99\97\108\32\98\32\61\32\123\49\48\125\10\32\32\32\32\32\97\32\61\32\98\91\49\93\32\88\32\43\32\89\32\98\91\49\93\10\32\32\32\32\32\98\32\61\32\52\10\32\32"
207168for _,i in ipairs(a)
208169do
209−local subs = {["X"] = string.rep("
210−",i)}
170+local subs = {["\88"] = string.rep("\10",i)}
211171for _,j in ipairs(a)
212172do
213−subs.Y=string.rep("
214−",j)
215−local s = string.gsub(s,"[XY]",subs)
173+subs.Y=string.rep("\10",j)
174+local s = string.gsub(s,"\91\88\89\93",subs)
216175test(s,{1,2 + i,2 + i + j,2 + i,2 + i + j,3 + i + j})
217176end
218177end
178+end
219179_G.a=nil
180+do
220181local function checkactivelines
221182(f,lines)
222−local t = debug.getinfo(f,"SL")
183+local t = debug.getinfo(f,"\83\76")
223184for _,l in pairs(lines)
224185do
225186l=l + t.linedefined
@@ -228,38 +189,38 @@ t.activelines[l]=undef
228189end
229190assert(next(t.activelines) == nil)
230191end
231−checkactivelines((...)
192+checkactivelines(function (...)
232193local a = 20
233194local b = 30
234195end,{4,6,8})
235−checkactivelines((a)
196+checkactivelines(function (a)
236197local a = 20
237198local b = 30
238199end,{3,4,6})
239−checkactivelines((a,b, ...)
200+checkactivelines(function (a,b, ...)
240201
241202end,{0})
242−checkactivelines((a,b)
203+checkactivelines(function (a,b)
243204
244205end,{1})
245−for _,n in pairs({0,1,2,10,50,100,1e3,1e4})
206+for _,n in pairs({0,1,2,10,50,100,1000,10000})
246207do
247−checkactivelines(load(string.format("%s return 1",string.rep("
248−",n))),{n + 1})
208+checkactivelines(load(string.format("\37\115\32\114\101\116\117\114\110\32\49",string.rep("\10",n))),{n + 1})
249209end
250−print("+")
210+end
211+print("\43")
251212assert(not pcall(debug.getlocal,20,1))
252213assert(not pcall(debug.setlocal,- 1,1,10))
253214local function foo
254215(a,b, ...)
255−local d,e =
216+local d,e
256217end
257218local co = coroutine.create(foo)
258−assert(debug.getlocal(foo,1) == "a")
259−assert(debug.getlocal(foo,2) == "b")
219+assert(debug.getlocal(foo,1) == "\97")
220+assert(debug.getlocal(foo,2) == "\98")
260221assert(not debug.getlocal(foo,3))
261−assert(debug.getlocal(co,foo,1) == "a")
262−assert(debug.getlocal(co,foo,2) == "b")
222+assert(debug.getlocal(co,foo,1) == "\97")
223+assert(debug.getlocal(co,foo,2) == "\98")
263224assert(not debug.getlocal(co,foo,3))
264225assert(not debug.getlocal(print,1))
265226local function foo
@@ -273,14 +234,14 @@ local t = table.pack(...)
273234for i = 1, t.n
274235do
275236local n,v = debug.getlocal(1,- i)
276−assert(n == "(vararg)" and v == t[i])
237+assert(n == "\40\118\97\114\97\114\103\41" and v == t[i])
277238end
278239assert(not debug.getlocal(1,- (t.n + 1)))
279240assert(not debug.setlocal(1,- (t.n + 1),30))
280241if t.n > 0 then
281−((x)
282−assert(debug.setlocal(2,- 1,x) == "(vararg)")
283−assert(debug.setlocal(2,- t.n,x) == "(vararg)")
242+(function (x)
243+assert(debug.setlocal(2,- 1,x) == "\40\118\97\114\97\114\103\41")
244+assert(debug.setlocal(2,- t.n,x) == "\40\118\97\114\97\114\103\41")
284245end)(430)
285246assert(... == 430)
286247end
@@ -289,94 +250,96 @@ foo()
289250foo(print)
290251foo(200,3,4)
291252local a = {}
292−for i = 1, (_soft and 100 or 1e3)
253+for i = 1, (_soft and 100 or 1000)
293254do
294255a[i]=i
295256end
296257foo(table.unpack(a))
258+do
297259assert(not debug.gethook())
298260local count = 0
299261local function f
300262()
301−assert(debug.getinfo(1).namewhat == "hook")
302−local sndline = string.match(debug.traceback(),"
303−(.-)
304−")
305−assert(string.find(sndline,"hook"))
263+assert(debug.getinfo(1).namewhat == "\104\111\111\107")
264+local sndline = string.match(debug.traceback(),"\10\40\46\45\41\10")
265+assert(string.find(sndline,"\104\111\111\107"))
306266count=count + 1
307267end
308−debug.sethook(f,"l")
268+debug.sethook(f,"\108")
309269local a = 0
310270_ENV.a=a
311271a=1
312272debug.sethook()
313273assert(count == 4)
274+end
314275_ENV.a=nil
315−assert(getmetatable(debug.getregistry()._HOOKKEY).__mode == "k")
276+assert(getmetatable(debug.getregistry()._HOOKKEY).__mode == "\107")
316277a={}
317278;
318279local L = nil
319280local glob = 1
320281local oldglob = glob
321−debug.sethook((e,l)
282+debug.sethook(function (e,l)
322283collectgarbage()
323284local f,m,c = debug.gethook()
324−assert(m == "crl" and c == 0)
325−if e == "line" then
285+assert(m == "\99\114\108" and c == 0)
286+if e == "\108\105\110\101" then
326287if glob ~= oldglob then
327288L=l - 1
328289oldglob=glob
329290end
330−elseife == "call" then
331−local f = debug.getinfo(2,"f").func
291+elseif e == "\99\97\108\108" then
292+local f = debug.getinfo(2,"\102").func
332293a[f]=1
333294else
334−assert(e == "return")
295+assert(e == "\114\101\116\117\114\110")
335296end
336−end,"crl")
297+end,"\99\114\108")
337298function f(a,b)
338299collectgarbage()
339300local _,x = debug.getlocal(1,1)
340301local _,y = debug.getlocal(1,2)
341302assert(x == a and y == b)
342−assert(debug.setlocal(2,3,"pera") == "AA" .. "AA")
343−assert(debug.setlocal(2,4,"manga") == "B")
303+assert(debug.setlocal(2,3,"\112\101\114\97") == "\65\65" .. "\65\65")
304+assert(debug.setlocal(2,4,"\109\97\110\103\97") == "\66")
344305x=debug.getinfo(2)
345−assert(x.func == g and x.what == "Lua" and x.name == "g" and x.nups == 2 and string.find(x.source,"^@.*db%.lua$"))
306+assert(x.func == g and x.what == "\76\117\97" and x.name == "\103" and x.nups == 2 and string.find(x.source,"\94\64\46\42\100\98\37\46\108\117\97\36"))
346307glob=glob + 1
347−assert(debug.getinfo(1,"l").currentline == L + 1)
348−assert(debug.getinfo(1,"l").currentline == L + 2)
308+assert(debug.getinfo(1,"\108").currentline == L + 1)
309+assert(debug.getinfo(1,"\108").currentline == L + 2)
349310end
350311function foo()
351312glob=glob + 1
352−assert(debug.getinfo(1,"l").currentline == L + 1)
313+assert(debug.getinfo(1,"\108").currentline == L + 1)
353314end
354315;
355316foo()
356−local _ = "alo
357−alo" .. "
358−"
359−assert(debug.getinfo(1,"l").currentline == L + 11)
317+local _ = "\97\108\111\10\97\108\111" .. "\10"
318+assert(debug.getinfo(1,"\108").currentline == L + 11)
360319function g(...)
361320local arg = {...}
362−local a,b,c =
321+do
322+local a,b,c
363323;
364324a=math.sin(40)
365325;
366−local feijao =
367−local AAAA,B = "xuxu","abacate"
326+end
327+local feijao
328+local AAAA,B = "\120\117\120\117","\97\98\97\99\97\116\101"
368329f(AAAA,B)
369−assert(AAAA == "pera" and B == "manga")
330+assert(AAAA == "\112\101\114\97" and B == "\109\97\110\103\97")
331+do
370332local B = 13
371333local x,y = debug.getlocal(1,5)
372−assert(x == "B" and y == 13)
334+assert(x == "\66" and y == 13)
335+end
373336end
374337g()
375338assert(a[f] and a[g] and a[assert] and a[debug.getlocal] and not a[print])
376339local n,v = debug.getlocal(0,1)
377−assert(v == 0 and n == "(C temporary)")
340+assert(v == 0 and n == "\40\67\32\116\101\109\112\111\114\97\114\121\41")
378341local n,v = debug.getlocal(0,2)
379−assert(v == 2 and n == "(C temporary)")
342+assert(v == 2 and n == "\40\67\32\116\101\109\112\111\114\97\114\121\41")
380343assert(not debug.getlocal(0,3))
381344assert(not debug.getlocal(0,0))
382345function f()
@@ -393,9 +356,12 @@ _G.f,_G.g=nil
393356debug.sethook(nil)
394357;
395358assert(not debug.gethook())
359+do
396360assert(not debug.setuservalue(io.stdin,10))
397361local a,b = debug.getuservalue(io.stdin,10)
398362assert(a == nil and not b)
363+end
364+do
399365local function f
400366(...)
401367return 3,...
@@ -406,7 +372,7 @@ for i = 1, 100
406372do
407373a[i]=i
408374end
409−debug.sethook(()
375+debug.sethook(function ()
410376count=count + 1
411377end,"",1)
412378local t = {table.unpack(a)}
@@ -415,13 +381,14 @@ t={table.unpack(a,1,3)}
415381assert(# t == 3)
416382t={f(table.unpack(a,1,30))}
417383assert(# t == 31)
384+end
418385local function collectlocals
419386(level)
420387local tab = {}
421388for i = 1, math.huge
422389do
423390local n,v = debug.getlocal(level + 1,i)
424−if not (n and string.find(n,"^[a-zA-Z0-9_]+$")) then
391+if not (n and string.find(n,"\94\91\97\45\122\65\45\90\48\45\57\95\93\43\36")) then
425392break
426393end
427394tab[n]=v
@@ -435,37 +402,40 @@ local arg = {...}
435402;
436403local c = 13
437404end
438−debug.sethook((e)
439−assert(e == "call")
440−dostring("XX = 12")
441−assert(not pcall(load("a='joao'+1")))
442−debug.sethook((e,l)
443−assert(debug.getinfo(2,"l").currentline == l)
405+debug.sethook(function (e)
406+assert(e == "\99\97\108\108")
407+dostring("\88\88\32\61\32\49\50")
408+assert(not pcall(load("\97\61\39\106\111\97\111\39\43\49")))
409+debug.sethook(function (e,l)
410+assert(debug.getinfo(2,"\108").currentline == l)
444411local f,m,c = debug.gethook()
445−assert(e == "line")
446−assert(m == "l" and c == 0)
412+assert(e == "\108\105\110\101")
413+assert(m == "\108" and c == 0)
447414debug.sethook(nil)
448415assert(not X)
449416X=collectlocals(2)
450−end,"l")
451−end,"c")
417+end,"\108")
418+end,"\99")
452419a:f(1,2,3,4,5)
453420assert(X.self == a and X.a == 1 and X.b == 2 and X.c == nil)
454421assert(XX == 12)
455422assert(not debug.gethook())
456423_G.XX=nil
424+do
457425local X = false
458426local function foo
459427(a,b, ...)
460−local x,y,z =
428+do
429+local x,y,z
430+end
461431local c,d = 10,20
462432return
463433end
464434local function aux
465435()
466−if debug.getinfo(2).name == "foo" then
436+if debug.getinfo(2).name == "\102\111\111" then
467437X=true
468−local tab = {["a"] = 100,["b"] = 200,["c"] = 10,["d"] = 20}
438+local tab = {["\97"] = 100,["\98"] = 200,["\99"] = 10,["\100"] = 20}
469439for n,v in pairs(collectlocals(2))
470440do
471441assert(tab[n] == v)
@@ -474,12 +444,13 @@ end
474444assert(next(tab) == nil)
475445end
476446end
477−debug.sethook(aux,"r")
447+debug.sethook(aux,"\114")
478448;
479449foo(100,200)
480450;
481451debug.sethook()
482452assert(X)
453+end
483454local function eqseq
484455(t1,t2)
485456assert(# t1 == # t2)
@@ -488,28 +459,29 @@ do
488459assert(t1[i] == t2[i])
489460end
490461end
491−print("testing inspection of parameters/returned values")
462+do
463+print("\116\101\115\116\105\110\103\32\105\110\115\112\101\99\116\105\111\110\32\111\102\32\112\97\114\97\109\101\116\101\114\115\47\114\101\116\117\114\110\101\100\32\118\97\108\117\101\115")
492464local on = false
493−local inp,out =
465+local inp,out
494466local function hook
495467(event)
496468if not on then
497469return
498470end
499−local ar = debug.getinfo(2,"ruS")
471+local ar = debug.getinfo(2,"\114\117\83")
500472local t = {}
501473for i = ar.ftransfer, ar.ftransfer + ar.ntransfer - 1
502474do
503475local _,v = debug.getlocal(2,i)
504476t[# t + 1]=v
505477end
506−if event == "return" then
478+if event == "\114\101\116\117\114\110" then
507479out=t
508480else
509481inp=t
510482end
511483end
512−debug.sethook(hook,"cr")
484+debug.sethook(hook,"\99\114")
513485on=true
514486;
515487math.sin(3)
@@ -543,6 +515,7 @@ eqseq(inp,{20})
543515;
544516eqseq(out,{10,0})
545517debug.sethook()
518+end
546519local function getupvalues
547520(f)
548521local t = {}
@@ -555,6 +528,7 @@ end
555528assert(not t[name])
556529t[name]=value
557530i=i + 1
531+end
558532return t
559533end
560534local a,b,c = 1,2,3
@@ -572,32 +546,32 @@ return c + b
572546end
573547assert(not debug.getupvalue(foo1,3))
574548assert(not debug.getupvalue(foo1,0))
575−assert(not debug.setupvalue(foo1,3,"xuxu"))
549+assert(not debug.setupvalue(foo1,3,"\120\117\120\117"))
576550local t = getupvalues(foo1)
577551assert(t.a == nil and t.b == 2 and t.c == 3)
578552t=getupvalues(foo2)
579553assert(t.a == 1 and t.b == 2 and t.c == 3)
580−assert(debug.setupvalue(foo1,1,"xuxu") == "b")
581−assert(({debug.getupvalue(foo2,3)})[2] == "xuxu")
582−assert(debug.getupvalue(string.gmatch("x","x"),1) == "")
554+assert(debug.setupvalue(foo1,1,"\120\117\120\117") == "\98")
555+assert(({debug.getupvalue(foo2,3)})[2] == "\120\117\120\117")
556+assert(debug.getupvalue(string.gmatch("\120","\120"),1) == "")
583557local a = 0
584−debug.sethook((e)
558+debug.sethook(function (e)
585559a=a + 1
586560end,"",1)
587561a=0
588562;
589−for i = 1, 1e3
563+for i = 1, 1000
590564do
591565
592566end
593567;
594−assert(1e3 < a and a < 1012)
595−debug.sethook((e)
568+assert(1000 < a and a < 1012)
569+debug.sethook(function (e)
596570a=a + 1
597571end,"",4)
598572a=0
599573;
600−for i = 1, 1e3
574+for i = 1, 1000
601575do
602576
603577end
@@ -605,31 +579,33 @@ end
605579assert(250 < a and a < 255)
606580local f,m,c = debug.gethook()
607581assert(m == "" and c == 4)
608−debug.sethook((e)
582+debug.sethook(function (e)
609583a=a + 1
610−end,"",4e3)
584+end,"",4000)
611585a=0
612586;
613−for i = 1, 1e3
587+for i = 1, 1000
614588do
615589
616590end
617591;
618592assert(a == 0)
593+do
619594debug.sethook(print,"",2 ^ 24 - 1)
620595local f,m,c = debug.gethook()
621596assert(({debug.gethook()})[3] == 2 ^ 24 - 1)
597+end
622598debug.sethook()
623−local g,g1 =
599+local g,g1
624600local function f
625601(x)
626602if x then
627−assert(debug.getinfo(1,"S").what == "Lua")
628−assert(debug.getinfo(1,"t").istailcall == true)
603+assert(debug.getinfo(1,"\83").what == "\76\117\97")
604+assert(debug.getinfo(1,"\116").istailcall == true)
629605local tail = debug.getinfo(2)
630606assert(tail.func == g1 and tail.istailcall == true)
631−assert(debug.getinfo(3,"S").what == "main")
632−print("+")
607+assert(debug.getinfo(3,"\83").what == "\109\97\105\110")
608+print("\43")
633609end
634610end
635611function g(x)
@@ -646,33 +622,33 @@ return f(x)
646622end
647623h(true)
648624local b = {}
649−debug.sethook((e)
625+debug.sethook(function (e)
650626table.insert(b,e)
651−end,"cr")
627+end,"\99\114")
652628h(false)
653629debug.sethook()
654−local res = {"return","call","tail call","call","tail call","return","return","call"}
630+local res = {"\114\101\116\117\114\110","\99\97\108\108","\116\97\105\108\32\99\97\108\108","\99\97\108\108","\116\97\105\108\32\99\97\108\108","\114\101\116\117\114\110","\114\101\116\117\114\110","\99\97\108\108"}
655631for i = 1, # res
656632do
657633assert(res[i] == table.remove(b,1))
658634end
659635b=0
660−debug.sethook((e)
661−if e == "tail call" then
636+debug.sethook(function (e)
637+if e == "\116\97\105\108\32\99\97\108\108" then
662638b=b + 1
663−assert(debug.getinfo(2,"t").istailcall == true)
639+assert(debug.getinfo(2,"\116").istailcall == true)
664640else
665−assert(debug.getinfo(2,"t").istailcall == false)
641+assert(debug.getinfo(2,"\116").istailcall == false)
666642end
667−end,"c")
643+end,"\99")
668644h(false)
669645debug.sethook()
670646assert(b == 2)
671−local lim = _soft and 3e3 or 3e4
647+local lim = _soft and 3000 or 30000
672648local function foo
673649(x)
674650if x == 0 then
675−assert(debug.getinfo(2).what == "main")
651+assert(debug.getinfo(2).what == "\109\97\105\110")
676652local info = debug.getinfo(1)
677653assert(info.istailcall == true and info.func == foo)
678654else
@@ -680,64 +656,57 @@ return foo(x - 1)
680656end
681657end
682658foo(lim)
683−print("+")
684−co=load(" local A = function ()
685− return x
686− end
687− return
688−")
659+print("\43")
660+co=load("\32\32\108\111\99\97\108\32\65\32\61\32\102\117\110\99\116\105\111\110\32\40\41\10\32\32\32\32\114\101\116\117\114\110\32\120\10\32\32\101\110\100\10\32\32\114\101\116\117\114\110\10")
689661local a = 0
690−debug.sethook((e,l)
662+debug.sethook(function (e,l)
691663if l == 3 then
692664a=a + 1
693665;
694−assert(debug.getlocal(2,1) == "(temporary)")
695−elseifl == 4 then
666+assert(debug.getlocal(2,1) == "\40\116\101\109\112\111\114\97\114\121\41")
667+elseif l == 4 then
696668a=a + 1
697669;
698−assert(debug.getlocal(2,1) == "A")
670+assert(debug.getlocal(2,1) == "\65")
699671end
700−end,"l")
672+end,"\108")
701673co()
702674debug.sethook()
703675assert(a == 2)
704676assert(debug.traceback(print) == print)
705677assert(debug.traceback(print,4) == print)
706−assert(string.find(debug.traceback("hi",4),"^hi
707−"))
708−assert(string.find(debug.traceback("hi"),"^hi
709−"))
710−assert(not string.find(debug.traceback("hi"),"'debug.traceback'"))
711−assert(string.find(debug.traceback("hi",0),"'debug.traceback'"))
712−assert(string.find(debug.traceback(),"^stack traceback:
713−"))
714−local st,msg = (()
678+assert(string.find(debug.traceback("\104\105",4),"\94\104\105\10"))
679+assert(string.find(debug.traceback("\104\105"),"\94\104\105\10"))
680+assert(not string.find(debug.traceback("\104\105"),"\39\100\101\98\117\103\46\116\114\97\99\101\98\97\99\107\39"))
681+assert(string.find(debug.traceback("\104\105",0),"\39\100\101\98\117\103\46\116\114\97\99\101\98\97\99\107\39"))
682+assert(string.find(debug.traceback(),"\94\115\116\97\99\107\32\116\114\97\99\101\98\97\99\107\58\10"))
683+do
684+local st,msg = (function ()
715685return pcall
716686end)()(debug.traceback)
717−assert(st == true and string.find(msg,"pcall"))
718−local t = debug.getinfo(print,"u")
687+assert(st == true and string.find(msg,"\112\99\97\108\108"))
688+end
689+local t = debug.getinfo(print,"\117")
719690assert(t.isvararg == true and t.nparams == 0 and t.nups == 0)
720−t=debug.getinfo((a,b,c)
691+t=debug.getinfo(function (a,b,c)
721692
722−end,"u")
693+end,"\117")
723694assert(t.isvararg == false and t.nparams == 3 and t.nups == 0)
724−t=debug.getinfo((a,b, ...)
695+t=debug.getinfo(function (a,b, ...)
725696return t[a]
726−end,"u")
697+end,"\117")
727698assert(t.isvararg == true and t.nparams == 2 and t.nups == 1)
728699t=debug.getinfo(1)
729−assert(t.isvararg == true and t.nparams == 0 and t.nups == 1 and debug.getupvalue(t.func,1) == "_ENV")
700+assert(t.isvararg == true and t.nparams == 0 and t.nups == 1 and debug.getupvalue(t.func,1) == "\95\69\78\86")
730701t=debug.getinfo(math.sin)
731702assert(t.isvararg == true and t.nparams == 0 and t.nups == 0)
732−t=debug.getinfo(string.gmatch("abc","a"))
703+t=debug.getinfo(string.gmatch("\97\98\99","\97"))
733704assert(t.isvararg == true and t.nparams == 0 and t.nups > 0)
734705local function checktraceback
735706(co,p,level)
736707local tb = debug.traceback(co,nil,level)
737708local i = 0
738−for l in string.gmatch(tb,"[^
739−]+
740−?")
709+for l in string.gmatch(tb,"\91\94\10\93\43\10\63")
741710do
742711assert(i == 0 or string.find(l,p[i]))
743712i=i + 1
@@ -754,28 +723,28 @@ end
754723end
755724local co = coroutine.create(f)
756725coroutine.resume(co,3)
757−checktraceback(co,{"yield","db.lua","db.lua","db.lua","db.lua"})
758−checktraceback(co,{"db.lua","db.lua","db.lua","db.lua"},1)
759−checktraceback(co,{"db.lua","db.lua","db.lua"},2)
760−checktraceback(co,{"db.lua"},4)
726+checktraceback(co,{"\121\105\101\108\100","\100\98\46\108\117\97","\100\98\46\108\117\97","\100\98\46\108\117\97","\100\98\46\108\117\97"})
727+checktraceback(co,{"\100\98\46\108\117\97","\100\98\46\108\117\97","\100\98\46\108\117\97","\100\98\46\108\117\97"},1)
728+checktraceback(co,{"\100\98\46\108\117\97","\100\98\46\108\117\97","\100\98\46\108\117\97"},2)
729+checktraceback(co,{"\100\98\46\108\117\97"},4)
761730checktraceback(co,{},40)
762−co=coroutine.create((x)
731+co=coroutine.create(function (x)
763732local a = 1
764−coroutine.yield(debug.getinfo(1,"l"))
765−coroutine.yield(debug.getinfo(1,"l").currentline)
733+coroutine.yield(debug.getinfo(1,"\108"))
734+coroutine.yield(debug.getinfo(1,"\108").currentline)
766735return a
767736end)
768737local tr = {}
769−local foo = (e,l)
738+local foo = function (e,l)
770739if l then
771740table.insert(tr,l)
772741end
773742end
774−debug.sethook(co,foo,"lcr")
743+debug.sethook(co,foo,"\108\99\114")
775744local _,l = coroutine.resume(co,10)
776−local x = debug.getinfo(co,1,"lfLS")
745+local x = debug.getinfo(co,1,"\108\102\76\83")
777746assert(x.currentline == l.currentline and x.activelines[x.currentline])
778−assert(type(x.func) == "function")
747+assert(type(x.func) == "\102\117\110\99\116\105\111\110")
779748for i = x.linedefined + 1, x.lastlinedefined
780749do
781750assert(x.activelines[i])
@@ -784,22 +753,22 @@ end
784753assert(next(x.activelines) == nil)
785754assert(not debug.getinfo(co,2))
786755local a,b = debug.getlocal(co,1,1)
787−assert(a == "x" and b == 10)
756+assert(a == "\120" and b == 10)
788757a,b=debug.getlocal(co,1,2)
789−assert(a == "a" and b == 1)
790−debug.setlocal(co,1,2,"hi")
758+assert(a == "\97" and b == 1)
759+debug.setlocal(co,1,2,"\104\105")
791760assert(debug.gethook(co) == foo)
792761assert(# tr == 2 and tr[1] == l.currentline - 1 and tr[2] == l.currentline)
793762a,b,c=pcall(coroutine.resume,co)
794763assert(a and b and c == l.currentline + 1)
795−checktraceback(co,{"yield","in function <"})
764+checktraceback(co,{"\121\105\101\108\100","\105\110\32\102\117\110\99\116\105\111\110\32\60"})
796765a,b=coroutine.resume(co)
797−assert(a and b == "hi")
766+assert(a and b == "\104\105")
798767assert(# tr == 4 and tr[4] == l.currentline + 2)
799768assert(debug.gethook(co) == foo)
800769assert(not debug.gethook())
801770checktraceback(co,{})
802−co=coroutine.create((x)
771+co=coroutine.create(function (x)
803772local a,b = coroutine.yield(x)
804773assert(a == 100 and b == nil)
805774return x
@@ -807,9 +776,9 @@ end)
807776a,b=coroutine.resume(co,10)
808777assert(a and b == 10)
809778a,b=debug.getlocal(co,1,1)
810−assert(a == "x" and b == 10)
779+assert(a == "\120" and b == 10)
811780assert(not debug.getlocal(co,1,5))
812−assert(debug.setlocal(co,1,1,30) == "x")
781+assert(debug.setlocal(co,1,1,30) == "\120")
813782assert(not debug.setlocal(co,1,5,40))
814783a,b=coroutine.resume(co,100)
815784assert(a and b == 30)
@@ -822,16 +791,17 @@ coroutine.yield()
822791f(i - 1)
823792end
824793end
825−co=coroutine.create((x)
794+co=coroutine.create(function (x)
826795f(x)
827796end)
828797a,b=coroutine.resume(co,3)
829−t={"'coroutine.yield'","'f'","in function <"}
830−while coroutine.status(co) == "suspended" do
798+t={"\39\99\111\114\111\117\116\105\110\101\46\121\105\101\108\100\39","\39\102\39","\105\110\32\102\117\110\99\116\105\111\110\32\60"}
799+while coroutine.status(co) == "\115\117\115\112\101\110\100\101\100" do
831800checktraceback(co,t)
832801a,b=coroutine.resume(co)
833−table.insert(t,2,"'f'")
834−t[1]="'error'"
802+table.insert(t,2,"\39\102\39")
803+end
804+t[1]="\39\101\114\114\111\114\39"
835805checktraceback(co,t)
836806local function g
837807(x)
@@ -839,10 +809,10 @@ coroutine.yield(x)
839809end
840810local function f
841811(i)
842−debug.sethook(()
812+debug.sethook(function ()
843813
844−end,"l")
845−for j = 1, 1e3
814+end,"\108")
815+for j = 1, 1000
846816do
847817g(i + j)
848818end
@@ -851,56 +821,61 @@ local co = coroutine.wrap(f)
851821co(10)
852822pcall(co)
853823pcall(co)
854−assert(type(debug.getregistry()) == "table")
824+assert(type(debug.getregistry()) == "\116\97\98\108\101")
855825local a = {}
856826local function f
857827(t)
858828local info = debug.getinfo(1)
859829;
860−assert(info.namewhat == "metamethod")
830+assert(info.namewhat == "\109\101\116\97\109\101\116\104\111\100")
861831a.op=info.name
862832return info.name
863833end
864−setmetatable(a,{["__index"] = f,["__add"] = f,["__div"] = f,["__mod"] = f,["__concat"] = f,["__pow"] = f,["__mul"] = f,["__idiv"] = f,["__unm"] = f,["__len"] = f,["__sub"] = f,["__shl"] = f,["__shr"] = f,["__bor"] = f,["__bxor"] = f,["__eq"] = f,["__le"] = f,["__lt"] = f,["__unm"] = f,["__len"] = f,["__band"] = f,["__bnot"] = f})
834+setmetatable(a,{["\95\95\105\110\100\101\120"] = f,["\95\95\97\100\100"] = f,["\95\95\100\105\118"] = f,["\95\95\109\111\100"] = f,["\95\95\99\111\110\99\97\116"] = f,["\95\95\112\111\119"] = f,["\95\95\109\117\108"] = f,["\95\95\105\100\105\118"] = f,["\95\95\117\110\109"] = f,["\95\95\108\101\110"] = f,["\95\95\115\117\98"] = f,["\95\95\115\104\108"] = f,["\95\95\115\104\114"] = f,["\95\95\98\111\114"] = f,["\95\95\98\120\111\114"] = f,["\95\95\101\113"] = f,["\95\95\108\101"] = f,["\95\95\108\116"] = f,["\95\95\117\110\109"] = f,["\95\95\108\101\110"] = f,["\95\95\98\97\110\100"] = f,["\95\95\98\110\111\116"] = f})
865835local b = setmetatable({},getmetatable(a))
866−assert(a[3] == "index" and a ^ 3 == "pow" and a .. a == "concat")
867−assert(a / 3 == "div" and 3 % a == "mod")
868−assert(a + 3 == "add" and 3 - a == "sub" and a * 3 == "mul" and - a == "unm" and # a == "len" and a & 3 == "band")
869−assert(a + 3e4 == "add" and a - 3 == "sub" and a * 3 == "mul" and - a == "unm" and # a == "len" and a & 3 == "band")
870−assert(a | 3 == "bor" and 3 ~ a == "bxor" and a << 3 == "shl" and a >> 1 == "shr")
871−assert(a == b and a.op == "eq")
872−assert(a >= b and a.op == "le")
873−assert("x" >= a and a.op == "le")
874−assert(a > b and a.op == "lt")
875−assert(a > 10 and a.op == "lt")
876−assert(~ a == "bnot")
836+assert(a[3] == "\105\110\100\101\120" and a ^ 3 == "\112\111\119" and a .. a == "\99\111\110\99\97\116")
837+assert(a / 3 == "\100\105\118" and 3 % a == "\109\111\100")
838+assert(a + 3 == "\97\100\100" and 3 - a == "\115\117\98" and a * 3 == "\109\117\108" and - a == "\117\110\109" and # a == "\108\101\110" and a & 3 == "\98\97\110\100")
839+assert(a + 30000 == "\97\100\100" and a - 3.0 == "\115\117\98" and a * 3.0 == "\109\117\108" and - a == "\117\110\109" and # a == "\108\101\110" and a & 3 == "\98\97\110\100")
840+assert(a | 3 == "\98\111\114" and 3 ~ a == "\98\120\111\114" and a << 3 == "\115\104\108" and a >> 1 == "\115\104\114")
841+assert(a == b and a.op == "\101\113")
842+assert(a >= b and a.op == "\108\101")
843+assert("\120" >= a and a.op == "\108\101")
844+assert(a > b and a.op == "\108\116")
845+assert(a > 10 and a.op == "\108\116")
846+assert(~ a == "\98\110\111\116")
847+do
877848local function f
878849()
879−assert(debug.getinfo(1).name == "for iterator")
850+assert(debug.getinfo(1).name == "\102\111\114\32\105\116\101\114\97\116\111\114")
880851end
881852for i in f
882853do
883854
884855end
856+end
857+do
885858local name = nil
886−setmetatable({},{["__gc"] = ()
859+setmetatable({},{["\95\95\103\99"] = function ()
887860local t = debug.getinfo(1)
888−assert(t.namewhat == "metamethod")
861+assert(t.namewhat == "\109\101\116\97\109\101\116\104\111\100")
889862name=t.name
890863end})
891864repeat
892−local a = {}until name
893−assert(name == "__gc")
894−print("testing traceback sizes")
865+local a = {}
866+until name
867+assert(name == "\95\95\103\99")
868+end
869+do
870+print("\116\101\115\116\105\110\103\32\116\114\97\99\101\98\97\99\107\32\115\105\122\101\115")
895871local function countlines
896872(s)
897−return select(2,string.gsub(s,"
898−",""))
873+return select(2,string.gsub(s,"\10",""))
899874end
900875local function deep
901876(lvl,n)
902877if lvl == 0 then
903−return (debug.traceback("message",n))
878+return (debug.traceback("\109\101\115\115\97\103\101",n))
904879else
905880return (deep(lvl - 1,n))
906881end
@@ -908,12 +883,10 @@ end
908883local function checkdeep
909884(total,start)
910885local s = deep(total,start)
911−local rest = string.match(s,"^message
912−stack traceback:
913−(.*)$")
886+local rest = string.match(s,"\94\109\101\115\115\97\103\101\10\115\116\97\99\107\32\116\114\97\99\101\98\97\99\107\58\10\40\46\42\41\36")
914887local cl = countlines(rest)
915888assert(cl <= 10 + 11 + 1)
916−local brk = string.find(rest,"%.%.%. %(skip")
889+local brk = string.find(rest,"\37\46\37\46\37\46\9\37\40\115\107\105\112")
917890if brk then
918891local rest1 = string.sub(rest,1,brk)
919892local rest2 = string.sub(rest,brk,# rest)
@@ -929,45 +902,12 @@ do
929902coroutine.wrap(checkdeep)(d,l)
930903end
931904end
932−print("testing debug functions on chunk without debug info")
933−local prog = "-- program to be loaded without debug information (strip)
934−local debug = require'debug'
935−local a = 12 -- a local variable
936−
937−local n, v = debug.getlocal(1, 1)
938−assert(n == "(temporary)" and v == debug) -- unkown name but known value
939−n, v = debug.getlocal(1, 2)
940−assert(n == "(temporary)" and v == 12) -- unkown name but known value
941−
942−-- a function with an upvalue
943−local f = function () local x; return a end
944−n, v = debug.getupvalue(f, 1)
945−assert(n == "(no name)" and v == 12)
946−assert(debug.setupvalue(f, 1, 13) == "(no name)")
947−assert(a == 13)
948−
949−local t = debug.getinfo(f)
950−assert(t.name == nil and t.linedefined > 0 and
951− t.lastlinedefined == t.linedefined and
952− t.short_src == "?")
953−assert(debug.getinfo(1).currentline == -1)
954−
955−t = debug.getinfo(f, "L").activelines
956−assert(next(t) == nil) -- active lines are empty
957−
958−-- dump/load a function without debug info
959−f = load(string.dump(f))
960−
961−t = debug.getinfo(f)
962−assert(t.name == nil and t.linedefined > 0 and
963− t.lastlinedefined == t.linedefined and
964− t.short_src == "?")
965−assert(debug.getinfo(1).currentline == -1)
966−
967−return a
968−"
905+end
906+print("\116\101\115\116\105\110\103\32\100\101\98\117\103\32\102\117\110\99\116\105\111\110\115\32\111\110\32\99\104\117\110\107\32\119\105\116\104\111\117\116\32\100\101\98\117\103\32\105\110\102\111")
907+local prog = "\45\45\32\112\114\111\103\114\97\109\32\116\111\32\98\101\32\108\111\97\100\101\100\32\119\105\116\104\111\117\116\32\100\101\98\117\103\32\105\110\102\111\114\109\97\116\105\111\110\32\40\115\116\114\105\112\41\10\108\111\99\97\108\32\100\101\98\117\103\32\61\32\114\101\113\117\105\114\101\39\100\101\98\117\103\39\10\108\111\99\97\108\32\97\32\61\32\49\50\32\32\45\45\32\97\32\108\111\99\97\108\32\118\97\114\105\97\98\108\101\10\10\108\111\99\97\108\32\110\44\32\118\32\61\32\100\101\98\117\103\46\103\101\116\108\111\99\97\108\40\49\44\32\49\41\10\97\115\115\101\114\116\40\110\32\61\61\32\34\40\116\101\109\112\111\114\97\114\121\41\34\32\97\110\100\32\118\32\61\61\32\100\101\98\117\103\41\32\32\32\45\45\32\117\110\107\111\119\110\32\110\97\109\101\32\98\117\116\32\107\110\111\119\110\32\118\97\108\117\101\10\110\44\32\118\32\61\32\100\101\98\117\103\46\103\101\116\108\111\99\97\108\40\49\44\32\50\41\10\97\115\115\101\114\116\40\110\32\61\61\32\34\40\116\101\109\112\111\114\97\114\121\41\34\32\97\110\100\32\118\32\61\61\32\49\50\41\32\32\32\45\45\32\117\110\107\111\119\110\32\110\97\109\101\32\98\117\116\32\107\110\111\119\110\32\118\97\108\117\101\10\10\45\45\32\97\32\102\117\110\99\116\105\111\110\32\119\105\116\104\32\97\110\32\117\112\118\97\108\117\101\10\108\111\99\97\108\32\102\32\61\32\102\117\110\99\116\105\111\110\32\40\41\32\108\111\99\97\108\32\120\59\32\114\101\116\117\114\110\32\97\32\101\110\100\10\110\44\32\118\32\61\32\100\101\98\117\103\46\103\101\116\117\112\118\97\108\117\101\40\102\44\32\49\41\10\97\115\115\101\114\116\40\110\32\61\61\32\34\40\110\111\32\110\97\109\101\41\34\32\97\110\100\32\118\32\61\61\32\49\50\41\10\97\115\115\101\114\116\40\100\101\98\117\103\46\115\101\116\117\112\118\97\108\117\101\40\102\44\32\49\44\32\49\51\41\32\61\61\32\34\40\110\111\32\110\97\109\101\41\34\41\10\97\115\115\101\114\116\40\97\32\61\61\32\49\51\41\10\10\108\111\99\97\108\32\116\32\61\32\100\101\98\117\103\46\103\101\116\105\110\102\111\40\102\41\10\97\115\115\101\114\116\40\116\46\110\97\109\101\32\61\61\32\110\105\108\32\97\110\100\32\116\46\108\105\110\101\100\101\102\105\110\101\100\32\62\32\48\32\97\110\100\10\32\32\32\32\32\32\32\116\46\108\97\115\116\108\105\110\101\100\101\102\105\110\101\100\32\61\61\32\116\46\108\105\110\101\100\101\102\105\110\101\100\32\97\110\100\10\32\32\32\32\32\32\32\116\46\115\104\111\114\116\95\115\114\99\32\61\61\32\34\63\34\41\10\97\115\115\101\114\116\40\100\101\98\117\103\46\103\101\116\105\110\102\111\40\49\41\46\99\117\114\114\101\110\116\108\105\110\101\32\61\61\32\45\49\41\10\10\116\32\61\32\100\101\98\117\103\46\103\101\116\105\110\102\111\40\102\44\32\34\76\34\41\46\97\99\116\105\118\101\108\105\110\101\115\10\97\115\115\101\114\116\40\110\101\120\116\40\116\41\32\61\61\32\110\105\108\41\32\32\32\32\45\45\32\97\99\116\105\118\101\32\108\105\110\101\115\32\97\114\101\32\101\109\112\116\121\10\10\45\45\32\100\117\109\112\47\108\111\97\100\32\97\32\102\117\110\99\116\105\111\110\32\119\105\116\104\111\117\116\32\100\101\98\117\103\32\105\110\102\111\10\102\32\61\32\108\111\97\100\40\115\116\114\105\110\103\46\100\117\109\112\40\102\41\41\10\10\116\32\61\32\100\101\98\117\103\46\103\101\116\105\110\102\111\40\102\41\10\97\115\115\101\114\116\40\116\46\110\97\109\101\32\61\61\32\110\105\108\32\97\110\100\32\116\46\108\105\110\101\100\101\102\105\110\101\100\32\62\32\48\32\97\110\100\10\32\32\32\32\32\32\32\116\46\108\97\115\116\108\105\110\101\100\101\102\105\110\101\100\32\61\61\32\116\46\108\105\110\101\100\101\102\105\110\101\100\32\97\110\100\10\32\32\32\32\32\32\32\116\46\115\104\111\114\116\95\115\114\99\32\61\61\32\34\63\34\41\10\97\115\115\101\114\116\40\100\101\98\117\103\46\103\101\116\105\110\102\111\40\49\41\46\99\117\114\114\101\110\116\108\105\110\101\32\61\61\32\45\49\41\10\10\114\101\116\117\114\110\32\97\10"
969908local f = assert(load(string.dump(load(prog),true)))
970909assert(f() == 13)
910+do
971911local function foo
972912()
973913local a = 1
@@ -976,24 +916,21 @@ return b
976916end
977917local s = load(string.dump(foo,true))
978918local line = true
979−debug.sethook((e,l)
980−assert(e == "line")
919+debug.sethook(function (e,l)
920+assert(e == "\108\105\110\101")
981921line=l
982−end,"l")
922+end,"\108")
983923assert(s() == 2)
984924;
985925debug.sethook(nil)
986926assert(line == nil)
987−local prog = " return function (x)
988− return function (y)
989− return x + y
990− end
991− end
992− "
993−local name = string.rep("x",1e3)
927+end
928+do
929+local prog = "\32\32\32\32\114\101\116\117\114\110\32\102\117\110\99\116\105\111\110\32\40\120\41\10\32\32\32\32\32\32\114\101\116\117\114\110\32\102\117\110\99\116\105\111\110\32\40\121\41\32\10\32\32\32\32\32\32\32\32\114\101\116\117\114\110\32\120\32\43\32\121\10\32\32\32\32\32\32\101\110\100\10\32\32\32\32\101\110\100\10\32\32"
930+local name = string.rep("\120",1000)
994931local p = assert(load(prog,name))
995932local c = string.dump(p)
996−assert(# c > 1e3 and # c < 2e3)
933+assert(# c > 1000 and # c < 2000)
997934local f = assert(load(c))
998935local g = f()
999936local h = g(3)
@@ -1005,5 +942,6 @@ local f = assert(load(c))
1005942local g = f()
1006943local h = g(30)
1007944assert(h(50) == 80)
1008−assert(debug.getinfo(f).source == "=?" and debug.getinfo(g).source == "=?" and debug.getinfo(h).source == "=?")
1009−print("OK")
945+assert(debug.getinfo(f).source == "\61\63" and debug.getinfo(g).source == "\61\63" and debug.getinfo(h).source == "\61\63")
946+end
947+print("\79\75")
zod/luau/res/lua/cycled/errors.lua+268−385
@@ -1,5 +1,5 @@
1−print("testing errors")
2−local debug = require("debug")
1+print("\116\101\115\116\105\110\103\32\101\114\114\111\114\115")
2+local debug = require("\100\101\98\117\103")
33local mt = getmetatable(_G) or {}
44local oldmm = mt.__index
55mt.__index=nil
@@ -28,246 +28,204 @@ end
2828local function checksyntax
2929(prog,extra,token,line)
3030local msg = doit(prog)
31−if not string.find(token,"^<%a") and not string.find(token,"^char%(") then
32−token="'" .. token .. "'"
31+if not string.find(token,"\94\60\37\97") and not string.find(token,"\94\99\104\97\114\37\40") then
32+token="\39" .. token .. "\39"
3333end
34−token=string.gsub(token,"(%p)","%%%1")
35−local pt = string.format("^%%[string ".*"%%]:%d: .- near %s$",line,token)
34+token=string.gsub(token,"\40\37\112\41","\37\37\37\49")
35+local pt = string.format("\94\37\37\91\115\116\114\105\110\103\32\34\46\42\34\37\37\93\58\37\100\58\32\46\45\32\110\101\97\114\32\37\115\36",line,token)
3636assert(string.find(msg,pt))
3737assert(string.find(msg,msg,1,true))
3838end
39−assert(doit("error('hi', 0)") == "hi")
40−assert(doit("error()") == nil)
41−assert(doit("table.unpack({}, 1, n=2^30)"))
42−assert(doit("a=math.sin()"))
43−assert(not doit("tostring(1)") and doit("tostring()"))
44−assert(doit("tonumber()"))
45−assert(doit("repeat until 1; a"))
46−assert(doit("return;;"))
47−assert(doit("assert(false)"))
48−assert(doit("assert(nil)"))
49−assert(doit("function a (... , ...) end"))
50−assert(doit("function a (, ...) end"))
51−assert(doit("local t={}; t = t[#t] + 1"))
52−checksyntax(" local a = {4
53−
54−","'}' expected (to close '{' at line 1)","<eof>",3)
39+assert(doit("\101\114\114\111\114\40\39\104\105\39\44\32\48\41") == "\104\105")
40+assert(doit("\101\114\114\111\114\40\41") == nil)
41+assert(doit("\116\97\98\108\101\46\117\110\112\97\99\107\40\123\125\44\32\49\44\32\110\61\50\94\51\48\41"))
42+assert(doit("\97\61\109\97\116\104\46\115\105\110\40\41"))
43+assert(not doit("\116\111\115\116\114\105\110\103\40\49\41") and doit("\116\111\115\116\114\105\110\103\40\41"))
44+assert(doit("\116\111\110\117\109\98\101\114\40\41"))
45+assert(doit("\114\101\112\101\97\116\32\117\110\116\105\108\32\49\59\32\97"))
46+assert(doit("\114\101\116\117\114\110\59\59"))
47+assert(doit("\97\115\115\101\114\116\40\102\97\108\115\101\41"))
48+assert(doit("\97\115\115\101\114\116\40\110\105\108\41"))
49+assert(doit("\102\117\110\99\116\105\111\110\32\97\32\40\46\46\46\32\44\32\46\46\46\41\32\101\110\100"))
50+assert(doit("\102\117\110\99\116\105\111\110\32\97\32\40\44\32\46\46\46\41\32\101\110\100"))
51+assert(doit("\108\111\99\97\108\32\116\61\123\125\59\32\116\32\61\32\116\91\35\116\93\32\43\32\49"))
52+checksyntax("\32\32\108\111\99\97\108\32\97\32\61\32\123\52\10\10","\39\125\39\32\101\120\112\101\99\116\101\100\32\40\116\111\32\99\108\111\115\101\32\39\123\39\32\97\116\32\108\105\110\101\32\49\41","\60\101\111\102\62",3)
53+do
5554local function checksyntax
5655(prog,msg,line)
5756local st,err = load(prog)
58−assert(string.find(err,"line " .. line))
57+assert(string.find(err,"\108\105\110\101\32" .. line))
5958assert(string.find(err,msg,1,true))
6059end
61−checksyntax(" ::A:: a = 1
62− ::A::
63− ","label 'A' already defined",1)
64−checksyntax(" a = 1
65− goto A
66− do ::A:: end
67− ","no visible label 'A'",2)
60+checksyntax("\32\32\32\32\58\58\65\58\58\32\97\32\61\32\49\10\32\32\32\32\58\58\65\58\58\10\32\32","\108\97\98\101\108\32\39\65\39\32\97\108\114\101\97\100\121\32\100\101\102\105\110\101\100",1)
61+checksyntax("\32\32\32\32\97\32\61\32\49\10\32\32\32\32\103\111\116\111\32\65\10\32\32\32\32\100\111\32\58\58\65\58\58\32\101\110\100\10\32\32","\110\111\32\118\105\115\105\98\108\101\32\108\97\98\101\108\32\39\65\39",2)
62+end
6863if not T then
69−(Message or print)("
70− >>> testC not active: skipping tests for messages in C <<<
71−")
64+(Message or print)("\10\32\62\62\62\32\116\101\115\116\67\32\110\111\116\32\97\99\116\105\118\101\58\32\115\107\105\112\112\105\110\103\32\116\101\115\116\115\32\102\111\114\32\109\101\115\115\97\103\101\115\32\105\110\32\67\32\60\60\60\10")
7265else
73−print("testing memory error message")
66+print("\116\101\115\116\105\110\103\32\109\101\109\111\114\121\32\101\114\114\111\114\32\109\101\115\115\97\103\101")
7467local a = {}
75−for i = 1, 1e4
68+for i = 1, 10000
7669do
7770a[i]=true
7871end
7972collectgarbage()
80−T.totalmem(T.totalmem() + 1e4)
81−local st,msg = pcall(()
82−for i = 1, 1e5
73+T.totalmem(T.totalmem() + 10000)
74+local st,msg = pcall(function ()
75+for i = 1, 100000
8376do
8477a[i]=tostring(i)
8578end
8679end)
8780T.totalmem(0)
88−assert(not st and msg == "not enough" .. " memory")
89−local res = T.testC(" # push 16 elements on the stack
90− pushnum 1; pushnum 1; pushnum 1; pushnum 1; pushnum 1;
91− pushnum 1; pushnum 1; pushnum 1; pushnum 1; pushnum 1;
92− pushnum 1; pushnum 1; pushnum 1; pushnum 1; pushnum 1;
93− pushnum 1;
94− # traceback should work with 4 remaining slots
95− traceback xuxu 1;
96− return 1
97− ")
98−assert(string.find(res,"xuxu.-main chunk"))
99−end
100−checkmessage("a = {} + 1","arithmetic")
101−checkmessage("a = {} | 1","bitwise operation")
102−checkmessage("a = {} < 1","attempt to compare")
103−checkmessage("a = {} <= 1","attempt to compare")
104−checkmessage("aaa=1; bbbb=2; aaa=math.sin(3)+bbbb(3)","global 'bbbb'")
105−checkmessage("aaa={}; do local aaa=1 end aaa:bbbb(3)","method 'bbbb'")
106−checkmessage("local a={}; a.bbbb(3)","field 'bbbb'")
107−assert(not string.find(doit("aaa={13}; local bbbb=1; aaa[bbbb](3)"),"'bbbb'"))
108−checkmessage("aaa={13}; local bbbb=1; aaa[bbbb](3)","number")
109−checkmessage("aaa=(1)..{}","a table value")
110−checkmessage("a = {_ENV = {}}; print(a._ENV.x + 1)","field 'x'")
81+assert(not st and msg == "\110\111\116\32\101\110\111\117\103\104" .. "\32\109\101\109\111\114\121")
82+local res = T.testC("\32\32\32\32\35\32\112\117\115\104\32\49\54\32\101\108\101\109\101\110\116\115\32\111\110\32\116\104\101\32\115\116\97\99\107\10\32\32\32\32\112\117\115\104\110\117\109\32\49\59\32\112\117\115\104\110\117\109\32\49\59\32\112\117\115\104\110\117\109\32\49\59\32\112\117\115\104\110\117\109\32\49\59\32\112\117\115\104\110\117\109\32\49\59\10\32\32\32\32\112\117\115\104\110\117\109\32\49\59\32\112\117\115\104\110\117\109\32\49\59\32\112\117\115\104\110\117\109\32\49\59\32\112\117\115\104\110\117\109\32\49\59\32\112\117\115\104\110\117\109\32\49\59\10\32\32\32\32\112\117\115\104\110\117\109\32\49\59\32\112\117\115\104\110\117\109\32\49\59\32\112\117\115\104\110\117\109\32\49\59\32\112\117\115\104\110\117\109\32\49\59\32\112\117\115\104\110\117\109\32\49\59\10\32\32\32\32\112\117\115\104\110\117\109\32\49\59\10\32\32\32\32\35\32\116\114\97\99\101\98\97\99\107\32\115\104\111\117\108\100\32\119\111\114\107\32\119\105\116\104\32\52\32\114\101\109\97\105\110\105\110\103\32\115\108\111\116\115\10\32\32\32\32\116\114\97\99\101\98\97\99\107\32\120\117\120\117\32\49\59\10\32\32\32\32\114\101\116\117\114\110\32\49\10\32\32")
83+assert(string.find(res,"\120\117\120\117\46\45\109\97\105\110\32\99\104\117\110\107"))
84+end
85+checkmessage("\97\32\61\32\123\125\32\43\32\49","\97\114\105\116\104\109\101\116\105\99")
86+checkmessage("\97\32\61\32\123\125\32\124\32\49","\98\105\116\119\105\115\101\32\111\112\101\114\97\116\105\111\110")
87+checkmessage("\97\32\61\32\123\125\32\60\32\49","\97\116\116\101\109\112\116\32\116\111\32\99\111\109\112\97\114\101")
88+checkmessage("\97\32\61\32\123\125\32\60\61\32\49","\97\116\116\101\109\112\116\32\116\111\32\99\111\109\112\97\114\101")
89+checkmessage("\97\97\97\61\49\59\32\98\98\98\98\61\50\59\32\97\97\97\61\109\97\116\104\46\115\105\110\40\51\41\43\98\98\98\98\40\51\41","\103\108\111\98\97\108\32\39\98\98\98\98\39")
90+checkmessage("\97\97\97\61\123\125\59\32\100\111\32\108\111\99\97\108\32\97\97\97\61\49\32\101\110\100\32\97\97\97\58\98\98\98\98\40\51\41","\109\101\116\104\111\100\32\39\98\98\98\98\39")
91+checkmessage("\108\111\99\97\108\32\97\61\123\125\59\32\97\46\98\98\98\98\40\51\41","\102\105\101\108\100\32\39\98\98\98\98\39")
92+assert(not string.find(doit("\97\97\97\61\123\49\51\125\59\32\108\111\99\97\108\32\98\98\98\98\61\49\59\32\97\97\97\91\98\98\98\98\93\40\51\41"),"\39\98\98\98\98\39"))
93+checkmessage("\97\97\97\61\123\49\51\125\59\32\108\111\99\97\108\32\98\98\98\98\61\49\59\32\97\97\97\91\98\98\98\98\93\40\51\41","\110\117\109\98\101\114")
94+checkmessage("\97\97\97\61\40\49\41\46\46\123\125","\97\32\116\97\98\108\101\32\118\97\108\117\101")
95+checkmessage("\97\32\61\32\123\95\69\78\86\32\61\32\123\125\125\59\32\112\114\105\110\116\40\97\46\95\69\78\86\46\120\32\43\32\49\41","\102\105\101\108\100\32\39\120\39")
11196_G.aaa,_G.bbbb=nil
112−checkmessage("local a; a(13)","local 'a'")
113−checkmessage(" local a = setmetatable({}, {__add = 34})
114− a = a + 1
115−","metamethod 'add'")
116−checkmessage(" local a = setmetatable({}, {__lt = {}})
117− a = a > a
118−","metamethod 'lt'")
119−checkmessage("local a={}; return a.bbbb(3)","field 'bbbb'")
120−checkmessage("aaa={}; do local aaa=1 end; return aaa:bbbb(3)","method 'bbbb'")
121−checkmessage("aaa = #print","length of a function value")
122−checkmessage("aaa = #3","length of a number value")
97+checkmessage("\108\111\99\97\108\32\97\59\32\97\40\49\51\41","\108\111\99\97\108\32\39\97\39")
98+checkmessage("\32\32\108\111\99\97\108\32\97\32\61\32\115\101\116\109\101\116\97\116\97\98\108\101\40\123\125\44\32\123\95\95\97\100\100\32\61\32\51\52\125\41\10\32\32\97\32\61\32\97\32\43\32\49\10","\109\101\116\97\109\101\116\104\111\100\32\39\97\100\100\39")
99+checkmessage("\32\32\108\111\99\97\108\32\97\32\61\32\115\101\116\109\101\116\97\116\97\98\108\101\40\123\125\44\32\123\95\95\108\116\32\61\32\123\125\125\41\10\32\32\97\32\61\32\97\32\62\32\97\10","\109\101\116\97\109\101\116\104\111\100\32\39\108\116\39")
100+checkmessage("\108\111\99\97\108\32\97\61\123\125\59\32\114\101\116\117\114\110\32\97\46\98\98\98\98\40\51\41","\102\105\101\108\100\32\39\98\98\98\98\39")
101+checkmessage("\97\97\97\61\123\125\59\32\100\111\32\108\111\99\97\108\32\97\97\97\61\49\32\101\110\100\59\32\114\101\116\117\114\110\32\97\97\97\58\98\98\98\98\40\51\41","\109\101\116\104\111\100\32\39\98\98\98\98\39")
102+checkmessage("\97\97\97\32\61\32\35\112\114\105\110\116","\108\101\110\103\116\104\32\111\102\32\97\32\102\117\110\99\116\105\111\110\32\118\97\108\117\101")
103+checkmessage("\97\97\97\32\61\32\35\51","\108\101\110\103\116\104\32\111\102\32\97\32\110\117\109\98\101\114\32\118\97\108\117\101")
123104_G.aaa=nil
124−checkmessage("aaa.bbb:ddd(9)","global 'aaa'")
125−checkmessage("local aaa={bbb=1}; aaa.bbb:ddd(9)","field 'bbb'")
126−checkmessage("local aaa={bbb={}}; aaa.bbb:ddd(9)","method 'ddd'")
127−checkmessage("local a,b,c; (function () a = b+1.1 end)()","upvalue 'b'")
128−assert(not doit("local aaa={bbb={ddd=next}}; aaa.bbb:ddd(nil)"))
129−checkmessage("local a,b,cc; (function () a = cc[1] end)()","upvalue 'cc'")
130−checkmessage("local a,b,cc; (function () a.x = 1 end)()","upvalue 'a'")
131−checkmessage("local _ENV = {x={}}; a = a + 1","global 'a'")
132−checkmessage("BB=1; local aaa={}; x=aaa+BB","local 'aaa'")
133−checkmessage("aaa={}; x=3.3/aaa","global 'aaa'")
134−checkmessage("aaa=2; BB=nil;x=aaa*BB","global 'BB'")
135−checkmessage("aaa={}; x=-aaa","global 'aaa'")
136−checkmessage("aaa=1; local aaa,bbbb=2,3; aaa = math.sin(1) and bbbb(3)","local 'bbbb'")
137−checkmessage("aaa=1; local aaa,bbbb=2,3; aaa = bbbb(1) or aaa(3)","local 'bbbb'")
138−checkmessage("local a,b,c,f = 1,1,1; f((a and b) or c)","local 'f'")
139−checkmessage("local a,b,c = 1,1,1; ((a and b) or c)()","call a number value")
140−assert(not string.find(doit("aaa={}; x=(aaa or aaa)+(aaa and aaa)"),"'aaa'"))
141−assert(not string.find(doit("aaa={}; (aaa or aaa)()"),"'aaa'"))
142−checkmessage("print(print < 10)","function with number")
143−checkmessage("print(print < print)","two function values")
144−checkmessage("print('10' < 10)","string with number")
145−checkmessage("print(10 < '23')","number with string")
146−checkmessage("local a = 2.0^100; x = a << 2","local a")
147−checkmessage("local a = 1 >> 2.0^100","has no integer representation")
148−checkmessage("local a = 10.1 << 2.0^100","has no integer representation")
149−checkmessage("local a = 2.0^100 & 1","has no integer representation")
150−checkmessage("local a = 2.0^100 & 1e100","has no integer representation")
151−checkmessage("local a = 2.0 | 1e40","has no integer representation")
152−checkmessage("local a = 2e100 ~ 1","has no integer representation")
153−checkmessage("string.sub('a', 2.0^100)","has no integer representation")
154−checkmessage("string.rep('a', 3.3)","has no integer representation")
155−checkmessage("return 6e40 & 7","has no integer representation")
156−checkmessage("return 34 << 7e30","has no integer representation")
157−checkmessage("return ~-3e40","has no integer representation")
158−checkmessage("return ~-3.009","has no integer representation")
159−checkmessage("return 3.009 & 1","has no integer representation")
160−checkmessage("return 34 >> {}","table value")
161−checkmessage("aaa = 24 // 0","divide by zero")
162−checkmessage("aaa = 1 % 0","'n%0'")
163−checkmessage("local a = setmetatable({}, {__index = 10}).x","attempt to index a number value")
164−checkmessage("for i = {}, 10 do end","table")
165−checkmessage("for i = io.stdin, 10 do end","FILE")
166−checkmessage("for i = {}, 10 do end","initial value")
167−checkmessage("for i = 1, 'x', 10 do end","string")
168−checkmessage("for i = 1, {}, 10 do end","limit")
169−checkmessage("for i = 1, {} do end","limit")
170−checkmessage("for i = 1, 10, print do end","step")
171−checkmessage("for i = 1, 10, print do end","function")
105+checkmessage("\97\97\97\46\98\98\98\58\100\100\100\40\57\41","\103\108\111\98\97\108\32\39\97\97\97\39")
106+checkmessage("\108\111\99\97\108\32\97\97\97\61\123\98\98\98\61\49\125\59\32\97\97\97\46\98\98\98\58\100\100\100\40\57\41","\102\105\101\108\100\32\39\98\98\98\39")
107+checkmessage("\108\111\99\97\108\32\97\97\97\61\123\98\98\98\61\123\125\125\59\32\97\97\97\46\98\98\98\58\100\100\100\40\57\41","\109\101\116\104\111\100\32\39\100\100\100\39")
108+checkmessage("\108\111\99\97\108\32\97\44\98\44\99\59\32\40\102\117\110\99\116\105\111\110\32\40\41\32\97\32\61\32\98\43\49\46\49\32\101\110\100\41\40\41","\117\112\118\97\108\117\101\32\39\98\39")
109+assert(not doit("\108\111\99\97\108\32\97\97\97\61\123\98\98\98\61\123\100\100\100\61\110\101\120\116\125\125\59\32\97\97\97\46\98\98\98\58\100\100\100\40\110\105\108\41"))
110+checkmessage("\108\111\99\97\108\32\97\44\98\44\99\99\59\32\40\102\117\110\99\116\105\111\110\32\40\41\32\97\32\61\32\99\99\91\49\93\32\101\110\100\41\40\41","\117\112\118\97\108\117\101\32\39\99\99\39")
111+checkmessage("\108\111\99\97\108\32\97\44\98\44\99\99\59\32\40\102\117\110\99\116\105\111\110\32\40\41\32\97\46\120\32\61\32\49\32\101\110\100\41\40\41","\117\112\118\97\108\117\101\32\39\97\39")
112+checkmessage("\108\111\99\97\108\32\95\69\78\86\32\61\32\123\120\61\123\125\125\59\32\97\32\61\32\97\32\43\32\49","\103\108\111\98\97\108\32\39\97\39")
113+checkmessage("\66\66\61\49\59\32\108\111\99\97\108\32\97\97\97\61\123\125\59\32\120\61\97\97\97\43\66\66","\108\111\99\97\108\32\39\97\97\97\39")
114+checkmessage("\97\97\97\61\123\125\59\32\120\61\51\46\51\47\97\97\97","\103\108\111\98\97\108\32\39\97\97\97\39")
115+checkmessage("\97\97\97\61\50\59\32\66\66\61\110\105\108\59\120\61\97\97\97\42\66\66","\103\108\111\98\97\108\32\39\66\66\39")
116+checkmessage("\97\97\97\61\123\125\59\32\120\61\45\97\97\97","\103\108\111\98\97\108\32\39\97\97\97\39")
117+checkmessage("\97\97\97\61\49\59\32\108\111\99\97\108\32\97\97\97\44\98\98\98\98\61\50\44\51\59\32\97\97\97\32\61\32\109\97\116\104\46\115\105\110\40\49\41\32\97\110\100\32\98\98\98\98\40\51\41","\108\111\99\97\108\32\39\98\98\98\98\39")
118+checkmessage("\97\97\97\61\49\59\32\108\111\99\97\108\32\97\97\97\44\98\98\98\98\61\50\44\51\59\32\97\97\97\32\61\32\98\98\98\98\40\49\41\32\111\114\32\97\97\97\40\51\41","\108\111\99\97\108\32\39\98\98\98\98\39")
119+checkmessage("\108\111\99\97\108\32\97\44\98\44\99\44\102\32\61\32\49\44\49\44\49\59\32\102\40\40\97\32\97\110\100\32\98\41\32\111\114\32\99\41","\108\111\99\97\108\32\39\102\39")
120+checkmessage("\108\111\99\97\108\32\97\44\98\44\99\32\61\32\49\44\49\44\49\59\32\40\40\97\32\97\110\100\32\98\41\32\111\114\32\99\41\40\41","\99\97\108\108\32\97\32\110\117\109\98\101\114\32\118\97\108\117\101")
121+assert(not string.find(doit("\97\97\97\61\123\125\59\32\120\61\40\97\97\97\32\111\114\32\97\97\97\41\43\40\97\97\97\32\97\110\100\32\97\97\97\41"),"\39\97\97\97\39"))
122+assert(not string.find(doit("\97\97\97\61\123\125\59\32\40\97\97\97\32\111\114\32\97\97\97\41\40\41"),"\39\97\97\97\39"))
123+checkmessage("\112\114\105\110\116\40\112\114\105\110\116\32\60\32\49\48\41","\102\117\110\99\116\105\111\110\32\119\105\116\104\32\110\117\109\98\101\114")
124+checkmessage("\112\114\105\110\116\40\112\114\105\110\116\32\60\32\112\114\105\110\116\41","\116\119\111\32\102\117\110\99\116\105\111\110\32\118\97\108\117\101\115")
125+checkmessage("\112\114\105\110\116\40\39\49\48\39\32\60\32\49\48\41","\115\116\114\105\110\103\32\119\105\116\104\32\110\117\109\98\101\114")
126+checkmessage("\112\114\105\110\116\40\49\48\32\60\32\39\50\51\39\41","\110\117\109\98\101\114\32\119\105\116\104\32\115\116\114\105\110\103")
127+checkmessage("\108\111\99\97\108\32\97\32\61\32\50\46\48\94\49\48\48\59\32\120\32\61\32\97\32\60\60\32\50","\108\111\99\97\108\32\97")
128+checkmessage("\108\111\99\97\108\32\97\32\61\32\49\32\62\62\32\50\46\48\94\49\48\48","\104\97\115\32\110\111\32\105\110\116\101\103\101\114\32\114\101\112\114\101\115\101\110\116\97\116\105\111\110")
129+checkmessage("\108\111\99\97\108\32\97\32\61\32\49\48\46\49\32\60\60\32\50\46\48\94\49\48\48","\104\97\115\32\110\111\32\105\110\116\101\103\101\114\32\114\101\112\114\101\115\101\110\116\97\116\105\111\110")
130+checkmessage("\108\111\99\97\108\32\97\32\61\32\50\46\48\94\49\48\48\32\38\32\49","\104\97\115\32\110\111\32\105\110\116\101\103\101\114\32\114\101\112\114\101\115\101\110\116\97\116\105\111\110")
131+checkmessage("\108\111\99\97\108\32\97\32\61\32\50\46\48\94\49\48\48\32\38\32\49\101\49\48\48","\104\97\115\32\110\111\32\105\110\116\101\103\101\114\32\114\101\112\114\101\115\101\110\116\97\116\105\111\110")
132+checkmessage("\108\111\99\97\108\32\97\32\61\32\50\46\48\32\124\32\49\101\52\48","\104\97\115\32\110\111\32\105\110\116\101\103\101\114\32\114\101\112\114\101\115\101\110\116\97\116\105\111\110")
133+checkmessage("\108\111\99\97\108\32\97\32\61\32\50\101\49\48\48\32\126\32\49","\104\97\115\32\110\111\32\105\110\116\101\103\101\114\32\114\101\112\114\101\115\101\110\116\97\116\105\111\110")
134+checkmessage("\115\116\114\105\110\103\46\115\117\98\40\39\97\39\44\32\50\46\48\94\49\48\48\41","\104\97\115\32\110\111\32\105\110\116\101\103\101\114\32\114\101\112\114\101\115\101\110\116\97\116\105\111\110")
135+checkmessage("\115\116\114\105\110\103\46\114\101\112\40\39\97\39\44\32\51\46\51\41","\104\97\115\32\110\111\32\105\110\116\101\103\101\114\32\114\101\112\114\101\115\101\110\116\97\116\105\111\110")
136+checkmessage("\114\101\116\117\114\110\32\54\101\52\48\32\38\32\55","\104\97\115\32\110\111\32\105\110\116\101\103\101\114\32\114\101\112\114\101\115\101\110\116\97\116\105\111\110")
137+checkmessage("\114\101\116\117\114\110\32\51\52\32\60\60\32\55\101\51\48","\104\97\115\32\110\111\32\105\110\116\101\103\101\114\32\114\101\112\114\101\115\101\110\116\97\116\105\111\110")
138+checkmessage("\114\101\116\117\114\110\32\126\45\51\101\52\48","\104\97\115\32\110\111\32\105\110\116\101\103\101\114\32\114\101\112\114\101\115\101\110\116\97\116\105\111\110")
139+checkmessage("\114\101\116\117\114\110\32\126\45\51\46\48\48\57","\104\97\115\32\110\111\32\105\110\116\101\103\101\114\32\114\101\112\114\101\115\101\110\116\97\116\105\111\110")
140+checkmessage("\114\101\116\117\114\110\32\51\46\48\48\57\32\38\32\49","\104\97\115\32\110\111\32\105\110\116\101\103\101\114\32\114\101\112\114\101\115\101\110\116\97\116\105\111\110")
141+checkmessage("\114\101\116\117\114\110\32\51\52\32\62\62\32\123\125","\116\97\98\108\101\32\118\97\108\117\101")
142+checkmessage("\97\97\97\32\61\32\50\52\32\47\47\32\48","\100\105\118\105\100\101\32\98\121\32\122\101\114\111")
143+checkmessage("\97\97\97\32\61\32\49\32\37\32\48","\39\110\37\48\39")
144+checkmessage("\108\111\99\97\108\32\97\32\61\32\115\101\116\109\101\116\97\116\97\98\108\101\40\123\125\44\32\123\95\95\105\110\100\101\120\32\61\32\49\48\125\41\46\120","\97\116\116\101\109\112\116\32\116\111\32\105\110\100\101\120\32\97\32\110\117\109\98\101\114\32\118\97\108\117\101")
145+checkmessage("\102\111\114\32\105\32\61\32\123\125\44\32\49\48\32\100\111\32\101\110\100","\116\97\98\108\101")
146+checkmessage("\102\111\114\32\105\32\61\32\105\111\46\115\116\100\105\110\44\32\49\48\32\100\111\32\101\110\100","\70\73\76\69")
147+checkmessage("\102\111\114\32\105\32\61\32\123\125\44\32\49\48\32\100\111\32\101\110\100","\105\110\105\116\105\97\108\32\118\97\108\117\101")
148+checkmessage("\102\111\114\32\105\32\61\32\49\44\32\39\120\39\44\32\49\48\32\100\111\32\101\110\100","\115\116\114\105\110\103")
149+checkmessage("\102\111\114\32\105\32\61\32\49\44\32\123\125\44\32\49\48\32\100\111\32\101\110\100","\108\105\109\105\116")
150+checkmessage("\102\111\114\32\105\32\61\32\49\44\32\123\125\32\100\111\32\101\110\100","\108\105\109\105\116")
151+checkmessage("\102\111\114\32\105\32\61\32\49\44\32\49\48\44\32\112\114\105\110\116\32\100\111\32\101\110\100","\115\116\101\112")
152+checkmessage("\102\111\114\32\105\32\61\32\49\44\32\49\48\44\32\112\114\105\110\116\32\100\111\32\101\110\100","\102\117\110\99\116\105\111\110")
172153_G.D=debug
173−checkmessage(" -- create light udata
174− local x = D.upvalueid(function () return debug end, 1)
175− D.setuservalue(x, {})
176−","light userdata")
154+checkmessage("\32\32\45\45\32\99\114\101\97\116\101\32\108\105\103\104\116\32\117\100\97\116\97\10\32\32\108\111\99\97\108\32\120\32\61\32\68\46\117\112\118\97\108\117\101\105\100\40\102\117\110\99\116\105\111\110\32\40\41\32\114\101\116\117\114\110\32\100\101\98\117\103\32\101\110\100\44\32\49\41\10\32\32\68\46\115\101\116\117\115\101\114\118\97\108\117\101\40\120\44\32\123\125\41\10","\108\105\103\104\116\32\117\115\101\114\100\97\116\97")
177155_G.D=nil
178−checkmessage("math.sin(io.input())","(number expected, got FILE*)")
179−_G.XX=setmetatable({},{["__name"] = "My Type"})
180−assert(string.find(tostring(XX),"^My Type"))
181−checkmessage("io.input(XX)","(FILE* expected, got My Type)")
182−checkmessage("return XX + 1","on a My Type value")
183−checkmessage("return ~io.stdin","on a FILE* value")
184−checkmessage("return XX < XX","two My Type values")
185−checkmessage("return {} < XX","table with My Type")
186−checkmessage("return XX < io.stdin","My Type with FILE*")
156+do
157+checkmessage("\109\97\116\104\46\115\105\110\40\105\111\46\105\110\112\117\116\40\41\41","\40\110\117\109\98\101\114\32\101\120\112\101\99\116\101\100\44\32\103\111\116\32\70\73\76\69\42\41")
158+_G.XX=setmetatable({},{["\95\95\110\97\109\101"] = "\77\121\32\84\121\112\101"})
159+assert(string.find(tostring(XX),"\94\77\121\32\84\121\112\101"))
160+checkmessage("\105\111\46\105\110\112\117\116\40\88\88\41","\40\70\73\76\69\42\32\101\120\112\101\99\116\101\100\44\32\103\111\116\32\77\121\32\84\121\112\101\41")
161+checkmessage("\114\101\116\117\114\110\32\88\88\32\43\32\49","\111\110\32\97\32\77\121\32\84\121\112\101\32\118\97\108\117\101")
162+checkmessage("\114\101\116\117\114\110\32\126\105\111\46\115\116\100\105\110","\111\110\32\97\32\70\73\76\69\42\32\118\97\108\117\101")
163+checkmessage("\114\101\116\117\114\110\32\88\88\32\60\32\88\88","\116\119\111\32\77\121\32\84\121\112\101\32\118\97\108\117\101\115")
164+checkmessage("\114\101\116\117\114\110\32\123\125\32\60\32\88\88","\116\97\98\108\101\32\119\105\116\104\32\77\121\32\84\121\112\101")
165+checkmessage("\114\101\116\117\114\110\32\88\88\32\60\32\105\111\46\115\116\100\105\110","\77\121\32\84\121\112\101\32\119\105\116\104\32\70\73\76\69\42")
187166_G.XX=nil
188167if T then
189−local x = setmetatable({},{["__name"] = "TABLE"})
190−assert(T.testC("Ltolstring -1; return 1",x) == tostring(x))
191−local a,b = T.testC("pushint 10; Ltolstring -2; return 2",x)
168+local x = setmetatable({},{["\95\95\110\97\109\101"] = "\84\65\66\76\69"})
169+assert(T.testC("\76\116\111\108\115\116\114\105\110\103\32\45\49\59\32\114\101\116\117\114\110\32\49",x) == tostring(x))
170+local a,b = T.testC("\112\117\115\104\105\110\116\32\49\48\59\32\76\116\111\108\115\116\114\105\110\103\32\45\50\59\32\114\101\116\117\114\110\32\50",x)
192171assert(a == 10 and b == tostring(x))
193−setmetatable(x,{["__tostring"] = (o)
172+setmetatable(x,{["\95\95\116\111\115\116\114\105\110\103"] = function (o)
194173assert(o == x)
195−return "ABC"
174+return "\65\66\67"
196175end})
197−local a,b,c = T.testC("pushint 10; Ltolstring -2; return 3",x)
198−assert(a == x and b == 10 and c == "ABC")
176+local a,b,c = T.testC("\112\117\115\104\105\110\116\32\49\48\59\32\76\116\111\108\115\116\114\105\110\103\32\45\50\59\32\114\101\116\117\114\110\32\51",x)
177+assert(a == x and b == 10 and c == "\65\66\67")
199178end
200−checkmessage("(io.write or print){}","io.write")
201−checkmessage("(collectgarbage or print){}","collectgarbage")
202−local f = (a)
179+end
180+checkmessage("\40\105\111\46\119\114\105\116\101\32\111\114\32\112\114\105\110\116\41\123\125","\105\111\46\119\114\105\116\101")
181+checkmessage("\40\99\111\108\108\101\99\116\103\97\114\98\97\103\101\32\111\114\32\112\114\105\110\116\41\123\125","\99\111\108\108\101\99\116\103\97\114\98\97\103\101")
182+do
183+local f = function (a)
203184return a + 1
204185end
205186f=assert(load(string.dump(f,true)))
206187assert(f(3) == 4)
207−checkerr("^%?:%-1:",f,{})
208−f=()
209−local a =
188+checkerr("\94\37\63\58\37\45\49\58",f,{})
189+f=function ()
190+local a
210191;
211192a={}
212193;
213194return a + 2
214195end
215196f=assert(load(string.dump(f,true)))
216−checkerr("^%?:%-1:.*table value",f)
197+checkerr("\94\37\63\58\37\45\49\58\46\42\116\97\98\108\101\32\118\97\108\117\101",f)
198+end
217199local t = {}
218−for i = 1, 1e3
200+for i = 1, 1000
219201do
220−t[i]="aaa = x" .. i
202+t[i]="\97\97\97\32\61\32\120" .. i
221203end
222−local s = table.concat(t,"; ")
204+local s = table.concat(t,"\59\32")
223205t=nil
224−checkmessage(s .. "; aaa = bbb + 1","global 'bbb'")
225−checkmessage("local _ENV=_ENV;" .. s .. "; aaa = bbb + 1","global 'bbb'")
226−checkmessage(s .. "; local t = {}; aaa = t.bbb + 1","field 'bbb'")
227−checkmessage(s .. "; local t = {}; t:bbb()","method 'bbb'")
228−checkmessage("aaa=9
229−repeat until 3==3
230−local x=math.sin(math.cos(3))
231−if math.sin(1) == x then return math.sin(1) end -- tail call
232−local a,b = 1, {
233− {x='a'..'b'..'c', y='b', z=x},
234− {1,2,3,4,5} or 3+3<=3+3,
235− 3+1>3+1,
236− {d = x and aaa[x or y]}}
237−","global 'aaa'")
238−checkmessage("local x,y = {},1
239−if math.sin(1) == 0 then return 3 end -- return
240−x.a()","field 'a'")
241−checkmessage("prefix = nil
242−insert = nil
243−while 1 do
244− local a
245− if nil then break end
246− insert(prefix, a)
247−end","global 'insert'")
248−checkmessage(" -- tail call
249− return math.sin("a")
250−","sin")
251−checkmessage("collectgarbage("nooption")","invalid option")
252−checkmessage("x = print .. "a"","concatenate")
253−checkmessage("x = "a" .. false","concatenate")
254−checkmessage("x = {} .. 2","concatenate")
255−checkmessage("getmetatable(io.stdin).__gc()","no value")
256−checkmessage("local Var
257−local function main()
258− NoSuchName (function() Var=0 end)
259−end
260−main()
261−","global 'NoSuchName'")
262−print("+")
206+checkmessage(s .. "\59\32\97\97\97\32\61\32\98\98\98\32\43\32\49","\103\108\111\98\97\108\32\39\98\98\98\39")
207+checkmessage("\108\111\99\97\108\32\95\69\78\86\61\95\69\78\86\59" .. s .. "\59\32\97\97\97\32\61\32\98\98\98\32\43\32\49","\103\108\111\98\97\108\32\39\98\98\98\39")
208+checkmessage(s .. "\59\32\108\111\99\97\108\32\116\32\61\32\123\125\59\32\97\97\97\32\61\32\116\46\98\98\98\32\43\32\49","\102\105\101\108\100\32\39\98\98\98\39")
209+checkmessage(s .. "\59\32\108\111\99\97\108\32\116\32\61\32\123\125\59\32\116\58\98\98\98\40\41","\109\101\116\104\111\100\32\39\98\98\98\39")
210+checkmessage("\97\97\97\61\57\10\114\101\112\101\97\116\32\117\110\116\105\108\32\51\61\61\51\10\108\111\99\97\108\32\120\61\109\97\116\104\46\115\105\110\40\109\97\116\104\46\99\111\115\40\51\41\41\10\105\102\32\109\97\116\104\46\115\105\110\40\49\41\32\61\61\32\120\32\116\104\101\110\32\114\101\116\117\114\110\32\109\97\116\104\46\115\105\110\40\49\41\32\101\110\100\32\32\32\45\45\32\116\97\105\108\32\99\97\108\108\10\108\111\99\97\108\32\97\44\98\32\61\32\49\44\32\123\10\32\32\123\120\61\39\97\39\46\46\39\98\39\46\46\39\99\39\44\32\121\61\39\98\39\44\32\122\61\120\125\44\10\32\32\123\49\44\50\44\51\44\52\44\53\125\32\111\114\32\51\43\51\60\61\51\43\51\44\10\32\32\51\43\49\62\51\43\49\44\10\32\32\123\100\32\61\32\120\32\97\110\100\32\97\97\97\91\120\32\111\114\32\121\93\125\125\10","\103\108\111\98\97\108\32\39\97\97\97\39")
211+checkmessage("\108\111\99\97\108\32\120\44\121\32\61\32\123\125\44\49\10\105\102\32\109\97\116\104\46\115\105\110\40\49\41\32\61\61\32\48\32\116\104\101\110\32\114\101\116\117\114\110\32\51\32\101\110\100\32\32\32\32\45\45\32\114\101\116\117\114\110\10\120\46\97\40\41","\102\105\101\108\100\32\39\97\39")
212+checkmessage("\112\114\101\102\105\120\32\61\32\110\105\108\10\105\110\115\101\114\116\32\61\32\110\105\108\10\119\104\105\108\101\32\49\32\100\111\10\32\32\108\111\99\97\108\32\97\10\32\32\105\102\32\110\105\108\32\116\104\101\110\32\98\114\101\97\107\32\101\110\100\10\32\32\105\110\115\101\114\116\40\112\114\101\102\105\120\44\32\97\41\10\101\110\100","\103\108\111\98\97\108\32\39\105\110\115\101\114\116\39")
213+checkmessage("\32\32\45\45\32\116\97\105\108\32\99\97\108\108\10\32\32\114\101\116\117\114\110\32\109\97\116\104\46\115\105\110\40\34\97\34\41\10","\115\105\110")
214+checkmessage("\99\111\108\108\101\99\116\103\97\114\98\97\103\101\40\34\110\111\111\112\116\105\111\110\34\41","\105\110\118\97\108\105\100\32\111\112\116\105\111\110")
215+checkmessage("\120\32\61\32\112\114\105\110\116\32\46\46\32\34\97\34","\99\111\110\99\97\116\101\110\97\116\101")
216+checkmessage("\120\32\61\32\34\97\34\32\46\46\32\102\97\108\115\101","\99\111\110\99\97\116\101\110\97\116\101")
217+checkmessage("\120\32\61\32\123\125\32\46\46\32\50","\99\111\110\99\97\116\101\110\97\116\101")
218+checkmessage("\103\101\116\109\101\116\97\116\97\98\108\101\40\105\111\46\115\116\100\105\110\41\46\95\95\103\99\40\41","\110\111\32\118\97\108\117\101")
219+checkmessage("\108\111\99\97\108\32\86\97\114\10\108\111\99\97\108\32\102\117\110\99\116\105\111\110\32\109\97\105\110\40\41\10\32\32\78\111\83\117\99\104\78\97\109\101\32\40\102\117\110\99\116\105\111\110\40\41\32\86\97\114\61\48\32\101\110\100\41\10\101\110\100\10\109\97\105\110\40\41\10","\103\108\111\98\97\108\32\39\78\111\83\117\99\104\78\97\109\101\39")
220+print("\43")
263221aaa={}
264222;
265−setmetatable(aaa,{["__index"] = string})
266−checkmessage("aaa:sub()","bad self")
267−checkmessage("string.sub('a', {})","#2")
268−checkmessage("('a'):sub{}","#1")
269−checkmessage("table.sort({1,2,3}, table.sort)","'table.sort'")
270−checkmessage("string.gsub('s', 's', setmetatable)","'setmetatable'")
223+setmetatable(aaa,{["\95\95\105\110\100\101\120"] = string})
224+checkmessage("\97\97\97\58\115\117\98\40\41","\98\97\100\32\115\101\108\102")
225+checkmessage("\115\116\114\105\110\103\46\115\117\98\40\39\97\39\44\32\123\125\41","\35\50")
226+checkmessage("\40\39\97\39\41\58\115\117\98\123\125","\35\49")
227+checkmessage("\116\97\98\108\101\46\115\111\114\116\40\123\49\44\50\44\51\125\44\32\116\97\98\108\101\46\115\111\114\116\41","\39\116\97\98\108\101\46\115\111\114\116\39")
228+checkmessage("\115\116\114\105\110\103\46\103\115\117\98\40\39\115\39\44\32\39\115\39\44\32\115\101\116\109\101\116\97\116\97\98\108\101\41","\39\115\101\116\109\101\116\97\116\97\98\108\101\39")
271229_G.aaa=nil
272230local function f
273231(n)
@@ -275,99 +233,43 @@ local c = coroutine.create(f)
275233local a,b = coroutine.resume(c)
276234return b
277235end
278−assert(string.find(f(),"C stack overflow"))
279−checkmessage("coroutine.yield()","outside a coroutine")
280−f=coroutine.wrap(()
236+assert(string.find(f(),"\67\32\115\116\97\99\107\32\111\118\101\114\102\108\111\119"))
237+checkmessage("\99\111\114\111\117\116\105\110\101\46\121\105\101\108\100\40\41","\111\117\116\115\105\100\101\32\97\32\99\111\114\111\117\116\105\110\101")
238+f=coroutine.wrap(function ()
281239table.sort({1,2,3},coroutine.yield)
282240end)
283−checkerr("yield across",f)
241+checkerr("\121\105\101\108\100\32\97\99\114\111\115\115",f)
284242local idsize = 60 - 1
285243local function checksize
286244(source)
287−local _,msg = load("x",source)
288−msg=string.match(msg,"^([^:]*):")
245+local _,msg = load("\120",source)
246+msg=string.match(msg,"\94\40\91\94\58\93\42\41\58")
289247assert(msg:len() <= idsize)
290248end
291249for i = 60 - 10, 60 + 10
292250do
293−checksize("@" .. string.rep("x",i))
294−checksize(string.rep("x",i - 10))
295−checksize("=" .. string.rep("x",i))
251+checksize("\64" .. string.rep("\120",i))
252+checksize(string.rep("\120",i - 10))
253+checksize("\61" .. string.rep("\120",i))
296254end
297255local function lineerror
298256(s,l)
299257local err,msg = pcall(load(s))
300−local line = tonumber(string.match(msg,":(%d+):"))
258+local line = tonumber(string.match(msg,"\58\40\37\100\43\41\58"))
301259assert(line == l or (not line and not l))
302260end
303−lineerror("local a
304− for i=1,'a' do
305− print(i)
306− end",2)
307−lineerror("
308− local a
309− for k,v in 3
310− do
311− print(k)
312− end",3)
313−lineerror("
314−
315− for k,v in
316− 3
317− do
318− print(k)
319− end",4)
320−lineerror("function a.x.y ()
321−a=a+1
322−end",1)
323−lineerror("a =
324−a
325−+
326−{}",3)
327−lineerror("a =
328−3
329−+
330−(
331−4
332−/
333−print)",6)
334−lineerror("a =
335−print
336−+
337−(
338−4
339−/
340−7)",3)
341−lineerror("a
342−=
343−-
344−
345−print
346−;",3)
347−lineerror("a
348−( -- <<
349−23)
350−",2)
351−lineerror("local a = {x = 13}
352−a
353−.
354−x
355−( -- <<
356−23
357−)
358−",5)
359−lineerror("local a = {x = 13}
360−a
361−.
362−x
363−(
364−23 + a
365−)
366−",6)
367−local p = " function g() f() end
368− function f(x) error('a', XX) end
369−g()
370−"
261+lineerror("\108\111\99\97\108\32\97\10\32\102\111\114\32\105\61\49\44\39\97\39\32\100\111\32\10\32\112\114\105\110\116\40\105\41\32\10\32\101\110\100",2)
262+lineerror("\10\32\108\111\99\97\108\32\97\32\10\32\102\111\114\32\107\44\118\32\105\110\32\51\32\10\32\100\111\32\10\32\112\114\105\110\116\40\107\41\32\10\32\101\110\100",3)
263+lineerror("\10\10\32\102\111\114\32\107\44\118\32\105\110\32\10\32\51\32\10\32\100\111\32\10\32\112\114\105\110\116\40\107\41\32\10\32\101\110\100",4)
264+lineerror("\102\117\110\99\116\105\111\110\32\97\46\120\46\121\32\40\41\10\97\61\97\43\49\10\101\110\100",1)
265+lineerror("\97\32\61\32\10\97\10\43\10\123\125",3)
266+lineerror("\97\32\61\32\10\51\10\43\10\40\10\52\10\47\10\112\114\105\110\116\41",6)
267+lineerror("\97\32\61\32\10\112\114\105\110\116\10\43\10\40\10\52\10\47\10\55\41",3)
268+lineerror("\97\10\61\10\45\10\10\112\114\105\110\116\10\59",3)
269+lineerror("\97\10\40\32\32\32\32\32\45\45\32\60\60\10\50\51\41\10",2)
270+lineerror("\108\111\99\97\108\32\97\32\61\32\123\120\32\61\32\49\51\125\10\97\10\46\10\120\10\40\32\32\32\32\32\45\45\32\60\60\10\50\51\10\41\10",5)
271+lineerror("\108\111\99\97\108\32\97\32\61\32\123\120\32\61\32\49\51\125\10\97\10\46\10\120\10\40\10\50\51\32\43\32\97\10\41\10",6)
272+local p = "\32\32\102\117\110\99\116\105\111\110\32\103\40\41\32\102\40\41\32\101\110\100\10\32\32\102\117\110\99\116\105\111\110\32\102\40\120\41\32\101\114\114\111\114\40\39\97\39\44\32\88\88\41\32\101\110\100\10\103\40\41\10"
371273XX=3
372274;
373275lineerror((p),3)
@@ -381,30 +283,18 @@ XX=2
381283;
382284lineerror((p),1)
383285_G.XX,_G.g,_G.f=nil
384−lineerror("local b = false
385−if not b then
386− error 'test'
387−end",3)
388−lineerror("local b = false
389−if not b then
390− if not b then
391− if not b then
392− error 'test'
393− end
394− end
395−end",5)
396−lineerror(" local a = 0
397− local b = 1
398− local c = b % a
399−",3)
400−local s = string.format("%s return __A.x",string.rep("
401−",300))
286+lineerror("\108\111\99\97\108\32\98\32\61\32\102\97\108\115\101\10\105\102\32\110\111\116\32\98\32\116\104\101\110\10\32\32\101\114\114\111\114\32\39\116\101\115\116\39\10\101\110\100",3)
287+lineerror("\108\111\99\97\108\32\98\32\61\32\102\97\108\115\101\10\105\102\32\110\111\116\32\98\32\116\104\101\110\10\32\32\105\102\32\110\111\116\32\98\32\116\104\101\110\10\32\32\32\32\105\102\32\110\111\116\32\98\32\116\104\101\110\10\32\32\32\32\32\32\101\114\114\111\114\32\39\116\101\115\116\39\10\32\32\32\32\101\110\100\10\32\32\101\110\100\10\101\110\100",5)
288+lineerror("\32\32\108\111\99\97\108\32\97\32\61\32\48\10\32\32\108\111\99\97\108\32\98\32\61\32\49\10\32\32\108\111\99\97\108\32\99\32\61\32\98\32\37\32\97\10",3)
289+do
290+local s = string.format("\37\115\32\114\101\116\117\114\110\32\95\95\65\46\120",string.rep("\10",300))
402291lineerror(s,301)
292+end
403293if not _soft then
404294collectgarbage()
405−print("testing stack overflow")
295+print("\116\101\115\116\105\110\103\32\115\116\97\99\107\32\111\118\101\114\102\108\111\119")
406296local C = 0
407−local l = debug.getinfo(1,"l").currentline + 1
297+local l = debug.getinfo(1,"\108").currentline + 1
408298local function auxy
409299()
410300C=C + 1
@@ -412,35 +302,34 @@ C=C + 1
412302auxy()
413303end
414304function YY()
415−collectgarbage("stop")
305+collectgarbage("\115\116\111\112")
416306auxy()
417−collectgarbage("restart")
307+collectgarbage("\114\101\115\116\97\114\116")
418308end
419309local function checkstackmessage
420310(m)
421−print("(expected stack overflow after " .. C .. " calls)")
311+print("\40\101\120\112\101\99\116\101\100\32\115\116\97\99\107\32\111\118\101\114\102\108\111\119\32\97\102\116\101\114\32" .. C .. "\32\99\97\108\108\115\41")
422312C=0
423−return (string.find(m,"stack overflow"))
313+return (string.find(m,"\115\116\97\99\107\32\111\118\101\114\102\108\111\119"))
424314end
425−assert(checkstackmessage(doit("YY()")))
426−assert(checkstackmessage(doit("YY()")))
427−assert(checkstackmessage(doit("YY()")))
315+assert(checkstackmessage(doit("\89\89\40\41")))
316+assert(checkstackmessage(doit("\89\89\40\41")))
317+assert(checkstackmessage(doit("\89\89\40\41")))
428318_G.YY=nil
429−local l1 =
319+local l1
430320local function g
431321(x)
432−l1=debug.getinfo(x,"l").currentline + 2
433−collectgarbage("stop")
322+l1=debug.getinfo(x,"\108").currentline + 2
323+collectgarbage("\115\116\111\112")
434324auxy()
435−collectgarbage("restart")
325+collectgarbage("\114\101\115\116\97\114\116")
436326end
437327local _,stackmsg = xpcall(g,debug.traceback,1)
438−print("+")
328+print("\43")
439329local stack = {}
440−for line in string.gmatch(stackmsg,"[^
441−]*")
330+for line in string.gmatch(stackmsg,"\91\94\10\93\42")
442331do
443−local curr = string.match(line,":(%d+):")
332+local curr = string.match(line,"\58\40\37\100\43\41\58")
444333if curr then
445334table.insert(stack,tonumber(curr))
446335end
@@ -449,17 +338,17 @@ local i = 1
449338while stack[i] ~= l1 do
450339assert(stack[i] == l)
451340i=i + 1
341+end
452342assert(i > 15)
453343local res,msg = xpcall(error,error)
454−assert(not res and type(msg) == "string")
455−print("+")
344+assert(not res and type(msg) == "\115\116\114\105\110\103")
345+print("\43")
456346local function f
457347(x)
458348if x == 0 then
459−error("a
460−")
349+error("\97\10")
461350else
462−local aux = ()
351+local aux = function ()
463352return f(x - 1)
464353end
465354local a,b = xpcall(aux,aux)
@@ -471,78 +360,80 @@ local function loop
471360(x,y,z)
472361return 1 + loop(x,y,z)
473362end
474−local res,msg = xpcall(loop,(m)
475−assert(string.find(m,"stack overflow"))
476−checkerr("error handling",loop)
363+local res,msg = xpcall(loop,function (m)
364+assert(string.find(m,"\115\116\97\99\107\32\111\118\101\114\102\108\111\119"))
365+checkerr("\101\114\114\111\114\32\104\97\110\100\108\105\110\103",loop)
477366assert(math.sin(0) == 0)
478367return 15
479368end)
480369assert(msg == 15)
481−local f = ()
482−for i = 999900, 1e6, 1
370+local f = function ()
371+for i = 999900, 1000000, 1
483372do
484373table.unpack({},1,i)
485374end
486375end
487−checkerr("too many results",f)
376+checkerr("\116\111\111\32\109\97\110\121\32\114\101\115\117\108\116\115",f)
488377end
378+do
489379local t = {}
490−local res,msg = pcall(()
380+local res,msg = pcall(function ()
491381error(t)
492382end)
493383assert(not res and msg == t)
494−res,msg=pcall(()
384+res,msg=pcall(function ()
495385error(nil)
496386end)
497387assert(not res and msg == nil)
498388local function f
499389()
500−error({["msg"] = "x"})
390+error({["\109\115\103"] = "\120"})
501391end
502−res,msg=xpcall(f,(r)
503−return {["msg"] = r.msg .. "y"}
392+res,msg=xpcall(f,function (r)
393+return {["\109\115\103"] = r.msg .. "\121"}
504394end)
505−assert(msg.msg == "xy")
506−res,msg=pcall(assert,false,"X",t)
507−assert(not res and msg == "X")
508−res,msg=pcall(()
395+assert(msg.msg == "\120\121")
396+res,msg=pcall(assert,false,"\88",t)
397+assert(not res and msg == "\88")
398+res,msg=pcall(function ()
509399assert(false)
510400end)
511−local line = string.match(msg,"%w+%.lua:(%d+): assertion failed!$")
512−assert(tonumber(line) == debug.getinfo(1,"l").currentline - 2)
401+local line = string.match(msg,"\37\119\43\37\46\108\117\97\58\40\37\100\43\41\58\32\97\115\115\101\114\116\105\111\110\32\102\97\105\108\101\100\33\36")
402+assert(tonumber(line) == debug.getinfo(1,"\108").currentline - 2)
513403res,msg=pcall(assert,false,t)
514404assert(not res and msg == t)
515405res,msg=pcall(assert,nil,nil)
516406assert(not res and msg == nil)
517407res,msg=pcall(assert)
518−assert(not res and string.find(msg,"value expected"))
519−local a,b,c = xpcall(string.find,error,"alo","al")
408+assert(not res and string.find(msg,"\118\97\108\117\101\32\101\120\112\101\99\116\101\100"))
409+end
410+local a,b,c = xpcall(string.find,error,"\97\108\111","\97\108")
520411assert(a and b == 1 and c == 2)
521−a,b,c=xpcall(string.find,(x)
412+a,b,c=xpcall(string.find,function (x)
522413return {}
523−end,true,"al")
524−assert(not a and type(b) == "table" and c == nil)
525−print("testing tokens in error messages")
526−checksyntax("syntax error","","error",1)
527−checksyntax("1.000","","1.000",1)
528−checksyntax("[[a]]","","[[a]]",1)
529−checksyntax("'aa'","","'aa'",1)
530−checksyntax("while << do end","","<<",1)
531−checksyntax("for >> do end","",">>",1)
532−checksyntax("aa = 1","","<\1>",1)
533−checksyntax("�a = 1","","<\255>",1)
534−doit("I = load("a=9+"); aaa=3")
414+end,true,"\97\108")
415+assert(not a and type(b) == "\116\97\98\108\101" and c == nil)
416+print("\116\101\115\116\105\110\103\32\116\111\107\101\110\115\32\105\110\32\101\114\114\111\114\32\109\101\115\115\97\103\101\115")
417+checksyntax("\115\121\110\116\97\120\32\101\114\114\111\114","","\101\114\114\111\114",1)
418+checksyntax("\49\46\48\48\48","","\49\46\48\48\48",1)
419+checksyntax("\91\91\97\93\93","","\91\91\97\93\93",1)
420+checksyntax("\39\97\97\39","","\39\97\97\39",1)
421+checksyntax("\119\104\105\108\101\32\60\60\32\100\111\32\101\110\100","","\60\60",1)
422+checksyntax("\102\111\114\32\62\62\32\100\111\32\101\110\100","","\62\62",1)
423+checksyntax("\97\1\97\32\61\32\49","","\60\92\49\62",1)
424+checksyntax("\255\97\32\61\32\49","","\60\92\50\53\53\62",1)
425+doit("\73\32\61\32\108\111\97\100\40\34\97\61\57\43\34\41\59\32\97\97\97\61\51")
535426assert(_G.aaa == 3 and not _G.I)
536427_G.I,_G.aaa=nil
537−print("+")
538−local lim = 1e3
428+print("\43")
429+local lim = 1000
539430if _soft then
540431lim=100
541432end
542433for i = 1, lim
543434do
544−doit("a = ")
545−doit("a = 4+nil")
435+doit("\97\32\61\32")
436+doit("\97\32\61\32\52\43\110\105\108")
546437end
547438local function testrep
548439(init,rep,close,repc,finalresult)
@@ -554,57 +445,49 @@ assert(res() == finalresult)
554445end
555446s=init .. string.rep(rep,500)
556447local res,msg = load(s)
557−assert(not res and (string.find(msg,"too many") or string.find(msg,"overflow")))
558−end
559−testrep("local a; a",",a","= 1",",1")
560−testrep("local a; a=","{","0","}")
561−testrep("return ","(","2",")",2)
562−testrep("local function a (x) return x end; return ","a(","2.2",")",2.2)
563−testrep("","do ",""," end")
564−testrep("","while a do ",""," end")
565−testrep("local a; ","if a then else ",""," end")
566−testrep("","function foo () ",""," end")
567−testrep("local a = ''; return ","a..","'a'","","a")
568−testrep("local a = 1; return ","a^","a","",1)
569−checkmessage("a = f(x" .. string.rep(",x",260) .. ")","too many registers")
448+assert(not res and (string.find(msg,"\116\111\111\32\109\97\110\121") or string.find(msg,"\111\118\101\114\102\108\111\119")))
449+end
450+testrep("\108\111\99\97\108\32\97\59\32\97","\44\97","\61\32\49","\44\49")
451+testrep("\108\111\99\97\108\32\97\59\32\97\61","\123","\48","\125")
452+testrep("\114\101\116\117\114\110\32","\40","\50","\41",2)
453+testrep("\108\111\99\97\108\32\102\117\110\99\116\105\111\110\32\97\32\40\120\41\32\114\101\116\117\114\110\32\120\32\101\110\100\59\32\114\101\116\117\114\110\32","\97\40","\50\46\50","\41",2.2)
454+testrep("","\100\111\32","","\32\101\110\100")
455+testrep("","\119\104\105\108\101\32\97\32\100\111\32","","\32\101\110\100")
456+testrep("\108\111\99\97\108\32\97\59\32","\105\102\32\97\32\116\104\101\110\32\101\108\115\101\32","","\32\101\110\100")
457+testrep("","\102\117\110\99\116\105\111\110\32\102\111\111\32\40\41\32","","\32\101\110\100")
458+testrep("\108\111\99\97\108\32\97\32\61\32\39\39\59\32\114\101\116\117\114\110\32","\97\46\46","\39\97\39","","\97")
459+testrep("\108\111\99\97\108\32\97\32\61\32\49\59\32\114\101\116\117\114\110\32","\97\94","\97","",1)
460+checkmessage("\97\32\61\32\102\40\120" .. string.rep("\44\120",260) .. "\41","\116\111\111\32\109\97\110\121\32\114\101\103\105\115\116\101\114\115")
570461local lim = 127
571−local s = "local function fooA ()
572− local "
462+local s = "\108\111\99\97\108\32\102\117\110\99\116\105\111\110\32\102\111\111\65\32\40\41\10\32\32\108\111\99\97\108\32"
573463for j = 1, lim
574464do
575−s=s .. "a" .. j .. ", "
465+s=s .. "\97" .. j .. "\44\32"
576466end
577−s=s .. "b,c
578−"
579−s=s .. "local function fooB ()
580− local "
467+s=s .. "\98\44\99\10"
468+s=s .. "\108\111\99\97\108\32\102\117\110\99\116\105\111\110\32\102\111\111\66\32\40\41\10\32\32\108\111\99\97\108\32"
581469for j = 1, lim
582470do
583−s=s .. "b" .. j .. ", "
471+s=s .. "\98" .. j .. "\44\32"
584472end
585−s=s .. "b
586−"
587−s=s .. "function fooC () return b+c"
473+s=s .. "\98\10"
474+s=s .. "\102\117\110\99\116\105\111\110\32\102\111\111\67\32\40\41\32\114\101\116\117\114\110\32\98\43\99"
588475local c = 1 + 2
589476for j = 1, lim
590477do
591−s=s .. "+a" .. j .. "+b" .. j
478+s=s .. "\43\97" .. j .. "\43\98" .. j
592479c=c + 2
593480end
594−s=s .. "
595−end end end"
481+s=s .. "\10\101\110\100\32\32\101\110\100\32\101\110\100"
596482local a,b = load(s)
597−assert(c > 255 and string.find(b,"too many upvalues") and string.find(b,"line 5"))
598−s="
599−function foo ()
600− local "
483+assert(c > 255 and string.find(b,"\116\111\111\32\109\97\110\121\32\117\112\118\97\108\117\101\115") and string.find(b,"\108\105\110\101\32\53"))
484+s="\10\102\117\110\99\116\105\111\110\32\102\111\111\32\40\41\10\32\32\108\111\99\97\108\32"
601485for j = 1, 300
602486do
603−s=s .. "a" .. j .. ", "
487+s=s .. "\97" .. j .. "\44\32"
604488end
605−s=s .. "b
606−"
489+s=s .. "\98\10"
607490local a,b = load(s)
608−assert(string.find(b,"line 2") and string.find(b,"too many local variables"))
491+assert(string.find(b,"\108\105\110\101\32\50") and string.find(b,"\116\111\111\32\109\97\110\121\32\108\111\99\97\108\32\118\97\114\105\97\98\108\101\115"))
609492mt.__index=oldmm
610−print("OK")
493+print("\79\75")
zod/luau/res/lua/cycled/events.lua+172−164
@@ -1,30 +1,30 @@
1−print("testing metatables")
2−local debug = require("debug")
1+print("\116\101\115\116\105\110\103\32\109\101\116\97\116\97\98\108\101\115")
2+local debug = require("\100\101\98\117\103")
33X=20
44;
55B=30
6−_ENV=setmetatable({},{["__index"] = _G})
6+_ENV=setmetatable({},{["\95\95\105\110\100\101\120"] = _G})
77collectgarbage()
88X=X + 10
99assert(X == 30 and _G.X == 20)
1010B=false
1111assert(B == false)
12−_ENV["B"]=undef
12+_ENV["\66"]=undef
1313assert(B == 30)
1414assert(getmetatable({}) == nil)
1515assert(getmetatable(4) == nil)
1616assert(getmetatable(nil) == nil)
17−a={["name"] = "NAME"}
17+a={["\110\97\109\101"] = "\78\65\77\69"}
1818;
19−setmetatable(a,{["__metatable"] = "xuxu",["__tostring"] = (x)
19+setmetatable(a,{["\95\95\109\101\116\97\116\97\98\108\101"] = "\120\117\120\117",["\95\95\116\111\115\116\114\105\110\103"] = function (x)
2020return x.name
2121end})
22−assert(getmetatable(a) == "xuxu")
23−assert(tostring(a) == "NAME")
22+assert(getmetatable(a) == "\120\117\120\117")
23+assert(tostring(a) == "\78\65\77\69")
2424assert(pcall(setmetatable,a,{}) == false)
25−a.name="gororoba"
26−assert(tostring(a) == "gororoba")
27−local a,t = {10,20,30,["x"] = "10",["y"] = "20"},{}
25+a.name="\103\111\114\111\114\111\98\97"
26+assert(tostring(a) == "\103\111\114\111\114\111\98\97")
27+local a,t = {10,20,30,["\120"] = "\49\48",["\121"] = "\50\48"},{}
2828assert(setmetatable(a,t) == a)
2929assert(getmetatable(a) == t)
3030assert(setmetatable(a,nil) == a)
@@ -32,12 +32,12 @@ assert(getmetatable(a) == nil)
3232assert(setmetatable(a,t) == a)
3333function f(t,i,e)
3434assert(not e)
35−local p = rawget(t,"parent")
36−return (p and p[i] + 3),"dummy return"
35+local p = rawget(t,"\112\97\114\101\110\116")
36+return (p and p[i] + 3),"\100\117\109\109\121\32\114\101\116\117\114\110"
3737end
3838t.__index=f
39−a.parent={["z"] = 25,["x"] = 12,[4] = 24}
40−assert(a[1] == 10 and a.z == 28 and a[4] == 27 and a.x == "10")
39+a.parent={["\122"] = 25,["\120"] = 12,[4] = 24}
40+assert(a[1] == 10 and a.z == 28 and a[4] == 27 and a.x == "\49\48")
4141collectgarbage()
4242a=setmetatable({},t)
4343function f(t,i,v)
@@ -47,15 +47,17 @@ setmetatable(t,t)
4747t.__newindex=f
4848a[1]=30
4949;
50−a.x="101"
50+a.x="\49\48\49"
5151;
5252a[5]=200
5353assert(a[1] == 27 and a.x == 98 and a[5] == 197)
54+do
5455local mt = {}
5556mt.__newindex=mt
5657local t = setmetatable({},mt)
5758t[1]=10
5859assert(mt[1] == 10)
60+end
5961local c = {}
6062a=setmetatable({},t)
6163t.__newindex=c
@@ -76,26 +78,29 @@ do
7678assert(a[i] == i * 10)
7779end
7880assert(next(a) == nil)
79−local a =
81+do
82+local a
8083;
81−a=setmetatable({},{["__index"] = setmetatable({},{["__index"] = setmetatable({},{["__index"] = (_,n)
82−return a[n - 3] + 4,"lixo"
84+a=setmetatable({},{["\95\95\105\110\100\101\120"] = setmetatable({},{["\95\95\105\110\100\101\120"] = setmetatable({},{["\95\95\105\110\100\101\120"] = function (_,n)
85+return a[n - 3] + 4,"\108\105\120\111"
8386end})})})
8487a[0]=20
8588for i = 0, 10
8689do
8790assert(a[i * 3] == 20 + i * 4)
8891end
89−local foi =
92+end
93+do
94+local foi
9095local a = {}
9196for i = 1, 10
9297do
9398a[i]=0
9499;
95−a["a" .. i]=0
100+a["\97" .. i]=0
96101;
97102end
98−setmetatable(a,{["__newindex"] = (t,k,v)
103+setmetatable(a,{["\95\95\110\101\119\105\110\100\101\120"] = function (t,k,v)
99104foi=true
100105;
101106rawset(t,k,v)
@@ -107,12 +112,12 @@ a[1]=0
107112assert(not foi)
108113foi=false
109114;
110−a["a1"]=0
115+a["\97\49"]=0
111116;
112117assert(not foi)
113118foi=false
114119;
115−a["a11"]=0
120+a["\97\49\49"]=0
116121;
117122assert(foi)
118123foi=false
@@ -131,41 +136,44 @@ foi=false
131136a[1]=nil
132137;
133138assert(foi)
139+end
134140setmetatable(t,nil)
135141function f(t, ...)
136142return t,{...}
137143end
138144t.__call=f
139−local x,y = a(table.unpack({"a",1}))
140−assert(x == a and y[1] == "a" and y[2] == 1 and y[3] == undef)
145+do
146+local x,y = a(table.unpack({"\97",1}))
147+assert(x == a and y[1] == "\97" and y[2] == 1 and y[3] == undef)
141148x,y=a()
142149assert(x == a and y[1] == undef)
150+end
143151local b = setmetatable({},t)
144152setmetatable(b,t)
145153function f(op)
146−return (...)
154+return function (...)
147155cap={[0] = op,...}
148156;
149157return (...)
150158end
151159end
152−t.__add=f("add")
153−t.__sub=f("sub")
154−t.__mul=f("mul")
155−t.__div=f("div")
156−t.__idiv=f("idiv")
157−t.__mod=f("mod")
158−t.__unm=f("unm")
159−t.__pow=f("pow")
160−t.__len=f("len")
161−t.__band=f("band")
162−t.__bor=f("bor")
163−t.__bxor=f("bxor")
164−t.__shl=f("shl")
165−t.__shr=f("shr")
166−t.__bnot=f("bnot")
167−t.__lt=f("lt")
168−t.__le=f("le")
160+t.__add=f("\97\100\100")
161+t.__sub=f("\115\117\98")
162+t.__mul=f("\109\117\108")
163+t.__div=f("\100\105\118")
164+t.__idiv=f("\105\100\105\118")
165+t.__mod=f("\109\111\100")
166+t.__unm=f("\117\110\109")
167+t.__pow=f("\112\111\119")
168+t.__len=f("\108\101\110")
169+t.__band=f("\98\97\110\100")
170+t.__bor=f("\98\111\114")
171+t.__bxor=f("\98\120\111\114")
172+t.__shl=f("\115\104\108")
173+t.__shr=f("\115\104\114")
174+t.__bnot=f("\98\110\111\116")
175+t.__lt=f("\108\116")
176+t.__le=f("\108\101")
169177local function checkcap
170178(t)
171179assert(# cap + 1 == # t)
@@ -177,174 +185,174 @@ end
177185end
178186assert(b + 5 == b)
179187;
180−checkcap({"add",b,5})
188+checkcap({"\97\100\100",b,5})
181189assert(5.2 + b == 5.2)
182190;
183−checkcap({"add",5.2,b})
184−assert(b + "5" == b)
191+checkcap({"\97\100\100",5.2,b})
192+assert(b + "\53" == b)
185193;
186−checkcap({"add",b,"5"})
194+checkcap({"\97\100\100",b,"\53"})
187195assert(5 + b == 5)
188196;
189−checkcap({"add",5,b})
190−assert("5" + b == "5")
197+checkcap({"\97\100\100",5,b})
198+assert("\53" + b == "\53")
191199;
192−checkcap({"add","5",b})
200+checkcap({"\97\100\100","\53",b})
193201b=b - 3
194202;
195203assert(getmetatable(b) == t)
196204;
197−checkcap({"sub",b,3})
205+checkcap({"\115\117\98",b,3})
198206assert(5 - a == 5)
199207;
200−checkcap({"sub",5,a})
201−assert("5" - a == "5")
208+checkcap({"\115\117\98",5,a})
209+assert("\53" - a == "\53")
202210;
203−checkcap({"sub","5",a})
211+checkcap({"\115\117\98","\53",a})
204212assert(a * a == a)
205213;
206−checkcap({"mul",a,a})
214+checkcap({"\109\117\108",a,a})
207215assert(a / 0 == a)
208216;
209−checkcap({"div",a,0})
210−assert(a / 0 == a)
217+checkcap({"\100\105\118",a,0})
218+assert(a / 0.0 == a)
211219;
212−checkcap({"div",a,0})
220+checkcap({"\100\105\118",a,0.0})
213221assert(a % 2 == a)
214222;
215−checkcap({"mod",a,2})
223+checkcap({"\109\111\100",a,2})
216224assert(a // (1 / 0) == a)
217225;
218−checkcap({"idiv",a,1 / 0})
226+checkcap({"\105\100\105\118",a,1 / 0})
219227;
220−(()
221−assert(a & "hi" == a)
228+(function ()
229+assert(a & "\104\105" == a)
222230end)()
223231;
224−checkcap({"band",a,"hi"})
232+checkcap({"\98\97\110\100",a,"\104\105"})
225233;
226−(()
234+(function ()
227235assert(10 & a == 10)
228236end)()
229237;
230−checkcap({"band",10,a})
238+checkcap({"\98\97\110\100",10,a})
231239;
232−(()
240+(function ()
233241assert(a | 10 == a)
234242end)()
235243;
236−checkcap({"bor",a,10})
237−assert(a | "hi" == a)
244+checkcap({"\98\111\114",a,10})
245+assert(a | "\104\105" == a)
238246;
239−checkcap({"bor",a,"hi"})
240−assert("hi" ~ a == "hi")
247+checkcap({"\98\111\114",a,"\104\105"})
248+assert("\104\105" ~ a == "\104\105")
241249;
242−checkcap({"bxor","hi",a})
250+checkcap({"\98\120\111\114","\104\105",a})
243251;
244−(()
252+(function ()
245253assert(10 ~ a == 10)
246254end)()
247255;
248−checkcap({"bxor",10,a})
256+checkcap({"\98\120\111\114",10,a})
249257assert(- a == a)
250258;
251−checkcap({"unm",a,a})
252−assert(a ^ 4 == a)
259+checkcap({"\117\110\109",a,a})
260+assert(a ^ 4.0 == a)
253261;
254−checkcap({"pow",a,4})
255−assert(a ^ "4" == a)
262+checkcap({"\112\111\119",a,4.0})
263+assert(a ^ "\52" == a)
256264;
257−checkcap({"pow",a,"4"})
265+checkcap({"\112\111\119",a,"\52"})
258266assert(4 ^ a == 4)
259267;
260−checkcap({"pow",4,a})
261−assert("4" ^ a == "4")
268+checkcap({"\112\111\119",4,a})
269+assert("\52" ^ a == "\52")
262270;
263−checkcap({"pow","4",a})
271+checkcap({"\112\111\119","\52",a})
264272assert(# a == a)
265273;
266−checkcap({"len",a,a})
274+checkcap({"\108\101\110",a,a})
267275assert(~ a == a)
268276;
269−checkcap({"bnot",a,a})
277+checkcap({"\98\110\111\116",a,a})
270278assert(a << 3 == a)
271279;
272−checkcap({"shl",a,3})
280+checkcap({"\115\104\108",a,3})
273281assert(1.5 >> a == 1.5)
274282;
275−checkcap({"shr",1.5,a})
276−assert(5 > a)
283+checkcap({"\115\104\114",1.5,a})
284+assert(5.0 > a)
277285;
278−checkcap({"lt",a,5})
286+checkcap({"\108\116",a,5.0})
279287assert(a >= 10)
280288;
281−checkcap({"le",10,a})
282−assert(a <= - 10)
289+checkcap({"\108\101",10,a})
290+assert(a <= - 10.0)
283291;
284−checkcap({"le",a,- 10})
292+checkcap({"\108\101",a,- 10.0})
285293assert(a < - 10)
286294;
287−checkcap({"lt",a,- 10})
288−t=setmetatable({1,2,3},{["__len"] = ()
295+checkcap({"\108\116",a,- 10})
296+t=setmetatable({1,2,3},{["\95\95\108\101\110"] = function ()
289297return 10
290298end})
291299assert(# t == 10 and rawlen(t) == 3)
292−assert(rawlen("abc") == 3)
300+assert(rawlen("\97\98\99") == 3)
293301assert(not pcall(rawlen,io.stdin))
294302assert(not pcall(rawlen,34))
295303assert(not pcall(rawlen))
296−assert(rawlen(string.rep("a",1e3)) == 1e3)
304+assert(rawlen(string.rep("\97",1000)) == 1000)
297305t={}
298−t.__lt=(a,b,c)
306+t.__lt=function (a,b,c)
299307collectgarbage()
300308assert(c == nil)
301−if type(a) == "table" then
309+if type(a) == "\116\97\98\108\101" then
302310a=a.x
303311end
304−if type(b) == "table" then
312+if type(b) == "\116\97\98\108\101" then
305313b=b.x
306314end
307−return a < b,"dummy"
315+return a < b,"\100\117\109\109\121"
308316end
309−t.__le=(a,b,c)
317+t.__le=function (a,b,c)
310318assert(c == nil)
311−if type(a) == "table" then
319+if type(a) == "\116\97\98\108\101" then
312320a=a.x
313321end
314−if type(b) == "table" then
322+if type(b) == "\116\97\98\108\101" then
315323b=b.x
316324end
317−return a <= b,"dummy"
325+return a <= b,"\100\117\109\109\121"
318326end
319−t.__eq=(a,b,c)
327+t.__eq=function (a,b,c)
320328assert(c == nil)
321−if type(a) == "table" then
329+if type(a) == "\116\97\98\108\101" then
322330a=a.x
323331end
324−if type(b) == "table" then
332+if type(b) == "\116\97\98\108\101" then
325333b=b.x
326334end
327−return a == b,"dummy"
335+return a == b,"\100\117\109\109\121"
328336end
329337function Op(x)
330−return setmetatable({["x"] = x},t)
338+return setmetatable({["\120"] = x},t)
331339end
332340local function test
333341(a,b,c)
334342assert(not (Op(1) < Op(1)) and (Op(1) < Op(2)) and not (Op(2) < Op(1)))
335343assert(not (1 < Op(1)) and (Op(1) < 2) and not (2 < Op(1)))
336−assert(not (Op("a") < Op("a")) and (Op("a") < Op("b")) and not (Op("b") < Op("a")))
337−assert(not ("a" < Op("a")) and (Op("a") < "b") and not (Op("b") < Op("a")))
344+assert(not (Op("\97") < Op("\97")) and (Op("\97") < Op("\98")) and not (Op("\98") < Op("\97")))
345+assert(not ("\97" < Op("\97")) and (Op("\97") < "\98") and not (Op("\98") < Op("\97")))
338346assert((Op(1) <= Op(1)) and (Op(1) <= Op(2)) and not (Op(2) <= Op(1)))
339−assert((Op("a") <= Op("a")) and (Op("a") <= Op("b")) and not (Op("b") <= Op("a")))
347+assert((Op("\97") <= Op("\97")) and (Op("\97") <= Op("\98")) and not (Op("\98") <= Op("\97")))
340348assert(not (Op(1) > Op(1)) and not (Op(1) > Op(2)) and (Op(2) > Op(1)))
341−assert(not (Op("a") > Op("a")) and not (Op("a") > Op("b")) and (Op("b") > Op("a")))
349+assert(not (Op("\97") > Op("\97")) and not (Op("\97") > Op("\98")) and (Op("\98") > Op("\97")))
342350assert((Op(1) >= Op(1)) and not (Op(1) >= Op(2)) and (Op(2) >= Op(1)))
343351assert((1 >= Op(1)) and not (1 >= Op(2)) and (Op(2) >= 1))
344−assert((Op("a") >= Op("a")) and not (Op("a") >= Op("b")) and (Op("b") >= Op("a")))
345−assert(("a" >= Op("a")) and not (Op("a") >= "b") and (Op("b") >= Op("a")))
352+assert((Op("\97") >= Op("\97")) and not (Op("\97") >= Op("\98")) and (Op("\98") >= Op("\97")))
353+assert(("\97" >= Op("\97")) and not (Op("\97") >= "\98") and (Op("\98") >= Op("\97")))
346354assert(Op(1) == Op(1) and Op(1) ~= Op(2))
347−assert(Op("a") == Op("a") and Op("a") ~= Op("b"))
355+assert(Op("\97") == Op("\97") and Op("\97") ~= Op("\98"))
348356assert(a == a and a ~= b)
349357assert(Op(3) == c)
350358end
@@ -362,7 +370,7 @@ local function Set
362370(x)
363371return setmetatable(rawSet(x),t)
364372end
365−t.__lt=(a,b)
373+t.__lt=function (a,b)
366374for k in pairs(a)
367375do
368376if not b[k] then
@@ -372,7 +380,7 @@ b[k]=undef
372380end
373381return next(b) ~= nil
374382end
375−t.__le=(a,b)
383+t.__le=function (a,b)
376384for k in pairs(a)
377385do
378386if not b[k] then
@@ -388,7 +396,7 @@ assert((Set({1,2,3,4}) >= Set({1,2,3,4})))
388396assert(not (Set({1,3}) <= Set({3,5})))
389397assert(not (Set({1,3}) <= Set({3,5})))
390398assert(not (Set({1,3}) >= Set({3,5})))
391−t.__eq=(a,b)
399+t.__eq=function (a,b)
392400for k in pairs(a)
393401do
394402if not b[k] then
@@ -407,19 +415,19 @@ assert(rawSet({1,3,5,1}) == Set({3,5,1}))
407415assert(Set({1,3,5}) ~= Set({3,5,1,6}))
408416t[Set({1,3,5})]=1
409417assert(t[Set({1,3,5})] == undef)
410−local mt = {["__eq"] = true}
418+do
419+local mt = {["\95\95\101\113"] = true}
411420local a = setmetatable({10},mt)
412421local b = setmetatable({10},mt)
413422mt.__eq=nil
414423assert(a ~= b)
415−mt.__eq=(x,y)
424+mt.__eq=function (x,y)
416425return x[1] == y[1]
417426end
418427assert(a == b)
428+end
419429if not T then
420−(Message or print)("
421− >>> testC not active: skipping tests for userdata <<<
422−")
430+(Message or print)("\10\32\62\62\62\32\116\101\115\116\67\32\110\111\116\32\97\99\116\105\118\101\58\32\115\107\105\112\112\105\110\103\32\116\101\115\116\115\32\102\111\114\32\117\115\101\114\100\97\116\97\32\60\60\60\10")
423431else
424432local u1 = T.newuserdata(0,1)
425433local u2 = T.newuserdata(0,1)
@@ -431,10 +439,10 @@ debug.setuservalue(u2,2)
431439;
432440debug.setuservalue(u3,1)
433441;
434−debug.setmetatable(u1,{["__eq"] = (a,b)
442+debug.setmetatable(u1,{["\95\95\101\113"] = function (a,b)
435443return debug.getuservalue(a) == debug.getuservalue(b)
436444end})
437−debug.setmetatable(u2,{["__eq"] = (a,b)
445+debug.setmetatable(u2,{["\95\95\101\113"] = function (a,b)
438446return true
439447end})
440448assert(u1 == u3 and u3 == u1 and u1 ~= u2)
@@ -442,7 +450,7 @@ assert(u2 == u1 and u2 == u3 and u3 == u2)
442450assert(u2 ~= {})
443451assert(rawequal(u1,u1) and not rawequal(u1,u3))
444452local mirror = {}
445−debug.setmetatable(u3,{["__index"] = mirror,["__newindex"] = mirror})
453+debug.setmetatable(u3,{["\95\95\105\110\100\101\120"] = mirror,["\95\95\110\101\119\105\110\100\101\120"] = mirror})
446454for i = 1, 10
447455do
448456u3[i]=i
@@ -452,57 +460,57 @@ do
452460assert(u3[i] == i)
453461end
454462end
455−t.__concat=(a,b,c)
463+t.__concat=function (a,b,c)
456464assert(c == nil)
457−if type(a) == "table" then
465+if type(a) == "\116\97\98\108\101" then
458466a=a.val
459467end
460−if type(b) == "table" then
468+if type(b) == "\116\97\98\108\101" then
461469b=b.val
462470end
463471if A then
464472return a .. b
465473else
466−return setmetatable({["val"] = a .. b},t)
474+return setmetatable({["\118\97\108"] = a .. b},t)
467475end
468476end
469−c={["val"] = "c"}
477+c={["\118\97\108"] = "\99"}
470478;
471479setmetatable(c,t)
472−d={["val"] = "d"}
480+d={["\118\97\108"] = "\100"}
473481;
474482setmetatable(d,t)
475483A=true
476−assert(c .. d == "cd")
477−assert(0 .. "a" .. "b" .. c .. d .. "e" .. "f" .. (5 + 3) .. "g" == "0abcdef8g")
484+assert(c .. d == "\99\100")
485+assert(0 .. "\97" .. "\98" .. c .. d .. "\101" .. "\102" .. (5 + 3) .. "\103" == "\48\97\98\99\100\101\102\56\103")
478486A=false
479−assert((c .. d .. c .. d).val == "cdcd")
487+assert((c .. d .. c .. d).val == "\99\100\99\100")
480488x=c .. d
481−assert(getmetatable(x) == t and x.val == "cd")
482−x=0 .. "a" .. "b" .. c .. d .. "e" .. "f" .. "g"
483−assert(x.val == "0abcdefg")
489+assert(getmetatable(x) == t and x.val == "\99\100")
490+x=0 .. "\97" .. "\98" .. c .. d .. "\101" .. "\102" .. "\103"
491+assert(x.val == "\48\97\98\99\100\101\102\103")
484492c={}
485−local x =
486−setmetatable(c,{["__concat"] = (a,b)
487−assert(type(a) == "number" and b == c or type(b) == "number" and a == c)
493+local x
494+setmetatable(c,{["\95\95\99\111\110\99\97\116"] = function (a,b)
495+assert(type(a) == "\110\117\109\98\101\114" and b == c or type(b) == "\110\117\109\98\101\114" and a == c)
488496return c
489497end})
490498assert(c .. 5 == c and 5 .. c == c)
491499assert(4 .. c .. 5 == c and 4 .. 5 .. 6 .. 7 .. c == c)
492−local t1,t2,c,d =
500+local t1,t2,c,d
493501t1={}
494502;
495503c={}
496504;
497505setmetatable(c,t1)
498506d={}
499−t1.__eq=()
507+t1.__eq=function ()
500508return true
501509end
502−t1.__lt=()
510+t1.__lt=function ()
503511return true
504512end
505−t1.__le=()
513+t1.__le=function ()
506514return false
507515end
508516setmetatable(d,t1)
@@ -512,8 +520,8 @@ t2.__eq=t1.__eq
512520t2.__lt=t1.__lt
513521setmetatable(d,t2)
514522assert(c == d and c < d and not (d <= c))
515−local i =
516−local tt = {["__call"] = (t, ...)
523+local i
524+local tt = {["\95\95\99\97\108\108"] = function (t, ...)
517525i=i + 1
518526if t.f then
519527return t.f(...)
@@ -522,37 +530,37 @@ return {...}
522530end
523531end}
524532local a = setmetatable({},tt)
525−local b = setmetatable({["f"] = a},tt)
526−local c = setmetatable({["f"] = b},tt)
533+local b = setmetatable({["\102"] = a},tt)
534+local c = setmetatable({["\102"] = b},tt)
527535i=0
528536x=c(3,4,5)
529537assert(i == 3 and x[1] == 3 and x[3] == 5)
530538assert(_G.X == 20)
531539_G.X,_G.B=nil
532−print("+")
540+print("\43")
533541local _g = _G
534−_ENV=setmetatable({},{["__index"] = (_,k)
542+_ENV=setmetatable({},{["\95\95\105\110\100\101\120"] = function (_,k)
535543return _g[k]
536544end})
537545a={}
538−rawset(a,"x",1,2,3)
539−assert(a.x == 1 and rawget(a,"x",3) == 1)
540−print("+")
541−mt={["__index"] = (a,b)
546+rawset(a,"\120",1,2,3)
547+assert(a.x == 1 and rawget(a,"\120",3) == 1)
548+print("\43")
549+mt={["\95\95\105\110\100\101\120"] = function (a,b)
542550return a + b
543−end,["__len"] = (x)
551+end,["\95\95\108\101\110"] = function (x)
544552return math.floor(x)
545553end}
546554debug.setmetatable(10,mt)
547555assert(getmetatable(- 2) == mt)
548556assert((10)[3] == 13)
549−assert((10)["3"] == 13)
557+assert((10)["\51"] == 13)
550558assert(# 3.45 == 3)
551559debug.setmetatable(23,nil)
552560assert(getmetatable(- 2) == nil)
553561debug.setmetatable(true,mt)
554562assert(getmetatable(false) == mt)
555−mt.__index=(a,b)
563+mt.__index=function (a,b)
556564return a or b
557565end
558566assert((true)[false] == true)
@@ -561,7 +569,7 @@ debug.setmetatable(false,nil)
561569assert(getmetatable(true) == nil)
562570debug.setmetatable(nil,mt)
563571assert(getmetatable(nil) == mt)
564−mt.__add=(a,b)
572+mt.__add=function (a,b)
565573return (a or 1) + (b or 2)
566574end
567575assert(10 + nil == 12)
@@ -577,15 +585,15 @@ setmetatable(a,a)
577585a.__index=a
578586;
579587a.__newindex=a
580−assert(not pcall((a,b)
588+assert(not pcall(function (a,b)
581589return a[b]
582590end,a,10))
583−assert(not pcall((a,b,c)
591+assert(not pcall(function (a,b,c)
584592a[b]=c
585593end,a,10,true))
586594T,K,V=nil
587595grandparent={}
588−grandparent.__newindex=(t,k,v)
596+grandparent.__newindex=function (t,k,v)
589597T=t
590598;
591599K=k
@@ -597,6 +605,6 @@ parent.__newindex=parent
597605setmetatable(parent,grandparent)
598606child=setmetatable({},parent)
599607child.foo=10
600−assert(T == parent and K == "foo" and V == 10)
601−print("OK")
608+assert(T == parent and K == "\102\111\111" and V == 10)
609+print("\79\75")
602610return 12
zod/luau/res/lua/cycled/files.lua+376−444
@@ -1,8 +1,8 @@
1−local debug = require("debug")
1+local debug = require("\100\101\98\117\103")
22local maxint = math.maxinteger
3−assert(type(os.getenv("PATH")) == "string")
3+assert(type(os.getenv("\80\65\84\72")) == "\115\116\114\105\110\103")
44assert(io.input(io.stdin) == io.stdin)
5−assert(not pcall(io.input,"non-existent-file"))
5+assert(not pcall(io.input,"\110\111\110\45\101\120\105\115\116\101\110\116\45\102\105\108\101"))
66assert(io.output(io.stdout) == io.stdout)
77local function testerr
88(msg,f, ...)
@@ -14,37 +14,37 @@ local function checkerr
1414assert(testerr(msg,f,...))
1515end
1616assert(not io.close(io.stdin) and not io.stdout:close() and not io.stderr:close())
17−checkerr("got no value",io.stdin.close)
18−assert(type(io.input()) == "userdata" and io.type(io.output()) == "file")
19−assert(type(io.stdin) == "userdata" and io.type(io.stderr) == "file")
17+checkerr("\103\111\116\32\110\111\32\118\97\108\117\101",io.stdin.close)
18+assert(type(io.input()) == "\117\115\101\114\100\97\116\97" and io.type(io.output()) == "\102\105\108\101")
19+assert(type(io.stdin) == "\117\115\101\114\100\97\116\97" and io.type(io.stderr) == "\102\105\108\101")
2020assert(not io.type(8))
2121local a = {}
2222;
2323setmetatable(a,{})
2424assert(not io.type(a))
25−assert(getmetatable(io.input()).__name == "FILE*")
26−local a,b,c = io.open("xuxu_nao_existe")
27−assert(not a and type(b) == "string" and type(c) == "number")
28−a,b,c=io.open("/a/b/c/d","w")
29−assert(not a and type(b) == "string" and type(c) == "number")
25+assert(getmetatable(io.input()).__name == "\70\73\76\69\42")
26+local a,b,c = io.open("\120\117\120\117\95\110\97\111\95\101\120\105\115\116\101")
27+assert(not a and type(b) == "\115\116\114\105\110\103" and type(c) == "\110\117\109\98\101\114")
28+a,b,c=io.open("\47\97\47\98\47\99\47\100","\119")
29+assert(not a and type(b) == "\115\116\114\105\110\103" and type(c) == "\110\117\109\98\101\114")
3030local file = os.tmpname()
31−local f,msg = io.open(file,"w")
31+local f,msg = io.open(file,"\119")
3232if not f then
33−(Message or print)("'os.tmpname' file cannot be open; skipping file tests")
33+(Message or print)("\39\111\115\46\116\109\112\110\97\109\101\39\32\102\105\108\101\32\99\97\110\110\111\116\32\98\101\32\111\112\101\110\59\32\115\107\105\112\112\105\110\103\32\102\105\108\101\32\116\101\115\116\115")
3434else
3535f:close()
36−print("testing i/o")
36+print("\116\101\115\116\105\110\103\32\105\47\111")
3737local otherfile = os.tmpname()
38−checkerr("invalid mode",io.open,file,"rw")
39−checkerr("invalid mode",io.open,file,"rb+")
40−checkerr("invalid mode",io.open,file,"r+bk")
41−checkerr("invalid mode",io.open,file,"")
42−checkerr("invalid mode",io.open,file,"+")
43−checkerr("invalid mode",io.open,file,"b")
44−assert(io.open(file,"r+b")):close()
45−assert(io.open(file,"r+")):close()
46−assert(io.open(file,"rb")):close()
47−assert(os.setlocale("C","all"))
38+checkerr("\105\110\118\97\108\105\100\32\109\111\100\101",io.open,file,"\114\119")
39+checkerr("\105\110\118\97\108\105\100\32\109\111\100\101",io.open,file,"\114\98\43")
40+checkerr("\105\110\118\97\108\105\100\32\109\111\100\101",io.open,file,"\114\43\98\107")
41+checkerr("\105\110\118\97\108\105\100\32\109\111\100\101",io.open,file,"")
42+checkerr("\105\110\118\97\108\105\100\32\109\111\100\101",io.open,file,"\43")
43+checkerr("\105\110\118\97\108\105\100\32\109\111\100\101",io.open,file,"\98")
44+assert(io.open(file,"\114\43\98")):close()
45+assert(io.open(file,"\114\43")):close()
46+assert(io.open(file,"\114\98")):close()
47+assert(os.setlocale("\67","\97\108\108"))
4848io.input(io.stdin)
4949;
5050io.output(io.stdout)
@@ -56,31 +56,28 @@ assert(not io.open(file))
5656io.output(file)
5757assert(io.output() ~= io.stdout)
5858if not _port then
59−local status,msg,code = io.stdin:seek("set",1e3)
60−assert(not status and type(msg) == "string" and type(code) == "number")
59+local status,msg,code = io.stdin:seek("\115\101\116",1000)
60+assert(not status and type(msg) == "\115\116\114\105\110\103" and type(code) == "\110\117\109\98\101\114")
6161end
6262assert(io.output():seek() == 0)
63−assert(io.write("alo alo"):seek() == string.len("alo alo"))
64−assert(io.output():seek("cur",- 3) == string.len("alo alo") - 3)
65−assert(io.write("joao"))
66−assert(io.output():seek("end") == string.len("alo joao"))
67−assert(io.output():seek("set") == 0)
68−assert(io.write(""alo"","{a}
69−","second line
70−","third line
71−"))
72−assert(io.write("Xfourth_line"))
63+assert(io.write("\97\108\111\32\97\108\111"):seek() == string.len("\97\108\111\32\97\108\111"))
64+assert(io.output():seek("\99\117\114",- 3) == string.len("\97\108\111\32\97\108\111") - 3)
65+assert(io.write("\106\111\97\111"))
66+assert(io.output():seek("\101\110\100") == string.len("\97\108\111\32\106\111\97\111"))
67+assert(io.output():seek("\115\101\116") == 0)
68+assert(io.write("\34\97\108\111\34","\123\97\125\10","\115\101\99\111\110\100\32\108\105\110\101\10","\116\104\105\114\100\32\108\105\110\101\32\10"))
69+assert(io.write("\88\102\111\117\114\116\104\95\108\105\110\101"))
7370io.output(io.stdout)
7471collectgarbage()
7572assert(io.input() == io.stdin and rawequal(io.output(),io.stdout))
76−print("+")
73+print("\43")
7774collectgarbage()
7875for i = 1, 120
7976do
8077for i = 1, 5
8178do
8279io.input(file)
83−assert(io.open(file,"r"))
80+assert(io.open(file,"\114"))
8481io.lines(file)
8582end
8683collectgarbage()
@@ -89,184 +86,164 @@ io.input():close()
8986io.close()
9087assert(os.rename(file,otherfile))
9188assert(not os.rename(file,otherfile))
92−io.output(io.open(otherfile,"ab"))
93−assert(io.write("
94−
95− ",3450,"
96−"))
89+io.output(io.open(otherfile,"\97\98"))
90+assert(io.write("\10\10\9\9\32\32",3450,"\10"))
9791;
9892io.close()
93+do
9994local F = nil
100−local f <close> = assert(io.open(file,"w"))
95+do
96+local f <close> = assert(io.open(file,"\119"))
10197F=f
102−assert(tostring(F) == "file (closed)")
98+end
99+assert(tostring(F) == "\102\105\108\101\32\40\99\108\111\115\101\100\41")
100+end
103101assert(os.remove(file))
104−local f <close> = assert(io.open(file,"w"))
105−f:write(maxint,"
106−")
107−f:write(string.format("0X%x
108−",maxint))
109−f:write("0xABCp-3","
110−")
111−f:write(0,"
112−")
113−f:write(- maxint,"
114−")
115−f:write(string.format("0x%X
116−",- maxint))
117−f:write("-0xABCp-3","
118−")
102+do
103+local f <close> = assert(io.open(file,"\119"))
104+f:write(maxint,"\10")
105+f:write(string.format("\48\88\37\120\10",maxint))
106+f:write("\48\120\65\66\67\112\45\51","\10")
107+f:write(0,"\10")
108+f:write(- maxint,"\10")
109+f:write(string.format("\48\120\37\88\10",- maxint))
110+f:write("\45\48\120\65\66\67\112\45\51","\10")
119111assert(f:close())
120−local f <close> = assert(io.open(file,"r"))
121−assert(f:read("n") == maxint)
122−assert(f:read("n") == maxint)
123−assert(f:read("n") == 343.5)
124−assert(f:read("n") == 0)
125−assert(f:read("*n") == - maxint)
126−assert(f:read("n") == - maxint)
127−assert(f:read("*n") == - 343.5)
112+local f <close> = assert(io.open(file,"\114"))
113+assert(f:read("\110") == maxint)
114+assert(f:read("\110") == maxint)
115+assert(f:read("\110") == 343.5)
116+assert(f:read("\110") == 0)
117+assert(f:read("\42\110") == - maxint)
118+assert(f:read("\110") == - maxint)
119+assert(f:read("\42\110") == - 343.5)
120+end
128121assert(os.remove(file))
129−local f <close> = assert(io.open(file,"w"))
130−f:write("a line
131−another line
132−1234
133−3.45
134−one
135−two
136−three
137−")
138−local l1,l2,l3,l4,n1,n2,c,dummy =
122+do
123+local f <close> = assert(io.open(file,"\119"))
124+f:write("\97\32\108\105\110\101\10\97\110\111\116\104\101\114\32\108\105\110\101\10\49\50\51\52\10\51\46\52\53\10\111\110\101\10\116\119\111\10\116\104\114\101\101\10")
125+local l1,l2,l3,l4,n1,n2,c,dummy
139126assert(f:close())
140−local f <close> = assert(io.open(file,"r"))
141−l1,l2,n1,n2,dummy=f:read("l","L","n","n")
142−assert(l1 == "a line" and l2 == "another line
143−" and n1 == 1234 and n2 == 3.45 and dummy == nil)
127+local f <close> = assert(io.open(file,"\114"))
128+l1,l2,n1,n2,dummy=f:read("\108","\76","\110","\110")
129+assert(l1 == "\97\32\108\105\110\101" and l2 == "\97\110\111\116\104\101\114\32\108\105\110\101\10" and n1 == 1234 and n2 == 3.45 and dummy == nil)
144130assert(f:close())
145−local f <close> = assert(io.open(file,"r"))
146−l1,l2,n1,n2,c,l3,l4,dummy=f:read(7,"l","n","n",1,"l","l")
147−assert(l1 == "a line
148−" and l2 == "another line" and c == "
149−" and n1 == 1234 and n2 == 3.45 and l3 == "one" and l4 == "two" and dummy == nil)
131+local f <close> = assert(io.open(file,"\114"))
132+l1,l2,n1,n2,c,l3,l4,dummy=f:read(7,"\108","\110","\110",1,"\108","\108")
133+assert(l1 == "\97\32\108\105\110\101\10" and l2 == "\97\110\111\116\104\101\114\32\108\105\110\101" and c == "\10" and n1 == 1234 and n2 == 3.45 and l3 == "\111\110\101" and l4 == "\116\119\111" and dummy == nil)
150134assert(f:close())
151−local f <close> = assert(io.open(file,"r"))
152−l1,n1,n2,dummy=f:read("l","n","n","l")
153−assert(l1 == "a line" and not n1)
135+local f <close> = assert(io.open(file,"\114"))
136+l1,n1,n2,dummy=f:read("\108","\110","\110","\108")
137+assert(l1 == "\97\32\108\105\110\101" and not n1)
138+end
154139assert(os.remove(file))
155−f=assert(io.open(file,"w"))
156−f:write("local x, z = coroutine.yield(10)
157−local y = coroutine.yield(20)
158−return x + y * z
159−")
140+f=assert(io.open(file,"\119"))
141+f:write("\108\111\99\97\108\32\120\44\32\122\32\61\32\99\111\114\111\117\116\105\110\101\46\121\105\101\108\100\40\49\48\41\10\108\111\99\97\108\32\121\32\61\32\99\111\114\111\117\116\105\110\101\46\121\105\101\108\100\40\50\48\41\10\114\101\116\117\114\110\32\120\32\43\32\121\32\42\32\122\10")
160142assert(f:close())
161143f=coroutine.wrap(dofile)
162144assert(f(file) == 10)
163145assert(f(100,101) == 20)
164146assert(f(200) == 100 + 200 * 101)
165147assert(os.remove(file))
166−f=assert(io.open(file,"w"))
167−f:write("-12.3- -0xffff+ .3|5.E-3X +234e+13E 0xDEADBEEFDEADBEEFx
168−0x1.13Ap+3e
169−")
170−f:write("1234")
148+f=assert(io.open(file,"\119"))
149+f:write("\45\49\50\46\51\45\9\45\48\120\102\102\102\102\43\32\32\46\51\124\53\46\69\45\51\88\32\32\43\50\51\52\101\43\49\51\69\32\48\120\68\69\65\68\66\69\69\70\68\69\65\68\66\69\69\70\120\10\48\120\49\46\49\51\65\112\43\51\101\10")
150+f:write("\49\50\51\52")
171151;
172−for i = 1, 1e3
152+for i = 1, 1000
173153do
174−f:write("0")
154+f:write("\48")
175155end
176156;
177−f:write("
178−")
179−f:write(".e+ 0.e; --; 0xX;
180−")
157+f:write("\10")
158+f:write("\46\101\43\9\48\46\101\59\9\45\45\59\32\32\48\120\88\59\10")
181159assert(f:close())
182−f=assert(io.open(file,"r"))
183−assert(f:read("n") == - 12.3)
160+f=assert(io.open(file,"\114"))
161+assert(f:read("\110") == - 12.3)
184162;
185−assert(f:read(1) == "-")
186−assert(f:read("n") == - 65535)
163+assert(f:read(1) == "\45")
164+assert(f:read("\110") == - 65535)
187165;
188−assert(f:read(2) == "+ ")
189−assert(f:read("n") == 0.3)
166+assert(f:read(2) == "\43\32")
167+assert(f:read("\110") == 0.3)
190168;
191−assert(f:read(1) == "|")
192−assert(f:read("n") == 5e-3)
169+assert(f:read(1) == "\124")
170+assert(f:read("\110") == 5e-3.0)
193171;
194−assert(f:read(1) == "X")
195−assert(f:read("n") == 2.34e15)
172+assert(f:read(1) == "\88")
173+assert(f:read("\110") == 2.34e15)
196174;
197−assert(f:read(1) == "E")
198−assert(f:read("n") == 16045690984833335023)
175+assert(f:read(1) == "\69")
176+assert(f:read("\110") == 16045690984833335023)
199177;
200−assert(f:read(2) == "x
201−")
202−assert(f:read("n") == 8.61328125)
178+assert(f:read(2) == "\120\10")
179+assert(f:read("\110") == 8.61328125)
203180;
204−assert(f:read(1) == "e")
205−assert(not f:read("n"))
206−local s = f:read("L")
207−assert(string.find(s,"^00*
208−$"))
209−assert(not f:read("n"))
181+assert(f:read(1) == "\101")
182+do
183+assert(not f:read("\110"))
184+local s = f:read("\76")
185+assert(string.find(s,"\94\48\48\42\10\36"))
186+end
187+assert(not f:read("\110"))
210188;
211−assert(f:read(2) == "e+")
212−assert(not f:read("n"))
189+assert(f:read(2) == "\101\43")
190+assert(not f:read("\110"))
213191;
214−assert(f:read(1) == ";")
215−assert(not f:read("n"))
192+assert(f:read(1) == "\59")
193+assert(not f:read("\110"))
216194;
217−assert(f:read(2) == "-;")
218−assert(not f:read("n"))
195+assert(f:read(2) == "\45\59")
196+assert(not f:read("\110"))
219197;
220−assert(f:read(1) == "X")
221−assert(not f:read("n"))
198+assert(f:read(1) == "\88")
199+assert(not f:read("\110"))
222200;
223−assert(f:read(1) == ";")
224−assert(not f:read("n"))
201+assert(f:read(1) == "\59")
202+assert(not f:read("\110"))
225203;
226204assert(not f:read(0))
227205assert(f:close())
228206assert(os.remove(file))
229−assert(not pcall(io.lines,"non-existent-file"))
207+assert(not pcall(io.lines,"\110\111\110\45\101\120\105\115\116\101\110\116\45\102\105\108\101"))
230208assert(os.rename(otherfile,file))
231209io.output(otherfile)
232210local n = 0
233211local f = io.lines(file)
234212while f() do
235213n=n + 1
214+end
236215;
237216assert(n == 6)
238−checkerr("file is already closed",f)
239−checkerr("file is already closed",f)
217+checkerr("\102\105\108\101\32\105\115\32\97\108\114\101\97\100\121\32\99\108\111\115\101\100",f)
218+checkerr("\102\105\108\101\32\105\115\32\97\108\114\101\97\100\121\32\99\108\111\115\101\100",f)
240219n=0
241220for l in io.lines(file)
242221do
243−io.write(l,"
244−")
222+io.write(l,"\10")
245223;
246224n=n + 1
247225end
248226io.close()
249227assert(n == 6)
250228local f = assert(io.open(otherfile))
251−assert(io.type(f) == "file")
229+assert(io.type(f) == "\102\105\108\101")
252230io.output(file)
253231assert(not io.output():read())
254232n=0
255233for l in f:lines()
256234do
257−io.write(l,"
258−")
235+io.write(l,"\10")
259236;
260237n=n + 1
261238end
262−assert(tostring(f):sub(1,5) == "file ")
239+assert(tostring(f):sub(1,5) == "\102\105\108\101\32")
263240assert(f:close())
264241;
265242io.close()
266243assert(n == 6)
267−checkerr("closed file",io.close,f)
268−assert(tostring(f) == "file (closed)")
269−assert(io.type(f) == "closed file")
244+checkerr("\99\108\111\115\101\100\32\102\105\108\101",io.close,f)
245+assert(tostring(f) == "\102\105\108\101\32\40\99\108\111\115\101\100\41")
246+assert(io.type(f) == "\99\108\111\115\101\100\32\102\105\108\101")
270247io.input(file)
271248f=io.open(otherfile):lines()
272249n=0
@@ -281,9 +258,9 @@ f=nil
281258collectgarbage()
282259assert(n == 6)
283260assert(os.remove(otherfile))
261+do
284262io.output(otherfile)
285−io.write(string.rep("a",300),"
286−")
263+io.write(string.rep("\97",300),"\10")
287264io.close()
288265local t = {}
289266;
@@ -292,48 +269,49 @@ do
292269t[i]=1
293270end
294271t={io.lines(otherfile,table.unpack(t))()}
295−assert(# t == 250 and t[1] == "a" and t[# t] == "a")
272+assert(# t == 250 and t[1] == "\97" and t[# t] == "\97")
296273t[# t + 1]=1
297−checkerr("too many arguments",io.lines,otherfile,table.unpack(t))
274+checkerr("\116\111\111\32\109\97\110\121\32\97\114\103\117\109\101\110\116\115",io.lines,otherfile,table.unpack(t))
298275collectgarbage()
299276assert(os.remove(otherfile))
277+end
300278io.input(file)
301−local a,b,c = io.input():write("xuxu")
302−assert(not a and type(b) == "string" and type(c) == "number")
303−checkerr("invalid format",io.read,"x")
279+do
280+local a,b,c = io.input():write("\120\117\120\117")
281+assert(not a and type(b) == "\115\116\114\105\110\103" and type(c) == "\110\117\109\98\101\114")
282+end
283+checkerr("\105\110\118\97\108\105\100\32\102\111\114\109\97\116",io.read,"\120")
304284assert(io.read(0) == "")
305−assert(io.read(5,"l") == ""alo"")
285+assert(io.read(5,"\108") == "\34\97\108\111\34")
306286assert(io.read(0) == "")
307−assert(io.read() == "second line")
287+assert(io.read() == "\115\101\99\111\110\100\32\108\105\110\101")
308288local x = io.input():seek()
309−assert(io.read() == "third line ")
310−assert(io.input():seek("set",x))
311−assert(io.read("L") == "third line
312−")
313−assert(io.read(1) == "X")
314−assert(io.read(string.len("fourth_line")) == "fourth_line")
315−assert(io.input():seek("cur",- string.len("fourth_line")))
316−assert(io.read() == "fourth_line")
289+assert(io.read() == "\116\104\105\114\100\32\108\105\110\101\32")
290+assert(io.input():seek("\115\101\116",x))
291+assert(io.read("\76") == "\116\104\105\114\100\32\108\105\110\101\32\10")
292+assert(io.read(1) == "\88")
293+assert(io.read(string.len("\102\111\117\114\116\104\95\108\105\110\101")) == "\102\111\117\114\116\104\95\108\105\110\101")
294+assert(io.input():seek("\99\117\114",- string.len("\102\111\117\114\116\104\95\108\105\110\101")))
295+assert(io.read() == "\102\111\117\114\116\104\95\108\105\110\101")
317296assert(io.read() == "")
318−assert(io.read("n") == 3450)
319−assert(io.read(1) == "
320−")
297+assert(io.read("\110") == 3450)
298+assert(io.read(1) == "\10")
321299assert(not io.read(0))
322300assert(not io.read(1))
323−assert(not io.read(3e4))
301+assert(not io.read(30000))
324302assert(({io.read(1)})[2] == undef)
325303assert(not io.read())
326304assert(({io.read()})[2] == undef)
327−assert(not io.read("n"))
328−assert(({io.read("n")})[2] == undef)
329−assert(io.read("a") == "")
330−assert(io.read("a") == "")
305+assert(not io.read("\110"))
306+assert(({io.read("\110")})[2] == undef)
307+assert(io.read("\97") == "")
308+assert(io.read("\97") == "")
331309collectgarbage()
332−print("+")
310+print("\43")
333311io.close(io.input())
334−checkerr(" input file is closed",io.read)
312+checkerr("\32\105\110\112\117\116\32\102\105\108\101\32\105\115\32\99\108\111\115\101\100",io.read)
335313assert(os.remove(file))
336−local t = "0123456789"
314+local t = "\48\49\50\51\52\53\54\55\56\57"
337315for i = 1, 10
338316do
339317t=t .. t
@@ -341,118 +319,100 @@ t=t .. t
341319end
342320assert(string.len(t) == 10 * 2 ^ 10)
343321io.output(file)
344−io.write("alo"):write("
345−")
322+io.write("\97\108\111"):write("\10")
346323io.close()
347−checkerr(" output file is closed",io.write)
348−local f = io.open(file,"a+b")
324+checkerr("\32\111\117\116\112\117\116\32\102\105\108\101\32\105\115\32\99\108\111\115\101\100",io.write)
325+local f = io.open(file,"\97\43\98")
349326io.output(f)
350327collectgarbage()
351−assert(io.write(" " .. t .. " "))
352−assert(io.write(";","end of file
353−"))
328+assert(io.write("\32" .. t .. "\32"))
329+assert(io.write("\59","\101\110\100\32\111\102\32\102\105\108\101\10"))
354330f:flush()
355331;
356332io.flush()
357333f:close()
358−print("+")
334+print("\43")
359335io.input(file)
360−assert(io.read() == "alo")
361−assert(io.read(1) == " ")
336+assert(io.read() == "\97\108\111")
337+assert(io.read(1) == "\32")
362338assert(io.read(string.len(t)) == t)
363−assert(io.read(1) == " ")
339+assert(io.read(1) == "\32")
364340assert(io.read(0))
365−assert(io.read("a") == ";end of file
366−")
341+assert(io.read("\97") == "\59\101\110\100\32\111\102\32\102\105\108\101\10")
367342assert(not io.read(0))
368343assert(io.close(io.input()))
344+do
369345local function ismsg
370346(m)
371−return (type(m) == "string" and not tonumber(m))
347+return (type(m) == "\115\116\114\105\110\103" and not tonumber(m))
372348end
373−local f = io.open(file,"w")
349+local f = io.open(file,"\119")
374350local r,m,c = f:read()
375−assert(not r and ismsg(m) and type(c) == "number")
351+assert(not r and ismsg(m) and type(c) == "\110\117\109\98\101\114")
376352assert(f:close())
377−f=io.open(file,"r")
378−r,m,c=f:write("whatever")
379−assert(not r and ismsg(m) and type(c) == "number")
353+f=io.open(file,"\114")
354+r,m,c=f:write("\119\104\97\116\101\118\101\114")
355+assert(not r and ismsg(m) and type(c) == "\110\117\109\98\101\114")
380356assert(f:close())
381−f=io.open(file,"w")
357+f=io.open(file,"\119")
382358r,m=pcall(f:lines())
383359assert(r == false and ismsg(m))
384360assert(f:close())
361+end
385362assert(os.remove(file))
386363io.output(file)
387364;
388−io.write("
389−
390−line
391−other"):close()
365+io.write("\10\10\108\105\110\101\10\111\116\104\101\114"):close()
392366io.input(file)
393−assert(io.read("L") == "
394−")
395−assert(io.read("L") == "
396−")
397−assert(io.read("L") == "line
398−")
399−assert(io.read("L") == "other")
400−assert(not io.read("L"))
367+assert(io.read("\76") == "\10")
368+assert(io.read("\76") == "\10")
369+assert(io.read("\76") == "\108\105\110\101\10")
370+assert(io.read("\76") == "\111\116\104\101\114")
371+assert(not io.read("\76"))
401372io.input():close()
402373local f = assert(io.open(file))
403374local s = ""
404−for l in f:lines("L")
375+for l in f:lines("\76")
405376do
406377s=s .. l
407378end
408−assert(s == "
409−
410−line
411−other")
379+assert(s == "\10\10\108\105\110\101\10\111\116\104\101\114")
412380f:close()
413381io.input(file)
414382s=""
415−for l in io.lines(nil,"L")
383+for l in io.lines(nil,"\76")
416384do
417385s=s .. l
418386end
419−assert(s == "
420−
421−line
422−other")
387+assert(s == "\10\10\108\105\110\101\10\111\116\104\101\114")
423388io.input():close()
424389s=""
425−for l in io.lines(file,"L")
390+for l in io.lines(file,"\76")
426391do
427392s=s .. l
428393end
429−assert(s == "
430−
431−line
432−other")
394+assert(s == "\10\10\108\105\110\101\10\111\116\104\101\114")
433395s=""
434−for l in io.lines(file,"l")
396+for l in io.lines(file,"\108")
435397do
436398s=s .. l
437399end
438−assert(s == "lineother")
400+assert(s == "\108\105\110\101\111\116\104\101\114")
439401io.output(file)
440402;
441−io.write("a = 10 + 34
442−a = 2*a
443−a = -a
444−"):close()
403+io.write("\97\32\61\32\49\48\32\43\32\51\52\10\97\32\61\32\50\42\97\10\97\32\61\32\45\97\10"):close()
445404local t = {}
446−assert(load(io.lines(file,"L"),nil,nil,t))()
405+assert(load(io.lines(file,"\76"),nil,nil,t))()
447406assert(t.a == - ((10 + 34) * 2))
407+do
448408local function gettoclose
449409(lv)
450410lv=lv + 1
451411local stvar = 0
452−for i = 1, 1e3
412+for i = 1, 1000
453413do
454414local n,v = debug.getlocal(lv,i)
455−if n == "(for state)" then
415+if n == "\40\102\111\114\32\115\116\97\116\101\41" then
456416stvar=stvar + 1
457417if stvar == 4 then
458418return v
@@ -460,62 +420,54 @@ end
460420end
461421end
462422end
463−local f =
423+local f
464424for l in io.lines(file)
465425do
466426f=gettoclose(1)
467−assert(io.type(f) == "file")
427+assert(io.type(f) == "\102\105\108\101")
468428break
469429end
470−assert(io.type(f) == "closed file")
430+assert(io.type(f) == "\99\108\111\115\101\100\32\102\105\108\101")
471431f=nil
472432local function foo
473433(name)
474434for l in io.lines(name)
475435do
476436f=gettoclose(1)
477−assert(io.type(f) == "file")
437+assert(io.type(f) == "\102\105\108\101")
478438error(f)
479439end
480440end
481441local st,msg = pcall(foo,file)
482−assert(st == false and io.type(msg) == "closed file")
442+assert(st == false and io.type(msg) == "\99\108\111\115\101\100\32\102\105\108\101")
443+end
483444io.output(file)
484445;
485−io.write("0123456789
486−"):close()
446+io.write("\48\49\50\51\52\53\54\55\56\57\10"):close()
487447for a,b in io.lines(file,1,1)
488448do
489−if a == "
490−" then
449+if a == "\10" then
491450assert(not b)
492451else
493452assert(tonumber(a) == tonumber(b) - 1)
494453end
495454end
496−for a,b,c in io.lines(file,1,2,"a")
455+for a,b,c in io.lines(file,1,2,"\97")
497456do
498−assert(a == "0" and b == "12" and c == "3456789
499−")
457+assert(a == "\48" and b == "\49\50" and c == "\51\52\53\54\55\56\57\10")
500458end
501−for a,b,c in io.lines(file,"a",0,1)
459+for a,b,c in io.lines(file,"\97",0,1)
502460do
503461if a == "" then
504462break
505463end
506−assert(a == "0123456789
507−" and not b and not c)
464+assert(a == "\48\49\50\51\52\53\54\55\56\57\10" and not b and not c)
508465end
509466collectgarbage()
510467io.output(file)
511468;
512−io.write("00
513−10
514−20
515−30
516−40
517−"):close()
518−for a,b in io.lines(file,"n","n")
469+io.write("\48\48\10\49\48\10\50\48\10\51\48\10\52\48\10"):close()
470+for a,b in io.lines(file,"\110","\110")
519471do
520472if a == 40 then
521473assert(not b)
@@ -525,38 +477,26 @@ end
525477end
526478io.output(file)
527479;
528−io.write("local y
529−= X
530−X =
531−X *
532−2 +
533−X;
534−X =
535−X
536−- y;
537−"):close()
480+io.write("\108\111\99\97\108\32\121\10\61\32\88\10\88\32\61\10\88\32\42\10\50\32\43\10\88\59\10\88\32\61\10\88\10\45\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\121\59\10"):close()
538481_G.X=1
539482assert(not load((io.lines(file))))
540483collectgarbage()
541−load((io.lines(file,"L")))()
484+load((io.lines(file,"\76")))()
542485assert(_G.X == 2)
543486load((io.lines(file,1)))()
544487assert(_G.X == 4)
545488load((io.lines(file,3)))()
546489assert(_G.X == 8)
547490_G.X=nil
548−print("+")
549−local x1 = "string
550−
551−\com ""''coisas [[estranhas]] ]]'"
491+print("\43")
492+local x1 = "\115\116\114\105\110\103\10\10\92\99\111\109\32\34\34\39\39\99\111\105\115\97\115\32\91\91\101\115\116\114\97\110\104\97\115\93\93\32\93\93\39"
552493io.output(file)
553−assert(io.write(string.format("X2 = %q
554−-- comment without ending EOS",x1)))
494+assert(io.write(string.format("\88\50\32\61\32\37\113\10\45\45\32\99\111\109\109\101\110\116\32\119\105\116\104\111\117\116\32\101\110\100\105\110\103\32\69\79\83",x1)))
555495io.close()
556496assert(loadfile(file))()
557497assert(x1 == _G.X2)
558498_G.X2=nil
559−print("+")
499+print("\43")
560500assert(os.remove(file))
561501assert(not os.remove(file))
562502assert(not os.remove(otherfile))
@@ -572,152 +512,142 @@ assert(os.remove(file))
572512assert(res == expres)
573513end
574514testloadfile(nil,nil)
575−testloadfile("# a non-ending comment",nil)
576−testloadfile("# some comment
577−return 234",234)
578−testloadfile("return 239",239)
579−testloadfile("",nil)
580−testloadfile("# a comment
581−return require'debug'.getinfo(1).currentline",2)
582−io.output(io.open(file,"wb"))
583−assert(io.write(string.dump(()
584−return 10,"alo�","hi"
515+testloadfile("\35\32\97\32\110\111\110\45\101\110\100\105\110\103\32\99\111\109\109\101\110\116",nil)
516+testloadfile("\239\187\191\35\32\115\111\109\101\32\99\111\109\109\101\110\116\10\114\101\116\117\114\110\32\50\51\52",234)
517+testloadfile("\239\187\191\114\101\116\117\114\110\32\50\51\57",239)
518+testloadfile("\239\187\191",nil)
519+testloadfile("\35\32\97\32\99\111\109\109\101\110\116\10\114\101\116\117\114\110\32\114\101\113\117\105\114\101\39\100\101\98\117\103\39\46\103\101\116\105\110\102\111\40\49\41\46\99\117\114\114\101\110\116\108\105\110\101",2)
520+io.output(io.open(file,"\119\98"))
521+assert(io.write(string.dump(function ()
522+return 10,"\97\108\111\255","\104\105"
585523end)))
586524io.close()
587525a,b,c=assert(loadfile(file))()
588−assert(a == 10 and b == "alo�" and c == "hi")
526+assert(a == 10 and b == "\97\108\111\255" and c == "\104\105")
589527assert(os.remove(file))
590−io.output(io.open(file,"wb"))
591−assert(io.write(string.dump(()
528+do
529+io.output(io.open(file,"\119\98"))
530+assert(io.write(string.dump(function ()
592531return 1
593532end)))
594533io.close()
595−f=assert(loadfile(file,"b",{}))
596−assert(type(f) == "function" and f() == 1)
534+f=assert(loadfile(file,"\98",{}))
535+assert(type(f) == "\102\117\110\99\116\105\111\110" and f() == 1)
597536assert(os.remove(file))
598−io.output(io.open(file,"wb"))
599−assert(io.write("#this is a comment for a binary file
600−",string.dump(()
537+end
538+io.output(io.open(file,"\119\98"))
539+assert(io.write("\35\116\104\105\115\32\105\115\32\97\32\99\111\109\109\101\110\116\32\102\111\114\32\97\32\98\105\110\97\114\121\32\102\105\108\101\10",string.dump(function ()
601540return 20,""
602541end)))
603542io.close()
604543a,b,c=assert(loadfile(file))()
605544assert(a == 20 and b == "" and c == nil)
606545assert(os.remove(file))
607−local f = io.open(file,"w")
608−f:write(" if (...) then a = 15; return b, c, d
609− else return _ENV
610− end
611− ")
546+do
547+local f = io.open(file,"\119")
548+f:write("\32\32\32\32\105\102\32\40\46\46\46\41\32\116\104\101\110\32\97\32\61\32\49\53\59\32\114\101\116\117\114\110\32\98\44\32\99\44\32\100\10\32\32\32\32\101\108\115\101\32\114\101\116\117\114\110\32\95\69\78\86\10\32\32\32\32\101\110\100\10\32\32")
612549f:close()
613−local t = {["b"] = 12,["c"] = "xuxu",["d"] = print}
614−local f = assert(loadfile(file,"t",t))
550+local t = {["\98"] = 12,["\99"] = "\120\117\120\117",["\100"] = print}
551+local f = assert(loadfile(file,"\116",t))
615552local b,c,d = f(1)
616553assert(t.a == 15 and b == 12 and c == t.c and d == print)
617554assert(f() == t)
618−f=assert(loadfile(file,"t",nil))
555+f=assert(loadfile(file,"\116",nil))
619556assert(f() == nil)
620557f=assert(loadfile(file))
621558assert(f() == _G)
622559assert(os.remove(file))
623−io.open(file,"w"):write("return 10"):close()
624−local s,m = loadfile(file,"b")
625−assert(not s and string.find(m,"a text chunk"))
626−io.open(file,"w"):write(" return 10"):close()
627−local s,m = loadfile(file,"t")
628−assert(not s and string.find(m,"a binary chunk"))
560+end
561+do
562+io.open(file,"\119"):write("\114\101\116\117\114\110\32\49\48"):close()
563+local s,m = loadfile(file,"\98")
564+assert(not s and string.find(m,"\97\32\116\101\120\116\32\99\104\117\110\107"))
565+io.open(file,"\119"):write("\27\32\114\101\116\117\114\110\32\49\48"):close()
566+local s,m = loadfile(file,"\116")
567+assert(not s and string.find(m,"\97\32\98\105\110\97\114\121\32\99\104\117\110\107"))
629568assert(os.remove(file))
569+end
630570io.output(file)
631−assert(io.write("qualquer coisa
632−"))
633−assert(io.write("mais qualquer coisa"))
571+assert(io.write("\113\117\97\108\113\117\101\114\32\99\111\105\115\97\10"))
572+assert(io.write("\109\97\105\115\32\113\117\97\108\113\117\101\114\32\99\111\105\115\97"))
634573io.close()
635−assert(io.output(assert(io.open(otherfile,"wb"))):write("outra coisa�"):close())
636−local filehandle = assert(io.open(file,"r+"))
637−local otherfilehandle = assert(io.open(otherfile,"rb"))
574+assert(io.output(assert(io.open(otherfile,"\119\98"))):write("\111\117\116\114\97\32\99\111\105\115\97\1\3\255"):close())
575+local filehandle = assert(io.open(file,"\114\43"))
576+local otherfilehandle = assert(io.open(otherfile,"\114\98"))
638577assert(filehandle ~= otherfilehandle)
639−assert(type(filehandle) == "userdata")
640−assert(filehandle:read("l") == "qualquer coisa")
578+assert(type(filehandle) == "\117\115\101\114\100\97\116\97")
579+assert(filehandle:read("\108") == "\113\117\97\108\113\117\101\114\32\99\111\105\115\97")
641580io.input(otherfilehandle)
642−assert(io.read(string.len("outra coisa")) == "outra coisa")
643−assert(filehandle:read("l") == "mais qualquer coisa")
581+assert(io.read(string.len("\111\117\116\114\97\32\99\111\105\115\97")) == "\111\117\116\114\97\32\99\111\105\115\97")
582+assert(filehandle:read("\108") == "\109\97\105\115\32\113\117\97\108\113\117\101\114\32\99\111\105\115\97")
644583filehandle:close()
645584;
646−assert(type(filehandle) == "userdata")
585+assert(type(filehandle) == "\117\115\101\114\100\97\116\97")
647586io.input(otherfilehandle)
648−assert(io.read(4) == "")
587+assert(io.read(4) == "\1\3")
649588assert(io.read(3) == "")
650589assert(io.read(0) == "")
651−assert(io.read(1) == "�")
652−assert(io.read("a") == "")
590+assert(io.read(1) == "\255")
591+assert(io.read("\97") == "")
653592assert(not io.read(0))
654593assert(otherfilehandle == io.input())
655594otherfilehandle:close()
656595assert(os.remove(file))
657596assert(os.remove(otherfile))
658597collectgarbage()
659−io.output(file):write(" 123.4 -56e-2 not a number
660−second line
661−third line
662−
663−and the rest of the file
664−"):close()
598+io.output(file):write("\32\49\50\51\46\52\9\45\53\54\101\45\50\32\32\110\111\116\32\97\32\110\117\109\98\101\114\10\115\101\99\111\110\100\32\108\105\110\101\10\116\104\105\114\100\32\108\105\110\101\10\10\97\110\100\32\116\104\101\32\114\101\115\116\32\111\102\32\116\104\101\32\102\105\108\101\10"):close()
665599io.input(file)
666−local _,a,b,c,d,e,h,__ = io.read(1,"n","n","l","l","l","a",10)
600+local _,a,b,c,d,e,h,__ = io.read(1,"\110","\110","\108","\108","\108","\97",10)
667601assert(io.close(io.input()))
668−assert(_ == " " and not __)
669−assert(type(a) == "number" and a == 123.4 and b == - 0.56)
670−assert(d == "second line" and e == "third line")
671−assert(h == "
672−and the rest of the file
673−")
602+assert(_ == "\32" and not __)
603+assert(type(a) == "\110\117\109\98\101\114" and a == 123.4 and b == - 0.56)
604+assert(d == "\115\101\99\111\110\100\32\108\105\110\101" and e == "\116\104\105\114\100\32\108\105\110\101")
605+assert(h == "\10\97\110\100\32\116\104\101\32\114\101\115\116\32\111\102\32\116\104\101\32\102\105\108\101\10")
674606assert(os.remove(file))
675607collectgarbage()
676−local f = assert(io.open(file,"w"))
677−local fr = assert(io.open(file,"r"))
678−assert(f:setvbuf("full",2e3))
679−f:write("x")
680−assert(fr:read("all") == "")
608+do
609+local f = assert(io.open(file,"\119"))
610+local fr = assert(io.open(file,"\114"))
611+assert(f:setvbuf("\102\117\108\108",2000))
612+f:write("\120")
613+assert(fr:read("\97\108\108") == "")
681614f:close()
682−fr:seek("set")
683−assert(fr:read("all") == "x")
684−f=assert(io.open(file),"w")
685−assert(f:setvbuf("no"))
686−f:write("x")
687−fr:seek("set")
688−assert(fr:read("all") == "x")
615+fr:seek("\115\101\116")
616+assert(fr:read("\97\108\108") == "\120")
617+f=assert(io.open(file),"\119")
618+assert(f:setvbuf("\110\111"))
619+f:write("\120")
620+fr:seek("\115\101\116")
621+assert(fr:read("\97\108\108") == "\120")
689622f:close()
690−f=assert(io.open(file,"a"))
691−assert(f:setvbuf("line"))
692−f:write("x")
693−fr:seek("set",1)
694−assert(fr:read("all") == "")
695−f:write("a
696−"):seek("set",1)
697−assert(fr:read("all") == "xa
698−")
623+f=assert(io.open(file,"\97"))
624+assert(f:setvbuf("\108\105\110\101"))
625+f:write("\120")
626+fr:seek("\115\101\116",1)
627+assert(fr:read("\97\108\108") == "")
628+f:write("\97\10"):seek("\115\101\116",1)
629+assert(fr:read("\97\108\108") == "\120\97\10")
699630f:close()
700631;
701632fr:close()
702633assert(os.remove(file))
634+end
703635if not _soft then
704−print("testing large files (> BUFSIZ)")
636+print("\116\101\115\116\105\110\103\32\108\97\114\103\101\32\102\105\108\101\115\32\40\62\32\66\85\70\83\73\90\41")
705637io.output(file)
706638for i = 1, 5001
707639do
708−io.write("0123456789123")
640+io.write("\48\49\50\51\52\53\54\55\56\57\49\50\51")
709641end
710−io.write("
711−12346"):close()
642+io.write("\10\49\50\51\52\54"):close()
712643io.input(file)
713−local x = io.read("a")
714−io.input():seek("set",0)
644+local x = io.read("\97")
645+io.input():seek("\115\101\116",0)
715646local y = io.read(30001) .. io.read(1005) .. io.read(0) .. io.read(1) .. io.read(100003)
716647assert(x == y and string.len(x) == 5001 * 13 + 6)
717−io.input():seek("set",0)
648+io.input():seek("\115\101\116",0)
718649y=io.read()
719−assert(x == y .. "
720−" .. io.read())
650+assert(x == y .. "\10" .. io.read())
721651assert(not io.read())
722652io.close(io.input())
723653assert(os.remove(file))
@@ -726,34 +656,38 @@ x=nil
726656y=nil
727657end
728658if not _port then
729−local progname =
659+local progname
660+do
730661local arg = arg or ARG
731662local i = 0
732663while arg[i] do
733664i=i - 1
734−progname=""" .. arg[i + 1] .. """
735−print("testing popen/pclose and execute")
736−checkerr("invalid mode",io.popen,"cat","")
737−checkerr("invalid mode",io.popen,"cat","r+")
738−checkerr("invalid mode",io.popen,"cat","rw")
665+end
666+progname="\34" .. arg[i + 1] .. "\34"
667+end
668+print("\116\101\115\116\105\110\103\32\112\111\112\101\110\47\112\99\108\111\115\101\32\97\110\100\32\101\120\101\99\117\116\101")
669+checkerr("\105\110\118\97\108\105\100\32\109\111\100\101",io.popen,"\99\97\116","")
670+checkerr("\105\110\118\97\108\105\100\32\109\111\100\101",io.popen,"\99\97\116","\114\43")
671+checkerr("\105\110\118\97\108\105\100\32\109\111\100\101",io.popen,"\99\97\116","\114\119")
672+do
739673local file = os.tmpname()
740−local f = assert(io.popen("cat - > " .. file,"w"))
741−f:write("a line")
674+local f = assert(io.popen("\99\97\116\32\45\32\62\32" .. file,"\119"))
675+f:write("\97\32\108\105\110\101")
742676assert(f:close())
743−local f = assert(io.popen("cat - < " .. file,"r"))
744−assert(f:read("a") == "a line")
677+local f = assert(io.popen("\99\97\116\32\45\32\60\32" .. file,"\114"))
678+assert(f:read("\97") == "\97\32\108\105\110\101")
745679assert(f:close())
746680assert(os.remove(file))
747−local tests = {{"ls > /dev/null","ok"},{"not-to-be-found-command","exit"},{"exit 3","exit",3},{"exit 129","exit",129},{"kill -s HUP $$","signal",1},{"kill -s KILL $$","signal",9},{"sh -c 'kill -s HUP $$'","exit"},{progname .. " -e " "","ok"},{progname .. " -e "os.exit(0, true)"","ok"},{progname .. " -e "os.exit(20, true)"","exit",20}}
748−print("
749−(some error messages are expected now)")
681+end
682+local tests = {{"\108\115\32\62\32\47\100\101\118\47\110\117\108\108","\111\107"},{"\110\111\116\45\116\111\45\98\101\45\102\111\117\110\100\45\99\111\109\109\97\110\100","\101\120\105\116"},{"\101\120\105\116\32\51","\101\120\105\116",3},{"\101\120\105\116\32\49\50\57","\101\120\105\116",129},{"\107\105\108\108\32\45\115\32\72\85\80\32\36\36","\115\105\103\110\97\108",1},{"\107\105\108\108\32\45\115\32\75\73\76\76\32\36\36","\115\105\103\110\97\108",9},{"\115\104\32\45\99\32\39\107\105\108\108\32\45\115\32\72\85\80\32\36\36\39","\101\120\105\116"},{progname .. "\32\45\101\32\34\32\34","\111\107"},{progname .. "\32\45\101\32\34\111\115\46\101\120\105\116\40\48\44\32\116\114\117\101\41\34","\111\107"},{progname .. "\32\45\101\32\34\111\115\46\101\120\105\116\40\50\48\44\32\116\114\117\101\41\34","\101\120\105\116",20}}
683+print("\10\40\115\111\109\101\32\101\114\114\111\114\32\109\101\115\115\97\103\101\115\32\97\114\101\32\101\120\112\101\99\116\101\100\32\110\111\119\41")
750684for _,v in ipairs(tests)
751685do
752686local x,y,z = io.popen(v[1]):close()
753687local x1,y1,z1 = os.execute(v[1])
754688assert(x == x1 and y == y1 and z == z1)
755−if v[2] == "ok" then
756−assert(x and y == "exit" and z == 0)
689+if v[2] == "\111\107" then
690+assert(x and y == "\101\120\105\116" and z == 0)
757691else
758692assert(not x and y == v[2])
759693assert((v[3] == nil and z > 0) or v[3] == z)
@@ -761,126 +695,124 @@ end
761695end
762696end
763697f=io.tmpfile()
764−assert(io.type(f) == "file")
765−f:write("alo")
766−f:seek("set")
767−assert(f:read("a") == "alo")
698+assert(io.type(f) == "\102\105\108\101")
699+f:write("\97\108\111")
700+f:seek("\115\101\116")
701+assert(f:read("\97") == "\97\108\111")
768702end
769−print("+")
770−print("testing date/time")
703+print("\43")
704+print("\116\101\115\116\105\110\103\32\100\97\116\101\47\116\105\109\101")
771705assert(os.date("") == "")
772−assert(os.date("!") == "")
706+assert(os.date("\33") == "")
773707assert(os.date("") == "")
774−assert(os.date("!") == "")
775−local x = string.rep("a",1e4)
708+assert(os.date("\33") == "")
709+local x = string.rep("\97",10000)
776710assert(os.date(x) == x)
777711local t = os.time()
778−D=os.date("*t",t)
779−assert(os.date(string.rep("%d",1e3),t) == string.rep(os.date("%d",t),1e3))
780−assert(os.date(string.rep("%",200)) == string.rep("%",100))
712+D=os.date("\42\116",t)
713+assert(os.date(string.rep("\37\100",1000),t) == string.rep(os.date("\37\100",t),1000))
714+assert(os.date(string.rep("\37",200)) == string.rep("\37",100))
781715local function checkDateTable
782716(t)
783−_G.D=os.date("*t",t)
717+_G.D=os.date("\42\116",t)
784718assert(os.time(D) == t)
785−load(os.date("assert(D.year==%Y and D.month==%m and D.day==%d and
786− D.hour==%H and D.min==%M and D.sec==%S and
787− D.wday==%w+1 and D.yday==%j)",t))()
719+load(os.date("\97\115\115\101\114\116\40\68\46\121\101\97\114\61\61\37\89\32\97\110\100\32\68\46\109\111\110\116\104\61\61\37\109\32\97\110\100\32\68\46\100\97\121\61\61\37\100\32\97\110\100\10\32\32\32\32\68\46\104\111\117\114\61\61\37\72\32\97\110\100\32\68\46\109\105\110\61\61\37\77\32\97\110\100\32\68\46\115\101\99\61\61\37\83\32\97\110\100\10\32\32\32\32\68\46\119\100\97\121\61\61\37\119\43\49\32\97\110\100\32\68\46\121\100\97\121\61\61\37\106\41",t))()
788720_G.D=nil
789721end
790722checkDateTable(os.time())
791723if not _port then
792724checkDateTable(0)
793725checkDateTable(1)
794−checkDateTable(1e3)
726+checkDateTable(1000)
795727checkDateTable(2147483647)
796728checkDateTable(2147483648)
797729end
798−checkerr("invalid conversion specifier",os.date,"%")
799−checkerr("invalid conversion specifier",os.date,"%9")
800−checkerr("invalid conversion specifier",os.date,"%")
801−checkerr("invalid conversion specifier",os.date,"%O")
802−checkerr("invalid conversion specifier",os.date,"%E")
803−checkerr("invalid conversion specifier",os.date,"%Ea")
804−checkerr("not an integer",os.time,{["year"] = 1e3,["month"] = 1,["day"] = 1,["hour"] = "x"})
805−checkerr("not an integer",os.time,{["year"] = 1e3,["month"] = 1,["day"] = 1,["hour"] = 1.5})
806−checkerr("missing",os.time,{["hour"] = 12})
807−if string.packsize("i") == 4 then
808−checkerr("field 'year' is out-of-bound",os.time,{["year"] = - (1 << 31) + 1899,["month"] = 1,["day"] = 1})
809−checkerr("field 'year' is out-of-bound",os.time,{["year"] = - (1 << 31),["month"] = 1,["day"] = 1})
730+checkerr("\105\110\118\97\108\105\100\32\99\111\110\118\101\114\115\105\111\110\32\115\112\101\99\105\102\105\101\114",os.date,"\37")
731+checkerr("\105\110\118\97\108\105\100\32\99\111\110\118\101\114\115\105\111\110\32\115\112\101\99\105\102\105\101\114",os.date,"\37\57")
732+checkerr("\105\110\118\97\108\105\100\32\99\111\110\118\101\114\115\105\111\110\32\115\112\101\99\105\102\105\101\114",os.date,"\37")
733+checkerr("\105\110\118\97\108\105\100\32\99\111\110\118\101\114\115\105\111\110\32\115\112\101\99\105\102\105\101\114",os.date,"\37\79")
734+checkerr("\105\110\118\97\108\105\100\32\99\111\110\118\101\114\115\105\111\110\32\115\112\101\99\105\102\105\101\114",os.date,"\37\69")
735+checkerr("\105\110\118\97\108\105\100\32\99\111\110\118\101\114\115\105\111\110\32\115\112\101\99\105\102\105\101\114",os.date,"\37\69\97")
736+checkerr("\110\111\116\32\97\110\32\105\110\116\101\103\101\114",os.time,{["\121\101\97\114"] = 1000,["\109\111\110\116\104"] = 1,["\100\97\121"] = 1,["\104\111\117\114"] = "\120"})
737+checkerr("\110\111\116\32\97\110\32\105\110\116\101\103\101\114",os.time,{["\121\101\97\114"] = 1000,["\109\111\110\116\104"] = 1,["\100\97\121"] = 1,["\104\111\117\114"] = 1.5})
738+checkerr("\109\105\115\115\105\110\103",os.time,{["\104\111\117\114"] = 12})
739+if string.packsize("\105") == 4 then
740+checkerr("\102\105\101\108\100\32\39\121\101\97\114\39\32\105\115\32\111\117\116\45\111\102\45\98\111\117\110\100",os.time,{["\121\101\97\114"] = - (1 << 31) + 1899,["\109\111\110\116\104"] = 1,["\100\97\121"] = 1})
741+checkerr("\102\105\101\108\100\32\39\121\101\97\114\39\32\105\115\32\111\117\116\45\111\102\45\98\111\117\110\100",os.time,{["\121\101\97\114"] = - (1 << 31),["\109\111\110\116\104"] = 1,["\100\97\121"] = 1})
810742if math.maxinteger > 2 ^ 31 then
811−checkerr("field 'year' is out-of-bound",os.time,{["year"] = (1 << 31) + 1900,["month"] = 1,["day"] = 1})
743+checkerr("\102\105\101\108\100\32\39\121\101\97\114\39\32\105\115\32\111\117\116\45\111\102\45\98\111\117\110\100",os.time,{["\121\101\97\114"] = (1 << 31) + 1900,["\109\111\110\116\104"] = 1,["\100\97\121"] = 1})
812744end
813745end
814746if not _port then
815−assert(type(os.date("%Ex")) == "string")
816−assert(type(os.date("%Oy")) == "string")
817−local t0 = os.time({["year"] = 1970,["month"] = 1,["day"] = 0})
818−local t1 = os.time({["year"] = 1970,["month"] = 1,["day"] = 0,["sec"] = (1 << 31) - 1})
747+assert(type(os.date("\37\69\120")) == "\115\116\114\105\110\103")
748+assert(type(os.date("\37\79\121")) == "\115\116\114\105\110\103")
749+local t0 = os.time({["\121\101\97\114"] = 1970,["\109\111\110\116\104"] = 1,["\100\97\121"] = 0})
750+local t1 = os.time({["\121\101\97\114"] = 1970,["\109\111\110\116\104"] = 1,["\100\97\121"] = 0,["\115\101\99"] = (1 << 31) - 1})
819751assert(t1 - t0 == (1 << 31) - 1)
820−t0=os.time({["year"] = 1970,["month"] = 1,["day"] = 1})
821−t1=os.time({["year"] = 1970,["month"] = 1,["day"] = 1,["sec"] = - (1 << 31)})
752+t0=os.time({["\121\101\97\114"] = 1970,["\109\111\110\116\104"] = 1,["\100\97\121"] = 1})
753+t1=os.time({["\121\101\97\114"] = 1970,["\109\111\110\116\104"] = 1,["\100\97\121"] = 1,["\115\101\99"] = - (1 << 31)})
822754assert(t1 - t0 == - (1 << 31))
823755if maxint >= 2 ^ 62 then
824−checkerr("out-of-bound",os.time,{["year"] = - maxint,["month"] = 1,["day"] = 1})
825−if string.packsize("i") == 4 then
826−if testerr("out-of-bound",os.date,"%Y",2 ^ 40) then
827−print(" 4-byte time_t")
828−checkerr("cannot be represented",os.time,{["year"] = 4e3,["month"] = 1,["day"] = 1})
756+checkerr("\111\117\116\45\111\102\45\98\111\117\110\100",os.time,{["\121\101\97\114"] = - maxint,["\109\111\110\116\104"] = 1,["\100\97\121"] = 1})
757+if string.packsize("\105") == 4 then
758+if testerr("\111\117\116\45\111\102\45\98\111\117\110\100",os.date,"\37\89",2 ^ 40) then
759+print("\32\32\52\45\98\121\116\101\32\116\105\109\101\95\116")
760+checkerr("\99\97\110\110\111\116\32\98\101\32\114\101\112\114\101\115\101\110\116\101\100",os.time,{["\121\101\97\114"] = 4000,["\109\111\110\116\104"] = 1,["\100\97\121"] = 1})
829761else
830−print(" 8-byte time_t")
831−checkerr("cannot be represented",os.date,"%Y",2 ^ 60)
832−assert(tonumber(os.time({["year"] = (1 << 31) + 1899,["month"] = 12,["day"] = 31,["hour"] = 23,["min"] = 59,["sec"] = 59})))
833−checkerr("represented",os.time,{["year"] = (1 << 31) + 1899,["month"] = 12,["day"] = 31,["hour"] = 23,["min"] = 59,["sec"] = 60})
834−end
835−checkerr("field 'day' is out-of-bound",os.time,{["year"] = 0,["month"] = 1,["day"] = 2 ^ 32})
836−checkerr("field 'month' is out-of-bound",os.time,{["year"] = 0,["month"] = - ((1 << 31) + 1),["day"] = 1})
837−checkerr("field 'year' is out-of-bound",os.time,{["year"] = (1 << 31) + 1900,["month"] = 1,["day"] = 1})
762+print("\32\32\56\45\98\121\116\101\32\116\105\109\101\95\116")
763+checkerr("\99\97\110\110\111\116\32\98\101\32\114\101\112\114\101\115\101\110\116\101\100",os.date,"\37\89",2 ^ 60)
764+assert(tonumber(os.time({["\121\101\97\114"] = (1 << 31) + 1899,["\109\111\110\116\104"] = 12,["\100\97\121"] = 31,["\104\111\117\114"] = 23,["\109\105\110"] = 59,["\115\101\99"] = 59})))
765+checkerr("\114\101\112\114\101\115\101\110\116\101\100",os.time,{["\121\101\97\114"] = (1 << 31) + 1899,["\109\111\110\116\104"] = 12,["\100\97\121"] = 31,["\104\111\117\114"] = 23,["\109\105\110"] = 59,["\115\101\99"] = 60})
766+end
767+checkerr("\102\105\101\108\100\32\39\100\97\121\39\32\105\115\32\111\117\116\45\111\102\45\98\111\117\110\100",os.time,{["\121\101\97\114"] = 0,["\109\111\110\116\104"] = 1,["\100\97\121"] = 2 ^ 32})
768+checkerr("\102\105\101\108\100\32\39\109\111\110\116\104\39\32\105\115\32\111\117\116\45\111\102\45\98\111\117\110\100",os.time,{["\121\101\97\114"] = 0,["\109\111\110\116\104"] = - ((1 << 31) + 1),["\100\97\121"] = 1})
769+checkerr("\102\105\101\108\100\32\39\121\101\97\114\39\32\105\115\32\111\117\116\45\111\102\45\98\111\117\110\100",os.time,{["\121\101\97\114"] = (1 << 31) + 1900,["\109\111\110\116\104"] = 1,["\100\97\121"] = 1})
838770else
839−print(" 8-byte time_t")
840−assert(tonumber(os.date("%Y",2 ^ 60)))
841−checkerr("cannot be represented",os.time,{["year"] = 2 ^ 60,["month"] = 1,["day"] = 1})
771+print("\32\32\56\45\98\121\116\101\32\116\105\109\101\95\116")
772+assert(tonumber(os.date("\37\89",2 ^ 60)))
773+checkerr("\99\97\110\110\111\116\32\98\101\32\114\101\112\114\101\115\101\110\116\101\100",os.time,{["\121\101\97\114"] = 2 ^ 60,["\109\111\110\116\104"] = 1,["\100\97\121"] = 1})
842774end
843775end
844776end
845−local D = os.date("*t")
777+do
778+local D = os.date("\42\116")
846779local t = os.time(D)
847780if D.isdst == nil then
848−print("no daylight saving information")
781+print("\110\111\32\100\97\121\108\105\103\104\116\32\115\97\118\105\110\103\32\105\110\102\111\114\109\97\116\105\111\110")
849782else
850−assert(type(D.isdst) == "boolean")
783+assert(type(D.isdst) == "\98\111\111\108\101\97\110")
851784end
852785D.isdst=nil
853786local t1 = os.time(D)
854787assert(t == t1)
855−local D = os.date("*t")
788+end
789+local D = os.date("\42\116")
856790t=os.time(D)
857791D.year=D.year - 1
858792;
859793local t1 = os.time(D)
860794assert(math.abs(os.difftime(t,t1) / (24 * 3600) - 365) < 2)
861795t=os.time()
862−t1=os.time(os.date("*t"))
796+t1=os.time(os.date("\42\116"))
863797local diff = os.difftime(t1,t)
864798assert(0 <= diff and diff <= 1)
865799diff=os.difftime(t,t1)
866800assert(- 1 <= diff and diff <= 0)
867−local t1 = os.time({["year"] = 2e3,["month"] = 10,["day"] = 1,["hour"] = 23,["min"] = 12})
868−local t2 = os.time({["year"] = 2e3,["month"] = 10,["day"] = 1,["hour"] = 23,["min"] = 10,["sec"] = 19})
801+local t1 = os.time({["\121\101\97\114"] = 2000,["\109\111\110\116\104"] = 10,["\100\97\121"] = 1,["\104\111\117\114"] = 23,["\109\105\110"] = 12})
802+local t2 = os.time({["\121\101\97\114"] = 2000,["\109\111\110\116\104"] = 10,["\100\97\121"] = 1,["\104\111\117\114"] = 23,["\109\105\110"] = 10,["\115\101\99"] = 19})
869803assert(os.difftime(t1,t2) == 60 * 2 - 19)
870−t1={["year"] = 2005,["month"] = 1,["day"] = 1,["hour"] = 1,["min"] = 0,["sec"] = - 3602}
804+t1={["\121\101\97\114"] = 2005,["\109\111\110\116\104"] = 1,["\100\97\121"] = 1,["\104\111\117\114"] = 1,["\109\105\110"] = 0,["\115\101\99"] = - 3602}
871805os.time(t1)
872806assert(t1.day == 31 and t1.month == 12 and t1.year == 2004 and t1.hour == 23 and t1.min == 59 and t1.sec == 58 and t1.yday == 366)
873807io.output(io.stdout)
874−local t = os.date("%d %m %Y %H %M %S")
875−local d,m,a,h,min,s = string.match(t,"(%d+) (%d+) (%d+) (%d+) (%d+) (%d+)")
808+local t = os.date("\37\100\32\37\109\32\37\89\32\37\72\32\37\77\32\37\83")
809+local d,m,a,h,min,s = string.match(t,"\40\37\100\43\41\32\40\37\100\43\41\32\40\37\100\43\41\32\40\37\100\43\41\32\40\37\100\43\41\32\40\37\100\43\41")
876810d=tonumber(d)
877811m=tonumber(m)
878812a=tonumber(a)
879813h=tonumber(h)
880814min=tonumber(min)
881815s=tonumber(s)
882−io.write(string.format("test done on %2.2d/%2.2d/%d",d,m,a))
883−io.write(string.format(", at %2.2d:%2.2d:%2.2d
884−",h,min,s))
885−io.write(string.format("%s
886−",_VERSION))
816+io.write(string.format("\116\101\115\116\32\100\111\110\101\32\111\110\32\37\50\46\50\100\47\37\50\46\50\100\47\37\100",d,m,a))
817+io.write(string.format("\44\32\97\116\32\37\50\46\50\100\58\37\50\46\50\100\58\37\50\46\50\100\10",h,min,s))
818+io.write(string.format("\37\115\10",_VERSION))
zod/luau/res/lua/cycled/foo.lua+26−19
@@ -3,32 +3,38 @@ az=bar[nil]
33baz=bar(1).foo
44i=3
55i,a[i]=i + 1,20 >> 9
6−hello="hellodkndjвговшов"
7−x={[hello] = 8,["hello"] = 12}
6+hello="\104\101\108\108\111\100\107\110\100\106\208\178\208\179\208\190\208\178\209\136\208\190\208\178"
7+x={[hello] = 8,["\104\101\108\108\111"] = 12}
88;
9−test_cases={{2147483647,"2147483647"},{2147483647,"2147483647"},{4294967295,"4294967295"},{4294967295,"4294967295"},{9223372036854775807,"9.2233720368548e+18"},{9.223372036854776e18,"9.2233720368548e+18"},{18446744073709551615,"1.844674407371e+19"},{1.8446744073709552e19,"1.844674407371e+19"},{4294967296,"4294967296"},{4294967296,"4294967296"},{17592186044416,"17592186044416"},{17592186044416,"17592186044416"},{2147483648,"2147483648"},{2147483648,"2147483648"},{140737488355328,"1.4073748835533e+14"},{140737488355328,"1.4073748835533e+14"}}
9+test_cases={{2147483647,"\50\49\52\55\52\56\51\54\52\55"},{2147483647,"\50\49\52\55\52\56\51\54\52\55"},{4294967295,"\52\50\57\52\57\54\55\50\57\53"},{4294967295,"\52\50\57\52\57\54\55\50\57\53"},{9223372036854775807,"\57\46\50\50\51\51\55\50\48\51\54\56\53\52\56\101\43\49\56"},{9223372036854775807,"\57\46\50\50\51\51\55\50\48\51\54\56\53\52\56\101\43\49\56"},{18446744073709551615,"\49\46\56\52\52\54\55\52\52\48\55\51\55\49\101\43\49\57"},{18446744073709551615,"\49\46\56\52\52\54\55\52\52\48\55\51\55\49\101\43\49\57"},{4294967296,"\52\50\57\52\57\54\55\50\57\54"},{4294967296,"\52\50\57\52\57\54\55\50\57\54"},{17592186044416,"\49\55\53\57\50\49\56\54\48\52\52\52\49\54"},{17592186044416,"\49\55\53\57\50\49\56\54\48\52\52\52\49\54"},{2147483648,"\50\49\52\55\52\56\51\54\52\56"},{2147483648,"\50\49\52\55\52\56\51\54\52\56"},{140737488355328,"\49\46\52\48\55\51\55\52\56\56\51\53\53\51\51\101\43\49\52"},{140737488355328,"\49\46\52\48\55\51\55\52\56\56\51\53\53\51\51\101\43\49\52"}}
1010::helli::
11−foo={3,3.1416,3.1416,3.1416,340,0.1171875,162.1875,162.1875,3.141592653589793,1984}
11+foo={3.0,3.1416,3.1416,3.1416,340.0,0.1171875,162.1875,162.1875,3.141592653589793,1984.0}
12+do
1213foo=1
1314return 8,foo
14−print("the way of the future")
15−print("hello")
16−h({["key1"] = "Sonmi~451"})
15+end
16+print("\116\104\101\32\119\97\121\32\111\102\32\116\104\101\32\102\117\116\117\114\101")
17+print("\104\101\108\108\111")
18+h({["\107\101\121\49"] = "\83\111\110\109\105\126\52\53\49"})
1719goto helli
1820break
1921while true do
2022break
23+end
2124repeat
25+do
2226foo=9
23−;until true
27+;
28+end
29+until true
2430if l == 3 then
2531a=a + 1
2632;
27−assert(getlocal(2,1) == "(temporary)")
28−elseifl == 4 then
33+assert(getlocal(2,1) == "\40\116\101\109\112\111\114\97\114\121\41")
34+elseif l == 4 then
2935a=a + 1
3036;
31−assert(getlocal(2,1) == "A")
37+assert(getlocal(2,1) == "\65")
3238else
3339;
3440end
@@ -45,31 +51,32 @@ do
4551print(key,val)
4652end
4753function Dog:new()
48−newObj={["sound"] = "woof"}
54+newObj={["\115\111\117\110\100"] = "\119\111\111\102"}
4955self.__index=self
5056return setmetatable(newObj,self)
5157end
5258function Dog:makeSound()
53−print("I say " .. self.sound)
59+print("\73\32\115\97\121\32" .. self.sound)
5460end
5561local function g
5662(x)
5763return math.sin(x)
5864end
59−local a = require("mod2")
60−local b = require("mod2")
65+local a = require("\109\111\100\50")
66+local b = require("\109\111\100\50")
6167function adder(x)
62−return (y)
68+return function (y)
6369return x + y
6470end
6571end
6672x=- 1 + 8
6773if _VERSION ~= version then
68−io.stderr:write("This test suite is for ",version,", not for ",_VERSION,"
69−Exiting tests")
74+io.stderr:write("\84\104\105\115\32\116\101\115\116\32\115\117\105\116\101\32\105\115\32\102\111\114\32",version,"\44\32\110\111\116\32\102\111\114\32",_VERSION,"\10\69\120\105\116\105\110\103\32\116\101\115\116\115")
7075return
7176end
7277math.randomseed()
7378local random_x,random_y = math.randomseed()
79+do
7480local random_x,random_y = math.randomseed()
75−print(string.format("random seeds: %d, %d",random_x,random_y))
81+print(string.format("\114\97\110\100\111\109\32\115\101\101\100\115\58\32\37\100\44\32\37\100",random_x,random_y))
82+end
zod/luau/res/lua/cycled/gc.lua+233−205
@@ -1,106 +1,114 @@
1−print("testing incremental garbage collection")
2−local debug = require("debug")
3−assert(collectgarbage("isrunning"))
4−collectgarbage()
5−local oldmode = collectgarbage("incremental")
6−assert(collectgarbage("generational") == "incremental")
7−assert(collectgarbage("generational") == "generational")
8−assert(collectgarbage("incremental") == "generational")
9−assert(collectgarbage("incremental") == "incremental")
1+print("\116\101\115\116\105\110\103\32\105\110\99\114\101\109\101\110\116\97\108\32\103\97\114\98\97\103\101\32\99\111\108\108\101\99\116\105\111\110")
2+local debug = require("\100\101\98\117\103")
3+assert(collectgarbage("\105\115\114\117\110\110\105\110\103"))
4+collectgarbage()
5+local oldmode = collectgarbage("\105\110\99\114\101\109\101\110\116\97\108")
6+assert(collectgarbage("\103\101\110\101\114\97\116\105\111\110\97\108") == "\105\110\99\114\101\109\101\110\116\97\108")
7+assert(collectgarbage("\103\101\110\101\114\97\116\105\111\110\97\108") == "\103\101\110\101\114\97\116\105\111\110\97\108")
8+assert(collectgarbage("\105\110\99\114\101\109\101\110\116\97\108") == "\103\101\110\101\114\97\116\105\111\110\97\108")
9+assert(collectgarbage("\105\110\99\114\101\109\101\110\116\97\108") == "\105\110\99\114\101\109\101\110\116\97\108")
1010local function nop
1111()
1212
1313end
1414local function gcinfo
1515()
16−return collectgarbage("count") * 1024
16+return collectgarbage("\99\111\117\110\116") * 1024
1717end
18−local a = collectgarbage("setpause",200)
19−local b = collectgarbage("setstepmul",200)
20−local t = {0,2,10,90,500,5e3,3e4,2147483646}
18+do
19+local a = collectgarbage("\115\101\116\112\97\117\115\101",200)
20+local b = collectgarbage("\115\101\116\115\116\101\112\109\117\108",200)
21+local t = {0,2,10,90,500,5000,30000,2147483646}
2122for i = 1, # t
2223do
2324local p = t[i]
2425for j = 1, # t
2526do
2627local m = t[j]
27−collectgarbage("setpause",p)
28−collectgarbage("setstepmul",m)
29−collectgarbage("step",0)
30−collectgarbage("step",1e4)
28+collectgarbage("\115\101\116\112\97\117\115\101",p)
29+collectgarbage("\115\101\116\115\116\101\112\109\117\108",m)
30+collectgarbage("\115\116\101\112",0)
31+collectgarbage("\115\116\101\112",10000)
3132end
3233end
33−collectgarbage("setpause",a)
34−collectgarbage("setstepmul",b)
34+collectgarbage("\115\101\116\112\97\117\115\101",a)
35+collectgarbage("\115\101\116\115\116\101\112\109\117\108",b)
3536collectgarbage()
36−_G["while"]=234
37+end
38+_G["\119\104\105\108\101"]=234
3739local function GC1
3840()
39−local u =
40−local b =
41+local u
42+local b
4143local finish = false
42−u=setmetatable({},{["__gc"] = ()
44+u=setmetatable({},{["\95\95\103\99"] = function ()
4345finish=true
4446end})
4547b={34}
4648repeat
47−u={}until finish
49+u={}
50+until finish
4851assert(b[1] == 34)
4952finish=false
5053;
5154local i = 1
52−u=setmetatable({},{["__gc"] = ()
55+u=setmetatable({},{["\95\95\103\99"] = function ()
5356finish=true
5457end})
5558repeat
5659i=i + 1
5760;
58−u=tostring(i) .. tostring(i)until finish
61+u=tostring(i) .. tostring(i)
62+until finish
5963assert(b[1] == 34)
6064finish=false
61−u=setmetatable({},{["__gc"] = ()
65+u=setmetatable({},{["\95\95\103\99"] = function ()
6266finish=true
6367end})
6468repeat
65−local i =
69+local i
6670;
67−u=()
71+u=function ()
6872return i
69−enduntil finish
73+end
74+until finish
7075assert(b[1] == 34)
7176end
7277local function GC2
7378()
74−local u =
79+local u
7580local finish = false
76−u={setmetatable({},{["__gc"] = ()
81+u={setmetatable({},{["\95\95\103\99"] = function ()
7782finish=true
7883end})}
7984local b = {34}
8085repeat
81−u={{}}until finish
86+u={{}}
87+until finish
8288assert(b[1] == 34)
8389finish=false
8490;
8591local i = 1
86−u={setmetatable({},{["__gc"] = ()
92+u={setmetatable({},{["\95\95\103\99"] = function ()
8793finish=true
8894end})}
8995repeat
9096i=i + 1
9197;
92−u={tostring(i) .. tostring(i)}until finish
98+u={tostring(i) .. tostring(i)}
99+until finish
93100assert(b[1] == 34)
94101finish=false
95−u={setmetatable({},{["__gc"] = ()
102+u={setmetatable({},{["\95\95\103\99"] = function ()
96103finish=true
97104end})}
98105repeat
99−local i =
106+local i
100107;
101−u={()
108+u={function ()
102109return i
103−end}until finish
110+end}
111+until finish
104112assert(b[1] == 34)
105113end
106114local function GC
@@ -109,45 +117,42 @@ GC1()
109117;
110118GC2()
111119end
112−print("creating many objects")
113−local limit = 5e3
120+do
121+print("\99\114\101\97\116\105\110\103\32\109\97\110\121\32\111\98\106\101\99\116\115")
122+local limit = 5000
114123for i = 1, limit
115124do
116125local a = {}
117126;
118127a=nil
119128end
120−local a = "a"
129+local a = "\97"
121130for i = 1, limit
122131do
123−a=i .. "b"
132+a=i .. "\98"
124133;
125−a=string.gsub(a,"(%d%d*)","%1 %1")
126−a="a"
134+a=string.gsub(a,"\40\37\100\37\100\42\41","\37\49\32\37\49")
135+a="\97"
127136end
128137a={}
129138function a:test()
130139for i = 1, limit
131140do
132−load(string.format("function temp(a) return 'a%d' end",i),"")()
133−assert(temp() == string.format("a%d",i))
141+load(string.format("\102\117\110\99\116\105\111\110\32\116\101\109\112\40\97\41\32\114\101\116\117\114\110\32\39\97\37\100\39\32\101\110\100",i),"")()
142+assert(temp() == string.format("\97\37\100",i))
134143end
135144end
136145a:test()
137146_G.temp=nil
138−local f = ()
147+end
148+do
149+local f = function ()
139150
140151end
141−print("functions with errors")
142−local prog = "do
143− a = 10;
144− function foo(x,y)
145− a = sin(a+0.456-0.23e-12);
146− return function (z) return sin(%x+z) end
147− end
148− local x = function (w) a=a+w; end
149152end
150−"
153+print("\102\117\110\99\116\105\111\110\115\32\119\105\116\104\32\101\114\114\111\114\115")
154+local prog = "\100\111\10\32\32\97\32\61\32\49\48\59\10\32\32\102\117\110\99\116\105\111\110\32\102\111\111\40\120\44\121\41\10\32\32\32\32\97\32\61\32\115\105\110\40\97\43\48\46\52\53\54\45\48\46\50\51\101\45\49\50\41\59\10\32\32\32\32\114\101\116\117\114\110\32\102\117\110\99\116\105\111\110\32\40\122\41\32\114\101\116\117\114\110\32\115\105\110\40\37\120\43\122\41\32\101\110\100\10\32\32\101\110\100\10\32\32\108\111\99\97\108\32\120\32\61\32\102\117\110\99\116\105\111\110\32\40\119\41\32\97\61\97\43\119\59\32\101\110\100\10\101\110\100\10"
155+do
151156local step = 1
152157if _soft then
153158step=13
@@ -159,11 +164,13 @@ do
159164pcall(load(string.sub(prog,i,j),""))
160165end
161166end
162−rawset(_G,"a",nil)
167+end
168+rawset(_G,"\97",nil)
163169_G.x=nil
170+do
164171foo=nil
165−print("long strings")
166−local x = "01234567890123456789012345678901234567890123456789012345678901234567890123456789"
172+print("\108\111\110\103\32\115\116\114\105\110\103\115")
173+local x = "\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57"
167174assert(string.len(x) == 80)
168175local s = ""
169176local k = math.min(300,(math.maxinteger // 80) // 2)
@@ -174,13 +181,15 @@ s=s .. x
174181local j = tostring(n)
175182end
176183assert(string.len(s) == k * 80)
177−s=string.sub(s,1,1e4)
178−local s,i = string.gsub(s,"(%d%d%d%d)","")
179−assert(i == 1e4 // 4)
180−assert(_G["while"] == 234)
181−_G["while"]=nil
182−print("steps")
183−print("steps (2)")
184+s=string.sub(s,1,10000)
185+local s,i = string.gsub(s,"\40\37\100\37\100\37\100\37\100\41","")
186+assert(i == 10000 // 4)
187+assert(_G["\119\104\105\108\101"] == 234)
188+_G["\119\104\105\108\101"]=nil
189+end
190+do
191+print("\115\116\101\112\115")
192+print("\115\116\101\112\115\32\40\50\41")
184193local function dosteps
185194(siz)
186195collectgarbage()
@@ -194,34 +203,38 @@ end
194203local x = gcinfo()
195204local i = 0
196205repeat
197−i=i + 1until collectgarbage("step",siz)
206+i=i + 1
207+until collectgarbage("\115\116\101\112",siz)
198208assert(gcinfo() < x)
199209return i
200210end
201−collectgarbage("stop")
211+collectgarbage("\115\116\111\112")
202212if not _port then
203213assert(dosteps(10) < dosteps(2))
204214end
205−assert(dosteps(2e4) == 1)
206−assert(collectgarbage("step",2e4) == true)
207−assert(collectgarbage("step",2e4) == true)
208−assert(not collectgarbage("isrunning"))
209−collectgarbage("restart")
210−assert(collectgarbage("isrunning"))
215+assert(dosteps(20000) == 1)
216+assert(collectgarbage("\115\116\101\112",20000) == true)
217+assert(collectgarbage("\115\116\101\112",20000) == true)
218+assert(not collectgarbage("\105\115\114\117\110\110\105\110\103"))
219+collectgarbage("\114\101\115\116\97\114\116")
220+assert(collectgarbage("\105\115\114\117\110\110\105\110\103"))
221+end
211222if not _port then
212223collectgarbage()
213224;
214225collectgarbage()
215226local x = gcinfo()
216−collectgarbage("stop")
227+collectgarbage("\115\116\111\112")
217228repeat
218−local a = {}until gcinfo() > 3 * x
219−collectgarbage("restart")
220−assert(collectgarbage("isrunning"))
229+local a = {}
230+until gcinfo() > 3 * x
231+collectgarbage("\114\101\115\116\97\114\116")
232+assert(collectgarbage("\105\115\114\117\110\110\105\110\103"))
221233repeat
222−local a = {}until gcinfo() <= x * 2
234+local a = {}
235+until gcinfo() <= x * 2
223236end
224−print("clearing tables")
237+print("\99\108\101\97\114\105\110\103\32\116\97\98\108\101\115")
225238local lim = 15
226239local a = {}
227240for i = 1, lim
@@ -236,14 +249,14 @@ end
236249for n in pairs(b)
237250do
238251a[n]=undef
239−assert(type(n) == "table" and next(n) == nil)
252+assert(type(n) == "\116\97\98\108\101" and next(n) == nil)
240253collectgarbage()
241254end
242255b=nil
243256collectgarbage()
244257for n in pairs(a)
245258do
246−error("cannot be here")
259+error("\99\97\110\110\111\116\32\98\101\32\104\101\114\101")
247260end
248261for i = 1, lim
249262do
@@ -253,10 +266,10 @@ for i = 1, lim
253266do
254267assert(a[i] == i)
255268end
256−print("weak tables")
269+print("\119\101\97\107\32\116\97\98\108\101\115")
257270a={}
258271;
259−setmetatable(a,{["__mode"] = "k"})
272+setmetatable(a,{["\95\95\109\111\100\101"] = "\107"})
260273;
261274for i = 1, lim
262275do
@@ -268,24 +281,24 @@ a[i]=i
268281end
269282for i = 1, lim
270283do
271−local s = string.rep("@",i)
284+local s = string.rep("\64",i)
272285;
273−a[s]=s .. "#"
286+a[s]=s .. "\35"
274287end
275288collectgarbage()
276289local i = 0
277290for k,v in pairs(a)
278291do
279−assert(k == v or k .. "#" == v)
292+assert(k == v or k .. "\35" == v)
280293;
281294i=i + 1
282295end
283296assert(i == 2 * lim)
284297a={}
285298;
286−setmetatable(a,{["__mode"] = "v"})
299+setmetatable(a,{["\95\95\109\111\100\101"] = "\118"})
287300;
288−a[1]=string.rep("b",21)
301+a[1]=string.rep("\98",21)
289302collectgarbage()
290303assert(a[1])
291304a[1]=undef
@@ -295,7 +308,7 @@ a[i]={}
295308end
296309for i = 1, lim
297310do
298−a[i .. "x"]={}
311+a[i .. "\120"]={}
299312end
300313for i = 1, lim
301314do
@@ -305,24 +318,24 @@ a[t]=t
305318end
306319for i = 1, lim
307320do
308−a[i + lim]=i .. "x"
321+a[i + lim]=i .. "\120"
309322end
310323collectgarbage()
311324local i = 0
312325for k,v in pairs(a)
313326do
314−assert(k == v or k - lim .. "x" == v)
327+assert(k == v or k - lim .. "\120" == v)
315328;
316329i=i + 1
317330end
318331assert(i == 2 * lim)
319332a={}
320333;
321−setmetatable(a,{["__mode"] = "kv"})
334+setmetatable(a,{["\95\95\109\111\100\101"] = "\107\118"})
322335;
323336local x,y,z = {},{},{}
324337a[1],a[2],a[3]=x,y,z
325−a[string.rep("$",11)]=string.rep("$",11)
338+a[string.rep("\36",11)]=string.rep("\36",11)
326339for i = 4, lim
327340do
328341a[i]={}
@@ -349,22 +362,22 @@ end
349362assert(i == 4)
350363x,y,z=nil
351364collectgarbage()
352−assert(next(a) == string.rep("$",11))
365+assert(next(a) == string.rep("\36",11))
353366a={}
354−local t = {["x"] = 10}
355−local C = setmetatable({["key"] = t},{["__mode"] = "v"})
356−local C1 = setmetatable({[t] = 1},{["__mode"] = "k"})
367+local t = {["\120"] = 10}
368+local C = setmetatable({["\107\101\121"] = t},{["\95\95\109\111\100\101"] = "\118"})
369+local C1 = setmetatable({[t] = 1},{["\95\95\109\111\100\101"] = "\107"})
357370a.x=t
358−setmetatable(a,{["__gc"] = (u)
371+setmetatable(a,{["\95\95\103\99"] = function (u)
359372assert(C.key == nil)
360−assert(type(next(C1)) == "table")
373+assert(type(next(C1)) == "\116\97\98\108\101")
361374end})
362375a,t=nil
363376collectgarbage()
364377collectgarbage()
365378assert(next(C) == nil and next(C1) == nil)
366379C,C1=nil
367−local mt = {["__mode"] = "k"}
380+local mt = {["\95\95\109\111\100\101"] = "\107"}
368381a={{10},{20},{30},{40}}
369382;
370383setmetatable(a,mt)
@@ -373,7 +386,7 @@ for i = 1, 100
373386do
374387local n = {}
375388;
376−a[n]={["k"] = {x}}
389+a[n]={["\107"] = {x}}
377390;
378391x=n
379392end
@@ -384,6 +397,7 @@ while n do
384397n=a[n].k[1]
385398;
386399i=i + 1
400+end
387401assert(i == 100)
388402x=nil
389403GC()
@@ -409,7 +423,7 @@ do
409423local n = {}
410424;
411425local nk = k % 10 + 1
412−a[a[K][nk]][n]={x,["k"] = k}
426+a[a[K][nk]][n]={x,["\107"] = k}
413427;
414428x=n
415429;
@@ -426,21 +440,22 @@ n=t[1]
426440k=t.k
427441;
428442i=i + 1
443+end
429444assert(i == 100)
430445K=nil
431446GC()
432447if T then
433−collectgarbage("stop")
448+collectgarbage("\115\116\111\112")
434449local u = {}
435450local s = {}
436451;
437−setmetatable(s,{["__mode"] = "k"})
438−setmetatable(u,{["__gc"] = (o)
452+setmetatable(s,{["\95\95\109\111\100\101"] = "\107"})
453+setmetatable(u,{["\95\95\103\99"] = function (o)
439454local i = s[o]
440455s[i]=true
441456assert(not s[i - 1])
442457if i == 8 then
443−error("@expected@")
458+error("\64\101\120\112\101\99\116\101\100\64")
444459end
445460end})
446461for i = 6, 10
@@ -448,12 +463,12 @@ do
448463local n = setmetatable({},getmetatable(u))
449464s[n]=i
450465end
451−warn("@on")
466+warn("\64\111\110")
452467;
453−warn("@store")
468+warn("\64\115\116\111\114\101")
454469collectgarbage()
455−assert(string.find(_WARN,"error in __gc"))
456−assert(string.match(_WARN,"@(.-)@") == "expected")
470+assert(string.find(_WARN,"\101\114\114\111\114\32\105\110\32\95\95\103\99"))
471+assert(string.match(_WARN,"\64\40\46\45\41\64") == "\101\120\112\101\99\116\101\100")
457472;
458473_WARN=false
459474for i = 8, 10
@@ -471,25 +486,23 @@ do
471486assert(s[i])
472487end
473488getmetatable(u).__gc=nil
474−warn("@normal")
489+warn("\64\110\111\114\109\97\108")
475490end
476−print("+")
491+print("\43")
477492if T == nil then
478−(Message or print)("
479− >>> testC not active: skipping userdata GC tests <<<
480−")
493+(Message or print)("\10\32\62\62\62\32\116\101\115\116\67\32\110\111\116\32\97\99\116\105\118\101\58\32\115\107\105\112\112\105\110\103\32\117\115\101\114\100\97\116\97\32\71\67\32\116\101\115\116\115\32\60\60\60\10")
481494else
482495local function newproxy
483496(u)
484497return debug.setmetatable(T.newuserdata(0),debug.getmetatable(u))
485498end
486−collectgarbage("stop")
499+collectgarbage("\115\116\111\112")
487500local u = newproxy(nil)
488−debug.setmetatable(u,{["__gc"] = true})
501+debug.setmetatable(u,{["\95\95\103\99"] = true})
489502local s = 0
490503local a = {[u] = 0}
491504;
492−setmetatable(a,{["__mode"] = "vk"})
505+setmetatable(a,{["\95\95\109\111\100\101"] = "\118\107"})
493506for i = 1, 10
494507do
495508a[newproxy(u)]=i
@@ -514,14 +527,16 @@ assert(a[i])
514527end
515528getmetatable(u).a=a1
516529getmetatable(u).u=u
530+do
517531local u = u
518−getmetatable(u).__gc=(o)
532+getmetatable(u).__gc=function (o)
519533assert(a[o] == 10 - s)
520534assert(a[10 - s] == undef)
521535assert(getmetatable(o) == getmetatable(u))
522536assert(getmetatable(o).a[o] == 10 - s)
523537s=s + 1
524538end
539+end
525540a1,u=nil
526541assert(next(a) ~= nil)
527542collectgarbage()
@@ -529,95 +544,100 @@ assert(s == 11)
529544collectgarbage()
530545assert(next(a) == nil)
531546end
532−local u = setmetatable({},{["__gc"] = true})
533−setmetatable(getmetatable(u),{["__mode"] = "v"})
534−getmetatable(u).__gc=(o)
547+local u = setmetatable({},{["\95\95\103\99"] = true})
548+setmetatable(getmetatable(u),{["\95\95\109\111\100\101"] = "\118"})
549+getmetatable(u).__gc=function (o)
535550os.exit(1)
536551end
537552u=nil
538553collectgarbage()
539−local u = setmetatable({},{["__gc"] = true})
554+local u = setmetatable({},{["\95\95\103\99"] = true})
540555local m = getmetatable(u)
541556m.x={[{0}] = 1,[0] = {1}}
542557;
543−setmetatable(m.x,{["__mode"] = "kv"})
558+setmetatable(m.x,{["\95\95\109\111\100\101"] = "\107\118"})
544559;
545−m.__gc=(o)
560+m.__gc=function (o)
546561assert(next(getmetatable(o).x) == nil)
547562m=10
548563end
549564u,m=nil
550565collectgarbage()
551566assert(m == 10)
567+do
552568collectgarbage()
553569;
554570collectgarbage()
555−local m = collectgarbage("count")
556−local a = setmetatable({},{["__mode"] = "kv"})
557−a[string.rep("a",2 ^ 22)]=25
558−a[string.rep("b",2 ^ 22)]={}
571+local m = collectgarbage("\99\111\117\110\116")
572+local a = setmetatable({},{["\95\95\109\111\100\101"] = "\107\118"})
573+a[string.rep("\97",2 ^ 22)]=25
574+a[string.rep("\98",2 ^ 22)]={}
559575a[{}]=14
560−assert(collectgarbage("count") > m + 2 ^ 13)
576+assert(collectgarbage("\99\111\117\110\116") > m + 2 ^ 13)
561577collectgarbage()
562−assert(collectgarbage("count") >= m + 2 ^ 12 and collectgarbage("count") < m + 2 ^ 13)
578+assert(collectgarbage("\99\111\117\110\116") >= m + 2 ^ 12 and collectgarbage("\99\111\117\110\116") < m + 2 ^ 13)
563579local k,v = next(a)
564−assert(k == string.rep("a",2 ^ 22) and v == 25)
580+assert(k == string.rep("\97",2 ^ 22) and v == 25)
565581assert(next(a,k) == nil)
566−assert(a[string.rep("b",2 ^ 22)] == undef)
582+assert(a[string.rep("\98",2 ^ 22)] == undef)
567583a[k]=undef
568584k=nil
569585collectgarbage()
570586assert(next(a) == nil)
571−assert(a[string.rep("b",100)] == undef)
572−assert(collectgarbage("count") <= m + 1)
587+assert(a[string.rep("\98",100)] == undef)
588+assert(collectgarbage("\99\111\117\110\116") <= m + 1)
589+end
573590if T then
574−warn("@store")
575−u=setmetatable({},{["__gc"] = ()
576−error("@expected error")
591+warn("\64\115\116\111\114\101")
592+u=setmetatable({},{["\95\95\103\99"] = function ()
593+error("\64\101\120\112\101\99\116\101\100\32\101\114\114\111\114")
577594end})
578595u=nil
579596collectgarbage()
580−assert(string.find(_WARN,"@expected error"))
597+assert(string.find(_WARN,"\64\101\120\112\101\99\116\101\100\32\101\114\114\111\114"))
581598;
582599_WARN=false
583−warn("@normal")
600+warn("\64\110\111\114\109\97\108")
584601end
585602if not _soft then
586−print("long list")
603+print("\108\111\110\103\32\108\105\115\116")
587604local a = {}
588−for i = 1, 2e5
605+for i = 1, 200000
589606do
590−a={["next"] = a}
607+a={["\110\101\120\116"] = a}
591608end
592609a=nil
593610collectgarbage()
594611end
595−print("self-referenced threads")
612+print("\115\101\108\102\45\114\101\102\101\114\101\110\99\101\100\32\116\104\114\101\97\100\115")
596613local thread_id = 0
597614local threads = {}
598615local function fn
599616(thread)
600617local x = {}
601−threads[thread_id]=()
618+threads[thread_id]=function ()
602619thread=x
603620end
604621coroutine.yield()
605622end
606−while thread_id < 1e3 do
623+while thread_id < 1000 do
607624local thread = coroutine.create(fn)
608625coroutine.resume(thread,thread)
609626thread_id=thread_id + 1
627+end
628+do
610629local collected = false
611630collectgarbage()
612631;
613−collectgarbage("stop")
632+collectgarbage("\115\116\111\112")
633+do
614634local function f
615635(param)
616636;
617−(()
618−assert(type(f) == "function" and type(param) == "thread")
637+(function ()
638+assert(type(f) == "\102\117\110\99\116\105\111\110" and type(param) == "\116\104\114\101\97\100")
619639param={param,f}
620−setmetatable(param,{["__gc"] = ()
640+setmetatable(param,{["\95\95\103\99"] = function ()
621641collected=true
622642end})
623643coroutine.yield(100)
@@ -625,72 +645,77 @@ end)()
625645end
626646local co = coroutine.create(f)
627647assert(coroutine.resume(co,co))
648+end
628649collectgarbage()
629650assert(collected)
630−collectgarbage("restart")
651+collectgarbage("\114\101\115\116\97\114\116")
652+end
653+do
631654collectgarbage()
632−collectgarbage("stop")
633−collectgarbage("step",0)
655+collectgarbage("\115\116\111\112")
656+collectgarbage("\115\116\101\112",0)
634657local x = gcinfo()
635658repeat
636−for i = 1, 1e3
659+for i = 1, 1000
637660do
638661_ENV.a={}
639−enduntil gcinfo() > 2 * x
640−collectgarbage("restart")
662+end
663+until gcinfo() > 2 * x
664+collectgarbage("\114\101\115\116\97\114\116")
641665_ENV.a=nil
666+end
642667if T then
643668local function foo
644669()
645−local a = {["x"] = 20}
646−coroutine.yield(()
670+local a = {["\120"] = 20}
671+coroutine.yield(function ()
647672return a.x
648673end)
649674assert(a.x == 20)
650−a={["x"] = 30}
651−assert(T.gccolor(a) == "white")
675+a={["\120"] = 30}
676+assert(T.gccolor(a) == "\119\104\105\116\101")
652677coroutine.yield(100)
653678end
654−local t = setmetatable({},{["__mode"] = "kv"})
679+local t = setmetatable({},{["\95\95\109\111\100\101"] = "\107\118"})
655680collectgarbage()
656681;
657−collectgarbage("stop")
682+collectgarbage("\115\116\111\112")
658683t.co=coroutine.wrap(foo)
659684local f = t.co()
660−T.gcstate("atomic")
661−assert(T.gcstate() == "atomic")
685+T.gcstate("\97\116\111\109\105\99")
686+assert(T.gcstate() == "\97\116\111\109\105\99")
662687assert(t.co() == 100)
663−assert(T.gccolor(t.co) == "white")
664−T.gcstate("pause")
688+assert(T.gccolor(t.co) == "\119\104\105\116\101")
689+T.gcstate("\112\97\117\115\101")
665690assert(t.co == nil and f() == 30)
666−collectgarbage("restart")
691+collectgarbage("\114\101\115\116\97\114\116")
667692local u = T.newuserdata(0,1)
668693collectgarbage()
669−collectgarbage("stop")
694+collectgarbage("\115\116\111\112")
670695local a = {}
671−T.gcstate("atomic")
672−T.gcstate("sweepallgc")
696+T.gcstate("\97\116\111\109\105\99")
697+T.gcstate("\115\119\101\101\112\97\108\108\103\99")
673698local x = {}
674−assert(T.gccolor(u) == "black")
675−assert(T.gccolor(x) == "white")
699+assert(T.gccolor(u) == "\98\108\97\99\107")
700+assert(T.gccolor(x) == "\119\104\105\116\101")
676701debug.setuservalue(u,x)
677−assert(T.gccolor(u) == "gray")
678−collectgarbage("restart")
679−print("+")
702+assert(T.gccolor(u) == "\103\114\97\121")
703+collectgarbage("\114\101\115\116\97\114\116")
704+print("\43")
680705end
681706if T then
682−local debug = require("debug")
683−collectgarbage("stop")
707+local debug = require("\100\101\98\117\103")
708+collectgarbage("\115\116\111\112")
684709local x = T.newuserdata(0)
685710local y = T.newuserdata(0)
686−debug.setmetatable(y,{["__gc"] = nop})
687−debug.setmetatable(x,{["__gc"] = nop})
688−assert(T.gccolor(y) == "white")
711+debug.setmetatable(y,{["\95\95\103\99"] = nop})
712+debug.setmetatable(x,{["\95\95\103\99"] = nop})
713+assert(T.gccolor(y) == "\119\104\105\116\101")
689714T.checkmemory()
690−collectgarbage("restart")
715+collectgarbage("\114\101\115\116\97\114\116")
691716end
692717if T then
693−print("emergency collections")
718+print("\101\109\101\114\103\101\110\99\121\32\99\111\108\108\101\99\116\105\111\110\115")
694719collectgarbage()
695720collectgarbage()
696721T.totalmem(T.totalmem() + 200)
@@ -700,63 +725,66 @@ local a = {}
700725end
701726T.totalmem(0)
702727collectgarbage()
703−local t = T.totalmem("table")
728+local t = T.totalmem("\116\97\98\108\101")
704729local a = {{},{},{}}
705−assert(T.totalmem("table") == t + 4)
706−t=T.totalmem("function")
707−a=()
730+assert(T.totalmem("\116\97\98\108\101") == t + 4)
731+t=T.totalmem("\102\117\110\99\116\105\111\110")
732+a=function ()
708733
709734end
710−assert(T.totalmem("function") == t + 1)
711−t=T.totalmem("thread")
712−a=coroutine.create(()
735+assert(T.totalmem("\102\117\110\99\116\105\111\110") == t + 1)
736+t=T.totalmem("\116\104\114\101\97\100")
737+a=coroutine.create(function ()
713738
714739end)
715−assert(T.totalmem("thread") == t + 1)
740+assert(T.totalmem("\116\104\114\101\97\100") == t + 1)
716741end
742+do
717743local setmetatable,assert,type,print,getmetatable = setmetatable,assert,type,print,getmetatable
718744local tt = {}
719−tt.__gc=(o)
745+tt.__gc=function (o)
720746assert(getmetatable(o) == tt)
721−local a = "xuxu" .. (10 + 3) .. "joao",{}
747+local a = "\120\117\120\117" .. (10 + 3) .. "\106\111\97\111",{}
722748___Glob=o
723749setmetatable({},tt)
724−print(">>> closing state " .. "<<<
725−")
750+print("\62\62\62\32\99\108\111\115\105\110\103\32\115\116\97\116\101\32" .. "\60\60\60\10")
726751end
727752local u = setmetatable({},tt)
728753___Glob={u}
754+end
729755if T then
730756local error,assert,find,warn = error,assert,string.find,warn
731757local n = 0
732−local lastmsg =
733−local mt = {["__gc"] = (o)
758+local lastmsg
759+local mt = {["\95\95\103\99"] = function (o)
734760n=n + 1
735761assert(n == o[1])
736762if n == 1 then
737763_WARN=false
738−elseifn == 2 then
739−assert(find(_WARN,"@expected warning"))
764+elseif n == 2 then
765+assert(find(_WARN,"\64\101\120\112\101\99\116\101\100\32\119\97\114\110\105\110\103"))
740766lastmsg=_WARN
741767else
742768assert(lastmsg == _WARN)
743769end
744−warn("@store")
770+warn("\64\115\116\111\114\101")
745771;
746772_WARN=false
747−error("@expected warning")
773+error("\64\101\120\112\101\99\116\101\100\32\119\97\114\110\105\110\103")
748774end}
749775for i = 10, 1, - 1
750776do
751777table.insert(___Glob,setmetatable({i},mt))
752778end
753779end
754−assert(collectgarbage("isrunning"))
780+assert(collectgarbage("\105\115\114\117\110\110\105\110\103"))
781+do
755782local res = true
756−setmetatable({},{["__gc"] = ()
783+setmetatable({},{["\95\95\103\99"] = function ()
757784res=collectgarbage()
758785end})
759786collectgarbage()
760787assert(not res)
788+end
761789collectgarbage(oldmode)
762−print("OK")
790+print("\79\75")
zod/luau/res/lua/cycled/gengc.lua+64−54
@@ -1,98 +1,108 @@
1−print("testing generational garbage collection")
2−local debug = require("debug")
3−assert(collectgarbage("isrunning"))
1+print("\116\101\115\116\105\110\103\32\103\101\110\101\114\97\116\105\111\110\97\108\32\103\97\114\98\97\103\101\32\99\111\108\108\101\99\116\105\111\110")
2+local debug = require("\100\101\98\117\103")
3+assert(collectgarbage("\105\115\114\117\110\110\105\110\103"))
44collectgarbage()
5−local oldmode = collectgarbage("generational")
5+local oldmode = collectgarbage("\103\101\110\101\114\97\116\105\111\110\97\108")
6+do
67local U = {}
78collectgarbage()
8−assert(not T or T.gcage(U) == "old")
9−U[1]={["x"] = {234}}
10−assert(not T or (T.gcage(U) == "touched1" and T.gcage(U[1]) == "new"))
11−collectgarbage("step",0)
12−assert(not T or (T.gcage(U) == "touched2" and T.gcage(U[1]) == "survival"))
13−collectgarbage("step",0)
14−assert(not T or (T.gcage(U) == "old" and T.gcage(U[1]) == "old1"))
9+assert(not T or T.gcage(U) == "\111\108\100")
10+U[1]={["\120"] = {234}}
11+assert(not T or (T.gcage(U) == "\116\111\117\99\104\101\100\49" and T.gcage(U[1]) == "\110\101\119"))
12+collectgarbage("\115\116\101\112",0)
13+assert(not T or (T.gcage(U) == "\116\111\117\99\104\101\100\50" and T.gcage(U[1]) == "\115\117\114\118\105\118\97\108"))
14+collectgarbage("\115\116\101\112",0)
15+assert(not T or (T.gcage(U) == "\111\108\100" and T.gcage(U[1]) == "\111\108\100\49"))
1516assert(U[1].x[1] == 234)
17+end
18+do
1619local function foo
1720()
1821
1922end
2023local old = {10}
2124collectgarbage()
22−assert(not T or T.gcage(old) == "old")
25+assert(not T or T.gcage(old) == "\111\108\100")
2326setmetatable(old,{})
24−assert(not T or T.gcage(getmetatable(old)) == "old0")
25−collectgarbage("step",0)
26−assert(not T or T.gcage(getmetatable(old)) == "old1")
27−setmetatable(getmetatable(old),{["__gc"] = foo})
28−collectgarbage("step",0)
27+assert(not T or T.gcage(getmetatable(old)) == "\111\108\100\48")
28+collectgarbage("\115\116\101\112",0)
29+assert(not T or T.gcage(getmetatable(old)) == "\111\108\100\49")
30+setmetatable(getmetatable(old),{["\95\95\103\99"] = foo})
31+collectgarbage("\115\116\101\112",0)
32+end
33+do
2934local A = {}
3035A[1]=false
3136local function gcf
3237(obj)
3338A[1]=obj
34−assert(not T or T.gcage(obj) == "old1")
39+assert(not T or T.gcage(obj) == "\111\108\100\49")
3540obj=nil
36−collectgarbage("step",0)
41+collectgarbage("\115\116\101\112",0)
3742print(getmetatable(A[1]).x)
3843end
3944collectgarbage()
4045local obj = {}
41−collectgarbage("step",0)
42−assert(not T or T.gcage(obj) == "survival")
43−setmetatable(obj,{["__gc"] = gcf,["x"] = "+"})
44−assert(not T or T.gcage(getmetatable(obj)) == "new")
46+collectgarbage("\115\116\101\112",0)
47+assert(not T or T.gcage(obj) == "\115\117\114\118\105\118\97\108")
48+setmetatable(obj,{["\95\95\103\99"] = gcf,["\120"] = "\43"})
49+assert(not T or T.gcage(getmetatable(obj)) == "\110\101\119")
4550obj=nil
46−collectgarbage("step",0)
51+collectgarbage("\115\116\101\112",0)
52+end
53+do
4754local old = {10}
4855collectgarbage()
49−local co = coroutine.create(()
56+local co = coroutine.create(function ()
5057local x = nil
51−local f = ()
58+local f = function ()
5259return x[1]
5360end
5461x=coroutine.yield(f)
5562coroutine.yield()
5663end)
5764local _,f = coroutine.resume(co)
58−collectgarbage("step",0)
59−old[1]={"hello"}
65+collectgarbage("\115\116\101\112",0)
66+old[1]={"\104\101\108\108\111"}
6067coroutine.resume(co,{123})
6168co=nil
62−collectgarbage("step",0)
63−assert(f() == 123 and old[1][1] == "hello")
64−collectgarbage("step",0)
65−assert(f() == 123 and old[1][1] == "hello")
66−local t = setmetatable({},{["__mode"] = "kv"})
69+collectgarbage("\115\116\101\112",0)
70+assert(f() == 123 and old[1][1] == "\104\101\108\108\111")
71+collectgarbage("\115\116\101\112",0)
72+assert(f() == 123 and old[1][1] == "\104\101\108\108\111")
73+end
74+do
75+local t = setmetatable({},{["\95\95\109\111\100\101"] = "\107\118"})
6776collectgarbage()
68−assert(not T or T.gcage(t) == "old")
77+assert(not T or T.gcage(t) == "\111\108\100")
6978t[1]={10}
70−assert(not T or (T.gcage(t) == "touched1" and T.gccolor(t) == "gray"))
71−collectgarbage("step",0)
72−assert(not T or (T.gcage(t) == "touched2" and T.gccolor(t) == "black"))
73−collectgarbage("step",0)
74−assert(not T or T.gcage(t) == "old")
79+assert(not T or (T.gcage(t) == "\116\111\117\99\104\101\100\49" and T.gccolor(t) == "\103\114\97\121"))
80+collectgarbage("\115\116\101\112",0)
81+assert(not T or (T.gcage(t) == "\116\111\117\99\104\101\100\50" and T.gccolor(t) == "\98\108\97\99\107"))
82+collectgarbage("\115\116\101\112",0)
83+assert(not T or T.gcage(t) == "\111\108\100")
7584t[1]={10}
76−collectgarbage("step",0)
85+collectgarbage("\115\116\101\112",0)
7786assert(t[1] == nil)
87+end
7888if T == nil then
79−(Message or print)("
80− >>> testC not active: skipping some generational tests <<<
81−")
82−print("OK")
89+(Message or print)("\10\32\62\62\62\32\116\101\115\116\67\32\110\111\116\32\97\99\116\105\118\101\58\32\115\107\105\112\112\105\110\103\32\115\111\109\101\32\103\101\110\101\114\97\116\105\111\110\97\108\32\116\101\115\116\115\32\60\60\60\10")
90+print("\79\75")
8391return
8492end
93+do
8594local U = T.newuserdata(0,1)
8695collectgarbage()
87−assert(T.gcage(U) == "old")
88−debug.setuservalue(U,{["x"] = {234}})
89−assert(T.gcage(U) == "touched1" and T.gcage(debug.getuservalue(U)) == "new")
90−collectgarbage("step",0)
91−assert(T.gcage(U) == "touched2" and T.gcage(debug.getuservalue(U)) == "survival")
92−collectgarbage("step",0)
93−assert(T.gcage(U) == "old" and T.gcage(debug.getuservalue(U)) == "old1")
96+assert(T.gcage(U) == "\111\108\100")
97+debug.setuservalue(U,{["\120"] = {234}})
98+assert(T.gcage(U) == "\116\111\117\99\104\101\100\49" and T.gcage(debug.getuservalue(U)) == "\110\101\119")
99+collectgarbage("\115\116\101\112",0)
100+assert(T.gcage(U) == "\116\111\117\99\104\101\100\50" and T.gcage(debug.getuservalue(U)) == "\115\117\114\118\105\118\97\108")
101+collectgarbage("\115\116\101\112",0)
102+assert(T.gcage(U) == "\111\108\100" and T.gcage(debug.getuservalue(U)) == "\111\108\100\49")
94103assert(debug.getuservalue(U).x[1] == 234)
95−assert(collectgarbage("isrunning"))
96−assert(collectgarbage("isrunning"))
104+end
105+assert(collectgarbage("\105\115\114\117\110\110\105\110\103"))
106+assert(collectgarbage("\105\115\114\117\110\110\105\110\103"))
97107collectgarbage(oldmode)
98−print("OK")
108+print("\79\75")
zod/luau/res/lua/cycled/goto.lua+70−57
@@ -4,24 +4,17 @@ local function errmsg
44local st,msg = load(code)
55assert(not st and string.find(msg,m))
66end
7−errmsg(" goto l1; do ::l1:: end ","label 'l1'")
8−errmsg(" do ::l1:: end goto l1; ","label 'l1'")
9−errmsg(" ::l1:: ::l1:: ","label 'l1'")
10−errmsg(" ::l1:: do ::l1:: end","label 'l1'")
11−errmsg(" goto l1; local aa ::l1:: ::l2:: print(3) ","local 'aa'")
12−errmsg("do local bb, cc; goto l1; end
13−local aa
14−::l1:: print(3)
15−","local 'aa'")
16−errmsg(" do ::l1:: end goto l1 ","label 'l1'")
17−errmsg(" goto l1 do ::l1:: end ","label 'l1'")
18−errmsg(" repeat
19− if x then goto cont end
20− local xuxu = 10
21− ::cont::
22− until xuxu < x
23−","local 'xuxu'")
24−local x =
7+errmsg("\32\103\111\116\111\32\108\49\59\32\100\111\32\58\58\108\49\58\58\32\101\110\100\32","\108\97\98\101\108\32\39\108\49\39")
8+errmsg("\32\100\111\32\58\58\108\49\58\58\32\101\110\100\32\103\111\116\111\32\108\49\59\32","\108\97\98\101\108\32\39\108\49\39")
9+errmsg("\32\58\58\108\49\58\58\32\58\58\108\49\58\58\32","\108\97\98\101\108\32\39\108\49\39")
10+errmsg("\32\58\58\108\49\58\58\32\100\111\32\58\58\108\49\58\58\32\101\110\100","\108\97\98\101\108\32\39\108\49\39")
11+errmsg("\32\103\111\116\111\32\108\49\59\32\108\111\99\97\108\32\97\97\32\58\58\108\49\58\58\32\58\58\108\50\58\58\32\112\114\105\110\116\40\51\41\32","\108\111\99\97\108\32\39\97\97\39")
12+errmsg("\100\111\32\108\111\99\97\108\32\98\98\44\32\99\99\59\32\103\111\116\111\32\108\49\59\32\101\110\100\10\108\111\99\97\108\32\97\97\10\58\58\108\49\58\58\32\112\114\105\110\116\40\51\41\10","\108\111\99\97\108\32\39\97\97\39")
13+errmsg("\32\100\111\32\58\58\108\49\58\58\32\101\110\100\32\103\111\116\111\32\108\49\32","\108\97\98\101\108\32\39\108\49\39")
14+errmsg("\32\103\111\116\111\32\108\49\32\100\111\32\58\58\108\49\58\58\32\101\110\100\32","\108\97\98\101\108\32\39\108\49\39")
15+errmsg("\32\32\114\101\112\101\97\116\10\32\32\32\32\105\102\32\120\32\116\104\101\110\32\103\111\116\111\32\99\111\110\116\32\101\110\100\10\32\32\32\32\108\111\99\97\108\32\120\117\120\117\32\61\32\49\48\10\32\32\32\32\58\58\99\111\110\116\58\58\10\32\32\117\110\116\105\108\32\120\117\120\117\32\60\32\120\10","\108\111\99\97\108\32\39\120\117\120\117\39")
16+local x
17+do
2518local y = 12
2619goto l1
2720::l2::
@@ -32,26 +25,23 @@ goto l3
3225x=y
3326;
3427goto l2
28+end
3529::l3::
3630::l3_1::
3731assert(x == 13)
38−local prog = " do
39− local a = 1
40− goto l%sa; a = a + 1
41− ::l%sa:: a = a + 10
42− goto l%sb; a = a + 2
43− ::l%sb:: a = a + 20
44− return a
45− end
46− "
47−local label = string.rep("0123456789",40)
32+do
33+local prog = "\32\32\100\111\10\32\32\32\32\108\111\99\97\108\32\97\32\61\32\49\10\32\32\32\32\103\111\116\111\32\108\37\115\97\59\32\97\32\61\32\97\32\43\32\49\10\32\32\32\58\58\108\37\115\97\58\58\32\97\32\61\32\97\32\43\32\49\48\10\32\32\32\32\103\111\116\111\32\108\37\115\98\59\32\97\32\61\32\97\32\43\32\50\10\32\32\32\58\58\108\37\115\98\58\58\32\97\32\61\32\97\32\43\32\50\48\10\32\32\32\32\114\101\116\117\114\110\32\97\10\32\32\101\110\100\10\32\32"
34+local label = string.rep("\48\49\50\51\52\53\54\55\56\57",40)
4835prog=string.format(prog,label,label,label,label)
4936assert(assert(load(prog))() == 31)
37+end
38+do
5039goto l1
5140local a = 23
5241x=a
5342::l1::
5443;
44+end
5545while true do
5646goto l4
5747goto l1
@@ -61,13 +51,14 @@ local x = 45
6151;
6252;
6353;
54+end
6455::l4::
6556assert(x == 13)
6657if print then
6758goto l1
68−error("should not be here")
59+error("\115\104\111\117\108\100\32\110\111\116\32\98\101\32\104\101\114\101")
6960goto l2
70−local x =
61+local x
7162::l1::
7263;
7364::l2::
@@ -116,9 +107,10 @@ end
116107end
117108::l6::
118109foo()
119−local x =
110+do
111+local x
120112::L1::
121−local y =
113+local y
122114assert(y == nil)
123115y=true
124116if x == nil then
@@ -128,6 +120,8 @@ else
128120x=x + 1
129121end
130122assert(x == 2 and y == true)
123+end
124+do
131125local first = true
132126local a = false
133127if true then
@@ -141,6 +135,8 @@ goto loop
141135end
142136end
143137assert(a)
138+end
139+do
144140goto escape
145141::a::
146142goto a
@@ -148,32 +144,39 @@ goto a
148144goto c
149145::c::
150146goto b
147+end
151148::escape::
152−local debug = require("debug")
149+local debug = require("\100\101\98\117\103")
153150local function foo
154151()
155152local t = {}
153+do
156154local i = 1
157−local a,b,c,d =
158−t[1]=()
155+local a,b,c,d
156+t[1]=function ()
159157return a,b,c,d
160158end
161159::l1::
162−local b =
163−local c =
164−t[# t + 1]=()
160+local b
161+do
162+local c
163+t[# t + 1]=function ()
165164return a,b,c,d
166165end
167166if i > 2 then
168167goto l2
169168end
170−local d =
171−t[# t + 1]=()
169+do
170+local d
171+t[# t + 1]=function ()
172172return a,b,c,d
173173end
174174i=i + 1
175−local a =
175+local a
176176goto l1
177+end
178+end
179+end
177180::l2::
178181return t
179182end
@@ -210,14 +213,14 @@ local function testG
210213(a)
211214if a == 1 then
212215goto l1
213−error("should never be here!")
214−elseifa == 2 then
216+error("\115\104\111\117\108\100\32\110\101\118\101\114\32\98\101\32\104\101\114\101\33")
217+elseif a == 2 then
215218goto l2
216−elseifa == 3 then
219+elseif a == 3 then
217220goto l3
218−elseifa == 4 then
221+elseif a == 4 then
219222goto l1
220−error("should never be here!")
223+error("\115\104\111\117\108\100\32\110\101\118\101\114\32\98\101\32\104\101\114\101\33")
221224::l1::
222225a=a + 1
223226else
@@ -226,37 +229,47 @@ goto l4
226229a=a * 2
227230;
228231goto l4b
229−error("should never be here!")
232+error("\115\104\111\117\108\100\32\110\101\118\101\114\32\98\101\32\104\101\114\101\33")
230233::l4::
231234goto l4a
232−error("should never be here!")
235+error("\115\104\111\117\108\100\32\110\101\118\101\114\32\98\101\32\104\101\114\101\33")
233236::l4b::
234237end
238+do
235239return a
240+end
236241::l2::
237−return "2"
242+do
243+return "\50"
244+end
238245::l3::
239−return "3"
246+do
247+return "\51"
248+end
240249::l1::
241−return "1"
250+return "\49"
242251end
243−assert(testG(1) == "1")
244−assert(testG(2) == "2")
245−assert(testG(3) == "3")
252+assert(testG(1) == "\49")
253+assert(testG(2) == "\50")
254+assert(testG(3) == "\51")
246255assert(testG(4) == 5)
247256assert(testG(5) == 10)
248−local X =
257+do
258+local X
249259goto L1
250260::L2::
251261goto L3
252262::L1::
253−local a <close> = setmetatable({},{["__close"] = ()
263+do
264+local a <close> = setmetatable({},{["\95\95\99\108\111\115\101"] = function ()
254265X=true
255266end})
256267assert(X == nil)
257268if a then
258269goto L2
259270end
271+end
260272::L3::
261273assert(X == true)
262−print("OK")
274+end
275+print("\79\75")
zod/luau/res/lua/cycled/heavy.lua+53−59
@@ -1,15 +1,18 @@
11local function teststring
22()
3−print("creating a string too long")
4−local a = "x"
5−local st,msg = pcall(()
3+print("\99\114\101\97\116\105\110\103\32\97\32\115\116\114\105\110\103\32\116\111\111\32\108\111\110\103")
4+do
5+local a = "\120"
6+local st,msg = pcall(function ()
67while true do
78a=a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a .. a
8−print(string.format("string with %d bytes",# a))
9+print(string.format("\115\116\114\105\110\103\32\119\105\116\104\32\37\100\32\98\121\116\101\115",# a))
10+end
911end)
10−assert(not st and (string.find(msg,"string length overflow") or string.find(msg,"not enough memory")))
11−print("string length overflow with " .. # a * 100)
12−print("+")
12+assert(not st and (string.find(msg,"\115\116\114\105\110\103\32\108\101\110\103\116\104\32\111\118\101\114\102\108\111\119") or string.find(msg,"\110\111\116\32\101\110\111\117\103\104\32\109\101\109\111\114\121")))
13+print("\115\116\114\105\110\103\32\108\101\110\103\116\104\32\111\118\101\114\102\108\111\119\32\119\105\116\104\32" .. # a * 100)
14+end
15+print("\43")
1316end
1417local function loadrep
1518(x,what)
@@ -20,51 +23,46 @@ local function f
2023()
2124count=count + p
2225if count % (128 * p) == 0 then
23−io.stderr:write("(",count // 2 ^ 20," M)")
26+io.stderr:write("\40",count // 2 ^ 20,"\32\77\41")
2427end
2528return s
2629end
27−local st,msg = load(f,"=big")
28−print("
29−memory: ",collectgarbage("count") * 1024)
30−msg=string.match(msg,"^[^
31−]+")
32−print(string.format("total: 0x%x %s ('%s')",count,what,msg))
30+local st,msg = load(f,"\61\98\105\103")
31+print("\10\109\101\109\111\114\121\58\32",collectgarbage("\99\111\117\110\116") * 1024)
32+msg=string.match(msg,"\94\91\94\10\93\43")
33+print(string.format("\116\111\116\97\108\58\32\48\120\37\120\32\37\115\32\40\39\37\115\39\41",count,what,msg))
3334return st,msg
3435end
3536function controlstruct()
36−print("control structure too long")
37+print("\99\111\110\116\114\111\108\32\115\116\114\117\99\116\117\114\101\32\116\111\111\32\108\111\110\103")
3738local lim = ((1 << 24) - 2) // 3
38−local s = string.rep("a = a + 1
39−",lim)
40−s="while true do " .. s .. "end"
39+local s = string.rep("\97\32\61\32\97\32\43\32\49\10",lim)
40+s="\119\104\105\108\101\32\116\114\117\101\32\100\111\32" .. s .. "\101\110\100"
4141assert(load(s))
42−print("ok with " .. lim .. " lines")
42+print("\111\107\32\119\105\116\104\32" .. lim .. "\32\108\105\110\101\115")
4343lim=lim + 3
44−s=string.rep("a = a + 1
45−",lim)
46−s="while true do " .. s .. "end"
44+s=string.rep("\97\32\61\32\97\32\43\32\49\10",lim)
45+s="\119\104\105\108\101\32\116\114\117\101\32\100\111\32" .. s .. "\101\110\100"
4746local st,msg = load(s)
48−assert(not st and string.find(msg,"too long"))
47+assert(not st and string.find(msg,"\116\111\111\32\108\111\110\103"))
4948print(msg)
5049end
5150function manylines()
52−print("loading chunk with too many lines")
53−local st,msg = loadrep("
54−","lines")
55−assert(not st and string.find(msg,"too many lines"))
56−print("+")
51+print("\108\111\97\100\105\110\103\32\99\104\117\110\107\32\119\105\116\104\32\116\111\111\32\109\97\110\121\32\108\105\110\101\115")
52+local st,msg = loadrep("\10","\108\105\110\101\115")
53+assert(not st and string.find(msg,"\116\111\111\32\109\97\110\121\32\108\105\110\101\115"))
54+print("\43")
5755end
5856function hugeid()
59−print("loading chunk with huge identifier")
60−local st,msg = loadrep("a","chars")
61−assert(not st and (string.find(msg,"lexical element too long") or string.find(msg,"not enough memory")))
62−print("+")
57+print("\108\111\97\100\105\110\103\32\99\104\117\110\107\32\119\105\116\104\32\104\117\103\101\32\105\100\101\110\116\105\102\105\101\114")
58+local st,msg = loadrep("\97","\99\104\97\114\115")
59+assert(not st and (string.find(msg,"\108\101\120\105\99\97\108\32\101\108\101\109\101\110\116\32\116\111\111\32\108\111\110\103") or string.find(msg,"\110\111\116\32\101\110\111\117\103\104\32\109\101\109\111\114\121")))
60+print("\43")
6361end
6462function toomanyinst()
65−print("loading chunk with too many instructions")
66−local st,msg = loadrep("a = 10; ","instructions")
67−print("+")
63+print("\108\111\97\100\105\110\103\32\99\104\117\110\107\32\119\105\116\104\32\116\111\111\32\109\97\110\121\32\105\110\115\116\114\117\99\116\105\111\110\115")
64+local st,msg = loadrep("\97\32\61\32\49\48\59\32","\105\110\115\116\114\117\99\116\105\111\110\115")
65+print("\43")
6866end
6967local function loadrepfunc
7068(prefix,f)
@@ -76,57 +74,53 @@ if count == 0 then
7674return prefix
7775else
7876if count % (1048576) == 0 then
79−io.stderr:write("(",count // 2 ^ 20," M)")
77+io.stderr:write("\40",count // 2 ^ 20,"\32\77\41")
8078end
8179return f(count)
8280end
8381end
84−local st,msg = load(aux,"k")
85−print("
86−memory: ",collectgarbage("count") * 1024)
87−msg=string.match(msg,"^[^
88−]+")
89−print("expected error: ",msg)
82+local st,msg = load(aux,"\107")
83+print("\10\109\101\109\111\114\121\58\32",collectgarbage("\99\111\117\110\116") * 1024)
84+msg=string.match(msg,"\94\91\94\10\93\43")
85+print("\101\120\112\101\99\116\101\100\32\101\114\114\111\114\58\32",msg)
9086end
9187function toomanyconst()
92−print("loading function with too many constants")
93−loadrepfunc("function foo () return {0,",(n)
88+print("\108\111\97\100\105\110\103\32\102\117\110\99\116\105\111\110\32\119\105\116\104\32\116\111\111\32\109\97\110\121\32\99\111\110\115\116\97\110\116\115")
89+loadrepfunc("\102\117\110\99\116\105\111\110\32\102\111\111\32\40\41\32\114\101\116\117\114\110\32\123\48\44",function (n)
9490return string.char(34,((n // 128 ^ 0) & 127) + 128,((n // 128 ^ 1) & 127) + 128,((n // 128 ^ 2) & 127) + 128,((n // 128 ^ 3) & 127) + 128,((n // 128 ^ 4) & 127) + 128,34,44)
9591end)
9692end
9793function toomanystr()
9894local a = {}
99−local st,msg = pcall(()
95+local st,msg = pcall(function ()
10096for i = 1, math.huge
10197do
10298if i % (1048576) == 0 then
103−io.stderr:write("(",i // 2 ^ 20," M)")
99+io.stderr:write("\40",i // 2 ^ 20,"\32\77\41")
104100end
105−a[i]=string.pack("I",i)
101+a[i]=string.pack("\73",i)
106102end
107103end)
108104local size = # a
109−a=collectgarbage("count")
110−print("
111−memory:",a * 1024)
112−print("expected error:",msg)
113−print("size:",size)
105+a=collectgarbage("\99\111\117\110\116")
106+print("\10\109\101\109\111\114\121\58",a * 1024)
107+print("\101\120\112\101\99\116\101\100\32\101\114\114\111\114\58",msg)
108+print("\115\105\122\101\58",size)
114109end
115110function toomanyidx()
116111local a = {}
117−local st,msg = pcall(()
112+local st,msg = pcall(function ()
118113for i = 1, math.huge
119114do
120115if i % (1048576) == 0 then
121−io.stderr:write("(",i // 2 ^ 20," M)")
116+io.stderr:write("\40",i // 2 ^ 20,"\32\77\41")
122117end
123118a[i]=i
124119end
125120end)
126−print("
127−memory: ",collectgarbage("count") * 1024)
128−print("expected error: ",msg)
129−print("size:",# a)
121+print("\10\109\101\109\111\114\121\58\32",collectgarbage("\99\111\117\110\116") * 1024)
122+print("\101\120\112\101\99\116\101\100\32\101\114\114\111\114\58\32",msg)
123+print("\115\105\122\101\58",# a)
130124end
131125toomanyidx()
132−print("OK")
126+print("\79\75")
zod/luau/res/lua/cycled/literals.lua+128−240
@@ -1,199 +1,113 @@
1−print("testing scanner")
2−local debug = require("debug")
1+print("\116\101\115\116\105\110\103\32\115\99\97\110\110\101\114")
2+local debug = require("\100\101\98\117\103")
33local function dostring
44(x)
55return assert(load(x),"")()
66end
7−dostring("x = 'aa' ")
8−assert(x == "aa" and string.len(x) == 3)
7+dostring("\120\32\11\12\32\61\32\9\13\32\39\97\97\39\32\11\12\12")
8+assert(x == "\97\97" and string.len(x) == 3)
99_G.x=nil
10−assert("
11−"'\" == "
12−"'\")
13−assert(string.find("
14− ","^%c%c%c%c%c%c%c$"))
15−assert("c12" == "c12")
16−assert("cab" == "cab")
17−assert("c" == "c")
18−assert("c
19−" == "c
20−")
21−assert("alo" == "" .. "" .. "alo")
22−assert(10 .. 20 .. - 30 == "1020-30")
23−assert("<��" == "<��")
10+assert("\10\34\39\92" == "\10\34\39\92")
11+assert(string.find("\7\8\12\10\13\9\11","\94\37\99\37\99\37\99\37\99\37\99\37\99\37\99\36"))
12+assert("\99\49\50" == "\99\49\50")
13+assert("\99\97\98" == "\99\97\98")
14+assert("\99" == "\99")
15+assert("\99\10" == "\99\10")
16+assert("\97\108\111" == "" .. "" .. "\97\108\111")
17+assert(10 .. 20 .. - 30 == "\49\48\50\48\45\51\48")
18+assert("\5\16\31\60\255\232" == "\5\16\31\60\255\232")
2419local function lexstring
2520(x,y,n)
26−local f = assert(load("return " .. x .. ", require"debug".getinfo(1).currentline",""))
21+local f = assert(load("\114\101\116\117\114\110\32" .. x .. "\44\32\114\101\113\117\105\114\101\34\100\101\98\117\103\34\46\103\101\116\105\110\102\111\40\49\41\46\99\117\114\114\101\110\116\108\105\110\101",""))
2722local s,l = f()
2823assert(s == y and l == n)
2924end
30−lexstring("'abc\z
31− efg'","abcefg",2)
32−lexstring("'abc\z
33−
34−
35−'","abc",4)
36−lexstring("'\z
37−
38−'","",3)
39−lexstring("[[
40−alo
41−alo
42−
43−]]","alo
44−alo
45−
46−",5)
47−lexstring("[[
48−alo alo
49−
50−]]","alo
51−alo
52−
53−",5)
54−lexstring("[[
55−alo alo
56−]]","alo
57−alo
58−",4)
59−lexstring("[[ alo
60− alo
61−]]","alo
62−alo
63−",4)
64−lexstring("[[alo]
65−]alo]]","alo]
66−]alo",2)
67−assert("abcdefghi" == "abcdefghi")
25+lexstring("\39\97\98\99\92\122\32\32\10\32\32\32\101\102\103\39","\97\98\99\101\102\103",2)
26+lexstring("\39\97\98\99\92\122\32\32\10\10\10\39","\97\98\99",4)
27+lexstring("\39\92\122\32\32\10\9\12\11\10\39","",3)
28+lexstring("\91\91\10\97\108\111\10\97\108\111\10\10\93\93","\97\108\111\10\97\108\111\10\10",5)
29+lexstring("\91\91\10\97\108\111\13\97\108\111\10\10\93\93","\97\108\111\10\97\108\111\10\10",5)
30+lexstring("\91\91\10\97\108\111\13\97\108\111\13\10\93\93","\97\108\111\10\97\108\111\10",4)
31+lexstring("\91\91\13\97\108\111\10\13\97\108\111\13\10\93\93","\97\108\111\10\97\108\111\10",4)
32+lexstring("\91\91\97\108\111\93\10\93\97\108\111\93\93","\97\108\111\93\10\93\97\108\111",2)
33+assert("\97\98\99\100\101\102\103\104\105" == "\97\98\99\100\101\102\103\104\105")
6834assert("" == string.char(0,0,0,0))
69−assert("" == "")
70−assert("��" == "€߿")
71−assert("��" == "ࠀ￿")
72−assert("��" == "𐀀����")
73−assert(" ���" == "����������")
74−assert("���" == "������������")
35+assert("\127" == "\127")
36+assert("\128\255\7" == "\194\128\223\191")
37+assert("\0\8\255\255" == "\224\160\128\239\191\191")
38+assert("\0\0\1\255\255\31" == "\240\144\128\128\247\191\191\191")
39+assert("\0\0\32\255\255\255\3" == "\248\136\128\128\128\251\191\191\191\191")
40+assert("\0\0\0\4\255\255\255\127" == "\252\132\128\128\128\128\253\191\191\191\191\191")
7541local function lexerror
7642(s,err)
77−local st,msg = load("return " .. s,"")
78−if err ~= "<eof>" then
79−err=err .. "'"
80−end
81−assert(not st and string.find(msg,"near .-" .. err))
82−end
83−lexerror(""abc\x"","\x"")
84−lexerror(""abc\x","\x")
85−lexerror(""\x","\x")
86−lexerror(""\x5"","\x5"")
87−lexerror(""\x5","\x5")
88−lexerror(""\xr"","\xr")
89−lexerror(""\xr","\xr")
90−lexerror(""\x.","\x.")
91−lexerror(""\x8%"","\x8%%")
92−lexerror(""\xAG","\xAG")
93−lexerror(""\g"","\g")
94−lexerror(""\g","\g")
95−lexerror(""\."","\%.")
96−lexerror(""\999"","\999"")
97−lexerror(""xyz\300"","\300"")
98−lexerror("" \256"","\256"")
99−lexerror(""abc\u{100000000}"","abc\u{100000000")
100−lexerror(""abc\u11r"","abc\u1")
101−lexerror(""abc\u"","abc\u"")
102−lexerror(""abc\u{11r"","abc\u{11r")
103−lexerror(""abc\u{11"","abc\u{11"")
104−lexerror(""abc\u{11","abc\u{11")
105−lexerror(""abc\u{r"","abc\u{r")
106−lexerror("[=[alo]]","<eof>")
107−lexerror("[=[alo]=","<eof>")
108−lexerror("[=[alo]","<eof>")
109−lexerror("'alo","<eof>")
110−lexerror("'alo \z
111−
112−","<eof>")
113−lexerror("'alo \z","<eof>")
114−lexerror("'alo \98","<eof>")
43+local st,msg = load("\114\101\116\117\114\110\32" .. s,"")
44+if err ~= "\60\101\111\102\62" then
45+err=err .. "\39"
46+end
47+assert(not st and string.find(msg,"\110\101\97\114\32\46\45" .. err))
48+end
49+lexerror("\34\97\98\99\92\120\34","\92\120\34")
50+lexerror("\34\97\98\99\92\120","\92\120")
51+lexerror("\34\92\120","\92\120")
52+lexerror("\34\92\120\53\34","\92\120\53\34")
53+lexerror("\34\92\120\53","\92\120\53")
54+lexerror("\34\92\120\114\34","\92\120\114")
55+lexerror("\34\92\120\114","\92\120\114")
56+lexerror("\34\92\120\46","\92\120\46")
57+lexerror("\34\92\120\56\37\34","\92\120\56\37\37")
58+lexerror("\34\92\120\65\71","\92\120\65\71")
59+lexerror("\34\92\103\34","\92\103")
60+lexerror("\34\92\103","\92\103")
61+lexerror("\34\92\46\34","\92\37\46")
62+lexerror("\34\92\57\57\57\34","\92\57\57\57\34")
63+lexerror("\34\120\121\122\92\51\48\48\34","\92\51\48\48\34")
64+lexerror("\34\32\32\32\92\50\53\54\34","\92\50\53\54\34")
65+lexerror("\34\97\98\99\92\117\123\49\48\48\48\48\48\48\48\48\125\34","\97\98\99\92\117\123\49\48\48\48\48\48\48\48\48")
66+lexerror("\34\97\98\99\92\117\49\49\114\34","\97\98\99\92\117\49")
67+lexerror("\34\97\98\99\92\117\34","\97\98\99\92\117\34")
68+lexerror("\34\97\98\99\92\117\123\49\49\114\34","\97\98\99\92\117\123\49\49\114")
69+lexerror("\34\97\98\99\92\117\123\49\49\34","\97\98\99\92\117\123\49\49\34")
70+lexerror("\34\97\98\99\92\117\123\49\49","\97\98\99\92\117\123\49\49")
71+lexerror("\34\97\98\99\92\117\123\114\34","\97\98\99\92\117\123\114")
72+lexerror("\91\61\91\97\108\111\93\93","\60\101\111\102\62")
73+lexerror("\91\61\91\97\108\111\93\61","\60\101\111\102\62")
74+lexerror("\91\61\91\97\108\111\93","\60\101\111\102\62")
75+lexerror("\39\97\108\111","\60\101\111\102\62")
76+lexerror("\39\97\108\111\32\92\122\32\32\10\10","\60\101\111\102\62")
77+lexerror("\39\97\108\111\32\92\122","\60\101\111\102\62")
78+lexerror("\39\97\108\111\32\92\57\56","\60\101\111\102\62")
11579for i = 0, 255
11680do
11781local s = string.char(i)
118−assert(not string.find(s,"[a-zA-Z_]") == not load(s .. "=1",""))
119−assert(not string.find(s,"[a-zA-Z_0-9]") == not load("a" .. s .. "1 = 1",""))
82+assert(not string.find(s,"\91\97\45\122\65\45\90\95\93") == not load(s .. "\61\49",""))
83+assert(not string.find(s,"\91\97\45\122\65\45\90\95\48\45\57\93") == not load("\97" .. s .. "\49\32\61\32\49",""))
12084end
121−local var1 = string.rep("a",1.5e4) .. "1"
122−local var2 = string.rep("a",1.5e4) .. "2"
123−local prog = string.format(" %s = 5
124− %s = %s + 1
125− return function () return %s - %s end
126−",var1,var2,var1,var1,var2)
85+local var1 = string.rep("\97",15000) .. "\49"
86+local var2 = string.rep("\97",15000) .. "\50"
87+local prog = string.format("\32\32\37\115\32\61\32\53\10\32\32\37\115\32\61\32\37\115\32\43\32\49\10\32\32\114\101\116\117\114\110\32\102\117\110\99\116\105\111\110\32\40\41\32\114\101\116\117\114\110\32\37\115\32\45\32\37\115\32\101\110\100\10",var1,var2,var1,var1,var2)
12788local f = dostring(prog)
12889assert(_G[var1] == 5 and _G[var2] == 6 and f() == - 1)
12990_G[var1],_G[var2]=nil
130−print("+")
131−assert("
132− " == "
133− ")
134−assert("
135− $debug" == "
136− $debug")
137−assert(" [ " ~= " ] ")
138−local b = "001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789"
139−assert(string.len(b) == 960)
140−prog="print('+')
141−
142−local a1 = [["this is a 'string' with several 'quotes'"]]
143−local a2 = "'quotes'"
144−
145−assert(string.find(a1, a2) == 34)
146−print('+')
147−
148−a1 = [==[temp = [[an arbitrary value]]; ]==]
149−assert(load(a1))()
150−assert(temp == 'an arbitrary value')
151−_G.temp = nil
152−-- long strings --
153−local b = "001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789"
91+print("\43")
92+assert("\10\9" == "\10\9")
93+assert("\10\32\36\100\101\98\117\103" == "\10\32\36\100\101\98\117\103")
94+assert("\32\91\32" ~= "\32\93\32")
95+local b = "\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57"
15496assert(string.len(b) == 960)
155−print('+')
156−
157−local a = [[00123456789012345678901234567890123456789123456789012345678901234567890123456789
158−00123456789012345678901234567890123456789123456789012345678901234567890123456789
159−00123456789012345678901234567890123456789123456789012345678901234567890123456789
160−00123456789012345678901234567890123456789123456789012345678901234567890123456789
161−00123456789012345678901234567890123456789123456789012345678901234567890123456789
162−00123456789012345678901234567890123456789123456789012345678901234567890123456789
163−00123456789012345678901234567890123456789123456789012345678901234567890123456789
164−00123456789012345678901234567890123456789123456789012345678901234567890123456789
165−00123456789012345678901234567890123456789123456789012345678901234567890123456789
166−00123456789012345678901234567890123456789123456789012345678901234567890123456789
167−00123456789012345678901234567890123456789123456789012345678901234567890123456789
168−00123456789012345678901234567890123456789123456789012345678901234567890123456789
169−00123456789012345678901234567890123456789123456789012345678901234567890123456789
170−00123456789012345678901234567890123456789123456789012345678901234567890123456789
171−00123456789012345678901234567890123456789123456789012345678901234567890123456789
172−00123456789012345678901234567890123456789123456789012345678901234567890123456789
173−00123456789012345678901234567890123456789123456789012345678901234567890123456789
174−00123456789012345678901234567890123456789123456789012345678901234567890123456789
175−00123456789012345678901234567890123456789123456789012345678901234567890123456789
176−00123456789012345678901234567890123456789123456789012345678901234567890123456789
177−00123456789012345678901234567890123456789123456789012345678901234567890123456789
178−00123456789012345678901234567890123456789123456789012345678901234567890123456789
179−00123456789012345678901234567890123456789123456789012345678901234567890123456789
180−]]
181−assert(string.len(a) == 1863)
182−assert(string.sub(a, 1, 40) == string.sub(b, 1, 40))
183−x = 1
184−"
185−print("+")
97+prog="\112\114\105\110\116\40\39\43\39\41\10\10\108\111\99\97\108\32\97\49\32\61\32\91\91\34\116\104\105\115\32\105\115\32\97\32\39\115\116\114\105\110\103\39\32\119\105\116\104\32\115\101\118\101\114\97\108\32\39\113\117\111\116\101\115\39\34\93\93\10\108\111\99\97\108\32\97\50\32\61\32\34\39\113\117\111\116\101\115\39\34\10\10\97\115\115\101\114\116\40\115\116\114\105\110\103\46\102\105\110\100\40\97\49\44\32\97\50\41\32\61\61\32\51\52\41\10\112\114\105\110\116\40\39\43\39\41\10\10\97\49\32\61\32\91\61\61\91\116\101\109\112\32\61\32\91\91\97\110\32\97\114\98\105\116\114\97\114\121\32\118\97\108\117\101\93\93\59\32\93\61\61\93\10\97\115\115\101\114\116\40\108\111\97\100\40\97\49\41\41\40\41\10\97\115\115\101\114\116\40\116\101\109\112\32\61\61\32\39\97\110\32\97\114\98\105\116\114\97\114\121\32\118\97\108\117\101\39\41\10\95\71\46\116\101\109\112\32\61\32\110\105\108\10\45\45\32\108\111\110\103\32\115\116\114\105\110\103\115\32\45\45\10\108\111\99\97\108\32\98\32\61\32\34\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\34\10\97\115\115\101\114\116\40\115\116\114\105\110\103\46\108\101\110\40\98\41\32\61\61\32\57\54\48\41\10\112\114\105\110\116\40\39\43\39\41\10\10\108\111\99\97\108\32\97\32\61\32\91\91\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\10\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\10\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\10\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\10\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\10\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\10\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\10\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\10\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\10\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\10\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\10\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\10\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\10\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\10\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\10\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\10\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\10\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\10\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\10\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\10\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\10\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\10\48\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\10\93\93\10\97\115\115\101\114\116\40\115\116\114\105\110\103\46\108\101\110\40\97\41\32\61\61\32\49\56\54\51\41\10\97\115\115\101\114\116\40\115\116\114\105\110\103\46\115\117\98\40\97\44\32\49\44\32\52\48\41\32\61\61\32\115\116\114\105\110\103\46\115\117\98\40\98\44\32\49\44\32\52\48\41\41\10\120\32\61\32\49\10"
98+print("\43")
18699_G.x=nil
187100dostring(prog)
188101assert(x)
189102_G.x=nil
103+do
190104local function getadd
191105(s)
192−return string.format("%p",s)
106+return string.format("\37\112",s)
193107end
194−local s1 <const> = "01234567890123456789012345678901234567890123456789"
195−local s2 <const> = "01234567890123456789012345678901234567890123456789"
196−local s3 = "01234567890123456789012345678901234567890123456789"
108+local s1 <const> = "\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57"
109+local s2 <const> = "\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57"
110+local s3 = "\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57"
197111local function foo
198112()
199113return s1
@@ -204,52 +118,33 @@ return s3
204118end
205119local function foo2
206120()
207−return "01234567890123456789012345678901234567890123456789"
121+return "\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57"
208122end
209123local a1 = getadd(s1)
210124assert(a1 == getadd(s2))
211125assert(a1 == getadd(foo()))
212126assert(a1 == getadd(foo1()))
213127assert(a1 == getadd(foo2()))
214−local sd = "0123456789" .. "0123456789012345678901234567890123456789"
128+local sd = "\48\49\50\51\52\53\54\55\56\57" .. "\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57"
215129assert(sd == s1 and getadd(sd) ~= a1)
216−prog="local a = 1 -- a comment
217−local b = 2
218−
219−
220−x = [=[
221−hi
222−]=]
223−y = "\
224−hello\r\n\
225−"
226−return require"debug".getinfo(1).currentline
227−"
228−for _,n in pairs({"
229−"," ","
230− ","
231−"})
130+end
131+prog="\108\111\99\97\108\32\97\32\61\32\49\32\32\32\32\32\32\32\32\45\45\32\97\32\99\111\109\109\101\110\116\10\108\111\99\97\108\32\98\32\61\32\50\10\10\10\120\32\61\32\91\61\91\10\104\105\10\93\61\93\10\121\32\61\32\34\92\10\104\101\108\108\111\92\114\92\110\92\10\34\10\114\101\116\117\114\110\32\114\101\113\117\105\114\101\34\100\101\98\117\103\34\46\103\101\116\105\110\102\111\40\49\41\46\99\117\114\114\101\110\116\108\105\110\101\10"
132+for _,n in pairs({"\10","\13","\10\13","\13\10"})
232133do
233−local prog,nn = string.gsub(prog,"
234−",n)
134+local prog,nn = string.gsub(prog,"\10",n)
235135assert(dostring(prog) == nn)
236−assert(_G.x == "hi
237−" and _G.y == "
238−hello
239−
240−")
136+assert(_G.x == "\104\105\10" and _G.y == "\10\104\101\108\108\111\13\10\10")
241137end
242138_G.x,_G.y=nil
243−local a = "]="
244−assert(a == "]=")
245−a="[===[[=[]]=][====[]]===]==="
246−assert(a == "[===[[=[]]=][====[]]===]===")
247−a="[===[[=[]]=][====[]]===]==="
248−assert(a == "[===[[=[]]=][====[]]===]===")
249−a="]]]]]]]]"
250−assert(a == "]]]]]]]]")
251−local x = {"=","[","]","
252−"}
139+local a = "\93\61"
140+assert(a == "\93\61")
141+a="\91\61\61\61\91\91\61\91\93\93\61\93\91\61\61\61\61\91\93\93\61\61\61\93\61\61\61"
142+assert(a == "\91\61\61\61\91\91\61\91\93\93\61\93\91\61\61\61\61\91\93\93\61\61\61\93\61\61\61")
143+a="\91\61\61\61\91\91\61\91\93\93\61\93\91\61\61\61\61\91\93\93\61\61\61\93\61\61\61"
144+assert(a == "\91\61\61\61\91\91\61\91\93\93\61\93\91\61\61\61\61\91\93\93\61\61\61\93\61\61\61")
145+a="\93\93\93\93\93\93\93\93"
146+assert(a == "\93\93\93\93\93\93\93\93")
147+local x = {"\61","\91","\93","\10"}
253148local len = 4
254149local function gen
255150(c,n)
@@ -262,50 +157,43 @@ gen(c .. a,n - 1)
262157end
263158end
264159end
265−for s in coroutine.wrap(()
160+for s in coroutine.wrap(function ()
266161gen("",len)
267162end)
268163do
269−assert(s == load("return [====[
270−" .. s .. "]====]","")())
271−end
272−if os.setlocale("pt_BR") or os.setlocale("ptb") then
273−assert(tonumber("3,4") == 3.4 and tonumber("3.4") == 3.4)
274−assert(tonumber(" -.4 ") == - 0.4)
275−assert(tonumber(" +0x.41 ") == 0.25390625)
276−assert(not load("a = (3,4)"))
277−assert(assert(load("return 3.4"))() == 3.4)
278−assert(assert(load("return .4,3"))() == 0.4)
279−assert(assert(load("return 4."))() == 4)
280−assert(assert(load("return 4.+.5"))() == 4.5)
281−assert(" 0x.1 " + " 0x,1" + "-0X.1 " == 0.0625)
282−assert(not tonumber("inf") and not tonumber("NAN"))
283−assert(assert(load(string.format("return %q",4.51)))() == 4.51)
284−local a,b = load("return 4.5.")
285−assert(string.find(b,"'4%.5%.'"))
286−assert(os.setlocale("C"))
164+assert(s == load("\114\101\116\117\114\110\32\91\61\61\61\61\91\10" .. s .. "\93\61\61\61\61\93","")())
165+end
166+if os.setlocale("\112\116\95\66\82") or os.setlocale("\112\116\98") then
167+assert(tonumber("\51\44\52") == 3.4 and tonumber("\51\46\52") == 3.4)
168+assert(tonumber("\32\32\45\46\52\32\32") == - 0.4)
169+assert(tonumber("\32\32\43\48\120\46\52\49\32\32") == 0.25390625)
170+assert(not load("\97\32\61\32\40\51\44\52\41"))
171+assert(assert(load("\114\101\116\117\114\110\32\51\46\52"))() == 3.4)
172+assert(assert(load("\114\101\116\117\114\110\32\46\52\44\51"))() == 0.4)
173+assert(assert(load("\114\101\116\117\114\110\32\52\46"))() == 4.0)
174+assert(assert(load("\114\101\116\117\114\110\32\52\46\43\46\53"))() == 4.5)
175+assert("\32\48\120\46\49\32" + "\32\48\120\44\49" + "\45\48\88\46\49\9" == 0.0625)
176+assert(not tonumber("\105\110\102") and not tonumber("\78\65\78"))
177+assert(assert(load(string.format("\114\101\116\117\114\110\32\37\113",4.51)))() == 4.51)
178+local a,b = load("\114\101\116\117\114\110\32\52\46\53\46")
179+assert(string.find(b,"\39\52\37\46\53\37\46\39"))
180+assert(os.setlocale("\67"))
287181else
288−(Message or print)("
289− >>> pt_BR locale not available: skipping decimal point tests <<<
290−")
182+(Message or print)("\10\32\62\62\62\32\112\116\95\66\82\32\108\111\99\97\108\101\32\110\111\116\32\97\118\97\105\108\97\98\108\101\58\32\115\107\105\112\112\105\110\103\32\100\101\99\105\109\97\108\32\112\111\105\110\116\32\116\101\115\116\115\32\60\60\60\10")
291183end
292−local s = "a string with and
293− and
294− and
295− "
296−local c = string.format("return %q",s)
184+local s = "\97\32\115\116\114\105\110\103\32\119\105\116\104\32\13\32\97\110\100\32\10\32\97\110\100\32\13\10\32\97\110\100\32\10\13"
185+local c = string.format("\114\101\116\117\114\110\32\37\113",s)
297186assert(assert(load(c))() == s)
298−assert(not load("a = 'non-ending string"))
299−assert(not load("a = 'non-ending string
300−'"))
301−assert(not load("a = '\345'"))
302−assert(not load("a = [=x]"))
187+assert(not load("\97\32\61\32\39\110\111\110\45\101\110\100\105\110\103\32\115\116\114\105\110\103"))
188+assert(not load("\97\32\61\32\39\110\111\110\45\101\110\100\105\110\103\32\115\116\114\105\110\103\10\39"))
189+assert(not load("\97\32\61\32\39\92\51\52\53\39"))
190+assert(not load("\97\32\61\32\91\61\120\93"))
303191local function malformednum
304192(n,exp)
305−local s,msg = load("return " .. n)
193+local s,msg = load("\114\101\116\117\114\110\32" .. n)
306194assert(not s and string.find(msg,exp))
307195end
308−malformednum("0xe-","near <eof>")
309−malformednum("0xep-p","malformed number")
310−malformednum("1print()","malformed number")
311−print("OK")
196+malformednum("\48\120\101\45","\110\101\97\114\32\60\101\111\102\62")
197+malformednum("\48\120\101\112\45\112","\109\97\108\102\111\114\109\101\100\32\110\117\109\98\101\114")
198+malformednum("\49\112\114\105\110\116\40\41","\109\97\108\102\111\114\109\101\100\32\110\117\109\98\101\114")
199+print("\79\75")
zod/luau/res/lua/cycled/locals.lua+344−281
@@ -1,6 +1,6 @@
1−print("testing local variables and environments")
2−local debug = require("debug")
3−local tracegc = require("tracegc")
1+print("\116\101\115\116\105\110\103\32\108\111\99\97\108\32\118\97\114\105\97\98\108\101\115\32\97\110\100\32\101\110\118\105\114\111\110\109\101\110\116\115")
2+local debug = require("\100\101\98\117\103")
3+local tracegc = require("\116\114\97\99\101\103\99")
44local function f
55(x)
66x=nil
@@ -10,7 +10,7 @@ end
1010assert(f(10) == nil)
1111local function f
1212()
13−local x =
13+local x
1414;
1515return x
1616end
@@ -19,18 +19,23 @@ local function f
1919(x)
2020x=nil
2121;
22−local y =
22+local y
2323;
2424return x,y
2525end
2626assert(f(10) == nil and select(2,f(20)) == nil)
27+do
2728local i = 10
29+do
2830local i = 100
2931;
3032assert(i == 100)
31−local i = 1e3
33+end
34+do
35+local i = 1000
3236;
33−assert(i == 1e3)
37+assert(i == 1000)
38+end
3439assert(i == 10)
3540if i ~= 10 then
3641local i = 20
@@ -38,20 +43,21 @@ else
3843local i = 30
3944assert(i == 30)
4045end
46+end
4147f=nil
42−local f =
48+local f
4349local x = 1
4450a=nil
45−load("local a = {}")()
51+load("\108\111\99\97\108\32\97\32\61\32\123\125")()
4652assert(a == nil)
4753function f(a)
48−local _1,_2,_3,_4,_5 =
49−local _6,_7,_8,_9,_10 =
54+local _1,_2,_3,_4,_5
55+local _6,_7,_8,_9,_10
5056local x = 3
5157local b = a
5258local c,d = a,b
5359if (d == b) then
54−local x = "q"
60+local x = "\113"
5561x=b
5662assert(x == 2)
5763else
@@ -61,54 +67,52 @@ assert(x == 3)
6167local f = 10
6268end
6369local b = 10
64−local a =
70+local a
6571;
6672repeat
67−local b =
73+local b
6874;
6975a,b=1,2
7076;
7177assert(a + 1 == b)
72−;until a + b == 3
78+;
79+until a + b == 3
7380assert(x == 1)
7481f(2)
75−assert(type(f) == "function")
82+assert(type(f) == "\102\117\110\99\116\105\111\110")
7683local function getenv
7784(f)
7885local a,b = debug.getupvalue(f,1)
79−assert(a == "_ENV")
86+assert(a == "\95\69\78\86")
8087return b
8188end
82−assert(getenv(load("a=3")) == _G)
89+assert(getenv(load("\97\61\51")) == _G)
8390local c = {}
8491;
85−local f = load("a = 3",nil,nil,c)
92+local f = load("\97\32\61\32\51",nil,nil,c)
8693assert(getenv(f) == c)
8794assert(c.a == nil)
8895f()
8996assert(c.a == 3)
97+do
9098local i = 2
9199local p = 4
92100repeat
93101for j = - 3, 3
94102do
95−assert(load(string.format("local a=%s;
96− a=a+%s;
97− assert(a ==2^%s)",j,p - j,i),""))()
98−assert(load(string.format("local a=%s;
99− a=a-%s;
100− assert(a==-2^%s)",- j,p - j,i),""))()
101−assert(load(string.format("local a,b=0,%s;
102− a=b-%s;
103− assert(a==-2^%s)",- j,p - j,i),""))()
103+assert(load(string.format("\108\111\99\97\108\32\97\61\37\115\59\10\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\97\61\97\43\37\115\59\10\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\97\115\115\101\114\116\40\97\32\61\61\50\94\37\115\41",j,p - j,i),""))()
104+assert(load(string.format("\108\111\99\97\108\32\97\61\37\115\59\10\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\97\61\97\45\37\115\59\10\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\97\115\115\101\114\116\40\97\61\61\45\50\94\37\115\41",- j,p - j,i),""))()
105+assert(load(string.format("\108\111\99\97\108\32\97\44\98\61\48\44\37\115\59\10\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\97\61\98\45\37\115\59\10\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\97\115\115\101\114\116\40\97\61\61\45\50\94\37\115\41",- j,p - j,i),""))()
104106end
105107p=2 * p
106108;
107−i=i + 1until p <= 0
108−print("+")
109−if rawget(_G,"T") then
110−collectgarbage("stop")
111−local a = {[{}] = 4,[3] = 0,["alo"] = 1,["a1234567890123456789012345678901234567890"] = 10}
109+i=i + 1
110+until p <= 0
111+end
112+print("\43")
113+if rawget(_G,"\84") then
114+collectgarbage("\115\116\111\112")
115+local a = {[{}] = 4,[3] = 0,["\97\108\111"] = 1,["\97\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57\48"] = 10}
112116local t = T.querytab(a)
113117for k,_ in pairs(a)
114118do
@@ -118,7 +122,7 @@ collectgarbage()
118122for i = 0, t - 1
119123do
120124local k = querytab(a,i)
121−assert(k == nil or type(k) == "number" or k == "alo")
125+assert(k == nil or type(k) == "\110\117\109\98\101\114" or k == "\97\108\111")
122126end
123127local a = {}
124128local function additems
@@ -150,92 +154,106 @@ end
150154end
151155end
152156assert(_ENV == _G)
153−local dummy =
154−local _ENV = ((...)
157+do
158+local dummy
159+local _ENV = (function (...)
155160return ...
156161end)(_G,dummy)
157−local _ENV = {["assert"] = assert}
162+do
163+local _ENV = {["\97\115\115\101\114\116"] = assert}
158164;
159165assert(true)
160−local mt = {["_G"] = _G}
161−local foo,x =
166+end
167+local mt = {["\95\71"] = _G}
168+local foo,x
162169A=false
170+do
163171local _ENV = mt
164172function foo(x)
165173A=x
174+do
166175local _ENV = _G
167176;
168−A=1e3
169−return (x)
177+A=1000
178+end
179+return function (x)
170180return A .. x
171181end
172182end
183+end
173184assert(getenv(foo) == mt)
174−x=foo("hi")
185+x=foo("\104\105")
175186;
176−assert(mt.A == "hi" and A == 1e3)
177−assert(x("*") == mt.A .. "*")
178−local _ENV = {["assert"] = assert,["A"] = 10}
187+assert(mt.A == "\104\105" and A == 1000)
188+assert(x("\42") == mt.A .. "\42")
189+do
190+local _ENV = {["\97\115\115\101\114\116"] = assert,["\65"] = 10}
179191;
180−local _ENV = {["assert"] = assert,["A"] = 20}
192+do
193+local _ENV = {["\97\115\115\101\114\116"] = assert,["\65"] = 20}
181194;
182195assert(A == 20)
183196;
184197x=A
198+end
185199assert(A == 10 and x == 20)
200+end
186201assert(x == 20)
187202A=nil
203+do
188204local a <const>,b,c <const> = 10,20,30
189205b=a + c + b
190206assert(a == 10 and b == 60 and c == 30)
191207local function checkro
192208(name,code)
193209local st,msg = load(code)
194−local gab = string.format("attempt to assign to const variable '%s'",name)
210+local gab = string.format("\97\116\116\101\109\112\116\32\116\111\32\97\115\115\105\103\110\32\116\111\32\99\111\110\115\116\32\118\97\114\105\97\98\108\101\32\39\37\115\39",name)
195211assert(not st and string.find(msg,gab))
196212end
197−checkro("y","local x, y <const>, z = 10, 20, 30; x = 11; y = 12")
198−checkro("x","local x <const>, y, z <const> = 10, 20, 30; x = 11")
199−checkro("z","local x <const>, y, z <const> = 10, 20, 30; y = 10; z = 11")
200−checkro("foo","local foo <const> = 10; function foo() end")
201−checkro("foo","local foo <const> = {}; function foo() end")
202−checkro("z"," local a, z <const>, b = 10;
203− function foo() a = 20; z = 32; end
204− ")
205−checkro("var1"," local a, var1 <const> = 10;
206− function foo() a = 20; z = function () var1 = 12; end end
207− ")
208−print("testing to-be-closed variables")
213+checkro("\121","\108\111\99\97\108\32\120\44\32\121\32\60\99\111\110\115\116\62\44\32\122\32\61\32\49\48\44\32\50\48\44\32\51\48\59\32\120\32\61\32\49\49\59\32\121\32\61\32\49\50")
214+checkro("\120","\108\111\99\97\108\32\120\32\60\99\111\110\115\116\62\44\32\121\44\32\122\32\60\99\111\110\115\116\62\32\61\32\49\48\44\32\50\48\44\32\51\48\59\32\120\32\61\32\49\49")
215+checkro("\122","\108\111\99\97\108\32\120\32\60\99\111\110\115\116\62\44\32\121\44\32\122\32\60\99\111\110\115\116\62\32\61\32\49\48\44\32\50\48\44\32\51\48\59\32\121\32\61\32\49\48\59\32\122\32\61\32\49\49")
216+checkro("\102\111\111","\108\111\99\97\108\32\102\111\111\32\60\99\111\110\115\116\62\32\61\32\49\48\59\32\102\117\110\99\116\105\111\110\32\102\111\111\40\41\32\101\110\100")
217+checkro("\102\111\111","\108\111\99\97\108\32\102\111\111\32\60\99\111\110\115\116\62\32\61\32\123\125\59\32\102\117\110\99\116\105\111\110\32\102\111\111\40\41\32\101\110\100")
218+checkro("\122","\32\32\32\32\108\111\99\97\108\32\97\44\32\122\32\60\99\111\110\115\116\62\44\32\98\32\61\32\49\48\59\10\32\32\32\32\102\117\110\99\116\105\111\110\32\102\111\111\40\41\32\97\32\61\32\50\48\59\32\122\32\61\32\51\50\59\32\101\110\100\10\32\32")
219+checkro("\118\97\114\49","\32\32\32\32\108\111\99\97\108\32\97\44\32\118\97\114\49\32\60\99\111\110\115\116\62\32\61\32\49\48\59\10\32\32\32\32\102\117\110\99\116\105\111\110\32\102\111\111\40\41\32\97\32\61\32\50\48\59\32\122\32\61\32\102\117\110\99\116\105\111\110\32\40\41\32\118\97\114\49\32\61\32\49\50\59\32\101\110\100\32\32\101\110\100\10\32\32")
220+end
221+print("\116\101\115\116\105\110\103\32\116\111\45\98\101\45\99\108\111\115\101\100\32\118\97\114\105\97\98\108\101\115")
209222local function stack
210223(n)
211224n=((n == 0) or stack(n - 1))
212225end
213226local function func2close
214227(f,x,y)
215−local obj = setmetatable({},{["__close"] = f})
228+local obj = setmetatable({},{["\95\95\99\108\111\115\101"] = f})
216229if x then
217230return x,obj,y
218231else
219232return obj
220233end
221234end
235+do
222236local a = {}
237+do
223238local b <close> = false
224−local x <close> = setmetatable({"x"},{["__close"] = (self)
239+local x <close> = setmetatable({"\120"},{["\95\95\99\108\111\115\101"] = function (self)
225240a[# a + 1]=self[1]
226241end})
227−local w,y <close>,z = func2close((self,err)
242+local w,y <close>,z = func2close(function (self,err)
228243assert(err == nil)
229244;
230−a[# a + 1]="y"
245+a[# a + 1]="\121"
231246end,10,20)
232247local c <close> = nil
233−a[# a + 1]="in"
248+a[# a + 1]="\105\110"
234249assert(w == 10 and z == 20)
235−a[# a + 1]="out"
236−assert(a[1] == "in" and a[2] == "y" and a[3] == "x" and a[4] == "out")
250+end
251+a[# a + 1]="\111\117\116"
252+assert(a[1] == "\105\110" and a[2] == "\121" and a[3] == "\120" and a[4] == "\111\117\116")
253+end
254+do
237255local X = false
238−local x,closescope = func2close((_,msg)
256+local x,closescope = func2close(function (_,msg)
239257stack(10)
240258;
241259assert(msg == nil)
@@ -253,9 +271,9 @@ end
253271local a,b,c = foo(1.5)
254272assert(a == 1.5 and b == false and c == 23 and X == true)
255273X=false
256−foo=(x)
257−local _ <close> = func2close((_,msg)
258−assert(debug.getinfo(2).name == "foo")
274+foo=function (x)
275+local _ <close> = func2close(function (_,msg)
276+assert(debug.getinfo(2).name == "\102\111\111")
259277assert(msg == nil)
260278end)
261279local _ <close> = closescope
@@ -264,30 +282,36 @@ return y
264282end
265283assert(foo() == 15 and X == true)
266284X=false
267−foo=()
285+foo=function ()
268286local x <close> = closescope
269287return x
270288end
271289assert(foo() == closescope and X == true)
290+end
291+do
272292local flag = false
273−local x = setmetatable({},{["__close"] = ()
293+local x = setmetatable({},{["\95\95\99\108\111\115\101"] = function ()
274294assert(flag == false)
275295;
276296flag=true
277297end})
278298local y <const> = nil
279299local z <const> = nil
300+do
280301local a <close> = x
302+end
281303assert(flag)
304+end
305+do
282306local flag = false
283−local x = setmetatable({},{["__close"] = ()
307+local x = setmetatable({},{["\95\95\99\108\111\115\101"] = function ()
284308assert(flag == false)
285309;
286310flag=true
287311end})
288312local function a
289313()
290−return (()
314+return (function ()
291315return nil
292316end),nil,nil,x
293317end
@@ -301,10 +325,12 @@ do
301325a=k
302326end
303327assert(flag)
304−local X,Y =
328+end
329+do
330+local X,Y
305331local function foo
306332()
307−local _ <close> = func2close(()
333+local _ <close> = func2close(function ()
308334Y=10
309335end)
310336assert(X == true and Y == nil)
@@ -312,20 +338,24 @@ return 1,2,3
312338end
313339local function bar
314340()
315−local _ <close> = func2close(()
341+local _ <close> = func2close(function ()
316342X=false
317343end)
318344X=true
345+do
319346return foo()
320347end
348+end
321349local a,b,c,d = bar()
322350assert(a == 1 and b == 2 and c == 3 and X == false and Y == 10 and d == nil)
351+end
352+do
323353local closed = false
324354local function foo
325355()
326−return ()
356+return function ()
327357return true
328−end,0,0,func2close(()
358+end,0,0,func2close(function ()
329359closed=true
330360end)
331361end
@@ -342,8 +372,10 @@ end
342372end
343373assert(foo1() == false)
344374assert(closed == true)
375+end
376+do
345377local closed = false
346−local o1 = setmetatable({},{["__close"] = ()
378+local o1 = setmetatable({},{["\95\95\99\108\111\115\101"] = function ()
347379closed=true
348380end})
349381local function test
@@ -359,106 +391,112 @@ end
359391assert(closed)
360392end
361393test()
362−print("testing errors in __close")
394+end
395+do
396+print("\116\101\115\116\105\110\103\32\101\114\114\111\114\115\32\105\110\32\95\95\99\108\111\115\101")
363397local function foo
364398()
365−local x <close> = func2close((self,msg)
366−assert(string.find(msg,"@y"))
367−error("@x")
399+local x <close> = func2close(function (self,msg)
400+assert(string.find(msg,"\64\121"))
401+error("\64\120")
368402end)
369−local x1 <close> = func2close((self,msg)
370−assert(string.find(msg,"@y"))
403+local x1 <close> = func2close(function (self,msg)
404+assert(string.find(msg,"\64\121"))
371405end)
372−local gc <close> = func2close(()
406+local gc <close> = func2close(function ()
373407collectgarbage()
374408end)
375−local y <close> = func2close((self,msg)
376−assert(string.find(msg,"@z"))
377−error("@y")
409+local y <close> = func2close(function (self,msg)
410+assert(string.find(msg,"\64\122"))
411+error("\64\121")
378412end)
379−local z <close> = func2close((self,msg)
413+local z <close> = func2close(function (self,msg)
380414assert(msg == nil)
381−error("@z")
415+error("\64\122")
382416end)
383417return 200
384418end
385419local stat,msg = pcall(foo,false)
386−assert(string.find(msg,"@x"))
420+assert(string.find(msg,"\64\120"))
387421local function foo
388422()
389−local x <close> = func2close((self,msg)
390−assert(debug.getinfo(2).name == "pcall")
391−assert(string.find(msg,"@x1"))
423+local x <close> = func2close(function (self,msg)
424+assert(debug.getinfo(2).name == "\112\99\97\108\108")
425+assert(string.find(msg,"\64\120\49"))
392426end)
393−local x1 <close> = func2close((self,msg)
394−assert(debug.getinfo(2).name == "pcall")
395−assert(string.find(msg,"@y"))
396−error("@x1")
427+local x1 <close> = func2close(function (self,msg)
428+assert(debug.getinfo(2).name == "\112\99\97\108\108")
429+assert(string.find(msg,"\64\121"))
430+error("\64\120\49")
397431end)
398−local gc <close> = func2close(()
432+local gc <close> = func2close(function ()
399433collectgarbage()
400434end)
401−local y <close> = func2close((self,msg)
402−assert(debug.getinfo(2).name == "pcall")
403−assert(string.find(msg,"@z"))
404−error("@y")
435+local y <close> = func2close(function (self,msg)
436+assert(debug.getinfo(2).name == "\112\99\97\108\108")
437+assert(string.find(msg,"\64\122"))
438+error("\64\121")
405439end)
406440local first = true
407−local z <close> = func2close((self,msg)
408−assert(debug.getinfo(2).name == "pcall")
441+local z <close> = func2close(function (self,msg)
442+assert(debug.getinfo(2).name == "\112\99\97\108\108")
409443assert(first and msg == 4)
410444first=false
411−error("@z")
445+error("\64\122")
412446end)
413447error(4)
414448end
415449local stat,msg = pcall(foo,true)
416−assert(string.find(msg,"@x1"))
450+assert(string.find(msg,"\64\120\49"))
417451local function foo
418452(...)
419−local x1 <close> = func2close((self,msg)
420−assert(string.find(msg,"@X"))
421−error("@Y")
453+do
454+local x1 <close> = func2close(function (self,msg)
455+assert(string.find(msg,"\64\88"))
456+error("\64\89")
422457end)
423−local x123 <close> = func2close((_,msg)
458+local x123 <close> = func2close(function (_,msg)
424459assert(msg == nil)
425−error("@X")
460+error("\64\88")
426461end)
462+end
427463os.exit(false)
428464end
429465local st,msg = xpcall(foo,debug.traceback)
430−assert(string.match(msg,"^[^ ]* @Y"))
466+assert(string.match(msg,"\94\91\94\32\93\42\32\64\89"))
431467local function foo
432468(...)
433−local x123 <close> = func2close(()
434−error("@x123")
469+local x123 <close> = func2close(function ()
470+error("\64\120\49\50\51")
435471end)
436472end
437473local st,msg = xpcall(foo,debug.traceback)
438−assert(string.match(msg,"^[^ ]* @x123"))
439−assert(string.find(msg,"in metamethod 'close'"))
474+assert(string.match(msg,"\94\91\94\32\93\42\32\64\120\49\50\51"))
475+assert(string.find(msg,"\105\110\32\109\101\116\97\109\101\116\104\111\100\32\39\99\108\111\115\101\39"))
476+end
477+do
440478local function foo
441479()
442480local x <close> = {}
443481os.exit(false)
444482end
445483local stat,msg = pcall(foo)
446−assert(not stat and string.find(msg,"variable 'x' got a non%-closable value"))
484+assert(not stat and string.find(msg,"\118\97\114\105\97\98\108\101\32\39\120\39\32\103\111\116\32\97\32\110\111\110\37\45\99\108\111\115\97\98\108\101\32\118\97\108\117\101"))
447485local function foo
448486()
449−local xyz <close> = setmetatable({},{["__close"] = print})
487+local xyz <close> = setmetatable({},{["\95\95\99\108\111\115\101"] = print})
450488getmetatable(xyz).__close=nil
451489end
452490local stat,msg = pcall(foo)
453−assert(not stat and string.find(msg,"metamethod 'close'"))
491+assert(not stat and string.find(msg,"\109\101\116\97\109\101\116\104\111\100\32\39\99\108\111\115\101\39"))
454492local function foo
455493()
456−local a1 <close> = func2close((_,msg)
457−assert(string.find(msg,"number value"))
494+local a1 <close> = func2close(function (_,msg)
495+assert(string.find(msg,"\110\117\109\98\101\114\32\118\97\108\117\101"))
458496error(12)
459497end)
460−local a2 <close> = setmetatable({},{["__close"] = print})
461−local a3 <close> = func2close((_,msg)
498+local a2 <close> = setmetatable({},{["\95\95\99\108\111\115\101"] = print})
499+local a3 <close> = func2close(function (_,msg)
462500assert(msg == nil)
463501error(123)
464502end)
@@ -466,44 +504,47 @@ getmetatable(a2).__close=4
466504end
467505local stat,msg = pcall(foo)
468506assert(not stat and msg == 12)
507+end
508+do
469509local track = {}
470510local function foo
471511()
472−local x <close> = func2close(()
473−local xx <close> = func2close((_,msg)
512+local x <close> = func2close(function ()
513+local xx <close> = func2close(function (_,msg)
474514assert(msg == nil)
475−track[# track + 1]="xx"
515+track[# track + 1]="\120\120"
476516end)
477−track[# track + 1]="x"
517+track[# track + 1]="\120"
478518end)
479−track[# track + 1]="foo"
519+track[# track + 1]="\102\111\111"
480520return 20,30,40
481521end
482522local a,b,c,d = foo()
483523assert(a == 20 and b == 30 and c == 40 and d == nil)
484−assert(track[1] == "foo" and track[2] == "x" and track[3] == "xx")
524+assert(track[1] == "\102\111\111" and track[2] == "\120" and track[3] == "\120\120")
485525local track = {}
486526local function foo
487527()
488−local x0 <close> = func2close((_,msg)
528+local x0 <close> = func2close(function (_,msg)
489529assert(msg == 202)
490−track[# track + 1]="x0"
530+track[# track + 1]="\120\48"
491531end)
492−local x <close> = func2close(()
493−local xx <close> = func2close((_,msg)
532+local x <close> = func2close(function ()
533+local xx <close> = func2close(function (_,msg)
494534assert(msg == 101)
495−track[# track + 1]="xx"
535+track[# track + 1]="\120\120"
496536error(202)
497537end)
498−track[# track + 1]="x"
538+track[# track + 1]="\120"
499539error(101)
500540end)
501−track[# track + 1]="foo"
541+track[# track + 1]="\102\111\111"
502542return 20,30,40
503543end
504544local st,msg = pcall(foo)
505545assert(not st and msg == 202)
506−assert(track[1] == "foo" and track[2] == "x" and track[3] == "xx" and track[4] == "x0")
546+assert(track[1] == "\102\111\111" and track[2] == "\120" and track[3] == "\120\120" and track[4] == "\120\48")
547+end
507548local function checktable
508549(t1,t2)
509550assert(# t1 == # t2)
@@ -512,22 +553,23 @@ do
512553assert(t1[i] == t2[i])
513554end
514555end
556+do
515557local function overflow
516558(n)
517559overflow(n + 1)
518560end
519561local function errorh
520562(m)
521−assert(string.find(m,"stack overflow"))
522−local x <close> = func2close((o)
563+assert(string.find(m,"\115\116\97\99\107\32\111\118\101\114\102\108\111\119"))
564+local x <close> = func2close(function (o)
523565o[1]=10
524566end)
525567return x
526568end
527−local flag =
528−local st,obj =
529−local co = coroutine.wrap(()
530−local y <close> = func2close((obj,msg)
569+local flag
570+local st,obj
571+local co = coroutine.wrap(function ()
572+local y <close> = func2close(function (obj,msg)
531573assert(msg == nil)
532574obj[1]=100
533575flag=obj
@@ -538,7 +580,9 @@ tracegc.start()
538580end)
539581co()
540582assert(not st and obj[1] == 10 and flag[1] == 100)
541−if rawget(_G,"T") then
583+end
584+if rawget(_G,"\84") then
585+do
542586collectgarbage()
543587;
544588collectgarbage()
@@ -550,28 +594,29 @@ if n < 400 then
550594loop(n + 1)
551595end
552596end
553−local o = setmetatable({},{["__close"] = ()
597+local o = setmetatable({},{["\95\95\99\108\111\115\101"] = function ()
554598loop(0)
555599end})
556−local script = "toclose 2; settop 1; return 1"
600+local script = "\116\111\99\108\111\115\101\32\50\59\32\115\101\116\116\111\112\32\49\59\32\114\101\116\117\114\110\32\49"
557601assert(T.testC(script,o) == script)
602+end
558603local function foo
559604()
560−local y <close> = func2close(()
605+local y <close> = func2close(function ()
561606T.alloccount()
562607end)
563−local x <close> = setmetatable({},{["__close"] = ()
608+local x <close> = setmetatable({},{["\95\95\99\108\111\115\101"] = function ()
564609T.alloccount(0)
565610;
566611local x = {}
567612end})
568−error(1e3)
613+error(1000)
569614end
570615stack(5)
571616local _,msg = pcall(foo)
572−assert(msg == "not enough memory")
573−local closemsg =
574−local close = func2close((self,msg)
617+assert(msg == "\110\111\116\32\101\110\111\117\103\104\32\109\101\109\111\114\121")
618+local closemsg
619+local close = func2close(function (self,msg)
575620T.alloccount()
576621closemsg=msg
577622end)
@@ -588,39 +633,42 @@ local x <close> = enter(0)
588633local y = {}
589634end
590635local _,msg = pcall(test)
591−assert(msg == "not enough memory" and closemsg == "not enough memory")
636+assert(msg == "\110\111\116\32\101\110\111\117\103\104\32\109\101\109\111\114\121" and closemsg == "\110\111\116\32\101\110\111\117\103\104\32\109\101\109\111\114\121")
592637local function test
593638()
594−local xxx <close> = func2close((self,msg)
595−assert(msg == "not enough memory")
639+local xxx <close> = func2close(function (self,msg)
640+assert(msg == "\110\111\116\32\101\110\111\117\103\104\32\109\101\109\111\114\121")
596641;
597−error(1e3)
642+error(1000)
598643end)
599−local xx <close> = func2close((self,msg)
600−assert(msg == "not enough memory")
644+local xx <close> = func2close(function (self,msg)
645+assert(msg == "\110\111\116\32\101\110\111\117\103\104\32\109\101\109\111\114\121")
601646;
602647end)
603648local x <close> = enter(0)
604649local y = {}
605650end
606651local _,msg = pcall(test)
607−assert(msg == 1e3 and closemsg == "not enough memory")
652+assert(msg == 1000 and closemsg == "\110\111\116\32\101\110\111\117\103\104\32\109\101\109\111\114\121")
653+do
608654collectgarbage()
609−local s = string.rep("a",1e4)
655+local s = string.rep("\97",10000)
610656local m = T.totalmem()
611−collectgarbage("stop")
657+collectgarbage("\115\116\111\112")
612658s=string.upper(s)
613−assert(T.totalmem() - m <= 1.1e4)
614−collectgarbage("restart")
615−local lim = 1e4
616−local extra = 2e3
617−local s = string.rep("a",lim)
659+assert(T.totalmem() - m <= 11000)
660+collectgarbage("\114\101\115\116\97\114\116")
661+end
662+do
663+local lim = 10000
664+local extra = 2000
665+local s = string.rep("\97",lim)
618666local a = {s,s}
619667collectgarbage()
620668;
621669collectgarbage()
622670local m = T.totalmem()
623−collectgarbage("stop")
671+collectgarbage("\115\116\111\112")
624672T.totalmem(m + extra)
625673assert(not pcall(table.concat,a))
626674assert(T.totalmem() - m <= extra)
@@ -633,82 +681,87 @@ assert(T.totalmem() - m <= extra)
633681T.totalmem(m + 4 * lim + extra)
634682assert(# table.concat(a) == 2 * lim)
635683T.totalmem(0)
636−collectgarbage("restart")
637−print("+")
684+collectgarbage("\114\101\115\116\97\114\116")
685+print("\43")
686+end
687+do
638688local trace = {}
639689local function hook
640690(event)
641−trace[# trace + 1]=event .. " " .. (debug.getinfo(2).name or "?")
691+trace[# trace + 1]=event .. "\32" .. (debug.getinfo(2).name or "\63")
642692end
643−local x = func2close((_,msg)
644−trace[# trace + 1]="x"
693+local x = func2close(function (_,msg)
694+trace[# trace + 1]="\120"
645695end)
646−local y = func2close((_,msg)
647−trace[# trace + 1]="y"
696+local y = func2close(function (_,msg)
697+trace[# trace + 1]="\121"
648698end)
649−debug.sethook(hook,"r")
650−local t = {T.testC(" toclose 2 # x
651− pushnum 10
652− pushint 20
653− toclose 3 # y
654− return 2
655− ",x,y)}
699+debug.sethook(hook,"\114")
700+local t = {T.testC("\32\32\32\32\32\32\32\116\111\99\108\111\115\101\32\50\32\32\32\32\32\32\35\32\120\10\32\32\32\32\32\32\32\112\117\115\104\110\117\109\32\49\48\10\32\32\32\32\32\32\32\112\117\115\104\105\110\116\32\50\48\10\32\32\32\32\32\32\32\116\111\99\108\111\115\101\32\51\32\32\32\32\32\32\35\32\121\10\32\32\32\32\32\32\32\114\101\116\117\114\110\32\50\10\32\32\32\32",x,y)}
656701debug.sethook()
657−checktable(trace,{"return sethook","y","return ?","x","return ?","return testC"})
702+checktable(trace,{"\114\101\116\117\114\110\32\115\101\116\104\111\111\107","\121","\114\101\116\117\114\110\32\63","\120","\114\101\116\117\114\110\32\63","\114\101\116\117\114\110\32\116\101\115\116\67"})
658703checktable(t,{10,20})
659704end
705+end
706+do
660707local trace = {}
661708local function hook
662709(event)
663−trace[# trace + 1]=event .. " " .. debug.getinfo(2).name
710+trace[# trace + 1]=event .. "\32" .. debug.getinfo(2).name
664711end
665712local function foo
666713(...)
667−local x <close> = func2close((_,msg)
668−trace[# trace + 1]="x"
714+local x <close> = func2close(function (_,msg)
715+trace[# trace + 1]="\120"
669716end)
670−local y <close> = func2close((_,msg)
671−debug.sethook(hook,"r")
717+local y <close> = func2close(function (_,msg)
718+debug.sethook(hook,"\114")
672719end)
673720return ...
674721end
675722local t = {foo(10,20,30)}
676723debug.sethook()
677724checktable(t,{10,20,30})
678−checktable(trace,{"return sethook","return close","x","return close","return foo"})
679−print("to-be-closed variables in coroutines")
725+checktable(trace,{"\114\101\116\117\114\110\32\115\101\116\104\111\111\107","\114\101\116\117\114\110\32\99\108\111\115\101","\120","\114\101\116\117\114\110\32\99\108\111\115\101","\114\101\116\117\114\110\32\102\111\111"})
726+end
727+print("\116\111\45\98\101\45\99\108\111\115\101\100\32\118\97\114\105\97\98\108\101\115\32\105\110\32\99\111\114\111\117\116\105\110\101\115")
728+do
680729local trace = {}
681−local co = coroutine.wrap(()
682−trace[# trace + 1]="nowX"
683−local x <close> = func2close((_,msg)
730+local co = coroutine.wrap(function ()
731+trace[# trace + 1]="\110\111\119\88"
732+local x <close> = func2close(function (_,msg)
684733assert(msg == nil)
685−trace[# trace + 1]="x1"
686−coroutine.yield("x")
687−trace[# trace + 1]="x2"
734+trace[# trace + 1]="\120\49"
735+coroutine.yield("\120")
736+trace[# trace + 1]="\120\50"
688737end)
689−return pcall(()
690−local z <close> = func2close((_,msg)
738+return pcall(function ()
739+do
740+local z <close> = func2close(function (_,msg)
691741assert(msg == nil)
692−trace[# trace + 1]="z1"
693−coroutine.yield("z")
694−trace[# trace + 1]="z2"
742+trace[# trace + 1]="\122\49"
743+coroutine.yield("\122")
744+trace[# trace + 1]="\122\50"
695745end)
696−trace[# trace + 1]="nowY"
697−local y <close> = func2close((_,msg)
746+end
747+trace[# trace + 1]="\110\111\119\89"
748+local y <close> = func2close(function (_,msg)
698749assert(msg == nil)
699−trace[# trace + 1]="y1"
700−coroutine.yield("y")
701−trace[# trace + 1]="y2"
750+trace[# trace + 1]="\121\49"
751+coroutine.yield("\121")
752+trace[# trace + 1]="\121\50"
702753end)
703754return 10,20,30
704755end)
705756end)
706−assert(co() == "z")
707−assert(co() == "y")
708−assert(co() == "x")
757+assert(co() == "\122")
758+assert(co() == "\121")
759+assert(co() == "\120")
709760checktable({co()},{true,10,20,30})
710−checktable(trace,{"nowX","z1","z2","nowY","y1","y2","x1","x2"})
711−local extrares =
761+checktable(trace,{"\110\111\119\88","\122\49","\122\50","\110\111\119\89","\121\49","\121\50","\120\49","\120\50"})
762+end
763+do
764+local extrares
712765local function check
713766(body,extra, ...)
714767local t = table.pack(...)
@@ -722,7 +775,7 @@ local res2 = table.pack(co())
722775assert(res2.n == t.n)
723776for i = 1, # t
724777do
725−if t[i] == "x" then
778+if t[i] == "\120" then
726779assert(res2[i] == res[1])
727780else
728781assert(res2[i] == t[i])
@@ -732,14 +785,14 @@ end
732785local function foo
733786()
734787local x <close> = func2close(coroutine.yield)
735−local extra <close> = func2close((self)
788+local extra <close> = func2close(function (self)
736789assert(self == extrares)
737790coroutine.yield(100)
738791end)
739792extrares=extra
740793return table.unpack({10,x,30})
741794end
742−check(foo,true,10,"x",30)
795+check(foo,true,10,"\120",30)
743796assert(extrares == 100)
744797local function foo
745798()
@@ -753,7 +806,7 @@ local x <close> = func2close(coroutine.yield)
753806local y,z = 20,30
754807return x
755808end
756−check(foo,false,"x")
809+check(foo,false,"\120")
757810local function foo
758811()
759812local x <close> = func2close(coroutine.yield)
@@ -761,24 +814,26 @@ local extra <close> = func2close(coroutine.yield)
761814return table.unpack({},1,100)
762815end
763816check(foo,true,table.unpack({},1,100))
764−local co = coroutine.wrap(()
817+end
818+do
819+local co = coroutine.wrap(function ()
765820local function foo
766821(err)
767−local z <close> = func2close((_,msg)
822+local z <close> = func2close(function (_,msg)
768823assert(msg == nil or msg == err + 20)
769−coroutine.yield("z")
824+coroutine.yield("\122")
770825return 100,200
771826end)
772−local y <close> = func2close((_,msg)
827+local y <close> = func2close(function (_,msg)
773828assert(msg == err or (msg == nil and err == 1))
774−coroutine.yield("y")
829+coroutine.yield("\121")
775830if err then
776831error(err + 20)
777832end
778833end)
779−local x <close> = func2close((_,msg)
834+local x <close> = func2close(function (_,msg)
780835assert(msg == err or (msg == nil and err == 1))
781−coroutine.yield("x")
836+coroutine.yield("\120")
782837return 100,200
783838end)
784839if err == 10 then
@@ -792,39 +847,43 @@ coroutine.yield(pcall(foo,1))
792847return pcall(foo,10)
793848end)
794849local a,b = co()
795−assert(a == "x" and b == nil)
850+assert(a == "\120" and b == nil)
796851a,b=co()
797−assert(a == "y" and b == nil)
852+assert(a == "\121" and b == nil)
798853a,b=co()
799−assert(a == "z" and b == nil)
854+assert(a == "\122" and b == nil)
800855local a,b,c = co()
801856assert(a and b == 10 and c == 20)
802857local a,b = co()
803−assert(a == "x" and b == nil)
858+assert(a == "\120" and b == nil)
804859a,b=co()
805−assert(a == "y" and b == nil)
860+assert(a == "\121" and b == nil)
806861a,b=co()
807−assert(a == "z" and b == nil)
862+assert(a == "\122" and b == nil)
808863local st,msg = co()
809864assert(not st and msg == 21)
810865local a,b = co()
811−assert(a == "x" and b == nil)
866+assert(a == "\120" and b == nil)
812867a,b=co()
813−assert(a == "y" and b == nil)
868+assert(a == "\121" and b == nil)
814869a,b=co()
815−assert(a == "z" and b == nil)
870+assert(a == "\122" and b == nil)
816871local st,msg = co()
817872assert(not st and msg == 10 + 20)
873+end
874+do
818875local x = false
819876local y = false
820−local co = coroutine.wrap(()
821−local xv <close> = func2close(()
877+local co = coroutine.wrap(function ()
878+local xv <close> = func2close(function ()
822879x=true
823880end)
824−local yv <close> = func2close(()
881+do
882+local yv <close> = func2close(function ()
825883y=true
826884end)
827885coroutine.yield(100)
886+end
828887coroutine.yield(200)
829888error(23)
830889end)
@@ -834,18 +893,20 @@ b=co()
834893assert(b == 200 and not x and y)
835894local a,b = pcall(co)
836895assert(not a and b == 23 and x and y)
896+end
897+do
837898local x = 0
838−local co = coroutine.wrap(()
839−local xx <close> = func2close((_,msg)
899+local co = coroutine.wrap(function ()
900+local xx <close> = func2close(function (_,msg)
840901x=x + 1
841902;
842−assert(string.find(msg,"@XXX"))
843−error("@YYY")
903+assert(string.find(msg,"\64\88\88\88"))
904+error("\64\89\89\89")
844905end)
845−local xv <close> = func2close(()
906+local xv <close> = func2close(function ()
846907x=x + 1
847908;
848−error("@XXX")
909+error("\64\88\88\88")
849910end)
850911coroutine.yield(100)
851912error(200)
@@ -856,20 +917,20 @@ assert(x == 0)
856917local st,msg = pcall(co)
857918;
858919assert(x == 2)
859−assert(not st and string.find(msg,"@YYY"))
920+assert(not st and string.find(msg,"\64\89\89\89"))
860921local x = 0
861922local y = 0
862−co=coroutine.wrap(()
863−local xx <close> = func2close((_,err)
923+co=coroutine.wrap(function ()
924+local xx <close> = func2close(function (_,err)
864925y=y + 1
865926;
866−assert(string.find(err,"XXX"))
867−error("YYY")
927+assert(string.find(err,"\88\88\88"))
928+error("\89\89\89")
868929end)
869−local xv <close> = func2close(()
930+local xv <close> = func2close(function ()
870931x=x + 1
871932;
872−error("XXX")
933+error("\88\88\88")
873934end)
874935coroutine.yield(100)
875936return 200
@@ -879,10 +940,11 @@ assert(co() == 100)
879940assert(x == 0)
880941local st,msg = pcall(co)
881942assert(x == 1 and y == 1)
882−assert(not st and string.find(msg,"%w+%.%w+:%d+: YYY"))
883−local co =
884−co=coroutine.wrap(()
885−local x <close> = func2close(()
943+assert(not st and string.find(msg,"\37\119\43\37\46\37\119\43\58\37\100\43\58\32\89\89\89"))
944+end
945+local co
946+co=coroutine.wrap(function ()
947+local x <close> = func2close(function ()
886948os.exit(false)
887949end)
888950co=nil
@@ -891,15 +953,13 @@ end)
891953co()
892954assert(co == nil)
893955collectgarbage()
894−if rawget(_G,"T") then
895−print("to-be-closed variables x coroutines in C")
956+if rawget(_G,"\84") then
957+print("\116\111\45\98\101\45\99\108\111\115\101\100\32\118\97\114\105\97\98\108\101\115\32\120\32\99\111\114\111\117\116\105\110\101\115\32\105\110\32\67")
958+do
896959local token = 0
897960local count = 0
898−local f = T.makeCfunc(" toclose 1
899− toclose 2
900− return .
901− ")
902−local obj = func2close((_,msg)
961+local f = T.makeCfunc("\32\32\32\32\32\32\116\111\99\108\111\115\101\32\49\10\32\32\32\32\32\32\116\111\99\108\111\115\101\32\50\10\32\32\32\32\32\32\114\101\116\117\114\110\32\46\10\32\32\32\32")
962+local obj = func2close(function (_,msg)
903963count=count + 1
904964token=coroutine.yield(count,token)
905965end)
@@ -911,47 +971,48 @@ assert(ct == 2 and res == 100)
911971res={co(200)}
912972assert(res[1] == 10 and res[2] == 20 and res[3] == 30 and res[4] == nil)
913973assert(token == 200)
914−local f = T.makeCfunc(" toclose 1
915− return .
916− ")
917−local obj = func2close(()
918−local temp =
919−local x <close> = func2close(()
974+end
975+do
976+local f = T.makeCfunc("\32\32\32\32\32\32\116\111\99\108\111\115\101\32\49\10\32\32\32\32\32\32\114\101\116\117\114\110\32\46\10\32\32\32\32")
977+local obj = func2close(function ()
978+local temp
979+local x <close> = func2close(function ()
920980coroutine.yield(temp)
921981return 1,2,3
922982end)
923−temp=coroutine.yield("closing obj")
983+temp=coroutine.yield("\99\108\111\115\105\110\103\32\111\98\106")
924984return 1,2,3
925985end)
926986local co = coroutine.wrap(f)
927987local res = co(obj,10,30,1)
928−assert(res == "closing obj")
929−res=co("closing x")
930−assert(res == "closing x")
988+assert(res == "\99\108\111\115\105\110\103\32\111\98\106")
989+res=co("\99\108\111\115\105\110\103\32\120")
990+assert(res == "\99\108\111\115\105\110\103\32\120")
931991res={co()}
932992assert(res[1] == 30 and res[2] == nil)
933−local f = T.makeCfunc(" toclose 1
934− closeslot 1
935− ")
993+end
994+do
995+local f = T.makeCfunc("\32\32\32\32\32\32\116\111\99\108\111\115\101\32\49\10\32\32\32\32\32\32\99\108\111\115\101\115\108\111\116\32\49\10\32\32\32\32")
936996local obj = func2close(coroutine.yield)
937997local co = coroutine.create(f)
938998local st,msg = coroutine.resume(co,obj)
939−assert(not st and string.find(msg,"attempt to yield across"))
940−local f = T.makeCfunc(" toclose 1
941− ")
999+assert(not st and string.find(msg,"\97\116\116\101\109\112\116\32\116\111\32\121\105\101\108\100\32\97\99\114\111\115\115"))
1000+local f = T.makeCfunc("\32\32\32\32\32\32\116\111\99\108\111\115\101\32\49\10\32\32\32\32")
9421001local st,msg = pcall(f,obj)
943−assert(not st and string.find(msg,"attempt to yield from outside"))
1002+assert(not st and string.find(msg,"\97\116\116\101\109\112\116\32\116\111\32\121\105\101\108\100\32\102\114\111\109\32\111\117\116\115\105\100\101"))
1003+end
9441004end
1005+do
9451006local numopen = 0
9461007local function open
9471008(x)
9481009numopen=numopen + 1
949−return ()
1010+return function ()
9501011x=x - 1
9511012if x > 0 then
9521013return x
9531014end
954−end,nil,nil,func2close(()
1015+end,nil,nil,func2close(function ()
9551016numopen=numopen - 1
9561017end)
9571018end
@@ -983,5 +1044,7 @@ end
9831044end
9841045::endloop::
9851046assert(s == 375 and numopen == 0)
986−print("OK")
987−return 5,f
1047+end
1048+print("\79\75")
1049+return 5,f
1050+end
zod/luau/res/lua/cycled/main.lua+211−346
@@ -1,20 +1,23 @@
11if _port then
22return
33end
4−print("testing stand-alone interpreter")
4+print("\116\101\115\116\105\110\103\32\115\116\97\110\100\45\97\108\111\110\101\32\105\110\116\101\114\112\114\101\116\101\114")
55assert(os.execute())
66local arg = arg or ARG
77local prog = os.tmpname()
88local otherprog = os.tmpname()
99local out = os.tmpname()
10−local progname =
10+local progname
11+do
1112local i = 0
1213while arg[i] do
1314i=i - 1
15+end
1416progname=arg[i + 1]
15−print("progname: " .. progname)
16−local prepfile = (s,mod,p)
17−mod=mod and "wb" or "w"
17+end
18+print("\112\114\111\103\110\97\109\101\58\32" .. progname)
19+local prepfile = function (s,mod,p)
20+mod=mod and "\119\98" or "\119"
1821p=p or prog
1922local f = io.open(p,mod)
2023f:write(s)
@@ -23,18 +26,16 @@ end
2326local function getoutput
2427()
2528local f = io.open(out)
26−local t = f:read("a")
29+local t = f:read("\97")
2730f:close()
2831assert(os.remove(out))
2932return t
3033end
3134local function checkprogout
3235(s)
33−assert(string.sub(s,- 1) == "
34−")
36+assert(string.sub(s,- 1) == "\10")
3537local t = getoutput()
36−for line in string.gmatch(s,".-
37−")
38+for line in string.gmatch(s,"\46\45\10")
3839do
3940assert(string.find(t,line,1,true))
4041end
@@ -43,396 +44,259 @@ local function checkout
4344(s)
4445local t = getoutput()
4546if s ~= t then
46−print(string.format("'%s' - '%s'
47−",s,t))
47+print(string.format("\39\37\115\39\32\45\32\39\37\115\39\10",s,t))
4848end
4949assert(s == t)
5050return t
5151end
5252local function RUN
5353(p, ...)
54−p=string.gsub(p,"lua",""" .. progname .. """,1)
54+p=string.gsub(p,"\108\117\97","\34" .. progname .. "\34",1)
5555local s = string.format(p,...)
5656assert(os.execute(s))
5757end
5858local function NoRun
5959(msg,p, ...)
60−p=string.gsub(p,"lua",""" .. progname .. """,1)
60+p=string.gsub(p,"\108\117\97","\34" .. progname .. "\34",1)
6161local s = string.format(p,...)
62−s=string.format("%s >%s 2>&1",s,out)
62+s=string.format("\37\115\32\62\37\115\32\50\62\38\49",s,out)
6363assert(not os.execute(s))
6464assert(string.find(getoutput(),msg,1,true))
6565end
66−RUN("lua -v")
67−print(string.format("(temporary program file used in these tests: %s)",prog))
66+RUN("\108\117\97\32\45\118")
67+print(string.format("\40\116\101\109\112\111\114\97\114\121\32\112\114\111\103\114\97\109\32\102\105\108\101\32\117\115\101\100\32\105\110\32\116\104\101\115\101\32\116\101\115\116\115\58\32\37\115\41",prog))
6868prepfile("")
69−RUN("lua - < %s > %s",prog,out)
69+RUN("\108\117\97\32\45\32\60\32\37\115\32\62\32\37\115",prog,out)
7070checkout("")
71−prepfile(" print(
72−1, a
73−)
74−")
75−RUN("lua - < %s > %s",prog,out)
76−checkout("1 nil
77−")
78−RUN("echo "print(10)
79−print(2)
80−" | lua > %s",out)
81−checkout("10
82−2
83−")
84−prepfile("")
85−RUN("lua %s > %s",prog,out)
71+prepfile("\32\32\112\114\105\110\116\40\10\49\44\32\97\10\41\10")
72+RUN("\108\117\97\32\45\32\60\32\37\115\32\62\32\37\115",prog,out)
73+checkout("\49\9\110\105\108\10")
74+RUN("\101\99\104\111\32\34\112\114\105\110\116\40\49\48\41\10\112\114\105\110\116\40\50\41\10\34\32\124\32\108\117\97\32\62\32\37\115",out)
75+checkout("\49\48\10\50\10")
76+prepfile("\239\187\191")
77+RUN("\108\117\97\32\37\115\32\62\32\37\115",prog,out)
8678checkout("")
87−prepfile("print(3)")
88−RUN("lua %s > %s",prog,out)
89−checkout("3
90−")
91−prepfile("# comment!!
92−print(3)")
93−RUN("lua %s > %s",prog,out)
94−checkout("3
95−")
96−prepfile("�",true)
97−NoRun("unexpected symbol","lua %s",prog)
98−prepfile("�",true)
99−NoRun("unexpected symbol","lua %s",prog)
100−prepfile("�print(3)",true)
101−NoRun("unexpected symbol","lua %s",prog)
102−prepfile("�print(3)",true)
103−NoRun("unexpected symbol","lua %s",prog)
104−RUN("echo "print(arg[1])" | lua - -h > %s",out)
105−checkout("-h
106−")
107−prepfile("print(package.path)")
108−RUN("env LUA_INIT= LUA_PATH=x lua %s > %s",prog,out)
109−checkout("x
110−")
111−RUN("env LUA_INIT= LUA_PATH_5_4=y LUA_PATH=x lua %s > %s",prog,out)
112−checkout("y
113−")
114−prepfile("print(package.cpath)")
115−RUN("env LUA_INIT= LUA_CPATH=xuxu lua %s > %s",prog,out)
116−checkout("xuxu
117−")
118−RUN("env LUA_INIT= LUA_CPATH_5_4=yacc LUA_CPATH=x lua %s > %s",prog,out)
119−checkout("yacc
120−")
121−prepfile("print(X)")
122−RUN("env LUA_INIT="X=tonumber(arg[1])" lua %s 3.2 > %s",prog,out)
123−checkout("3.2
124−")
125−prepfile("print(X)")
126−RUN("env LUA_INIT_5_4="X=10" LUA_INIT="X=3" lua %s > %s",prog,out)
127−checkout("10
128−")
129−prepfile("x = x or 10; print(x); x = x + 1")
130−RUN("env LUA_INIT="@%s" lua %s > %s",prog,prog,out)
131−checkout("10
132−11
133−")
134−NoRun("LUA_INIT:1: msg","env LUA_INIT="error('msg')" lua")
135−local defaultpath,defaultCpath =
136−prepfile("print(package.path, package.cpath)")
137−RUN("env LUA_INIT="error(10)" LUA_PATH=xxx LUA_CPATH=xxx lua -E %s > %s",prog,out)
79+prepfile("\239\187\191\112\114\105\110\116\40\51\41")
80+RUN("\108\117\97\32\37\115\32\62\32\37\115",prog,out)
81+checkout("\51\10")
82+prepfile("\239\187\191\35\32\99\111\109\109\101\110\116\33\33\10\112\114\105\110\116\40\51\41")
83+RUN("\108\117\97\32\37\115\32\62\32\37\115",prog,out)
84+checkout("\51\10")
85+prepfile("\239",true)
86+NoRun("\117\110\101\120\112\101\99\116\101\100\32\115\121\109\98\111\108","\108\117\97\32\37\115",prog)
87+prepfile("\239\187",true)
88+NoRun("\117\110\101\120\112\101\99\116\101\100\32\115\121\109\98\111\108","\108\117\97\32\37\115",prog)
89+prepfile("\239\112\114\105\110\116\40\51\41",true)
90+NoRun("\117\110\101\120\112\101\99\116\101\100\32\115\121\109\98\111\108","\108\117\97\32\37\115",prog)
91+prepfile("\239\187\112\114\105\110\116\40\51\41",true)
92+NoRun("\117\110\101\120\112\101\99\116\101\100\32\115\121\109\98\111\108","\108\117\97\32\37\115",prog)
93+RUN("\101\99\104\111\32\34\112\114\105\110\116\40\97\114\103\91\49\93\41\34\32\124\32\108\117\97\32\45\32\45\104\32\62\32\37\115",out)
94+checkout("\45\104\10")
95+prepfile("\112\114\105\110\116\40\112\97\99\107\97\103\101\46\112\97\116\104\41")
96+RUN("\101\110\118\32\76\85\65\95\73\78\73\84\61\32\76\85\65\95\80\65\84\72\61\120\32\108\117\97\32\37\115\32\62\32\37\115",prog,out)
97+checkout("\120\10")
98+RUN("\101\110\118\32\76\85\65\95\73\78\73\84\61\32\76\85\65\95\80\65\84\72\95\53\95\52\61\121\32\76\85\65\95\80\65\84\72\61\120\32\108\117\97\32\37\115\32\62\32\37\115",prog,out)
99+checkout("\121\10")
100+prepfile("\112\114\105\110\116\40\112\97\99\107\97\103\101\46\99\112\97\116\104\41")
101+RUN("\101\110\118\32\76\85\65\95\73\78\73\84\61\32\76\85\65\95\67\80\65\84\72\61\120\117\120\117\32\108\117\97\32\37\115\32\62\32\37\115",prog,out)
102+checkout("\120\117\120\117\10")
103+RUN("\101\110\118\32\76\85\65\95\73\78\73\84\61\32\76\85\65\95\67\80\65\84\72\95\53\95\52\61\121\97\99\99\32\76\85\65\95\67\80\65\84\72\61\120\32\108\117\97\32\37\115\32\62\32\37\115",prog,out)
104+checkout("\121\97\99\99\10")
105+prepfile("\112\114\105\110\116\40\88\41")
106+RUN("\101\110\118\32\76\85\65\95\73\78\73\84\61\34\88\61\116\111\110\117\109\98\101\114\40\97\114\103\91\49\93\41\34\32\108\117\97\32\37\115\32\51\46\50\32\62\32\37\115",prog,out)
107+checkout("\51\46\50\10")
108+prepfile("\112\114\105\110\116\40\88\41")
109+RUN("\101\110\118\32\76\85\65\95\73\78\73\84\95\53\95\52\61\34\88\61\49\48\34\32\76\85\65\95\73\78\73\84\61\34\88\61\51\34\32\108\117\97\32\37\115\32\62\32\37\115",prog,out)
110+checkout("\49\48\10")
111+prepfile("\120\32\61\32\120\32\111\114\32\49\48\59\32\112\114\105\110\116\40\120\41\59\32\120\32\61\32\120\32\43\32\49")
112+RUN("\101\110\118\32\76\85\65\95\73\78\73\84\61\34\64\37\115\34\32\108\117\97\32\37\115\32\62\32\37\115",prog,prog,out)
113+checkout("\49\48\10\49\49\10")
114+NoRun("\76\85\65\95\73\78\73\84\58\49\58\32\109\115\103","\101\110\118\32\76\85\65\95\73\78\73\84\61\34\101\114\114\111\114\40\39\109\115\103\39\41\34\32\108\117\97")
115+local defaultpath,defaultCpath
116+do
117+prepfile("\112\114\105\110\116\40\112\97\99\107\97\103\101\46\112\97\116\104\44\32\112\97\99\107\97\103\101\46\99\112\97\116\104\41")
118+RUN("\101\110\118\32\76\85\65\95\73\78\73\84\61\34\101\114\114\111\114\40\49\48\41\34\32\76\85\65\95\80\65\84\72\61\120\120\120\32\76\85\65\95\67\80\65\84\72\61\120\120\120\32\108\117\97\32\45\69\32\37\115\32\62\32\37\115",prog,out)
138119local output = getoutput()
139−defaultpath=string.match(output,"^(.-) ")
140−defaultCpath=string.match(output," (.-)$")
141−RUN("env -i lua %s > %s",prog,out)
120+defaultpath=string.match(output,"\94\40\46\45\41\9")
121+defaultCpath=string.match(output,"\9\40\46\45\41\36")
122+RUN("\101\110\118\32\45\105\32\108\117\97\32\37\115\32\62\32\37\115",prog,out)
142123local out = getoutput()
143−assert(defaultpath == string.match(output,"^(.-) "))
144−assert(defaultCpath == string.match(output," (.-)$"))
145−assert(not string.find(defaultpath,"xxx") and string.find(defaultpath,"lua") and not string.find(defaultCpath,"xxx") and string.find(defaultCpath,"lua"))
124+assert(defaultpath == string.match(output,"\94\40\46\45\41\9"))
125+assert(defaultCpath == string.match(output,"\9\40\46\45\41\36"))
126+end
127+assert(not string.find(defaultpath,"\120\120\120") and string.find(defaultpath,"\108\117\97") and not string.find(defaultCpath,"\120\120\120") and string.find(defaultCpath,"\108\117\97"))
146128local function convert
147129(p)
148−prepfile("print(package.path)")
149−RUN("env LUA_PATH="%s" lua %s > %s",p,prog,out)
130+prepfile("\112\114\105\110\116\40\112\97\99\107\97\103\101\46\112\97\116\104\41")
131+RUN("\101\110\118\32\76\85\65\95\80\65\84\72\61\34\37\115\34\32\108\117\97\32\37\115\32\62\32\37\115",p,prog,out)
150132local expected = getoutput()
151133expected=string.sub(expected,1,- 2)
152−if string.find(p,";;") then
153−p=string.gsub(p,";;",";" .. defaultpath .. ";")
154−p=string.gsub(p,"^;","")
155−p=string.gsub(p,";$","")
134+if string.find(p,"\59\59") then
135+p=string.gsub(p,"\59\59","\59" .. defaultpath .. "\59")
136+p=string.gsub(p,"\94\59","")
137+p=string.gsub(p,"\59\36","")
156138end
157139assert(p == expected)
158140end
159−convert(";")
160−convert(";;")
161−convert("a;;b")
162−convert(";;b")
163−convert("a;;")
164−convert("a;b;;c")
165−prepfile("print(1); a=2; return {x=15}")
166−prepfile(("print(a); print(_G['%s'].x)"):format(prog),false,otherprog)
167−RUN("env LUA_PATH="?;;" lua -l %s -l%s -lstring -l io %s > %s",prog,otherprog,otherprog,out)
168−checkout("1
169−2
170−15
171−2
172−15
173−")
174−prepfile("print(str.upper'alo alo', m.max(10, 20))")
175−RUN("lua -l 'str=string' '-lm=math' -e 'print(m.sin(0))' %s > %s",prog,out)
176−checkout("0.0
177−ALO ALO 20
178−")
179−RUN("env LUA_CPATH='./libs/?.so' lua -l lib2-v2 -e 'print(lib2.id())' > %s",out)
180−checkout("true
181−")
182−local a = " assert(#arg == 3 and arg[1] == 'a' and
183− arg[2] == 'b' and arg[3] == 'c')
184− assert(arg[-1] == '--' and arg[-2] == "-e " and arg[-3] == '%s')
185− assert(arg[4] == undef and arg[-4] == undef)
186− local a, b, c = ...
187− assert(... == 'a' and a == 'a' and b == 'b' and c == 'c')
188−"
141+convert("\59")
142+convert("\59\59")
143+convert("\97\59\59\98")
144+convert("\59\59\98")
145+convert("\97\59\59")
146+convert("\97\59\98\59\59\99")
147+prepfile("\112\114\105\110\116\40\49\41\59\32\97\61\50\59\32\114\101\116\117\114\110\32\123\120\61\49\53\125")
148+prepfile(("\112\114\105\110\116\40\97\41\59\32\112\114\105\110\116\40\95\71\91\39\37\115\39\93\46\120\41"):format(prog),false,otherprog)
149+RUN("\101\110\118\32\76\85\65\95\80\65\84\72\61\34\63\59\59\34\32\108\117\97\32\45\108\32\37\115\32\45\108\37\115\32\45\108\115\116\114\105\110\103\32\45\108\32\105\111\32\37\115\32\62\32\37\115",prog,otherprog,otherprog,out)
150+checkout("\49\10\50\10\49\53\10\50\10\49\53\10")
151+prepfile("\112\114\105\110\116\40\115\116\114\46\117\112\112\101\114\39\97\108\111\32\97\108\111\39\44\32\109\46\109\97\120\40\49\48\44\32\50\48\41\41")
152+RUN("\108\117\97\32\45\108\32\39\115\116\114\61\115\116\114\105\110\103\39\32\39\45\108\109\61\109\97\116\104\39\32\45\101\32\39\112\114\105\110\116\40\109\46\115\105\110\40\48\41\41\39\32\37\115\32\62\32\37\115",prog,out)
153+checkout("\48\46\48\10\65\76\79\32\65\76\79\9\50\48\10")
154+RUN("\101\110\118\32\76\85\65\95\67\80\65\84\72\61\39\46\47\108\105\98\115\47\63\46\115\111\39\32\108\117\97\32\45\108\32\108\105\98\50\45\118\50\32\45\101\32\39\112\114\105\110\116\40\108\105\98\50\46\105\100\40\41\41\39\32\62\32\37\115",out)
155+checkout("\116\114\117\101\10")
156+local a = "\32\32\97\115\115\101\114\116\40\35\97\114\103\32\61\61\32\51\32\97\110\100\32\97\114\103\91\49\93\32\61\61\32\39\97\39\32\97\110\100\10\32\32\32\32\32\32\32\32\32\97\114\103\91\50\93\32\61\61\32\39\98\39\32\97\110\100\32\97\114\103\91\51\93\32\61\61\32\39\99\39\41\10\32\32\97\115\115\101\114\116\40\97\114\103\91\45\49\93\32\61\61\32\39\45\45\39\32\97\110\100\32\97\114\103\91\45\50\93\32\61\61\32\34\45\101\32\34\32\97\110\100\32\97\114\103\91\45\51\93\32\61\61\32\39\37\115\39\41\10\32\32\97\115\115\101\114\116\40\97\114\103\91\52\93\32\61\61\32\117\110\100\101\102\32\97\110\100\32\97\114\103\91\45\52\93\32\61\61\32\117\110\100\101\102\41\10\32\32\108\111\99\97\108\32\97\44\32\98\44\32\99\32\61\32\46\46\46\10\32\32\97\115\115\101\114\116\40\46\46\46\32\61\61\32\39\97\39\32\97\110\100\32\97\32\61\61\32\39\97\39\32\97\110\100\32\98\32\61\61\32\39\98\39\32\97\110\100\32\99\32\61\61\32\39\99\39\41\10"
189157a=string.format(a,progname)
190158prepfile(a)
191−RUN("lua "-e " -- %s a b c",prog)
192−prepfile("assert(arg)")
193−prepfile("assert(arg)",false,otherprog)
194−RUN("env LUA_PATH="?;;" lua -l%s - < %s",prog,otherprog)
195−RUN("echo "print(...)" | lua -e "arg[1] = 100" - > %s",out)
196−checkout("100
197−")
198−NoRun("'arg' is not a table","echo "" | lua -e "arg = 1" -")
199−RUN("echo 10 | lua -e "print=nil" -i > /dev/null 2> %s",out)
200−assert(string.find(getoutput(),"error calling 'print'"))
201−RUN("echo "io.stderr:write(1000)
202−cont" | lua -e "require'debug'.debug()" 2> %s",out)
203−checkout("lua_debug> 1000lua_debug> ")
204−print("testing warnings")
205−RUN("echo "io.stderr:write(1); warn[[XXX]]" | lua 2> %s",out)
206−checkout("1")
207−prepfile("warn("@allow") -- unknown control, ignored
208−warn("@off", "XXX", "@off") -- these are not control messages
209−warn("@off") -- this one is
210−warn("@on", "YYY", "@on") -- not control, but warn is off
211−warn("@off") -- keep it off
212−warn("@on") -- restart warnings
213−warn("", "@on") -- again, no control, real warning
214−warn("@on") -- keep it "started"
215−warn("Z", "Z", "Z") -- common warning
216−")
217−RUN("lua -W %s 2> %s",prog,out)
218−checkout("Lua warning: @offXXX@off
219−Lua warning: @on
220−Lua warning: ZZZ
221−")
222−prepfile("warn("@allow")
223−-- create two objects to be finalized when closing state
224−-- the errors in the finalizers must generate warnings
225−u1 = setmetatable({}, {__gc = function () error("XYZ") end})
226−u2 = setmetatable({}, {__gc = function () error("ZYX") end})
227−")
228−RUN("lua -W %s 2> %s",prog,out)
229−checkprogout("ZYX)
230−XYZ)
231−")
232−prepfile("-- should be called last
233−print("creating 1")
234−setmetatable({}, {__gc = function () print(1) end})
235−
236−print("creating 2")
237−setmetatable({}, {__gc = function ()
238− print("2")
239− print("creating 3")
240− -- this finalizer should not be called, as object will be
241− -- created after 'lua_close' has been called
242− setmetatable({}, {__gc = function () print(3) end})
243− print(collectgarbage()) -- cannot call collector here
244− os.exit(0, true)
245−end})
246−")
247−RUN("lua -W %s > %s",prog,out)
248−checkout("creating 1
249−creating 2
250−2
251−creating 3
252−nil
253−1
254−")
255−prepfile("print(({...})[30])")
256−RUN("lua %s %s > %s",prog,string.rep(" a",30),out)
257−checkout("a
258−")
259−RUN("lua "-eprint(1)" -ea=3 -e "print(a)" > %s",out)
260−checkout("1
261−3
262−")
263−prepfile("(6*2-6) -- ===
264−a =
265−10
266−print(a)
267−a")
268−RUN("lua -e"_PROMPT='' _PROMPT2=''" -i < %s > %s",prog,out)
269−checkprogout("6
270−10
271−10
272−
273−")
274−prepfile("a = [[b
275−c
276−d
277−e]]
278−=a")
279−RUN("lua -e"_PROMPT='' _PROMPT2=''" -i < %s > %s",prog,out)
280−checkprogout("b
281−c
282−d
283−e
284−
285−")
286−local prompt = "alo"
287−prepfile(" --
288−a = 2
289−")
290−RUN("lua "-e_PROMPT='%s'" -i < %s > %s",prompt,prog,out)
159+RUN("\108\117\97\32\34\45\101\32\34\32\45\45\32\37\115\32\97\32\98\32\99",prog)
160+prepfile("\97\115\115\101\114\116\40\97\114\103\41")
161+prepfile("\97\115\115\101\114\116\40\97\114\103\41",false,otherprog)
162+RUN("\101\110\118\32\76\85\65\95\80\65\84\72\61\34\63\59\59\34\32\108\117\97\32\45\108\37\115\32\45\32\60\32\37\115",prog,otherprog)
163+RUN("\101\99\104\111\32\34\112\114\105\110\116\40\46\46\46\41\34\32\124\32\108\117\97\32\45\101\32\34\97\114\103\91\49\93\32\61\32\49\48\48\34\32\45\32\62\32\37\115",out)
164+checkout("\49\48\48\10")
165+NoRun("\39\97\114\103\39\32\105\115\32\110\111\116\32\97\32\116\97\98\108\101","\101\99\104\111\32\34\34\32\124\32\108\117\97\32\45\101\32\34\97\114\103\32\61\32\49\34\32\45")
166+RUN("\101\99\104\111\32\49\48\32\124\32\108\117\97\32\45\101\32\34\112\114\105\110\116\61\110\105\108\34\32\45\105\32\62\32\47\100\101\118\47\110\117\108\108\32\50\62\32\37\115",out)
167+assert(string.find(getoutput(),"\101\114\114\111\114\32\99\97\108\108\105\110\103\32\39\112\114\105\110\116\39"))
168+RUN("\101\99\104\111\32\34\105\111\46\115\116\100\101\114\114\58\119\114\105\116\101\40\49\48\48\48\41\10\99\111\110\116\34\32\124\32\108\117\97\32\45\101\32\34\114\101\113\117\105\114\101\39\100\101\98\117\103\39\46\100\101\98\117\103\40\41\34\32\50\62\32\37\115",out)
169+checkout("\108\117\97\95\100\101\98\117\103\62\32\49\48\48\48\108\117\97\95\100\101\98\117\103\62\32")
170+print("\116\101\115\116\105\110\103\32\119\97\114\110\105\110\103\115")
171+RUN("\101\99\104\111\32\34\105\111\46\115\116\100\101\114\114\58\119\114\105\116\101\40\49\41\59\32\119\97\114\110\91\91\88\88\88\93\93\34\32\124\32\108\117\97\32\50\62\32\37\115",out)
172+checkout("\49")
173+prepfile("\119\97\114\110\40\34\64\97\108\108\111\119\34\41\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\45\45\32\117\110\107\110\111\119\110\32\99\111\110\116\114\111\108\44\32\105\103\110\111\114\101\100\10\119\97\114\110\40\34\64\111\102\102\34\44\32\34\88\88\88\34\44\32\34\64\111\102\102\34\41\32\32\45\45\32\116\104\101\115\101\32\97\114\101\32\110\111\116\32\99\111\110\116\114\111\108\32\109\101\115\115\97\103\101\115\10\119\97\114\110\40\34\64\111\102\102\34\41\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\45\45\32\116\104\105\115\32\111\110\101\32\105\115\10\119\97\114\110\40\34\64\111\110\34\44\32\34\89\89\89\34\44\32\34\64\111\110\34\41\32\32\32\32\45\45\32\110\111\116\32\99\111\110\116\114\111\108\44\32\98\117\116\32\119\97\114\110\32\105\115\32\111\102\102\10\119\97\114\110\40\34\64\111\102\102\34\41\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\45\45\32\107\101\101\112\32\105\116\32\111\102\102\10\119\97\114\110\40\34\64\111\110\34\41\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\45\45\32\114\101\115\116\97\114\116\32\119\97\114\110\105\110\103\115\10\119\97\114\110\40\34\34\44\32\34\64\111\110\34\41\32\32\32\32\32\32\32\32\32\32\32\32\32\32\45\45\32\97\103\97\105\110\44\32\110\111\32\99\111\110\116\114\111\108\44\32\114\101\97\108\32\119\97\114\110\105\110\103\10\119\97\114\110\40\34\64\111\110\34\41\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\45\45\32\107\101\101\112\32\105\116\32\34\115\116\97\114\116\101\100\34\10\119\97\114\110\40\34\90\34\44\32\34\90\34\44\32\34\90\34\41\32\32\32\32\32\32\32\32\32\32\45\45\32\99\111\109\109\111\110\32\119\97\114\110\105\110\103\10")
174+RUN("\108\117\97\32\45\87\32\37\115\32\50\62\32\37\115",prog,out)
175+checkout("\76\117\97\32\119\97\114\110\105\110\103\58\32\64\111\102\102\88\88\88\64\111\102\102\10\76\117\97\32\119\97\114\110\105\110\103\58\32\64\111\110\10\76\117\97\32\119\97\114\110\105\110\103\58\32\90\90\90\10")
176+prepfile("\119\97\114\110\40\34\64\97\108\108\111\119\34\41\10\45\45\32\99\114\101\97\116\101\32\116\119\111\32\111\98\106\101\99\116\115\32\116\111\32\98\101\32\102\105\110\97\108\105\122\101\100\32\119\104\101\110\32\99\108\111\115\105\110\103\32\115\116\97\116\101\10\45\45\32\116\104\101\32\101\114\114\111\114\115\32\105\110\32\116\104\101\32\102\105\110\97\108\105\122\101\114\115\32\109\117\115\116\32\103\101\110\101\114\97\116\101\32\119\97\114\110\105\110\103\115\10\117\49\32\61\32\115\101\116\109\101\116\97\116\97\98\108\101\40\123\125\44\32\123\95\95\103\99\32\61\32\102\117\110\99\116\105\111\110\32\40\41\32\101\114\114\111\114\40\34\88\89\90\34\41\32\101\110\100\125\41\10\117\50\32\61\32\115\101\116\109\101\116\97\116\97\98\108\101\40\123\125\44\32\123\95\95\103\99\32\61\32\102\117\110\99\116\105\111\110\32\40\41\32\101\114\114\111\114\40\34\90\89\88\34\41\32\101\110\100\125\41\10")
177+RUN("\108\117\97\32\45\87\32\37\115\32\50\62\32\37\115",prog,out)
178+checkprogout("\90\89\88\41\10\88\89\90\41\10")
179+prepfile("\45\45\32\115\104\111\117\108\100\32\98\101\32\99\97\108\108\101\100\32\108\97\115\116\10\112\114\105\110\116\40\34\99\114\101\97\116\105\110\103\32\49\34\41\10\115\101\116\109\101\116\97\116\97\98\108\101\40\123\125\44\32\123\95\95\103\99\32\61\32\102\117\110\99\116\105\111\110\32\40\41\32\112\114\105\110\116\40\49\41\32\101\110\100\125\41\10\10\112\114\105\110\116\40\34\99\114\101\97\116\105\110\103\32\50\34\41\10\115\101\116\109\101\116\97\116\97\98\108\101\40\123\125\44\32\123\95\95\103\99\32\61\32\102\117\110\99\116\105\111\110\32\40\41\10\32\32\112\114\105\110\116\40\34\50\34\41\10\32\32\112\114\105\110\116\40\34\99\114\101\97\116\105\110\103\32\51\34\41\10\32\32\45\45\32\116\104\105\115\32\102\105\110\97\108\105\122\101\114\32\115\104\111\117\108\100\32\110\111\116\32\98\101\32\99\97\108\108\101\100\44\32\97\115\32\111\98\106\101\99\116\32\119\105\108\108\32\98\101\10\32\32\45\45\32\99\114\101\97\116\101\100\32\97\102\116\101\114\32\39\108\117\97\95\99\108\111\115\101\39\32\104\97\115\32\98\101\101\110\32\99\97\108\108\101\100\10\32\32\115\101\116\109\101\116\97\116\97\98\108\101\40\123\125\44\32\123\95\95\103\99\32\61\32\102\117\110\99\116\105\111\110\32\40\41\32\112\114\105\110\116\40\51\41\32\101\110\100\125\41\10\32\32\112\114\105\110\116\40\99\111\108\108\101\99\116\103\97\114\98\97\103\101\40\41\41\32\32\32\32\45\45\32\99\97\110\110\111\116\32\99\97\108\108\32\99\111\108\108\101\99\116\111\114\32\104\101\114\101\10\32\32\111\115\46\101\120\105\116\40\48\44\32\116\114\117\101\41\10\101\110\100\125\41\10")
180+RUN("\108\117\97\32\45\87\32\37\115\32\62\32\37\115",prog,out)
181+checkout("\99\114\101\97\116\105\110\103\32\49\10\99\114\101\97\116\105\110\103\32\50\10\50\10\99\114\101\97\116\105\110\103\32\51\10\110\105\108\10\49\10")
182+prepfile("\112\114\105\110\116\40\40\123\46\46\46\125\41\91\51\48\93\41")
183+RUN("\108\117\97\32\37\115\32\37\115\32\62\32\37\115",prog,string.rep("\32\97",30),out)
184+checkout("\97\10")
185+RUN("\108\117\97\32\34\45\101\112\114\105\110\116\40\49\41\34\32\45\101\97\61\51\32\45\101\32\34\112\114\105\110\116\40\97\41\34\32\62\32\37\115",out)
186+checkout("\49\10\51\10")
187+prepfile("\40\54\42\50\45\54\41\32\45\45\32\61\61\61\10\97\32\61\10\49\48\10\112\114\105\110\116\40\97\41\10\97")
188+RUN("\108\117\97\32\45\101\34\95\80\82\79\77\80\84\61\39\39\32\95\80\82\79\77\80\84\50\61\39\39\34\32\45\105\32\60\32\37\115\32\62\32\37\115",prog,out)
189+checkprogout("\54\10\49\48\10\49\48\10\10")
190+prepfile("\97\32\61\32\91\91\98\10\99\10\100\10\101\93\93\10\61\97")
191+RUN("\108\117\97\32\45\101\34\95\80\82\79\77\80\84\61\39\39\32\95\80\82\79\77\80\84\50\61\39\39\34\32\45\105\32\60\32\37\115\32\62\32\37\115",prog,out)
192+checkprogout("\98\10\99\10\100\10\101\10\10")
193+local prompt = "\97\108\111"
194+prepfile("\32\45\45\10\97\32\61\32\50\10")
195+RUN("\108\117\97\32\34\45\101\95\80\82\79\77\80\84\61\39\37\115\39\34\32\45\105\32\60\32\37\115\32\62\32\37\115",prompt,prog,out)
291196local t = getoutput()
292−assert(string.find(t,prompt .. ".*" .. prompt .. ".*" .. prompt))
293−prepfile(" --
294−a = 2
295−")
296−RUN("lua -i < %s > %s",prog,out)
197+assert(string.find(t,prompt .. "\46\42" .. prompt .. "\46\42" .. prompt))
198+prepfile("\32\45\45\10\97\32\61\32\50\10")
199+RUN("\108\117\97\32\45\105\32\60\32\37\115\32\62\32\37\115",prog,out)
297200local t = getoutput()
298−prompt="> "
299−assert(string.find(t,prompt .. ".*" .. prompt .. ".*" .. prompt))
300−prompt="local C = 0;_PROMPT=setmetatable({},{__tostring = function () C = C + 1; return C end})"
301−prepfile(" --
302−a = 2
303−")
304−RUN("lua -e "%s" -i < %s > %s",prompt,prog,out)
201+prompt="\62\32"
202+assert(string.find(t,prompt .. "\46\42" .. prompt .. "\46\42" .. prompt))
203+prompt="\108\111\99\97\108\32\67\32\61\32\48\59\95\80\82\79\77\80\84\61\115\101\116\109\101\116\97\116\97\98\108\101\40\123\125\44\123\95\95\116\111\115\116\114\105\110\103\32\61\32\102\117\110\99\116\105\111\110\32\40\41\32\67\32\61\32\67\32\43\32\49\59\32\114\101\116\117\114\110\32\67\32\101\110\100\125\41"
204+prepfile("\32\45\45\10\97\32\61\32\50\10")
205+RUN("\108\117\97\32\45\101\32\34\37\115\34\32\45\105\32\60\32\37\115\32\62\32\37\115",prompt,prog,out)
305206local t = getoutput()
306−assert(string.find(t,"1 --
307−2a = 2
308−3
309−",1,true))
310−prepfile("debug = require "debug"
311−m = {x=0}
312−setmetatable(m, {__tostring = function(x)
313− return tostring(debug.getinfo(4).currentline + x.x)
314−end})
315−error(m)
316−")
317−NoRun(progname .. ": 6
318−","lua %s",prog)
319−prepfile("error{}")
320−NoRun("error object is a table value","lua %s",prog)
321−local s = " --
322−function f ( x )
323− local a = [[
324−xuxu
325−]]
326− local b = "\
327−xuxu\n"
328− if x == 11 then return 1 + 12 , 2 + 20 end --[[ test multiple returns ]]
329− return x + 1
330− --\\
331−end
332−return( f( 100 ) )
333−assert( a == b )
334−do return f( 11 ) end "
335−s=string.gsub(s," ","
336−
337−")
207+assert(string.find(t,"\49\32\45\45\10\50\97\32\61\32\50\10\51\10",1,true))
208+prepfile("\100\101\98\117\103\32\61\32\114\101\113\117\105\114\101\32\34\100\101\98\117\103\34\10\109\32\61\32\123\120\61\48\125\10\115\101\116\109\101\116\97\116\97\98\108\101\40\109\44\32\123\95\95\116\111\115\116\114\105\110\103\32\61\32\102\117\110\99\116\105\111\110\40\120\41\10\32\32\114\101\116\117\114\110\32\116\111\115\116\114\105\110\103\40\100\101\98\117\103\46\103\101\116\105\110\102\111\40\52\41\46\99\117\114\114\101\110\116\108\105\110\101\32\43\32\120\46\120\41\10\101\110\100\125\41\10\101\114\114\111\114\40\109\41\10")
209+NoRun(progname .. "\58\32\54\10","\108\117\97\32\37\115",prog)
210+prepfile("\101\114\114\111\114\123\125")
211+NoRun("\101\114\114\111\114\32\111\98\106\101\99\116\32\105\115\32\97\32\116\97\98\108\101\32\118\97\108\117\101","\108\117\97\32\37\115",prog)
212+local s = "\32\45\45\10\102\117\110\99\116\105\111\110\32\102\32\40\32\120\32\41\10\32\32\108\111\99\97\108\32\97\32\61\32\91\91\10\120\117\120\117\10\93\93\10\32\32\108\111\99\97\108\32\98\32\61\32\34\92\10\120\117\120\117\92\110\34\10\32\32\105\102\32\120\32\61\61\32\49\49\32\116\104\101\110\32\114\101\116\117\114\110\32\49\32\43\32\49\50\32\44\32\50\32\43\32\50\48\32\101\110\100\32\32\45\45\91\91\32\116\101\115\116\32\109\117\108\116\105\112\108\101\32\114\101\116\117\114\110\115\32\93\93\10\32\32\114\101\116\117\114\110\32\120\32\43\32\49\10\32\32\45\45\92\92\10\101\110\100\10\114\101\116\117\114\110\40\32\102\40\32\49\48\48\32\41\32\41\10\97\115\115\101\114\116\40\32\97\32\61\61\32\98\32\41\10\100\111\32\114\101\116\117\114\110\32\102\40\32\49\49\32\41\32\101\110\100\32\32"
213+s=string.gsub(s,"\32","\10\10")
338214prepfile(s)
339−RUN("lua -e"_PROMPT='' _PROMPT2=''" -i < %s > %s",prog,out)
340−checkprogout("101
341−13 22
342−
343−")
344−prepfile("#comment in 1st line without \n at the end")
345−RUN("lua %s",prog)
346−prepfile("#comment
347−" .. string.dump(load("print(3)")),true)
348−RUN("lua %s > %s",prog,out)
349−checkout("3
350−")
351−prepfile(string.format("io.output(%q); io.write('alo')",out))
352−RUN("lua %s",prog)
353−checkout("alo")
354−RUN("lua -v -e"print'hello'" > %s",out)
215+RUN("\108\117\97\32\45\101\34\95\80\82\79\77\80\84\61\39\39\32\95\80\82\79\77\80\84\50\61\39\39\34\32\45\105\32\60\32\37\115\32\62\32\37\115",prog,out)
216+checkprogout("\49\48\49\10\49\51\9\50\50\10\10")
217+prepfile("\35\99\111\109\109\101\110\116\32\105\110\32\49\115\116\32\108\105\110\101\32\119\105\116\104\111\117\116\32\92\110\32\97\116\32\116\104\101\32\101\110\100")
218+RUN("\108\117\97\32\37\115",prog)
219+prepfile("\35\99\111\109\109\101\110\116\10" .. string.dump(load("\112\114\105\110\116\40\51\41")),true)
220+RUN("\108\117\97\32\37\115\32\62\32\37\115",prog,out)
221+checkout("\51\10")
222+prepfile(string.format("\105\111\46\111\117\116\112\117\116\40\37\113\41\59\32\105\111\46\119\114\105\116\101\40\39\97\108\111\39\41",out))
223+RUN("\108\117\97\32\37\115",prog)
224+checkout("\97\108\111")
225+RUN("\108\117\97\32\45\118\32\32\45\101\34\112\114\105\110\116\39\104\101\108\108\111\39\34\32\62\32\37\115",out)
355226t=getoutput()
356−assert(string.find(t,"PUC%-Rio
357−hello"))
358−prepfile("os.exit(nil, true)")
359−RUN("lua %s",prog)
360−prepfile("os.exit(0, true)")
361−RUN("lua %s",prog)
362−prepfile("os.exit(true, true)")
363−RUN("lua %s",prog)
364−prepfile("os.exit(1, true)")
365−NoRun("","lua %s",prog)
366−prepfile("os.exit(false, true)")
367−NoRun("","lua %s",prog)
368−prepfile(" local x <close> = setmetatable({},
369− {__close = function (self, err)
370− assert(err == nil)
371− print("Ok")
372− end})
373− local e1 <close> = setmetatable({}, {__close = function () print(120) end})
374− os.exit(true, true)
375−")
376−RUN("lua %s > %s",prog,out)
377−checkprogout("120
378−Ok
379−")
227+assert(string.find(t,"\80\85\67\37\45\82\105\111\10\104\101\108\108\111"))
228+prepfile("\111\115\46\101\120\105\116\40\110\105\108\44\32\116\114\117\101\41")
229+RUN("\108\117\97\32\37\115",prog)
230+prepfile("\111\115\46\101\120\105\116\40\48\44\32\116\114\117\101\41")
231+RUN("\108\117\97\32\37\115",prog)
232+prepfile("\111\115\46\101\120\105\116\40\116\114\117\101\44\32\116\114\117\101\41")
233+RUN("\108\117\97\32\37\115",prog)
234+prepfile("\111\115\46\101\120\105\116\40\49\44\32\116\114\117\101\41")
235+NoRun("","\108\117\97\32\37\115",prog)
236+prepfile("\111\115\46\101\120\105\116\40\102\97\108\115\101\44\32\116\114\117\101\41")
237+NoRun("","\108\117\97\32\37\115",prog)
238+prepfile("\32\32\108\111\99\97\108\32\120\32\60\99\108\111\115\101\62\32\61\32\115\101\116\109\101\116\97\116\97\98\108\101\40\123\125\44\10\32\32\32\32\32\32\32\32\123\95\95\99\108\111\115\101\32\61\32\102\117\110\99\116\105\111\110\32\40\115\101\108\102\44\32\101\114\114\41\10\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\97\115\115\101\114\116\40\101\114\114\32\61\61\32\110\105\108\41\10\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\112\114\105\110\116\40\34\79\107\34\41\10\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\101\110\100\125\41\10\32\32\108\111\99\97\108\32\101\49\32\60\99\108\111\115\101\62\32\61\32\115\101\116\109\101\116\97\116\97\98\108\101\40\123\125\44\32\123\95\95\99\108\111\115\101\32\61\32\102\117\110\99\116\105\111\110\32\40\41\32\112\114\105\110\116\40\49\50\48\41\32\101\110\100\125\41\10\32\32\111\115\46\101\120\105\116\40\116\114\117\101\44\32\116\114\117\101\41\10")
239+RUN("\108\117\97\32\37\115\32\62\32\37\115",prog,out)
240+checkprogout("\49\50\48\10\79\107\10")
380241assert(os.remove(prog))
381242assert(os.remove(otherprog))
382243assert(not os.remove(out))
383−NoRun("unrecognized option '-h'","lua -h")
384−NoRun("unrecognized option '---'","lua ---")
385−NoRun("unrecognized option '-Ex'","lua -Ex")
386−NoRun("unrecognized option '-vv'","lua -vv")
387−NoRun("unrecognized option '-iv'","lua -iv")
388−NoRun("'-e' needs argument","lua -e")
389−NoRun("syntax error","lua -e a")
390−NoRun("'-l' needs argument","lua -l")
244+NoRun("\117\110\114\101\99\111\103\110\105\122\101\100\32\111\112\116\105\111\110\32\39\45\104\39","\108\117\97\32\45\104")
245+NoRun("\117\110\114\101\99\111\103\110\105\122\101\100\32\111\112\116\105\111\110\32\39\45\45\45\39","\108\117\97\32\45\45\45")
246+NoRun("\117\110\114\101\99\111\103\110\105\122\101\100\32\111\112\116\105\111\110\32\39\45\69\120\39","\108\117\97\32\45\69\120")
247+NoRun("\117\110\114\101\99\111\103\110\105\122\101\100\32\111\112\116\105\111\110\32\39\45\118\118\39","\108\117\97\32\45\118\118")
248+NoRun("\117\110\114\101\99\111\103\110\105\122\101\100\32\111\112\116\105\111\110\32\39\45\105\118\39","\108\117\97\32\45\105\118")
249+NoRun("\39\45\101\39\32\110\101\101\100\115\32\97\114\103\117\109\101\110\116","\108\117\97\32\45\101")
250+NoRun("\115\121\110\116\97\120\32\101\114\114\111\114","\108\117\97\32\45\101\32\97")
251+NoRun("\39\45\108\39\32\110\101\101\100\115\32\97\114\103\117\109\101\110\116","\108\117\97\32\45\108")
391252if T then
392−print("testing 'not enough memory' to create a state")
393−NoRun("not enough memory","env MEMLIMIT=100 lua")
394−warn("@store")
395−warn("@123","456","789")
396−assert(_WARN == "@123456789")
253+print("\116\101\115\116\105\110\103\32\39\110\111\116\32\101\110\111\117\103\104\32\109\101\109\111\114\121\39\32\116\111\32\99\114\101\97\116\101\32\97\32\115\116\97\116\101")
254+NoRun("\110\111\116\32\101\110\111\117\103\104\32\109\101\109\111\114\121","\101\110\118\32\77\69\77\76\73\77\73\84\61\49\48\48\32\108\117\97")
255+warn("\64\115\116\111\114\101")
256+warn("\64\49\50\51","\52\53\54","\55\56\57")
257+assert(_WARN == "\64\49\50\51\52\53\54\55\56\57")
397258;
398259_WARN=false
399−warn("zip",""," ","zap")
400−assert(_WARN == "zip zap")
260+warn("\122\105\112","","\32","\122\97\112")
261+assert(_WARN == "\122\105\112\32\122\97\112")
401262;
402263_WARN=false
403−warn("ZIP",""," ","ZAP")
404−assert(_WARN == "ZIP ZAP")
264+warn("\90\73\80","","\32","\90\65\80")
265+assert(_WARN == "\90\73\80\32\90\65\80")
405266;
406267_WARN=false
407−warn("@normal")
268+warn("\64\110\111\114\109\97\108")
408269end
270+do
409271local st,msg = pcall(warn)
410−assert(string.find(msg,"string expected"))
411−st,msg=pcall(warn,"SHOULD NOT APPEAR",{})
412−assert(string.find(msg,"string expected"))
413−print("+")
414−print("testing Ctrl C")
272+assert(string.find(msg,"\115\116\114\105\110\103\32\101\120\112\101\99\116\101\100"))
273+st,msg=pcall(warn,"\83\72\79\85\76\68\32\78\79\84\32\65\80\80\69\65\82",{})
274+assert(string.find(msg,"\115\116\114\105\110\103\32\101\120\112\101\99\116\101\100"))
275+end
276+print("\43")
277+print("\116\101\115\116\105\110\103\32\67\116\114\108\32\67")
278+do
415279local function kill
416280(pid)
417−return os.execute(string.format("kill -INT %s 2> /dev/null",pid))
281+return os.execute(string.format("\107\105\108\108\32\45\73\78\84\32\37\115\32\50\62\32\47\100\101\118\47\110\117\108\108",pid))
418282end
419283local function runback
420284(luaprg)
421−local shellprg = string.format("%s -e "%s" & echo $!",progname,luaprg)
422−local f = io.popen(shellprg,"r")
285+local shellprg = string.format("\37\115\32\45\101\32\34\37\115\34\32\38\32\101\99\104\111\32\36\33",progname,luaprg)
286+local f = io.popen(shellprg,"\114")
423287local pid = f:read()
424−print("(if test fails now, it may leave a Lua script running in background, pid " .. pid .. ")")
288+print("\40\105\102\32\116\101\115\116\32\102\97\105\108\115\32\110\111\119\44\32\105\116\32\109\97\121\32\108\101\97\118\101\32\97\32\76\117\97\32\115\99\114\105\112\116\32\114\117\110\110\105\110\103\32\105\110\32\98\97\99\107\103\114\111\117\110\100\44\32\112\105\100\32" .. pid .. "\41")
425289return f,pid
426290end
427−local f,pid = runback(" pcall(function () print(12); while true do end end); print(42)")
428−assert(f:read() == "12")
291+local f,pid = runback("\32\32\32\32\112\99\97\108\108\40\102\117\110\99\116\105\111\110\32\40\41\32\112\114\105\110\116\40\49\50\41\59\32\119\104\105\108\101\32\116\114\117\101\32\100\111\32\101\110\100\32\101\110\100\41\59\32\112\114\105\110\116\40\52\50\41")
292+assert(f:read() == "\49\50")
429293kill(pid)
430−assert(f:read() == "42")
294+assert(f:read() == "\52\50")
431295assert(f:close())
432−print("done")
433−local f,pid = runback(" print(15); string.find(string.rep('a', 100000), '.*b')")
434−assert(f:read() == "15")
435−assert(os.execute("sleep 1"))
296+print("\100\111\110\101")
297+local f,pid = runback("\32\32\32\32\112\114\105\110\116\40\49\53\41\59\32\115\116\114\105\110\103\46\102\105\110\100\40\115\116\114\105\110\103\46\114\101\112\40\39\97\39\44\32\49\48\48\48\48\48\41\44\32\39\46\42\98\39\41")
298+assert(f:read() == "\49\53")
299+assert(os.execute("\115\108\101\101\112\32\49"))
436300local n = 100
437301for i = 0, 100
438302do
@@ -443,5 +307,6 @@ end
443307end
444308assert(f:close())
445309assert(n >= 2)
446−print(string.format("done (with %d kills)",n))
447−print("OK")
310+print(string.format("\100\111\110\101\32\40\119\105\116\104\32\37\100\32\107\105\108\108\115\41",n))
311+end
312+print("\79\75")
zod/luau/res/lua/cycled/math.lua+311−263
@@ -1,4 +1,4 @@
1−print("testing numbers and math lib")
1+print("\116\101\115\116\105\110\103\32\110\117\109\98\101\114\115\32\97\110\100\32\109\97\116\104\32\108\105\98")
22local minint <const> = math.mininteger
33local maxint <const> = math.maxinteger
44local intbits <const> = math.floor(math.log(maxint,2) + 0.5) + 1
@@ -6,33 +6,38 @@ assert((1 << intbits) == 0)
66assert(minint == 1 << (intbits - 1))
77assert(maxint == minint - 1)
88local floatbits = 24
9−local p = 2 ^ floatbits
10−while p < p + 1 do
11−p=p * 2
9+do
10+local p = 2.0 ^ floatbits
11+while p < p + 1.0 do
12+p=p * 2.0
1213floatbits=floatbits + 1
14+end
15+end
1316local function isNaN
1417(x)
1518return (x ~= x)
1619end
1720assert(isNaN(0 / 0))
1821assert(not isNaN(1 / 0))
19−local x = 2 ^ floatbits
20−assert(x > x - 1 and x == x + 1)
21−print(string.format("%d-bit integers, %d-bit (mantissa) floats",intbits,floatbits))
22−assert(math.type(0) == "integer" and math.type(0) == "float" and not math.type("10"))
22+do
23+local x = 2.0 ^ floatbits
24+assert(x > x - 1.0 and x == x + 1.0)
25+print(string.format("\37\100\45\98\105\116\32\105\110\116\101\103\101\114\115\44\32\37\100\45\98\105\116\32\40\109\97\110\116\105\115\115\97\41\32\102\108\111\97\116\115",intbits,floatbits))
26+end
27+assert(math.type(0) == "\105\110\116\101\103\101\114" and math.type(0.0) == "\102\108\111\97\116" and not math.type("\49\48"))
2328local function checkerror
2429(msg,f, ...)
2530local s,err = pcall(f,...)
2631assert(not s and string.find(err,msg))
2732end
28−local msgf2i = "number.* has no integer representation"
33+local msgf2i = "\110\117\109\98\101\114\46\42\32\104\97\115\32\110\111\32\105\110\116\101\103\101\114\32\114\101\112\114\101\115\101\110\116\97\116\105\111\110"
2934local function eq
3035(a,b,limit)
3136if not limit then
3237if floatbits >= 50 then
33−limit=1e-11
38+limit=1e-11.0
3439else
35−limit=1e-5
40+limit=1e-5.0
3641end
3742end
3843return a == b or math.abs(a - b) <= limit
@@ -41,38 +46,44 @@ local function eqT
4146(a,b)
4247return a == b and math.type(a) == math.type(b)
4348end
44−assert(0 == 0 and 0 == 0 and 0 == 0 and 20 == 20 and 0.2 == 0.2)
45−local a,b,c = "2"," 3e0 "," 10 "
46−assert(a + b == 5 and - b == - 3 and b + "2" == 5 and "10" - c == 0)
47−assert(type(a) == "string" and type(b) == "string" and type(c) == "string")
48−assert(a == "2" and b == " 3e0 " and c == " 10 " and - c == - " 10 ")
49+assert(0.0 == 0 and 0.0 == 0 and 0.0 == 0 and 20.0 == 20 and 0.2 == 0.2)
50+do
51+local a,b,c = "\50","\32\51\101\48\32","\32\49\48\32\32"
52+assert(a + b == 5 and - b == - 3 and b + "\50" == 5 and "\49\48" - c == 0)
53+assert(type(a) == "\115\116\114\105\110\103" and type(b) == "\115\116\114\105\110\103" and type(c) == "\115\116\114\105\110\103")
54+assert(a == "\50" and b == "\32\51\101\48\32" and c == "\32\49\48\32\32" and - c == - "\32\32\49\48\32")
4955assert(c % a == 0 and a ^ b == 8)
5056a=0
5157assert(a == - a and 0 == - 0)
58+end
59+do
5260local x = - 1
5361local mz = 0 / x
5462local t = {[0] = 10,20,30,40,50}
5563assert(t[mz] == t[0] and t[- 0] == t[0])
64+end
65+do
5666local a,b = math.modf(3.5)
57−assert(a == 3 and b == 0.5)
67+assert(a == 3.0 and b == 0.5)
5868a,b=math.modf(- 2.5)
59−assert(a == - 2 and b == - 0.5)
60−a,b=math.modf(- 3e23)
61−assert(a == - 3e23 and b == 0)
62−a,b=math.modf(3e35)
63−assert(a == 3e35 and b == 0)
69+assert(a == - 2.0 and b == - 0.5)
70+a,b=math.modf(- 3e23.0)
71+assert(a == - 3e23.0 and b == 0.0)
72+a,b=math.modf(3e35.0)
73+assert(a == 3e35.0 and b == 0.0)
6474a,b=math.modf(- 1 / 0)
65−assert(a == - 1 / 0 and b == 0)
75+assert(a == - 1 / 0 and b == 0.0)
6676a,b=math.modf(1 / 0)
67−assert(a == 1 / 0 and b == 0)
77+assert(a == 1 / 0 and b == 0.0)
6878a,b=math.modf(0 / 0)
6979assert(isNaN(a) and isNaN(b))
7080a,b=math.modf(3)
71−assert(eqT(a,3) and eqT(b,0))
81+assert(eqT(a,3) and eqT(b,0.0))
7282a,b=math.modf(minint)
73−assert(eqT(a,minint) and eqT(b,0))
74−assert(math.huge > 1e31)
75−assert(- math.huge < - 1e31)
83+assert(eqT(a,minint) and eqT(b,0.0))
84+end
85+assert(math.huge > 1e31.0)
86+assert(- math.huge < - 1e31.0)
7687assert(minint < minint + 1)
7788assert(maxint - 1 < maxint)
7889assert(0 - minint == minint)
@@ -82,9 +93,9 @@ for _,i in pairs({- 16,- 15,- 3,- 2,- 1,0,1,2,3,15})
8293do
8394for _,j in pairs({- 16,- 15,- 3,- 2,- 1,1,2,3,15})
8495do
85−for _,ti in pairs({0,0})
96+for _,ti in pairs({0,0.0})
8697do
87−for _,tj in pairs({0,0})
98+for _,tj in pairs({0,0.0})
8899do
89100local x = i + ti
90101local y = j + tj
@@ -93,31 +104,33 @@ end
93104end
94105end
95106end
96−assert(1 // 0 == 1 / 0)
97−assert(- 1 // 0 == - 1 / 0)
98−assert(eqT(3.5 // 1.5,2))
99−assert(eqT(3.5 // - 1.5,- 3))
100−local x,y =
107+assert(1 // 0.0 == 1 / 0)
108+assert(- 1 // 0.0 == - 1 / 0)
109+assert(eqT(3.5 // 1.5,2.0))
110+assert(eqT(3.5 // - 1.5,- 3.0))
111+do
112+local x,y
101113x=1
102114;
103−assert(x // 0 == 1 / 0)
104−x=1
115+assert(x // 0.0 == 1 / 0)
116+x=1.0
105117;
106118assert(x // 0 == 1 / 0)
107119x=3.5
108120;
109−assert(eqT(x // 1,3))
110−assert(eqT(x // - 1,- 4))
121+assert(eqT(x // 1,3.0))
122+assert(eqT(x // - 1,- 4.0))
111123x=3.5
112124;
113125y=1.5
114126;
115−assert(eqT(x // y,2))
127+assert(eqT(x // y,2.0))
116128x=3.5
117129;
118130y=- 1.5
119131;
120−assert(eqT(x // y,- 3))
132+assert(eqT(x // y,- 3.0))
133+end
121134assert(maxint // maxint == 1)
122135assert(maxint // 1 == maxint)
123136assert((maxint - 1) // maxint == 0)
@@ -130,6 +143,7 @@ assert(minint // 1 == minint)
130143assert(minint // - 1 == - minint)
131144assert(minint // - 2 == 2 ^ (intbits - 2))
132145assert(maxint // - 1 == - maxint)
146+do
133147assert(2 ^ - 3 == 1 / 2 ^ 3)
134148assert(eq((- 3) ^ - 3,1 / (- 3) ^ 3))
135149for i = - 3, 3
@@ -141,20 +155,21 @@ assert(eq(i ^ j,1 / i ^ (- j)))
141155end
142156end
143157end
158+end
144159if floatbits < intbits then
145−assert(2 ^ floatbits == (1 << floatbits))
146−assert(2 ^ floatbits - 1 == (1 << floatbits) - 1)
147−assert(2 ^ floatbits - 1 ~= (1 << floatbits))
148−assert(2 ^ floatbits + 1 ~= (1 << floatbits) + 1)
160+assert(2.0 ^ floatbits == (1 << floatbits))
161+assert(2.0 ^ floatbits - 1.0 == (1 << floatbits) - 1.0)
162+assert(2.0 ^ floatbits - 1.0 ~= (1 << floatbits))
163+assert(2.0 ^ floatbits + 1.0 ~= (1 << floatbits) + 1)
149164else
150−assert(maxint == maxint + 0)
151−assert(maxint - 1 == maxint - 1)
152−assert(minint + 1 == minint + 1)
153−assert(maxint ~= maxint - 1)
154−end
155−assert(maxint + 0 == 2 ^ (intbits - 1) - 1)
156−assert(minint + 0 == minint)
157−assert(minint + 0 == - 2 ^ (intbits - 1))
165+assert(maxint == maxint + 0.0)
166+assert(maxint - 1 == maxint - 1.0)
167+assert(minint + 1 == minint + 1.0)
168+assert(maxint ~= maxint - 1.0)
169+end
170+assert(maxint + 0.0 == 2.0 ^ (intbits - 1) - 1.0)
171+assert(minint + 0.0 == minint)
172+assert(minint + 0.0 == - 2.0 ^ (intbits - 1))
158173assert(1 < 1.1)
159174;
160175assert(not (1 < 0.9))
@@ -173,20 +188,22 @@ assert(not (- 1 < - 1.1))
173188assert(- 1 <= - 0.9)
174189;
175190assert(not (- 1 <= - 1.1))
176−assert(minint <= minint + 0)
177−assert(minint + 0 <= minint)
178−assert(not (minint < minint + 0))
179−assert(not (minint + 0 < minint))
180−assert(maxint < minint * - 1)
181−assert(maxint <= minint * - 1)
191+assert(minint <= minint + 0.0)
192+assert(minint + 0.0 <= minint)
193+assert(not (minint < minint + 0.0))
194+assert(not (minint + 0.0 < minint))
195+assert(maxint < minint * - 1.0)
196+assert(maxint <= minint * - 1.0)
197+do
182198local fmaxi1 = 2 ^ (intbits - 1)
183199assert(maxint < fmaxi1)
184200assert(maxint <= fmaxi1)
185201assert(not (fmaxi1 <= maxint))
186202assert(minint <= - 2 ^ (intbits - 1))
187203assert(- 2 ^ (intbits - 1) <= minint)
204+end
188205if floatbits < intbits then
189−print("testing order (floats cannot represent all integers)")
206+print("\116\101\115\116\105\110\103\32\111\114\100\101\114\32\40\102\108\111\97\116\115\32\99\97\110\110\111\116\32\114\101\112\114\101\115\101\110\116\32\97\108\108\32\105\110\116\101\103\101\114\115\41")
190207local fmax = 2 ^ floatbits
191208local ifmax = fmax | 0
192209assert(fmax < ifmax + 1)
@@ -202,34 +219,35 @@ assert(minint > - 2 ^ intbits)
202219assert(maxint <= 2 ^ intbits)
203220assert(minint >= - 2 ^ intbits)
204221else
205−print("testing order (floats can represent all integers)")
206−assert(maxint < maxint + 1)
222+print("\116\101\115\116\105\110\103\32\111\114\100\101\114\32\40\102\108\111\97\116\115\32\99\97\110\32\114\101\112\114\101\115\101\110\116\32\97\108\108\32\105\110\116\101\103\101\114\115\41")
223+assert(maxint < maxint + 1.0)
207224assert(maxint < maxint + 0.5)
208−assert(maxint - 1 < maxint)
225+assert(maxint - 1.0 < maxint)
209226assert(maxint - 0.5 < maxint)
210−assert(not (maxint + 0 < maxint))
211−assert(maxint + 0 <= maxint)
212−assert(not (maxint < maxint + 0))
213−assert(maxint + 0 <= maxint)
214−assert(maxint <= maxint + 0)
215−assert(not (maxint + 1 <= maxint))
227+assert(not (maxint + 0.0 < maxint))
228+assert(maxint + 0.0 <= maxint)
229+assert(not (maxint < maxint + 0.0))
230+assert(maxint + 0.0 <= maxint)
231+assert(maxint <= maxint + 0.0)
232+assert(not (maxint + 1.0 <= maxint))
216233assert(not (maxint + 0.5 <= maxint))
217−assert(not (maxint <= maxint - 1))
234+assert(not (maxint <= maxint - 1.0))
218235assert(not (maxint <= maxint - 0.5))
219−assert(minint < minint + 1)
236+assert(minint < minint + 1.0)
220237assert(minint < minint + 0.5)
221238assert(minint <= minint + 0.5)
222−assert(minint - 1 < minint)
223−assert(minint - 1 <= minint)
224−assert(not (minint + 0 < minint))
239+assert(minint - 1.0 < minint)
240+assert(minint - 1.0 <= minint)
241+assert(not (minint + 0.0 < minint))
225242assert(not (minint + 0.5 < minint))
226−assert(not (minint < minint + 0))
227−assert(minint + 0 <= minint)
228−assert(minint <= minint + 0)
229−assert(not (minint + 1 <= minint))
243+assert(not (minint < minint + 0.0))
244+assert(minint + 0.0 <= minint)
245+assert(minint <= minint + 0.0)
246+assert(not (minint + 1.0 <= minint))
230247assert(not (minint + 0.5 <= minint))
231−assert(not (minint <= minint - 1))
248+assert(not (minint <= minint - 1.0))
232249end
250+do
233251local NaN <const> = 0 / 0
234252assert(not (NaN < 0))
235253assert(not (NaN > minint))
@@ -240,16 +258,17 @@ assert(not (minint <= NaN))
240258assert(not (minint < NaN))
241259assert(not (4 <= NaN))
242260assert(not (4 < NaN))
261+end
243262local function checkcompt
244263(msg,code)
245264checkerror(msg,assert(load(code)))
246265end
247−checkcompt("divide by zero","return 2 // 0")
248−checkcompt(msgf2i,"return 2.3 >> 0")
249−checkcompt(msgf2i,("return 2.0^%d & 1"):format(intbits - 1))
250−checkcompt("field 'huge'","return math.huge << 1")
251−checkcompt(msgf2i,("return 1 | 2.0^%d"):format(intbits - 1))
252−checkcompt(msgf2i,"return 2.3 ~ 0.0")
266+checkcompt("\100\105\118\105\100\101\32\98\121\32\122\101\114\111","\114\101\116\117\114\110\32\50\32\47\47\32\48")
267+checkcompt(msgf2i,"\114\101\116\117\114\110\32\50\46\51\32\62\62\32\48")
268+checkcompt(msgf2i,("\114\101\116\117\114\110\32\50\46\48\94\37\100\32\38\32\49"):format(intbits - 1))
269+checkcompt("\102\105\101\108\100\32\39\104\117\103\101\39","\114\101\116\117\114\110\32\109\97\116\104\46\104\117\103\101\32\60\60\32\49")
270+checkcompt(msgf2i,("\114\101\116\117\114\110\32\49\32\124\32\50\46\48\94\37\100"):format(intbits - 1))
271+checkcompt(msgf2i,"\114\101\116\117\114\110\32\50\46\51\32\126\32\48\46\48")
253272local function f2i
254273(x)
255274return x | x
@@ -258,191 +277,193 @@ checkerror(msgf2i,f2i,math.huge)
258277checkerror(msgf2i,f2i,- math.huge)
259278checkerror(msgf2i,f2i,0 / 0)
260279if floatbits < intbits then
261−assert(maxint + 1 == maxint + 0)
262−assert(minint - 1 == minint + 0)
263−checkerror(msgf2i,f2i,maxint + 0)
264−assert(f2i(2 ^ (intbits - 2)) == 1 << (intbits - 2))
265−assert(f2i(- 2 ^ (intbits - 2)) == - (1 << (intbits - 2)))
266−assert((2 ^ (floatbits - 1) + 1) // 1 == (1 << (floatbits - 1)) + 1)
280+assert(maxint + 1.0 == maxint + 0.0)
281+assert(minint - 1.0 == minint + 0.0)
282+checkerror(msgf2i,f2i,maxint + 0.0)
283+assert(f2i(2.0 ^ (intbits - 2)) == 1 << (intbits - 2))
284+assert(f2i(- 2.0 ^ (intbits - 2)) == - (1 << (intbits - 2)))
285+assert((2.0 ^ (floatbits - 1) + 1.0) // 1 == (1 << (floatbits - 1)) + 1)
267286local mf = maxint - (1 << (floatbits - intbits)) + 1
268−assert(f2i(mf + 0) == mf)
287+assert(f2i(mf + 0.0) == mf)
269288mf=mf + 1
270−assert(f2i(mf + 0) ~= mf)
289+assert(f2i(mf + 0.0) ~= mf)
271290else
272−assert(maxint + 1 > maxint)
273−assert(minint - 1 < minint)
274−assert(f2i(maxint + 0) == maxint)
275−checkerror("no integer rep",f2i,maxint + 1)
276−checkerror("no integer rep",f2i,minint - 1)
277−end
278−assert(f2i(minint + 0) == minint)
279−assert("2" + 1 == 3)
280−assert("2 " + 1 == 3)
281−assert(" -2 " + 1 == - 1)
282−assert(" -0xa " + 1 == - 9)
291+assert(maxint + 1.0 > maxint)
292+assert(minint - 1.0 < minint)
293+assert(f2i(maxint + 0.0) == maxint)
294+checkerror("\110\111\32\105\110\116\101\103\101\114\32\114\101\112",f2i,maxint + 1.0)
295+checkerror("\110\111\32\105\110\116\101\103\101\114\32\114\101\112",f2i,minint - 1.0)
296+end
297+assert(f2i(minint + 0.0) == minint)
298+assert("\50" + 1 == 3)
299+assert("\50\32" + 1 == 3)
300+assert("\32\45\50\32" + 1 == - 1)
301+assert("\32\45\48\120\97\32" + 1 == - 9)
302+do
283303assert(eqT(tonumber(tostring(maxint)),maxint))
284304assert(eqT(tonumber(tostring(minint)),minint))
285305local function incd
286306(n)
287−local s = string.format("%d",n)
288−s=string.gsub(s,"%d$",(d)
289−assert(d ~= "9")
307+local s = string.format("\37\100",n)
308+s=string.gsub(s,"\37\100\36",function (d)
309+assert(d ~= "\57")
290310return string.char(string.byte(d) + 1)
291311end)
292312return s
293313end
294−assert(eqT(tonumber(incd(maxint)),maxint + 1))
295−assert(eqT(tonumber(incd(minint)),minint - 1))
296−assert(eqT(tonumber("1" .. string.rep("0",30)),1e30))
297−assert(eqT(tonumber("-1" .. string.rep("0",30)),- 1e30))
298−assert(eqT(tonumber("0x1" .. string.rep("0",30)),0))
299−assert(minint == load("return " .. minint)())
300−assert(eqT(maxint,load("return " .. maxint)()))
301−assert(eqT(1e22,1e22))
302−assert(eqT(- 1e22,- 1e22))
314+assert(eqT(tonumber(incd(maxint)),maxint + 1.0))
315+assert(eqT(tonumber(incd(minint)),minint - 1.0))
316+assert(eqT(tonumber("\49" .. string.rep("\48",30)),1e30.0))
317+assert(eqT(tonumber("\45\49" .. string.rep("\48",30)),- 1e30.0))
318+assert(eqT(tonumber("\48\120\49" .. string.rep("\48",30)),0))
319+assert(minint == load("\114\101\116\117\114\110\32" .. minint)())
320+assert(eqT(maxint,load("\114\101\116\117\114\110\32" .. maxint)()))
321+assert(eqT(1e22.0,10000000000000000000000))
322+assert(eqT(- 1e22.0,- 10000000000000000000000))
323+end
303324assert(tonumber(3.4) == 3.4)
304325assert(eqT(tonumber(3),3))
305326assert(eqT(tonumber(maxint),maxint) and eqT(tonumber(minint),minint))
306327assert(tonumber(1 / 0) == 1 / 0)
307−assert(tonumber("0") == 0)
328+assert(tonumber("\48") == 0)
308329assert(not tonumber(""))
309−assert(not tonumber(" "))
310−assert(not tonumber("-"))
311−assert(not tonumber(" -0x "))
330+assert(not tonumber("\32\32"))
331+assert(not tonumber("\45"))
332+assert(not tonumber("\32\32\45\48\120\32"))
312333assert(not tonumber({}))
313−assert(tonumber("+0.01") == 1 / 100 and tonumber("+.01") == 0.01 and tonumber(".01") == 0.01 and tonumber("-1.") == - 1 and tonumber("+1.") == 1)
314−assert(not tonumber("+ 0.01") and not tonumber("+.e1") and not tonumber("1e") and not tonumber("1.0e+") and not tonumber("."))
315−assert(tonumber("-012") == - 10 - 2)
316−assert(tonumber("-1.2e2") == - - - 120)
317−assert(tonumber("0xffffffffffff") == (1 << (4 * 12)) - 1)
318−assert(tonumber("0x" .. string.rep("f",(intbits // 4))) == - 1)
319−assert(tonumber("-0x" .. string.rep("f",(intbits // 4))) == 1)
320−assert(tonumber(" 001010 ",2) == 10)
321−assert(tonumber(" 001010 ",10) == 1010)
322−assert(tonumber(" -1010 ",2) == - 10)
323−assert(tonumber("10",36) == 36)
324−assert(tonumber(" -10 ",36) == - 36)
325−assert(tonumber(" +1Z ",36) == 36 + 35)
326−assert(tonumber(" -1z ",36) == - 36 + - 35)
327−assert(tonumber("-fFfa",16) == - (10 + (16 * (15 + (16 * (15 + (16 * 15)))))))
328−assert(tonumber(string.rep("1",(intbits - 2)),2) + 1 == 2 ^ (intbits - 2))
329−assert(tonumber("ffffFFFF",16) + 1 == (1 << 32))
330−assert(tonumber("0ffffFFFF",16) + 1 == (1 << 32))
331−assert(tonumber("-0ffffffFFFF",16) - 1 == - (1 << 40))
334+assert(tonumber("\43\48\46\48\49") == 1 / 100 and tonumber("\43\46\48\49") == 0.01 and tonumber("\46\48\49") == 0.01 and tonumber("\45\49\46") == - 1 and tonumber("\43\49\46") == 1)
335+assert(not tonumber("\43\32\48\46\48\49") and not tonumber("\43\46\101\49") and not tonumber("\49\101") and not tonumber("\49\46\48\101\43") and not tonumber("\46"))
336+assert(tonumber("\45\48\49\50") == - 10 - 2)
337+assert(tonumber("\45\49\46\50\101\50") == - - - 120)
338+assert(tonumber("\48\120\102\102\102\102\102\102\102\102\102\102\102\102") == (1 << (4 * 12)) - 1)
339+assert(tonumber("\48\120" .. string.rep("\102",(intbits // 4))) == - 1)
340+assert(tonumber("\45\48\120" .. string.rep("\102",(intbits // 4))) == 1)
341+assert(tonumber("\32\32\48\48\49\48\49\48\32\32",2) == 10)
342+assert(tonumber("\32\32\48\48\49\48\49\48\32\32",10) == 1010)
343+assert(tonumber("\32\32\45\49\48\49\48\32\32",2) == - 10)
344+assert(tonumber("\49\48",36) == 36)
345+assert(tonumber("\32\32\45\49\48\32\32",36) == - 36)
346+assert(tonumber("\32\32\43\49\90\32\32",36) == 36 + 35)
347+assert(tonumber("\32\32\45\49\122\32\32",36) == - 36 + - 35)
348+assert(tonumber("\45\102\70\102\97",16) == - (10 + (16 * (15 + (16 * (15 + (16 * 15)))))))
349+assert(tonumber(string.rep("\49",(intbits - 2)),2) + 1 == 2 ^ (intbits - 2))
350+assert(tonumber("\102\102\102\102\70\70\70\70",16) + 1 == (1 << 32))
351+assert(tonumber("\48\102\102\102\102\70\70\70\70",16) + 1 == (1 << 32))
352+assert(tonumber("\45\48\102\102\102\102\102\102\70\70\70\70",16) - 1 == - (1 << 40))
332353for i = 2, 36
333354do
334355local i2 = i * i
335356local i10 = i2 * i2 * i2 * i2 * i2
336−assert(tonumber(" 10000000000 ",i) == i10)
357+assert(tonumber("\9\49\48\48\48\48\48\48\48\48\48\48\9",i) == i10)
337358end
338359if not _soft then
339−assert(tonumber("0x" .. string.rep("f",13) .. ".0") == 2 ^ (4 * 13) - 1)
340−assert(tonumber("0x" .. string.rep("f",150) .. ".0") == 2 ^ (4 * 150) - 1)
341−assert(tonumber("0x" .. string.rep("f",300) .. ".0") == 2 ^ (4 * 300) - 1)
342−assert(tonumber("0x" .. string.rep("f",500) .. ".0") == 2 ^ (4 * 500) - 1)
343−assert(tonumber("0x3." .. string.rep("0",1e3)) == 3)
344−assert(tonumber("0x" .. string.rep("0",1e3) .. "a") == 10)
345−assert(tonumber("0x0." .. string.rep("0",13) .. "1") == 2 ^ (- 4 * 14))
346−assert(tonumber("0x0." .. string.rep("0",150) .. "1") == 2 ^ (- 4 * 151))
347−assert(tonumber("0x0." .. string.rep("0",300) .. "1") == 2 ^ (- 4 * 301))
348−assert(tonumber("0x0." .. string.rep("0",500) .. "1") == 2 ^ (- 4 * 501))
349−assert(tonumber("0xe03" .. string.rep("0",1e3) .. "p-4000") == 3587)
350−assert(tonumber("0x." .. string.rep("0",1e3) .. "74p4004") == 7.25)
360+assert(tonumber("\48\120" .. string.rep("\102",13) .. "\46\48") == 2.0 ^ (4 * 13) - 1)
361+assert(tonumber("\48\120" .. string.rep("\102",150) .. "\46\48") == 2.0 ^ (4 * 150) - 1)
362+assert(tonumber("\48\120" .. string.rep("\102",300) .. "\46\48") == 2.0 ^ (4 * 300) - 1)
363+assert(tonumber("\48\120" .. string.rep("\102",500) .. "\46\48") == 2.0 ^ (4 * 500) - 1)
364+assert(tonumber("\48\120\51\46" .. string.rep("\48",1000)) == 3)
365+assert(tonumber("\48\120" .. string.rep("\48",1000) .. "\97") == 10)
366+assert(tonumber("\48\120\48\46" .. string.rep("\48",13) .. "\49") == 2.0 ^ (- 4 * 14))
367+assert(tonumber("\48\120\48\46" .. string.rep("\48",150) .. "\49") == 2.0 ^ (- 4 * 151))
368+assert(tonumber("\48\120\48\46" .. string.rep("\48",300) .. "\49") == 2.0 ^ (- 4 * 301))
369+assert(tonumber("\48\120\48\46" .. string.rep("\48",500) .. "\49") == 2.0 ^ (- 4 * 501))
370+assert(tonumber("\48\120\101\48\51" .. string.rep("\48",1000) .. "\112\45\52\48\48\48") == 3587.0)
371+assert(tonumber("\48\120\46" .. string.rep("\48",1000) .. "\55\52\112\52\48\48\52") == 7.25)
351372end
352373local function f
353374(...)
354−if select("#",...) == 1 then
375+if select("\35",...) == 1 then
355376return (...)
356377else
357−return "***"
378+return "\42\42\42"
358379end
359380end
360−assert(not f(tonumber("fFfa",15)))
361−assert(not f(tonumber("099",8)))
362−assert(not f(tonumber("1",2)))
381+assert(not f(tonumber("\102\70\102\97",15)))
382+assert(not f(tonumber("\48\57\57",8)))
383+assert(not f(tonumber("\49",2)))
363384assert(not f(tonumber("",8)))
364−assert(not f(tonumber(" ",9)))
365−assert(not f(tonumber(" ",9)))
366−assert(not f(tonumber("0xf",10)))
367−assert(not f(tonumber("inf")))
368−assert(not f(tonumber(" INF ")))
369−assert(not f(tonumber("Nan")))
370−assert(not f(tonumber("nan")))
371−assert(not f(tonumber(" ")))
385+assert(not f(tonumber("\32\32",9)))
386+assert(not f(tonumber("\32\32",9)))
387+assert(not f(tonumber("\48\120\102",10)))
388+assert(not f(tonumber("\105\110\102")))
389+assert(not f(tonumber("\32\73\78\70\32")))
390+assert(not f(tonumber("\78\97\110")))
391+assert(not f(tonumber("\110\97\110")))
392+assert(not f(tonumber("\32\32")))
372393assert(not f(tonumber("")))
373−assert(not f(tonumber("1 a")))
374−assert(not f(tonumber("1 a",2)))
375−assert(not f(tonumber("1")))
376−assert(not f(tonumber("1 ")))
377−assert(not f(tonumber("1 ")))
378−assert(not f(tonumber("e1")))
379−assert(not f(tonumber("e 1")))
380−assert(not f(tonumber(" 3.4.5 ")))
381−assert(not tonumber("0x"))
382−assert(not tonumber("x"))
383−assert(not tonumber("x3"))
384−assert(not tonumber("0x3.3.3"))
385−assert(not tonumber("00x2"))
386−assert(not tonumber("0x 2"))
387−assert(not tonumber("0 x2"))
388−assert(not tonumber("23x"))
389−assert(not tonumber("- 0xaa"))
390−assert(not tonumber("-0xaaP "))
391−assert(not tonumber("0x0.51p"))
392−assert(not tonumber("0x5p+-2"))
394+assert(not f(tonumber("\49\32\32\97")))
395+assert(not f(tonumber("\49\32\32\97",2)))
396+assert(not f(tonumber("\49")))
397+assert(not f(tonumber("\49\32")))
398+assert(not f(tonumber("\49\32")))
399+assert(not f(tonumber("\101\49")))
400+assert(not f(tonumber("\101\32\32\49")))
401+assert(not f(tonumber("\32\51\46\52\46\53\32")))
402+assert(not tonumber("\48\120"))
403+assert(not tonumber("\120"))
404+assert(not tonumber("\120\51"))
405+assert(not tonumber("\48\120\51\46\51\46\51"))
406+assert(not tonumber("\48\48\120\50"))
407+assert(not tonumber("\48\120\32\50"))
408+assert(not tonumber("\48\32\120\50"))
409+assert(not tonumber("\50\51\120"))
410+assert(not tonumber("\45\32\48\120\97\97"))
411+assert(not tonumber("\45\48\120\97\97\80\32"))
412+assert(not tonumber("\48\120\48\46\53\49\112"))
413+assert(not tonumber("\48\120\53\112\43\45\50"))
393414assert(16 == 16 and 4095 == 2 ^ 12 - 1 and 251 == 251)
394−assert(0 == 0 and 0 == 0)
415+assert(0.0 == 0 and 0.0 == 0)
395416assert(4294967295 == (1 << 32) - 1)
396−assert(tonumber("+0x2") == 2)
397−assert(tonumber("-0xaA") == - 170)
398−assert(tonumber("-0xffFFFfff") == - (1 << 32) + 1)
399−assert(0 == 0 and 14 + 1 == 15 and 14 - 1 == 13)
400−assert(tonumber(" 0x2.5 ") == 37 / 16)
401−assert(tonumber(" -0x2.5 ") == - 37 / 16)
402−assert(tonumber(" +0x0.51p+8 ") == 81)
403−assert(0.9999999997671694 == 1 - "0x.00000001")
404−assert("0xA.a" + 0 == 10 + 10 / 16)
405−assert(170 == 170)
406−assert(1 == 1)
407−assert(1.0625 == "0x1." + "+0x.1")
408−assert(11259375 == 11259375)
409−assert(1.1 == 1 + 0.1)
410−assert(100 == 100 and 0.01 == 0.01)
411−assert(1111111111 - 1111111110 == 1)
412−assert(1.1 == "1." + ".1")
413−assert(tonumber("1111111111") - tonumber("1111111110") == tonumber(" +0.001e+3
414− "))
415−assert(1e-31 > 9e-32 and 9e29 < 1e30)
417+assert(tonumber("\43\48\120\50") == 2)
418+assert(tonumber("\45\48\120\97\65") == - 170)
419+assert(tonumber("\45\48\120\102\102\70\70\70\102\102\102") == - (1 << 32) + 1)
420+assert(0.0 == 0 and 14 + 1 == 15 and 14 - 1 == 13)
421+assert(tonumber("\32\32\48\120\50\46\53\32\32") == 37 / 16)
422+assert(tonumber("\32\32\45\48\120\50\46\53\32\32") == - 37 / 16)
423+assert(tonumber("\32\32\43\48\120\48\46\53\49\112\43\56\32\32") == 81)
424+assert(0.9999999997671694 == 1 - "\48\120\46\48\48\48\48\48\48\48\49")
425+assert("\48\120\65\46\97" + 0 == 10 + 10 / 16)
426+assert(170.0 == 170)
427+assert(1.0 == 1)
428+assert(1.0625 == "\48\120\49\46" + "\43\48\120\46\49")
429+assert(11259375.0 == 11259375.0)
430+assert(1.1 == 1.0 + 0.1)
431+assert(100.0 == 100.0 and 0.01 == 0.01)
432+assert(1111111111 - 1111111110 == 1.0)
433+assert(1.1 == "\49\46" + "\46\49")
434+assert(tonumber("\49\49\49\49\49\49\49\49\49\49") - tonumber("\49\49\49\49\49\49\49\49\49\48") == tonumber("\32\32\43\48\46\48\48\49\101\43\51\32\10\9"))
435+assert(1e-31.0 > 9e-32.0 and 9e29.0 < 1e30.0)
416436assert(0.123456 > 0.123455)
417−assert(tonumber("+1.23E18") == 1.23 * 10 ^ 18)
437+assert(tonumber("\43\49\46\50\51\69\49\56") == 1.23 * 10.0 ^ 18)
418438assert(not (1 < 1) and (1 < 2) and not (2 < 1))
419−assert(not ("a" < "a") and ("a" < "b") and not ("b" < "a"))
439+assert(not ("\97" < "\97") and ("\97" < "\98") and not ("\98" < "\97"))
420440assert((1 <= 1) and (1 <= 2) and not (2 <= 1))
421−assert(("a" <= "a") and ("a" <= "b") and not ("b" <= "a"))
441+assert(("\97" <= "\97") and ("\97" <= "\98") and not ("\98" <= "\97"))
422442assert(not (1 > 1) and not (1 > 2) and (2 > 1))
423−assert(not ("a" > "a") and not ("a" > "b") and ("b" > "a"))
443+assert(not ("\97" > "\97") and not ("\97" > "\98") and ("\98" > "\97"))
424444assert((1 >= 1) and not (1 >= 2) and (2 >= 1))
425−assert(("a" >= "a") and not ("a" >= "b") and ("b" >= "a"))
445+assert(("\97" >= "\97") and not ("\97" >= "\98") and ("\98" >= "\97"))
426446assert(1.3 < 1.4 and 1.3 <= 1.4 and not (1.3 < 1.3) and 1.3 <= 1.3)
427447assert(eqT(- 4 % 3,2))
428448assert(eqT(4 % - 3,- 2))
429−assert(eqT(- 4 % 3,2))
430−assert(eqT(4 % - 3,- 2))
449+assert(eqT(- 4.0 % 3,2.0))
450+assert(eqT(4 % - 3.0,- 2.0))
431451assert(eqT(4 % - 5,- 1))
432−assert(eqT(4 % - 5,- 1))
433−assert(eqT(4 % 5,4))
452+assert(eqT(4 % - 5.0,- 1.0))
434453assert(eqT(4 % 5,4))
454+assert(eqT(4 % 5.0,4.0))
435455assert(eqT(- 4 % - 5,- 4))
436−assert(eqT(- 4 % - 5,- 4))
437−assert(eqT(- 4 % 5,1))
456+assert(eqT(- 4 % - 5.0,- 4.0))
438457assert(eqT(- 4 % 5,1))
458+assert(eqT(- 4 % 5.0,1.0))
439459assert(eqT(4.25 % 4,0.25))
440−assert(eqT(10 % 2,0))
441−assert(eqT(- 10 % 2,0))
442−assert(eqT(- 10 % - 2,0))
460+assert(eqT(10.0 % 2,0.0))
461+assert(eqT(- 10.0 % 2,0.0))
462+assert(eqT(- 10.0 % - 2,0.0))
443463assert(math.pi - math.pi % 1 == 3)
444−assert(math.pi - math.pi % 1e-3 == 3.141)
445−local i,j = 0,2e4
464+assert(math.pi - math.pi % 1e-3.0 == 3.141)
465+do
466+local i,j = 0,20000
446467while i < j do
447468local m = (i + j) // 2
448469if 10 ^ - m > 0 then
@@ -450,19 +471,21 @@ i=m + 1
450471else
451472j=m
452473end
474+end
453475local b = 10 ^ - (i - (i // 10))
454476assert(b > 0 and b * b == 0)
455−local delta = b / 1e3
477+local delta = b / 1000
456478assert(eq((2.1 * b) % (2 * b),(0.1 * b),delta))
457479assert(eq((- 2.1 * b) % (2 * b),(2 * b) - (0.1 * b),delta))
458480assert(eq((2.1 * b) % (- 2 * b),(0.1 * b) - (2 * b),delta))
459481assert(eq((- 2.1 * b) % (- 2 * b),(- 0.1 * b),delta))
482+end
460483for i = - 10, 10
461484do
462485for j = - 10, 10
463486do
464487if j ~= 0 then
465−assert((i + 0) % j == i % j)
488+assert((i + 0.0) % j == i % j)
466489end
467490end
468491end
@@ -475,14 +498,18 @@ assert((2 ^ i) % j == (1 << i) % j)
475498end
476499end
477500end
501+do
478502local i = 10
479503while (1 << i) > 0 do
480504assert((1 << i) % 3 == i % 2 + 1)
481505i=i + 1
506+end
482507i=10
483508while 2 ^ i < math.huge do
484509assert(2 ^ i % 3 == i % 2 + 1)
485510i=i + 1
511+end
512+end
486513assert(eqT(minint % minint,0))
487514assert(eqT(maxint % maxint,0))
488515assert((minint + 1) % minint == minint + 1)
@@ -496,15 +523,15 @@ local function anan
496523(x)
497524assert(isNaN(x))
498525end
499−anan(0 % 0)
526+anan(0.0 % 0)
500527anan(1.3 % 0)
501528anan(math.huge % 1)
502−anan(math.huge % 1e30)
503−anan(- math.huge % 1e30)
504−anan(- math.huge % - 1e30)
529+anan(math.huge % 1e30.0)
530+anan(- math.huge % 1e30.0)
531+anan(- math.huge % - 1e30.0)
505532assert(1 % math.huge == 1)
506−assert(1e30 % math.huge == 1e30)
507−assert(1e30 % - math.huge == - math.huge)
533+assert(1e30.0 % math.huge == 1e30.0)
534+assert(1e30.0 % - math.huge == - math.huge)
508535assert(- 1 % math.huge == math.huge)
509536assert(- 1 % - math.huge == - 1)
510537end
@@ -532,11 +559,12 @@ assert(eq(math.log(2,2),1))
532559assert(eq(math.log(9,3),2))
533560assert(eq(math.exp(0),1))
534561assert(eq(math.sin(10),math.sin(10 % (2 * math.pi))))
535−assert(tonumber(" 1.3e-2 ") == 0.013)
536−assert(tonumber(" -1.00000000000001 ") == - 1.00000000000001)
562+assert(tonumber("\32\49\46\51\101\45\50\32") == 0.013)
563+assert(tonumber("\32\45\49\46\48\48\48\48\48\48\48\48\48\48\48\48\48\49\32") == - 1.00000000000001)
537564assert(8388609 + - 8388609 == 0)
538565assert(8388608 + - 8388608 == 0)
539566assert(8388607 + - 8388607 == 0)
567+do
540568assert(eqT(math.floor(3.4),3))
541569assert(eqT(math.ceil(3.4),4))
542570assert(eqT(math.floor(- 3.4),- 4))
@@ -544,13 +572,13 @@ assert(eqT(math.ceil(- 3.4),- 3))
544572assert(eqT(math.floor(maxint),maxint))
545573assert(eqT(math.ceil(maxint),maxint))
546574assert(eqT(math.floor(minint),minint))
547−assert(eqT(math.floor(minint + 0),minint))
575+assert(eqT(math.floor(minint + 0.0),minint))
548576assert(eqT(math.ceil(minint),minint))
549−assert(eqT(math.ceil(minint + 0),minint))
550−assert(math.floor(1e50) == 1e50)
551−assert(math.ceil(1e50) == 1e50)
552−assert(math.floor(- 1e50) == - 1e50)
553−assert(math.ceil(- 1e50) == - 1e50)
577+assert(eqT(math.ceil(minint + 0.0),minint))
578+assert(math.floor(1e50.0) == 1e50.0)
579+assert(math.ceil(1e50.0) == 1e50.0)
580+assert(math.floor(- 1e50.0) == - 1e50.0)
581+assert(math.ceil(- 1e50.0) == - 1e50.0)
554582for _,p in pairs({31,32,63,64})
555583do
556584assert(math.floor(2 ^ p) == 2 ^ p)
@@ -558,14 +586,14 @@ assert(math.floor(2 ^ p + 0.5) == 2 ^ p)
558586assert(math.ceil(2 ^ p) == 2 ^ p)
559587assert(math.ceil(2 ^ p - 0.5) == 2 ^ p)
560588end
561−checkerror("number expected",math.floor,{})
562−checkerror("number expected",math.ceil,print)
589+checkerror("\110\117\109\98\101\114\32\101\120\112\101\99\116\101\100",math.floor,{})
590+checkerror("\110\117\109\98\101\114\32\101\120\112\101\99\116\101\100",math.ceil,print)
563591assert(eqT(math.tointeger(minint),minint))
564592assert(eqT(math.tointeger(minint .. ""),minint))
565593assert(eqT(math.tointeger(maxint),maxint))
566594assert(eqT(math.tointeger(maxint .. ""),maxint))
567−assert(eqT(math.tointeger(minint + 0),minint))
568−assert(not math.tointeger(0 - minint))
595+assert(eqT(math.tointeger(minint + 0.0),minint))
596+assert(not math.tointeger(0.0 - minint))
569597assert(not math.tointeger(math.pi))
570598assert(not math.tointeger(- math.pi))
571599assert(math.floor(math.huge) == math.huge)
@@ -574,19 +602,20 @@ assert(not math.tointeger(math.huge))
574602assert(math.floor(- math.huge) == - math.huge)
575603assert(math.ceil(- math.huge) == - math.huge)
576604assert(not math.tointeger(- math.huge))
577−assert(math.tointeger("34.0") == 34)
578−assert(not math.tointeger("34.3"))
605+assert(math.tointeger("\51\52\46\48") == 34)
606+assert(not math.tointeger("\51\52\46\51"))
579607assert(not math.tointeger({}))
580608assert(not math.tointeger(0 / 0))
609+end
581610for i = - 6, 6
582611do
583612for j = - 6, 6
584613do
585614if j ~= 0 then
586615local mi = math.fmod(i,j)
587−local mf = math.fmod(i + 0,j)
616+local mf = math.fmod(i + 0.0,j)
588617assert(mi == mf)
589−assert(math.type(mi) == "integer" and math.type(mf) == "float")
618+assert(math.type(mi) == "\105\110\116\101\103\101\114" and math.type(mf) == "\102\108\111\97\116")
590619if (i >= 0 and j >= 0) or (i <= 0 and j <= 0) or mi == 0 then
591620assert(eqT(mi,i % j))
592621end
@@ -597,26 +626,29 @@ assert(eqT(math.fmod(minint,minint),0))
597626assert(eqT(math.fmod(maxint,maxint),0))
598627assert(eqT(math.fmod(minint + 1,minint),minint + 1))
599628assert(eqT(math.fmod(maxint - 1,maxint),maxint - 1))
600−checkerror("zero",math.fmod,3,0)
601−checkerror("value expected",math.max)
602−checkerror("value expected",math.min)
629+checkerror("\122\101\114\111",math.fmod,3,0)
630+do
631+checkerror("\118\97\108\117\101\32\101\120\112\101\99\116\101\100",math.max)
632+checkerror("\118\97\108\117\101\32\101\120\112\101\99\116\101\100",math.min)
603633assert(eqT(math.max(3),3))
604634assert(eqT(math.max(3,5,9,1),9))
605−assert(math.max(maxint,1e61) == 1e61)
635+assert(math.max(maxint,1e61.0) == 1e61.0)
606636assert(eqT(math.max(minint,minint + 1),minint + 1))
607637assert(eqT(math.min(3),3))
608638assert(eqT(math.min(3,5,9,1),1))
609639assert(math.min(3.2,5.9,- 9.2,1.1) == - 9.2)
610640assert(math.min(1.9,1.7,1.72) == 1.7)
611−assert(math.min(- 1e61,minint) == - 1e61)
641+assert(math.min(- 1e61.0,minint) == - 1e61.0)
612642assert(eqT(math.min(maxint,maxint - 1),maxint - 1))
613643assert(eqT(math.min(maxint - 2,maxint,maxint - 1),maxint - 2))
614−local a,b = "10","20"
644+end
645+local a,b = "\49\48","\50\48"
615646assert(a * b == 200 and a + b == 30 and a - b == - 10 and a / b == 0.5 and - b == - 20)
616−assert(a == "10" and b == "20")
617−print("testing -0 and NaN")
618−local mz <const> = - 0
619−local z <const> = 0
647+assert(a == "\49\48" and b == "\50\48")
648+do
649+print("\116\101\115\116\105\110\103\32\45\48\32\97\110\100\32\78\97\78")
650+local mz <const> = - 0.0
651+local z <const> = 0.0
620652assert(mz == z)
621653assert(1 / mz < 0 and 0 < 1 / z)
622654local a = {[mz] = 1}
@@ -646,19 +678,21 @@ assert(a[NaN] == undef)
646678local a1,a2,a3,a4,a5 = 0,0,"",0,""
647679assert(a1 == a2 and a2 == a4 and a1 ~= a3)
648680assert(a3 == a5)
649−print("testing 'math.random'")
681+end
682+print("\116\101\115\116\105\110\103\32\39\109\97\116\104\46\114\97\110\100\111\109\39")
650683local random,max,min = math.random,math.max,math.min
651684local function testnear
652685(val,ref,tol)
653686return (math.abs(val - ref) < ref * tol)
654687end
688+do
655689local h <const> = 2054176933
656690local l <const> = 2737031638
657691math.randomseed(1007)
658692local res = (h << 32 | l) & ~ (~ 0 << intbits)
659693assert(random(0) == res)
660694math.randomseed(1007,0)
661−local res =
695+local res
662696if floatbits <= 32 then
663697res=(h >> (32 - floatbits)) % 2 ^ 32
664698else
@@ -667,13 +701,17 @@ end
667701local rand = random()
668702assert(eq(rand,0.4782753376376966,2 ^ - floatbits))
669703assert(rand * 2 ^ floatbits == res)
704+end
705+do
670706local x,y = math.randomseed()
671707local res = math.random(0)
672708x,y=math.randomseed(x,y)
673709assert(math.random(0) == res)
674710math.randomseed(x,y)
675711assert(math.random(0) == res)
676−print(string.format("random seeds: %d, %d",x,y))
712+print(string.format("\114\97\110\100\111\109\32\115\101\101\100\115\58\32\37\100\44\32\37\100",x,y))
713+end
714+do
677715local randbits = math.min(floatbits,64)
678716local mult = 2 ^ randbits
679717local counts = {}
@@ -699,7 +737,7 @@ counts[bit + 1]=counts[bit + 1] + 1
699737end
700738end
701739totalrounds=totalrounds + rounds
702−if not (eq(up,1,1e-3) and eq(low,0,1e-3)) then
740+if not (eq(up,1,1e-3.0) and eq(low,0,1e-3.0)) then
703741goto doagain
704742end
705743local expected = (totalrounds / randbits / 2)
@@ -709,7 +747,9 @@ if not testnear(counts[i],expected,0.1) then
709747goto doagain
710748end
711749end
712−print(string.format("float random range in %d calls: [%f, %f]",totalrounds,low,up))
750+print(string.format("\102\108\111\97\116\32\114\97\110\100\111\109\32\114\97\110\103\101\32\105\110\32\37\100\32\99\97\108\108\115\58\32\91\37\102\44\32\37\102\93",totalrounds,low,up))
751+end
752+do
713753local up = 0
714754local low = 0
715755local counts = {}
@@ -740,7 +780,9 @@ if not testnear(counts[i],expected,0.1) then
740780goto doagain
741781end
742782end
743−print(string.format("integer random range in %d calls: [minint + %.0fppm, maxint - %.0fppm]",totalrounds,(minint - low) / minint * 1e6,(maxint - up) / maxint * 1e6))
783+print(string.format("\105\110\116\101\103\101\114\32\114\97\110\100\111\109\32\114\97\110\103\101\32\105\110\32\37\100\32\99\97\108\108\115\58\32\91\109\105\110\105\110\116\32\43\32\37\46\48\102\112\112\109\44\32\109\97\120\105\110\116\32\45\32\37\46\48\102\112\112\109\93",totalrounds,(minint - low) / minint * 1e6.0,(maxint - up) / maxint * 1e6.0))
784+end
785+do
744786local count = {0,0,0,0,0,0}
745787local rep = 200
746788local totalrep = 0
@@ -757,6 +799,8 @@ if not testnear(count[i],totalrep,0.05) then
757799goto doagain
758800end
759801end
802+end
803+do
760804local function aux
761805(x1,x2)
762806local mark = {}
@@ -772,6 +816,7 @@ if count == x2 - x1 + 1 then
772816goto ok
773817end
774818end
819+end
775820::ok::
776821end
777822aux(- 10,0)
@@ -787,6 +832,8 @@ aux(minint,minint)
787832aux(maxint,maxint)
788833aux(minint,minint + 9)
789834aux(maxint - 3,maxint)
835+end
836+do
790837local function aux
791838(p1,p2)
792839local max = minint
@@ -824,8 +871,9 @@ aux(minint,maxint)
824871aux(minint + 1,maxint)
825872aux(minint,maxint - 1)
826873aux(0,1 << (intbits - 5))
874+end
827875assert(not pcall(random,1,2,3))
828876assert(not pcall(random,minint + 1,minint))
829877assert(not pcall(random,maxint,maxint - 1))
830878assert(not pcall(random,maxint,minint))
831−print("OK")
879+print("\79\75")
zod/luau/res/lua/cycled/nextvar.lua+173−142
@@ -1,4 +1,4 @@
1−print("testing tables, next, and for")
1+print("\116\101\115\116\105\110\103\32\116\97\98\108\101\115\44\32\110\101\120\116\44\32\97\110\100\32\102\111\114")
22local function checkerror
33(msg,f, ...)
44local s,err = pcall(f,...)
@@ -18,17 +18,18 @@ end
1818local a = {}
1919for i = 1, 100
2020do
21−a[i .. "+"]=true
21+a[i .. "\43"]=true
2222end
2323for i = 1, 100
2424do
25−a[i .. "+"]=undef
25+a[i .. "\43"]=undef
2626end
2727for i = 1, 100
2828do
2929a[i]=true
3030assert(# a == i)
3131end
32+do
3233local a = {}
3334for i = 1, 100
3435do
@@ -55,13 +56,14 @@ do
5556assert(a[i] == i)
5657end
5758assert(a.x == 1)
59+end
5860local x = 0
59−for k,v in ipairs({10,20,30,["x"] = 12})
61+for k,v in ipairs({10,20,30,["\120"] = 12})
6062do
6163x=x + 1
6264assert(k == x and v == x * 10)
6365end
64−for _ in ipairs({["x"] = 12,["y"] = 24})
66+for _ in ipairs({["\120"] = 12,["\121"] = 24})
6567do
6668assert(nil)
6769end
@@ -74,16 +76,16 @@ x=not x
7476assert(x == v)
7577end
7678assert(i == 4)
77−assert(type(ipairs({})) == "function" and ipairs({}) == ipairs({}))
79+assert(type(ipairs({})) == "\102\117\110\99\116\105\111\110" and ipairs({}) == ipairs({}))
80+do
7881local f = ipairs({})
7982local k,v = f({[math.mininteger] = 10},math.maxinteger)
8083assert(k == math.mininteger and v == 10)
8184k,v=f({[math.mininteger] = 10},k)
8285assert(k == nil)
86+end
8387if not T then
84−(Message or print)("
85− >>> testC not active: skipping tests for table sizes <<<
86−")
88+(Message or print)("\10\32\62\62\62\32\116\101\115\116\67\32\110\111\116\32\97\99\116\105\118\101\58\32\115\107\105\112\112\105\110\103\32\116\101\115\116\115\32\102\111\114\32\116\97\98\108\101\32\115\105\122\101\115\32\60\60\60\10")
8789else
8890local function mp2
8991(n)
@@ -91,30 +93,32 @@ local mp = 2 ^ math.ceil(math.log(n,2))
9193assert(n == 0 or (mp / 2 < n and n <= mp))
9294return mp
9395end
96+do
9497local s = 0
9598for _ in pairs(math)
9699do
97100s=s + 1
98101end
99102check(math,0,mp2(s))
100−local sizes = {0,1,2,3,4,5,7,8,9,15,16,17,30,31,32,33,34,254,255,256,500,1e3}
103+end
104+local sizes = {0,1,2,3,4,5,7,8,9,15,16,17,30,31,32,33,34,254,255,256,500,1000}
101105for _,sa in ipairs(sizes)
102106do
103−local arr = {"return {"}
107+local arr = {"\114\101\116\117\114\110\32\123"}
104108for i = 1, sa
105109do
106−arr[1 + i]="1,"
110+arr[1 + i]="\49\44"
107111end
108112for _,sh in ipairs(sizes)
109113do
110114for j = 1, sh
111115do
112−arr[1 + sa + j]=string.format("k%x=%d,",j,j)
116+arr[1 + sa + j]=string.format("\107\37\120\61\37\100\44",j,j)
113117end
114−arr[1 + sa + sh + 1]="}"
118+arr[1 + sa + sh + 1]="\125"
115119local prog = table.concat(arr)
116120local f = assert(load(prog))
117−collectgarbage("stop")
121+collectgarbage("\115\116\111\112")
118122f()
119123if sa == 0 or sh == 0 then
120124T.alloccount(2)
@@ -126,7 +130,7 @@ end
126130local t = f()
127131T.alloccount()
128132;
129−collectgarbage("restart")
133+collectgarbage("\114\101\115\116\97\114\116")
130134assert(# t == sa)
131135check(t,sa,mp2(sh))
132136end
@@ -177,7 +181,7 @@ end
177181a={}
178182for i = 1, lim
179183do
180−a["a" .. i]=1
184+a["\97" .. i]=1
181185assert(# a == 0)
182186check(a,0,mp2(i))
183187end
@@ -187,6 +191,7 @@ do
187191a[i]=i
188192end
189193check(a,16,0)
194+do
190195for i = 1, 11
191196do
192197a[i]=undef
@@ -219,6 +224,7 @@ a[i]=true
219224a[i]=undef
220225end
221226check(a,0,4)
227+end
222228for i = 1, lim
223229do
224230local a = {}
@@ -233,7 +239,7 @@ local function foo
233239(n, ...)
234240local arg = {...}
235241check(arg,n,0)
236−assert(select("#",...) == n)
242+assert(select("\35",...) == n)
237243arg[n + 1]=true
238244check(arg,mp2(n + 1),0)
239245arg.x=true
@@ -273,14 +279,14 @@ assert(# {nil,nil} == 0)
273279assert(# {nil,nil,nil} == 0)
274280assert(# {nil,nil,nil,nil} == 0)
275281assert(# {1,2,3,nil,nil} == 3)
276−print("+")
282+print("\43")
277283local nofind = {}
278284a,b,c=1,2,3
279285a,b,c=nil
280286assert(next({}) == next({}))
281287local function find
282288(name)
283−local n,v =
289+local n,v
284290while 1 do
285291n,v=next(_G,n)
286292if not n then
@@ -291,6 +297,7 @@ if n == name then
291297return v
292298end
293299end
300+end
294301local function find1
295302(name)
296303for n,v in pairs(_G)
@@ -301,34 +308,35 @@ end
301308end
302309return nil
303310end
304−assert(print == find("print") and print == find1("print"))
305−assert(_G["print"] == find("print"))
306−assert(assert == find1("assert"))
307−assert(nofind == find("return"))
308−assert(not find1("return"))
309−_G["ret" .. "urn"]=undef
310−assert(nofind == find("return"))
311−_G["xxx"]=1
312−assert(xxx == find("xxx"))
313−checkerror("invalid key",next,{10,20},3)
314−checkerror("bad argument",pairs)
315−checkerror("bad argument",ipairs)
316−print("+")
311+assert(print == find("\112\114\105\110\116") and print == find1("\112\114\105\110\116"))
312+assert(_G["\112\114\105\110\116"] == find("\112\114\105\110\116"))
313+assert(assert == find1("\97\115\115\101\114\116"))
314+assert(nofind == find("\114\101\116\117\114\110"))
315+assert(not find1("\114\101\116\117\114\110"))
316+_G["\114\101\116" .. "\117\114\110"]=undef
317+assert(nofind == find("\114\101\116\117\114\110"))
318+_G["\120\120\120"]=1
319+assert(xxx == find("\120\120\120"))
320+checkerror("\105\110\118\97\108\105\100\32\107\101\121",next,{10,20},3)
321+checkerror("\98\97\100\32\97\114\103\117\109\101\110\116",pairs)
322+checkerror("\98\97\100\32\97\114\103\117\109\101\110\116",ipairs)
323+print("\43")
317324a={}
318−for i = 0, 1e4
325+for i = 0, 10000
319326do
320327if math.fmod(i,10) ~= 0 then
321−a["x" .. i]=i
328+a["\120" .. i]=i
322329end
323330end
324−n={["n"] = 0}
331+n={["\110"] = 0}
325332for i,v in pairs(a)
326333do
327334n.n=n.n + 1
328335assert(i and v and a[i] == v)
329336end
330−assert(n.n == 9e3)
337+assert(n.n == 9000)
331338a=nil
339+do
332340local a = {}
333341for n,v in pairs(_G)
334342do
@@ -336,20 +344,24 @@ a[n]=v
336344end
337345for n,v in pairs(a)
338346do
339−if not package.loaded[n] and type(v) ~= "function" and not string.find(n,"^[%u_]") then
347+if not package.loaded[n] and type(v) ~= "\102\117\110\99\116\105\111\110" and not string.find(n,"\94\91\37\117\95\93") then
340348_G[n]=undef
341349end
342350collectgarbage()
343351end
352+end
344353local function checknext
345354(a)
346355local b = {}
356+do
347357local k,v = next(a)
348358;
349359while k do
350360b[k]=v
351361;
352362k,v=next(a,k)
363+end
364+end
353365for k,v in pairs(b)
354366do
355367assert(a[k] == v)
@@ -359,11 +371,11 @@ do
359371assert(b[k] == v)
360372end
361373end
362−checknext({1,["x"] = 1,["y"] = 2,["z"] = 3})
363−checknext({1,2,["x"] = 1,["y"] = 2,["z"] = 3})
364−checknext({1,2,3,["x"] = 1,["y"] = 2,["z"] = 3})
365−checknext({1,2,3,4,["x"] = 1,["y"] = 2,["z"] = 3})
366−checknext({1,2,3,4,5,["x"] = 1,["y"] = 2,["z"] = 3})
374+checknext({1,["\120"] = 1,["\121"] = 2,["\122"] = 3})
375+checknext({1,2,["\120"] = 1,["\121"] = 2,["\122"] = 3})
376+checknext({1,2,3,["\120"] = 1,["\121"] = 2,["\122"] = 3})
377+checknext({1,2,3,4,["\120"] = 1,["\121"] = 2,["\122"] = 3})
378+checknext({1,2,3,4,5,["\120"] = 1,["\121"] = 2,["\122"] = 3})
367379assert(# {} == 0)
368380assert(# {[- 1] = 2} == 0)
369381for i = 0, 40
@@ -379,14 +391,14 @@ function table.maxn(t)
379391local max = 0
380392for k in pairs(t)
381393do
382−max=(type(k) == "number") and math.max(max,k) or max
394+max=(type(k) == "\110\117\109\98\101\114") and math.max(max,k) or max
383395end
384396return max
385397end
386398assert(table.maxn({}) == 0)
387−assert(table.maxn({["1000"] = true}) == 0)
388−assert(table.maxn({["1000"] = true,[24.5] = 3}) == 24.5)
389−assert(table.maxn({[1e3] = true}) == 1e3)
399+assert(table.maxn({["\49\48\48\48"] = true}) == 0)
400+assert(table.maxn({["\49\48\48\48"] = true,[24.5] = 3}) == 24.5)
401+assert(table.maxn({[1000] = true}) == 1000)
390402assert(table.maxn({[10] = true,[100 * math.pi] = print}) == 100 * math.pi)
391403table.maxn=nil
392404a={}
@@ -395,8 +407,9 @@ do
395407a[2 ^ i]=true
396408end
397409assert(a[# a])
398−print("+")
399−local a = {[1] = 1,[1.1] = 2,["x"] = 3,[string.rep("x",1e3)] = 4,[print] = 5,[checkerror] = 6,[coroutine.running()] = 7,[true] = 8,[io.stdin] = 9,[{}] = 10}
410+print("\43")
411+do
412+local a = {[1] = 1,[1.1] = 2,["\120"] = 3,[string.rep("\120",1000)] = 4,[print] = 5,[checkerror] = 6,[coroutine.running()] = 7,[true] = 8,[io.stdin] = 9,[{}] = 10}
400413local b = {}
401414;
402415for i = 1, 10
@@ -410,7 +423,8 @@ assert(b[v])
410423b[v]=undef
411424end
412425assert(next(b) == nil)
413−local t = {[{1}] = 1,[{2}] = 2,[string.rep("x ",4)] = 3,[100.3] = 4,[4] = 5}
426+end
427+local t = {[{1}] = 1,[{2}] = 2,[string.rep("\120\32",4)] = 3,[100.3] = 4,[4] = 5}
414428local n = 0
415429for k,v in pairs(t)
416430do
@@ -421,14 +435,15 @@ collectgarbage()
421435assert(t[k] == undef)
422436end
423437assert(n == 5)
424−print("testing next x GC of deleted keys")
425−local co = coroutine.wrap((t)
438+do
439+print("\116\101\115\116\105\110\103\32\110\101\120\116\32\120\32\71\67\32\111\102\32\100\101\108\101\116\101\100\32\107\101\121\115")
440+local co = coroutine.wrap(function (t)
426441for k,v in pairs(t)
427442do
428443local k1 = next(t)
429444assert(k == k1)
430445t[k]=nil
431−local expected = (type(k) == "table" and k[1] or type(k) == "function" and k() or string.sub(k,1,1))
446+local expected = (type(k) == "\116\97\98\108\101" and k[1] or type(k) == "\102\117\110\99\116\105\111\110" and k() or string.sub(k,1,1))
432447assert(expected == v)
433448coroutine.yield(v)
434449end
@@ -436,18 +451,20 @@ end)
436451local t = {}
437452t[{1}]=1
438453t[{2}]=2
439−t[string.rep("a",50)]="a"
440−t[string.rep("b",50)]="b"
454+t[string.rep("\97",50)]="\97"
455+t[string.rep("\98",50)]="\98"
441456t[{3}]=3
442−t[string.rep("c",10)]="c"
443−t[()
457+t[string.rep("\99",10)]="\99"
458+t[function ()
444459return 10
445460end]=10
446461local count = 7
447462while co(t) do
448−collectgarbage("collect")
463+collectgarbage("\99\111\108\108\101\99\116")
449464count=count - 1
465+end
450466assert(count == 0 and next(t) == nil)
467+end
451468local function test
452469(a)
453470assert(not pcall(table.insert,a,2,20))
@@ -463,7 +480,7 @@ table.insert(a,40)
463480table.insert(a,# a + 1,50)
464481table.insert(a,2,- 2)
465482assert(a[2] ~= undef)
466−assert(a["2"] == undef)
483+assert(a["\50"] == undef)
467484assert(not pcall(table.insert,a,0,20))
468485;
469486assert(not pcall(table.insert,a,# a + 2,20))
@@ -478,18 +495,18 @@ assert(table.remove(a,1) == nil)
478495assert(table.remove(a) == nil)
479496assert(table.remove(a,# a) == nil)
480497end
481−a={["n"] = 0,[- 7] = "ban"}
498+a={["\110"] = 0,[- 7] = "\98\97\110"}
482499test(a)
483−assert(a.n == 0 and a[- 7] == "ban")
484−a={[- 7] = "ban"}
500+assert(a.n == 0 and a[- 7] == "\98\97\110")
501+a={[- 7] = "\98\97\110"}
485502;
486503test(a)
487−assert(a.n == nil and # a == 0 and a[- 7] == "ban")
488−a={[- 1] = "ban"}
504+assert(a.n == nil and # a == 0 and a[- 7] == "\98\97\110")
505+a={[- 1] = "\98\97\110"}
489506test(a)
490−assert(# a == 0 and table.remove(a) == nil and a[- 1] == "ban")
491−a={[0] = "ban"}
492−assert(# a == 0 and table.remove(a) == "ban" and a[0] == undef)
507+assert(# a == 0 and table.remove(a) == nil and a[- 1] == "\98\97\110")
508+a={[0] = "\98\97\110"}
509+assert(# a == 0 and table.remove(a) == "\98\97\110" and a[0] == undef)
493510table.insert(a,1,10)
494511;
495512table.insert(a,1,20)
@@ -499,13 +516,13 @@ assert(table.remove(a) == 10)
499516assert(table.remove(a) == 20)
500517assert(table.remove(a) == - 1)
501518assert(table.remove(a) == nil)
502−a={"c","d"}
503−table.insert(a,3,"a")
504−table.insert(a,"b")
505−assert(table.remove(a,1) == "c")
506−assert(table.remove(a,1) == "d")
507−assert(table.remove(a,1) == "a")
508−assert(table.remove(a,1) == "b")
519+a={"\99","\100"}
520+table.insert(a,3,"\97")
521+table.insert(a,"\98")
522+assert(table.remove(a,1) == "\99")
523+assert(table.remove(a,1) == "\100")
524+assert(table.remove(a,1) == "\97")
525+assert(table.remove(a,1) == "\98")
509526assert(table.remove(a,1) == nil)
510527assert(# a == 0 and a.n == nil)
511528a={10,20,30,40}
@@ -516,6 +533,7 @@ assert(table.remove(a,# a) == 40)
516533assert(a[# a] == 30)
517534assert(table.remove(a,2) == 20)
518535assert(a[# a] == 30 and # a == 2)
536+do
519537local function test
520538(proxy,t)
521539for i = 1, 10
@@ -532,7 +550,7 @@ for i = 1, 10
532550do
533551assert(t[i] == i and proxy[i] == i)
534552end
535−assert(table.concat(proxy,",") == "1,2,3,4,5,6,7,8,9,10")
553+assert(table.concat(proxy,"\44") == "\49\44\50\44\51\44\52\44\53\44\54\44\55\44\56\44\57\44\49\48")
536554for i = 1, 8
537555do
538556assert(table.remove(proxy,1) == i)
@@ -542,51 +560,52 @@ local a,b,c = table.unpack(proxy)
542560assert(a == 9 and b == 10 and c == nil)
543561end
544562local t = {}
545−local proxy = setmetatable({},{["__len"] = ()
563+local proxy = setmetatable({},{["\95\95\108\101\110"] = function ()
546564return # t
547−end,["__index"] = t,["__newindex"] = t})
565+end,["\95\95\105\110\100\101\120"] = t,["\95\95\110\101\119\105\110\100\101\120"] = t})
548566test(proxy,t)
549567local count = 0
550−t=setmetatable({},{["__newindex"] = (t,k,v)
568+t=setmetatable({},{["\95\95\110\101\119\105\110\100\101\120"] = function (t,k,v)
551569count=count + 1
552570;
553571rawset(t,k,v)
554572end})
555573test(t,t)
556574assert(count == 10)
557−t=setmetatable({},{["__index"] = (_,k)
575+t=setmetatable({},{["\95\95\105\110\100\101\120"] = function (_,k)
558576return k + 1
559−end,["__len"] = (_)
577+end,["\95\95\108\101\110"] = function (_)
560578return 5
561579end})
562−assert(table.concat(t,";") == "2;3;4;5;6")
563−local t = setmetatable({},{["__len"] = ()
580+assert(table.concat(t,"\59") == "\50\59\51\59\52\59\53\59\54")
581+end
582+do
583+local t = setmetatable({},{["\95\95\108\101\110"] = function ()
564584return math.maxinteger
565585end})
566586table.insert(t,20)
567587local k,v = next(t)
568588assert(k == math.mininteger and v == 20)
589+end
569590if not T then
570−(Message or print)("
571− >>> testC not active: skipping tests for table library on non-tables <<<
572−")
591+(Message or print)("\10\32\62\62\62\32\116\101\115\116\67\32\110\111\116\32\97\99\116\105\118\101\58\32\115\107\105\112\112\105\110\103\32\116\101\115\116\115\32\102\111\114\32\116\97\98\108\101\32\108\105\98\114\97\114\121\32\111\110\32\110\111\110\45\116\97\98\108\101\115\32\60\60\60\10")
573592else
574−local debug = require("debug")
593+local debug = require("\100\101\98\117\103")
575594local tab = {10,20,30}
576595local mt = {}
577596local u = T.newuserdata(0)
578−checkerror("table expected",table.insert,u,40)
579−checkerror("table expected",table.remove,u)
597+checkerror("\116\97\98\108\101\32\101\120\112\101\99\116\101\100",table.insert,u,40)
598+checkerror("\116\97\98\108\101\32\101\120\112\101\99\116\101\100",table.remove,u)
580599debug.setmetatable(u,mt)
581−checkerror("table expected",table.insert,u,40)
582−checkerror("table expected",table.remove,u)
600+checkerror("\116\97\98\108\101\32\101\120\112\101\99\116\101\100",table.insert,u,40)
601+checkerror("\116\97\98\108\101\32\101\120\112\101\99\116\101\100",table.remove,u)
583602mt.__index=tab
584−checkerror("table expected",table.insert,u,40)
585−checkerror("table expected",table.remove,u)
603+checkerror("\116\97\98\108\101\32\101\120\112\101\99\116\101\100",table.insert,u,40)
604+checkerror("\116\97\98\108\101\32\101\120\112\101\99\116\101\100",table.remove,u)
586605mt.__newindex=tab
587−checkerror("table expected",table.insert,u,40)
588−checkerror("table expected",table.remove,u)
589−mt.__len=()
606+checkerror("\116\97\98\108\101\32\101\120\112\101\99\116\101\100",table.insert,u,40)
607+checkerror("\116\97\98\108\101\32\101\120\112\101\99\116\101\100",table.remove,u)
608+mt.__len=function ()
590609return # tab
591610end
592611table.insert(u,40)
@@ -598,34 +617,34 @@ mt.__newindex=nil
598617mt.__len=nil
599618local tab2 = {}
600619local u2 = T.newuserdata(0)
601−debug.setmetatable(u2,{["__newindex"] = (_,k,v)
620+debug.setmetatable(u2,{["\95\95\110\101\119\105\110\100\101\120"] = function (_,k,v)
602621tab2[k]=v
603622end})
604623table.move(u,1,4,1,u2)
605624assert(# tab2 == 4 and tab2[1] == tab[1] and tab2[4] == tab[4])
606625end
607−print("+")
626+print("\43")
608627a={}
609−for i = 1, 1e3
628+for i = 1, 1000
610629do
611630a[i]=i
612631;
613632a[i - 1]=undef
614633end
615−assert(next(a,nil) == 1e3 and next(a,1e3) == nil)
634+assert(next(a,nil) == 1000 and next(a,1000) == nil)
616635assert(next({}) == nil)
617636assert(next({},nil) == nil)
618637for a,b in pairs({})
619638do
620−error("not here")
639+error("\110\111\116\32\104\101\114\101")
621640end
622641for i = 1, 0
623642do
624−error("not here")
643+error("\110\111\116\32\104\101\114\101")
625644end
626645for i = 0, 1, - 1
627646do
628−error("not here")
647+error("\110\111\116\32\104\101\114\101")
629648end
630649a=nil
631650;
@@ -647,8 +666,9 @@ a=1
647666end
648667;
649668assert(a)
650−print("testing floats in numeric for")
651−local a =
669+do
670+print("\116\101\115\116\105\110\103\32\102\108\111\97\116\115\32\105\110\32\110\117\109\101\114\105\99\32\102\111\114")
671+local a
652672a=0
653673;
654674for i = 1, 1, 1
@@ -659,7 +679,7 @@ end
659679assert(a == 1)
660680a=0
661681;
662−for i = 1e4, 1e4, - 1
682+for i = 10000, 1e4.0, - 1
663683do
664684a=a + 1
665685end
@@ -675,7 +695,7 @@ end
675695assert(a == 0)
676696a=0
677697;
678−for i = 9999, 1e4, - 1
698+for i = 9999, 1e4.0, - 1
679699do
680700a=a + 1
681701end
@@ -699,7 +719,7 @@ end
699719assert(a == 10)
700720a=0
701721;
702−for i = 1, 1, 1
722+for i = 1.0, 1, 1
703723do
704724a=a + 1
705725end
@@ -715,7 +735,7 @@ end
715735assert(a == 1)
716736a=0
717737;
718−for i = 1e6, 1e6, - 1
738+for i = 1e6.0, 1e6.0, - 1
719739do
720740a=a + 1
721741end
@@ -723,7 +743,7 @@ end
723743assert(a == 1)
724744a=0
725745;
726−for i = 1, 0.99999, 1
746+for i = 1.0, 0.99999, 1
727747do
728748a=a + 1
729749end
@@ -731,7 +751,7 @@ end
731751assert(a == 0)
732752a=0
733753;
734−for i = 99999, 1e5, - 1
754+for i = 99999, 1e5.0, - 1.0
735755do
736756a=a + 1
737757end
@@ -739,64 +759,68 @@ end
739759assert(a == 0)
740760a=0
741761;
742−for i = 1, 0.99999, - 1
762+for i = 1.0, 0.99999, - 1
743763do
744764a=a + 1
745765end
746766;
747767assert(a == 1)
748−local a =
768+end
769+do
770+local a
749771a=0
750772;
751773for i = 1, 10
752774do
753775a=a + 1
754776;
755−i="x"
777+i="\120"
756778end
757779;
758780assert(a == 10)
759781a=0
760782;
761−for i = 10, 1, - 1
783+for i = 10.0, 1, - 1
762784do
763785a=a + 1
764786;
765−i="x"
787+i="\120"
766788end
767789;
768790assert(a == 10)
791+end
769792a=0
770793;
771−for i = "10", "1", "-2"
794+for i = "\49\48", "\49", "\45\50"
772795do
773796a=a + 1
774797end
775798;
776799assert(a == 5)
777−local c =
800+do
801+local c
778802local function checkfloat
779803(i)
780−assert(math.type(i) == "float")
804+assert(math.type(i) == "\102\108\111\97\116")
781805c=c + 1
782806end
783807c=0
784808;
785−for i = 1, 10
809+for i = 1.0, 10
786810do
787811checkfloat(i)
788812end
789813assert(c == 10)
790814c=0
791815;
792−for i = - 1, - 10, - 1
816+for i = - 1, - 10, - 1.0
793817do
794818checkfloat(i)
795819end
796820assert(c == 10)
797821local function checkint
798822(i)
799−assert(math.type(i) == "integer")
823+assert(math.type(i) == "\105\110\116\101\103\101\114")
800824c=c + 1
801825end
802826local m = math.maxinteger
@@ -816,35 +840,35 @@ end
816840assert(c == 10)
817841c=0
818842;
819−for i = 10, 1e-3, - 1
843+for i = 10, 1e-3.0, - 1
820844do
821845checkint(i)
822846end
823847assert(c == 10)
824848c=0
825849;
826−for i = 1, "10.8"
850+for i = 1, "\49\48\46\56"
827851do
828852checkint(i)
829853end
830854assert(c == 10)
831855c=0
832856;
833−for i = 9, "3.4", - 1
857+for i = 9, "\51\46\52", - 1
834858do
835859checkint(i)
836860end
837861assert(c == 6)
838862c=0
839863;
840−for i = 0, " -3.4 ", - 1
864+for i = 0, "\32\45\51\46\52\32\32", - 1
841865do
842866checkint(i)
843867end
844868assert(c == 4)
845869c=0
846870;
847−for i = 100, "96.3", - 2
871+for i = 100, "\57\54\46\51", - 2
848872do
849873checkint(i)
850874end
@@ -871,14 +895,16 @@ end
871895checkint(i)
872896end
873897assert(c == 10)
874−for i = math.mininteger, - 1e101
898+for i = math.mininteger, - 1e101.0
875899do
876900assert(false)
877901end
878−for i = math.maxinteger, 1e101, - 1
902+for i = math.maxinteger, 1e101.0, - 1
879903do
880904assert(false)
881905end
906+end
907+do
882908local function checkfor
883909(from,to,step,t)
884910local c = 0
@@ -917,20 +943,21 @@ checkfor(maxi,maxi,maxi,{maxi})
917943checkfor(maxi,maxi,mini,{maxi})
918944checkfor(mini,mini,maxi,{mini})
919945checkfor(mini,mini,mini,{mini})
920−checkerror("'for' step is zero",()
946+end
947+checkerror("\39\102\111\114\39\32\115\116\101\112\32\105\115\32\122\101\114\111",function ()
921948for i = 1, 10, 0
922949do
923950
924951end
925952end)
926−checkerror("'for' step is zero",()
953+checkerror("\39\102\111\114\39\32\115\116\101\112\32\105\115\32\122\101\114\111",function ()
927954for i = 1, - 10, 0
928955do
929956
930957end
931958end)
932−checkerror("'for' step is zero",()
933−for i = 1, - 10, 0
959+checkerror("\39\102\111\114\39\32\115\116\101\112\32\105\115\32\122\101\114\111",function ()
960+for i = 1.0, - 10, 0.0
934961do
935962
936963end
@@ -944,8 +971,8 @@ for i = 1, p
944971do
945972t[i]=i * 10
946973end
947−return (_,n, ...)
948−assert(select("#",...) == 0)
974+return function (_,n, ...)
975+assert(select("\35",...) == 0)
949976if n > 0 then
950977n=n - 1
951978return n,table.unpack(t)
@@ -960,8 +987,10 @@ assert(a == 10 and b == 20 and c == 30 and d == nil)
960987end
961988assert(x == 5)
962989a={}
990+do
963991local x,y,z = pairs(a)
964−assert(type(x) == "function" and y == a and z == nil)
992+assert(type(x) == "\102\117\110\99\116\105\111\110" and y == a and z == nil)
993+end
965994local function foo
966995(e,i)
967996assert(e == a)
@@ -977,7 +1006,7 @@ if i <= e.n then
9771006return i,a[i]
9781007end
9791008end
980−setmetatable(a,{["__pairs"] = (x)
1009+setmetatable(a,{["\95\95\112\97\105\114\115"] = function (x)
9811010return foo,x,0
9821011end})
9831012local i = 0
@@ -988,8 +1017,8 @@ assert(k == i and v == k + 1)
9881017end
9891018a.n=5
9901019a[3]=30
991−a={["n"] = 10}
992−setmetatable(a,{["__index"] = (t,k)
1020+a={["\110"] = 10}
1021+setmetatable(a,{["\95\95\105\110\100\101\120"] = function (t,k)
9931022if k <= t.n then
9941023return k * 10
9951024end
@@ -1001,9 +1030,10 @@ i=i + 1
10011030assert(k == i and v == i * 10)
10021031end
10031032assert(i == a.n)
1004−local t = setmetatable({10,20,30},{["__pairs"] = (t)
1033+do
1034+local t = setmetatable({10,20,30},{["\95\95\112\97\105\114\115"] = function (t)
10051035local inc = coroutine.yield()
1006−return (t,i)
1036+return function (t,i)
10071037if i > 1 then
10081038return i - inc,t[i - inc]
10091039else
@@ -1012,7 +1042,7 @@ end
10121042end,t,# t + 1
10131043end})
10141044local res = {}
1015−local co = coroutine.wrap(()
1045+local co = coroutine.wrap(function ()
10161046for i,p in pairs(t)
10171047do
10181048res[# res + 1]=p
@@ -1021,4 +1051,5 @@ end)
10211051co()
10221052co(1)
10231053assert(res[1] == 30 and res[2] == 20 and res[3] == 10 and # res == 3)
1024−print("OK")
1054+end
1055+print("\79\75")
zod/luau/res/lua/cycled/pm.lua+229−231
@@ -1,4 +1,4 @@
1−print("testing pattern matching")
1+print("\116\101\115\116\105\110\103\32\112\97\116\116\101\114\110\32\109\97\116\99\104\105\110\103")
22local function checkerror
33(msg,f, ...)
44local s,err = pcall(f,...)
@@ -14,104 +14,97 @@ end
1414local a,b = string.find("","")
1515assert(a == 1 and b == 0)
1616;
17−a,b=string.find("alo","")
17+a,b=string.find("\97\108\111","")
1818assert(a == 1 and b == 0)
19−a,b=string.find("ao ao ao","a",1)
19+a,b=string.find("\97\111\32\97\111\32\97\111","\97",1)
2020assert(a == 1 and b == 1)
21−a,b=string.find("ao ao ao","ao",2)
21+a,b=string.find("\97\111\32\97\111\32\97\111","\97\111",2)
2222assert(a == 5 and b == 7)
23−a,b=string.find("ao ao ao","ao",9)
23+a,b=string.find("\97\111\32\97\111\32\97\111","\97\111",9)
2424assert(a == 9 and b == 11)
25−a,b=string.find("aaaaab","ab",2)
25+a,b=string.find("\97\97\97\97\97\98","\97\98",2)
2626;
2727assert(a == 9 and b == 11)
2828;
29−a,b=string.find("aaaaab","b")
29+a,b=string.find("\97\97\97\97\97\98","\98")
3030assert(a == 11 and b == 11)
31−assert(not string.find("aaaaab","b"))
31+assert(not string.find("\97\97\97\97\97\98","\98"))
3232assert(not string.find("",""))
33−assert(string.find("alo123alo","12") == 4)
34−assert(not string.find("alo123alo","^12"))
35−assert(string.match("aaab",".*b") == "aaab")
36−assert(string.match("aaa",".*a") == "aaa")
37−assert(string.match("b",".*b") == "b")
38−assert(string.match("aaab",".+b") == "aaab")
39−assert(string.match("aaa",".+a") == "aaa")
40−assert(not string.match("b",".+b"))
41−assert(string.match("aaab",".?b") == "ab")
42−assert(string.match("aaa",".?a") == "aa")
43−assert(string.match("b",".?b") == "b")
44−assert(f("aloALO","%l*") == "alo")
45−assert(f("aLo_ALO","%a*") == "aLo")
46−assert(f("
47− *&
48− xuxu
49−
50−","%g%g%g+") == "xuxu")
33+assert(string.find("\97\108\111\49\50\51\97\108\111","\49\50") == 4)
34+assert(not string.find("\97\108\111\49\50\51\97\108\111","\94\49\50"))
35+assert(string.match("\97\97\97\98","\46\42\98") == "\97\97\97\98")
36+assert(string.match("\97\97\97","\46\42\97") == "\97\97\97")
37+assert(string.match("\98","\46\42\98") == "\98")
38+assert(string.match("\97\97\97\98","\46\43\98") == "\97\97\97\98")
39+assert(string.match("\97\97\97","\46\43\97") == "\97\97\97")
40+assert(not string.match("\98","\46\43\98"))
41+assert(string.match("\97\97\97\98","\46\63\98") == "\97\98")
42+assert(string.match("\97\97\97","\46\63\97") == "\97\97")
43+assert(string.match("\98","\46\63\98") == "\98")
44+assert(f("\97\108\111\65\76\79","\37\108\42") == "\97\108\111")
45+assert(f("\97\76\111\95\65\76\79","\37\97\42") == "\97\76\111")
46+assert(f("\32\32\10\13\42\38\10\13\32\32\32\120\117\120\117\32\32\10\10","\37\103\37\103\37\103\43") == "\120\117\120\117")
5147local function PU
5248(p)
53−p=string.gsub(p,"(" .. utf8.charpattern .. ")%?",(c)
54−return string.gsub(c,".","%0?")
49+p=string.gsub(p,"\40" .. utf8.charpattern .. "\41\37\63",function (c)
50+return string.gsub(c,"\46","\37\48\63")
5551end)
56−p=string.gsub(p,"%.",utf8.charpattern)
52+p=string.gsub(p,"\37\46",utf8.charpattern)
5753return p
5854end
59−assert(f("aaab","a*") == "aaa")
55+assert(f("\97\97\97\98","\97\42") == "\97\97\97")
6056;
61−assert(f("aaa","^.*$") == "aaa")
57+assert(f("\97\97\97","\94\46\42\36") == "\97\97\97")
6258;
63−assert(f("aaa","b*") == "")
59+assert(f("\97\97\97","\98\42") == "")
6460;
65−assert(f("aaa","ab*a") == "aa")
66−assert(f("aba","ab*a") == "aba")
67−assert(f("aaab","a+") == "aaa")
68−assert(f("aaa","^.+$") == "aaa")
69−assert(not f("aaa","b+"))
70−assert(not f("aaa","ab+a"))
71−assert(f("aba","ab+a") == "aba")
72−assert(f("a$a",".$") == "a")
73−assert(f("a$a",".%$") == "a$")
74−assert(f("a$a",".$.") == "a$a")
75−assert(not f("a$a","$$"))
76−assert(not f("a$b","a$"))
77−assert(f("a$a","$") == "")
78−assert(f("","b*") == "")
79−assert(not f("aaa","bb*"))
80−assert(f("aaab","a-") == "")
81−assert(f("aaa","^.-$") == "aaa")
82−assert(f("aabaaabaaabaaaba","b.*b") == "baaabaaabaaab")
83−assert(f("aabaaabaaabaaaba","b.-b") == "baaab")
84−assert(f("alo xo",".o$") == "xo")
85−assert(f("
86− isto é assim","%S%S*") == "isto")
87−assert(f("
88− isto é assim","%S*$") == "assim")
89−assert(f("
90− isto é assim","[a-z]*$") == "assim")
91−assert(f("um caracter ? extra","[^%sa-z]") == "?")
92−assert(f("","a?") == "")
93−assert(f("á",PU("á?")) == "á")
94−assert(f("ábl",PU("á?b?l?")) == "ábl")
95−assert(f(" ábl",PU("á?b?l?")) == "")
96−assert(f("aa","^aa?a?a") == "aa")
97−assert(f("]]]áb","[^]]+") == "áb")
98−assert(f("0alo alo","%x*") == "0a")
99−assert(f("alo alo","%C+") == "alo alo")
100−print("+")
61+assert(f("\97\97\97","\97\98\42\97") == "\97\97")
62+assert(f("\97\98\97","\97\98\42\97") == "\97\98\97")
63+assert(f("\97\97\97\98","\97\43") == "\97\97\97")
64+assert(f("\97\97\97","\94\46\43\36") == "\97\97\97")
65+assert(not f("\97\97\97","\98\43"))
66+assert(not f("\97\97\97","\97\98\43\97"))
67+assert(f("\97\98\97","\97\98\43\97") == "\97\98\97")
68+assert(f("\97\36\97","\46\36") == "\97")
69+assert(f("\97\36\97","\46\37\36") == "\97\36")
70+assert(f("\97\36\97","\46\36\46") == "\97\36\97")
71+assert(not f("\97\36\97","\36\36"))
72+assert(not f("\97\36\98","\97\36"))
73+assert(f("\97\36\97","\36") == "")
74+assert(f("","\98\42") == "")
75+assert(not f("\97\97\97","\98\98\42"))
76+assert(f("\97\97\97\98","\97\45") == "")
77+assert(f("\97\97\97","\94\46\45\36") == "\97\97\97")
78+assert(f("\97\97\98\97\97\97\98\97\97\97\98\97\97\97\98\97","\98\46\42\98") == "\98\97\97\97\98\97\97\97\98\97\97\97\98")
79+assert(f("\97\97\98\97\97\97\98\97\97\97\98\97\97\97\98\97","\98\46\45\98") == "\98\97\97\97\98")
80+assert(f("\97\108\111\32\120\111","\46\111\36") == "\120\111")
81+assert(f("\32\10\32\105\115\116\111\32\195\169\32\97\115\115\105\109","\37\83\37\83\42") == "\105\115\116\111")
82+assert(f("\32\10\32\105\115\116\111\32\195\169\32\97\115\115\105\109","\37\83\42\36") == "\97\115\115\105\109")
83+assert(f("\32\10\32\105\115\116\111\32\195\169\32\97\115\115\105\109","\91\97\45\122\93\42\36") == "\97\115\115\105\109")
84+assert(f("\117\109\32\99\97\114\97\99\116\101\114\32\63\32\101\120\116\114\97","\91\94\37\115\97\45\122\93") == "\63")
85+assert(f("","\97\63") == "")
86+assert(f("\195\161",PU("\195\161\63")) == "\195\161")
87+assert(f("\195\161\98\108",PU("\195\161\63\98\63\108\63")) == "\195\161\98\108")
88+assert(f("\32\32\195\161\98\108",PU("\195\161\63\98\63\108\63")) == "")
89+assert(f("\97\97","\94\97\97\63\97\63\97") == "\97\97")
90+assert(f("\93\93\93\195\161\98","\91\94\93\93\43") == "\195\161\98")
91+assert(f("\48\97\108\111\32\97\108\111","\37\120\42") == "\48\97")
92+assert(f("\97\108\111\32\97\108\111","\37\67\43") == "\97\108\111\32\97\108\111")
93+print("\43")
10194local function f1
10295(s,p)
103−p=string.gsub(p,"%%([0-9])",(s)
104−return "%" .. (tonumber(s) + 1)
96+p=string.gsub(p,"\37\37\40\91\48\45\57\93\41",function (s)
97+return "\37" .. (tonumber(s) + 1)
10598end)
106−p=string.gsub(p,"^(^?)","%1()",1)
107−p=string.gsub(p,"($?)$","()%1",1)
99+p=string.gsub(p,"\94\40\94\63\41","\37\49\40\41",1)
100+p=string.gsub(p,"\40\36\63\41\36","\40\41\37\49",1)
108101local t = {string.match(s,p)}
109102return string.sub(s,t[1],t[# t] - 1)
110103end
111−assert(f1("alo alx 123 bo bo","(..*) %1") == "bo bo")
112−assert(f1("axz123= 4= 4 34","(.+)=(.*)=%2 %1") == "3= 4= 4 3")
113−assert(f1("=======","^(=*)=%1$") == "=======")
114−assert(not string.match("==========","^([=]*)=%1$"))
104+assert(f1("\97\108\111\32\97\108\120\32\49\50\51\32\98\111\32\98\111","\40\46\46\42\41\32\37\49") == "\98\111\32\98\111")
105+assert(f1("\97\120\122\49\50\51\61\32\52\61\32\52\32\51\52","\40\46\43\41\61\40\46\42\41\61\37\50\32\37\49") == "\51\61\32\52\61\32\52\32\51")
106+assert(f1("\61\61\61\61\61\61\61","\94\40\61\42\41\61\37\49\36") == "\61\61\61\61\61\61\61")
107+assert(not string.match("\61\61\61\61\61\61\61\61\61\61","\94\40\91\61\93\42\41\61\37\49\36"))
115108local function range
116109(i,j)
117110if i <= j then
@@ -123,90 +116,91 @@ local abc = string.char(range(0,127)) .. string.char(range(128,255))
123116assert(string.len(abc) == 256)
124117local function strset
125118(p)
126−local res = {["s"] = ""}
127−string.gsub(abc,p,(c)
119+local res = {["\115"] = ""}
120+string.gsub(abc,p,function (c)
128121res.s=res.s .. c
129122end)
130123return res.s
131124end
132125;
133−assert(string.len(strset("[�-�]")) == 11)
134−assert(strset("[a-z]") == "abcdefghijklmnopqrstuvwxyz")
135−assert(strset("[a-z%d]") == strset("[%da-uu-z]"))
136−assert(strset("[a-]") == "-a")
137−assert(strset("[^%W]") == strset("[%w]"))
138−assert(strset("[]%%]") == "%]")
139−assert(strset("[a%-z]") == "-az")
140−assert(strset("[%^%[%-a%]%-b]") == "-[]^ab")
141−assert(strset("%Z") == strset("[-�]"))
142−assert(strset(".") == strset("[-�%z]"))
143−print("+")
126+assert(string.len(strset("\91\200\45\210\93")) == 11)
127+assert(strset("\91\97\45\122\93") == "\97\98\99\100\101\102\103\104\105\106\107\108\109\110\111\112\113\114\115\116\117\118\119\120\121\122")
128+assert(strset("\91\97\45\122\37\100\93") == strset("\91\37\100\97\45\117\117\45\122\93"))
129+assert(strset("\91\97\45\93") == "\45\97")
130+assert(strset("\91\94\37\87\93") == strset("\91\37\119\93"))
131+assert(strset("\91\93\37\37\93") == "\37\93")
132+assert(strset("\91\97\37\45\122\93") == "\45\97\122")
133+assert(strset("\91\37\94\37\91\37\45\97\37\93\37\45\98\93") == "\45\91\93\94\97\98")
134+assert(strset("\37\90") == strset("\91\1\45\255\93"))
135+assert(strset("\46") == strset("\91\1\45\255\37\122\93"))
136+print("\43")
144137;
145−assert(string.match("alo xyzK","(%w+)K") == "xyz")
146−assert(string.match("254 K","(%d*)K") == "")
147−assert(string.match("alo ","(%w*)$") == "")
148−assert(not string.match("alo ","(%w+)$"))
149−assert(string.find("(álo)","%(á") == 1)
150−local a,b,c,d,e = string.match("âlo alo",PU("^(((.).). (%w*))$"))
151−assert(a == "âlo alo" and b == "âl" and c == "â" and d == "alo" and e == nil)
152−a,b,c,d=string.match("0123456789","(.+(.?)())")
153−assert(a == "0123456789" and b == "" and c == 11 and d == nil)
154−print("+")
155−assert(string.gsub("ülo ülo","ü","x") == "xlo xlo")
156−assert(string.gsub("alo úlo "," +$","") == "alo úlo")
157−assert(string.gsub(" alo alo ","^%s*(.-)%s*$","%1") == "alo alo")
158−assert(string.gsub("alo alo
159− 123
160− ","%s+"," ") == "alo alo 123 ")
161−local t = "abç d"
162−a,b=string.gsub(t,PU("(.)"),"%1@")
163−assert(a == "a@b@ç@ @d@" and b == 5)
164−a,b=string.gsub("abçd",PU("(.)"),"%0@",2)
165−assert(a == "a@b@çd" and b == 2)
166−assert(string.gsub("alo alo","()[al]","%1") == "12o 56o")
167−assert(string.gsub("abc=xyz","(%w*)(%p)(%w+)","%3%2%1-%0") == "xyz=abc-abc=xyz")
168−assert(string.gsub("abc","%w","%1%0") == "aabbcc")
169−assert(string.gsub("abc","%w+","%0%1") == "abcabc")
170−assert(string.gsub("áéí","$","óú") == "áéíóú")
171−assert(string.gsub("","^","r") == "r")
172−assert(string.gsub("","$","r") == "r")
173−print("+")
174−assert(string.gsub("a b cd"," *","-") == "-a-b-c-d-")
138+assert(string.match("\97\108\111\32\120\121\122\75","\40\37\119\43\41\75") == "\120\121\122")
139+assert(string.match("\50\53\52\32\75","\40\37\100\42\41\75") == "")
140+assert(string.match("\97\108\111\32","\40\37\119\42\41\36") == "")
141+assert(not string.match("\97\108\111\32","\40\37\119\43\41\36"))
142+assert(string.find("\40\195\161\108\111\41","\37\40\195\161") == 1)
143+local a,b,c,d,e = string.match("\195\162\108\111\32\97\108\111",PU("\94\40\40\40\46\41\46\41\46\32\40\37\119\42\41\41\36"))
144+assert(a == "\195\162\108\111\32\97\108\111" and b == "\195\162\108" and c == "\195\162" and d == "\97\108\111" and e == nil)
145+a,b,c,d=string.match("\48\49\50\51\52\53\54\55\56\57","\40\46\43\40\46\63\41\40\41\41")
146+assert(a == "\48\49\50\51\52\53\54\55\56\57" and b == "" and c == 11 and d == nil)
147+print("\43")
148+assert(string.gsub("\195\188\108\111\32\195\188\108\111","\195\188","\120") == "\120\108\111\32\120\108\111")
149+assert(string.gsub("\97\108\111\32\195\186\108\111\32\32","\32\43\36","") == "\97\108\111\32\195\186\108\111")
150+assert(string.gsub("\32\32\97\108\111\32\97\108\111\32\32","\94\37\115\42\40\46\45\41\37\115\42\36","\37\49") == "\97\108\111\32\97\108\111")
151+assert(string.gsub("\97\108\111\32\32\97\108\111\32\32\10\32\49\50\51\10\32","\37\115\43","\32") == "\97\108\111\32\97\108\111\32\49\50\51\32")
152+local t = "\97\98\195\167\32\100"
153+a,b=string.gsub(t,PU("\40\46\41"),"\37\49\64")
154+assert(a == "\97\64\98\64\195\167\64\32\64\100\64" and b == 5)
155+a,b=string.gsub("\97\98\195\167\100",PU("\40\46\41"),"\37\48\64",2)
156+assert(a == "\97\64\98\64\195\167\100" and b == 2)
157+assert(string.gsub("\97\108\111\32\97\108\111","\40\41\91\97\108\93","\37\49") == "\49\50\111\32\53\54\111")
158+assert(string.gsub("\97\98\99\61\120\121\122","\40\37\119\42\41\40\37\112\41\40\37\119\43\41","\37\51\37\50\37\49\45\37\48") == "\120\121\122\61\97\98\99\45\97\98\99\61\120\121\122")
159+assert(string.gsub("\97\98\99","\37\119","\37\49\37\48") == "\97\97\98\98\99\99")
160+assert(string.gsub("\97\98\99","\37\119\43","\37\48\37\49") == "\97\98\99\97\98\99")
161+assert(string.gsub("\195\161\195\169\195\173","\36","\195\179\195\186") == "\195\161\195\169\195\173\195\179\195\186")
162+assert(string.gsub("","\94","\114") == "\114")
163+assert(string.gsub("","\36","\114") == "\114")
164+print("\43")
165+do
166+assert(string.gsub("\97\32\98\32\99\100","\32\42","\45") == "\45\97\45\98\45\99\45\100\45")
175167local res = ""
176−local sub = "a
177−bc d"
168+local sub = "\97\32\32\10\98\99\9\9\100"
178169local i = 1
179−for p,e in string.gmatch(sub,"()%s*()")
170+for p,e in string.gmatch(sub,"\40\41\37\115\42\40\41")
180171do
181−res=res .. string.sub(sub,i,p - 1) .. "-"
172+res=res .. string.sub(sub,i,p - 1) .. "\45"
182173i=e
183174end
184−assert(res == "-a-b-c-d-")
185−assert(string.gsub("um (dois) tres (quatro)","(%(%w+%))",string.upper) == "um (DOIS) tres (QUATRO)")
175+assert(res == "\45\97\45\98\45\99\45\100\45")
176+end
177+assert(string.gsub("\117\109\32\40\100\111\105\115\41\32\116\114\101\115\32\40\113\117\97\116\114\111\41","\40\37\40\37\119\43\37\41\41",string.upper) == "\117\109\32\40\68\79\73\83\41\32\116\114\101\115\32\40\81\85\65\84\82\79\41")
178+do
186179local function setglobal
187180(n,v)
188181rawset(_G,n,v)
189182end
190−string.gsub("a=roberto,roberto=a","(%w+)=(%w%w*)",setglobal)
191−assert(_G.a == "roberto" and _G.roberto == "a")
183+string.gsub("\97\61\114\111\98\101\114\116\111\44\114\111\98\101\114\116\111\61\97","\40\37\119\43\41\61\40\37\119\37\119\42\41",setglobal)
184+assert(_G.a == "\114\111\98\101\114\116\111" and _G.roberto == "\97")
192185_G.a=nil
193186;
194187_G.roberto=nil
188+end
195189function f(a,b)
196−return string.gsub(a,".",b)
190+return string.gsub(a,"\46",b)
197191end
198−assert(string.gsub("trocar tudo em |teste|b| é |beleza|al|","|([^|]*)|([^|]*)|",f) == "trocar tudo em bbbbb é alalalalalal")
192+assert(string.gsub("\116\114\111\99\97\114\32\116\117\100\111\32\101\109\32\124\116\101\115\116\101\124\98\124\32\195\169\32\124\98\101\108\101\122\97\124\97\108\124","\124\40\91\94\124\93\42\41\124\40\91\94\124\93\42\41\124",f) == "\116\114\111\99\97\114\32\116\117\100\111\32\101\109\32\98\98\98\98\98\32\195\169\32\97\108\97\108\97\108\97\108\97\108\97\108")
199193local function dostring
200194(s)
201195return load(s,"")() or ""
202196end
203−assert(string.gsub("alo $a='x'$ novamente $return a$","$([^$]*)%$",dostring) == "alo novamente x")
204−local x = string.gsub("$x=string.gsub('alo', '.', string.upper)$ assim vai para $return x$","$([^$]*)%$",dostring)
205−assert(x == " assim vai para ALO")
197+assert(string.gsub("\97\108\111\32\36\97\61\39\120\39\36\32\110\111\118\97\109\101\110\116\101\32\36\114\101\116\117\114\110\32\97\36","\36\40\91\94\36\93\42\41\37\36",dostring) == "\97\108\111\32\32\110\111\118\97\109\101\110\116\101\32\120")
198+local x = string.gsub("\36\120\61\115\116\114\105\110\103\46\103\115\117\98\40\39\97\108\111\39\44\32\39\46\39\44\32\115\116\114\105\110\103\46\117\112\112\101\114\41\36\32\97\115\115\105\109\32\118\97\105\32\112\97\114\97\32\36\114\101\116\117\114\110\32\120\36","\36\40\91\94\36\93\42\41\37\36",dostring)
199+assert(x == "\32\97\115\115\105\109\32\118\97\105\32\112\97\114\97\32\65\76\79")
206200_G.a,_G.x=nil
207201local t = {}
208−local s = "a alo jose joao"
209−local r = string.gsub(s,"()(%w+)()",(a,w,b)
202+local s = "\97\32\97\108\111\32\106\111\115\101\32\32\106\111\97\111"
203+local r = string.gsub(s,"\40\41\40\37\119\43\41\40\41",function (a,w,b)
210204assert(string.len(w) == b - a)
211205;
212206t[a]=b - a
@@ -215,88 +209,88 @@ end)
215209assert(s == r and t[1] == 1 and t[3] == 3 and t[7] == 4 and t[13] == 4)
216210local function isbalanced
217211(s)
218−return not string.find(string.gsub(s,"%b()",""),"[()]")
212+return not string.find(string.gsub(s,"\37\98\40\41",""),"\91\40\41\93")
219213end
220−assert(isbalanced("(9 ((8))() 7) a b ()(c)() a"))
221−assert(not isbalanced("(9 ((8) 7) a b ( c) a"))
222−assert(string.gsub("alo 'oi' alo","%b''",""") == "alo " alo")
223−local t = {"apple","orange","lime",["n"] = 0}
224−assert(string.gsub("x and x and x","x",()
214+assert(isbalanced("\40\57\32\40\40\56\41\41\40\41\32\55\41\32\32\97\32\98\32\40\41\40\99\41\40\41\32\97"))
215+assert(not isbalanced("\40\57\32\40\40\56\41\32\55\41\32\97\32\98\32\40\32\99\41\32\97"))
216+assert(string.gsub("\97\108\111\32\39\111\105\39\32\97\108\111","\37\98\39\39","\34") == "\97\108\111\32\34\32\97\108\111")
217+local t = {"\97\112\112\108\101","\111\114\97\110\103\101","\108\105\109\101",["\110"] = 0}
218+assert(string.gsub("\120\32\97\110\100\32\120\32\97\110\100\32\120","\120",function ()
225219t.n=t.n + 1
226220;
227221return t[t.n]
228−end) == "apple and orange and lime")
229−t={["n"] = 0}
230−string.gsub("first second word","%w%w*",(w)
222+end) == "\97\112\112\108\101\32\97\110\100\32\111\114\97\110\103\101\32\97\110\100\32\108\105\109\101")
223+t={["\110"] = 0}
224+string.gsub("\102\105\114\115\116\32\115\101\99\111\110\100\32\119\111\114\100","\37\119\37\119\42",function (w)
231225t.n=t.n + 1
232226;
233227t[t.n]=w
234228end)
235−assert(t[1] == "first" and t[2] == "second" and t[3] == "word" and t.n == 3)
236−t={["n"] = 0}
237−assert(string.gsub("first second word","%w+",(w)
229+assert(t[1] == "\102\105\114\115\116" and t[2] == "\115\101\99\111\110\100" and t[3] == "\119\111\114\100" and t.n == 3)
230+t={["\110"] = 0}
231+assert(string.gsub("\102\105\114\115\116\32\115\101\99\111\110\100\32\119\111\114\100","\37\119\43",function (w)
238232t.n=t.n + 1
239233;
240234t[t.n]=w
241−end,2) == "first second word")
242−assert(t[1] == "first" and t[2] == "second" and t[3] == undef)
243−checkerror("invalid replacement value %(a table%)",string.gsub,"alo",".",{["a"] = {}})
244−checkerror("invalid capture index %%2",string.gsub,"alo",".","%2")
245−checkerror("invalid capture index %%0",string.gsub,"alo","(%0)","a")
246−checkerror("invalid capture index %%1",string.gsub,"alo","(%1)","a")
247−checkerror("invalid use of '%%'",string.gsub,"alo",".","%x")
235+end,2) == "\102\105\114\115\116\32\115\101\99\111\110\100\32\119\111\114\100")
236+assert(t[1] == "\102\105\114\115\116" and t[2] == "\115\101\99\111\110\100" and t[3] == undef)
237+checkerror("\105\110\118\97\108\105\100\32\114\101\112\108\97\99\101\109\101\110\116\32\118\97\108\117\101\32\37\40\97\32\116\97\98\108\101\37\41",string.gsub,"\97\108\111","\46",{["\97"] = {}})
238+checkerror("\105\110\118\97\108\105\100\32\99\97\112\116\117\114\101\32\105\110\100\101\120\32\37\37\50",string.gsub,"\97\108\111","\46","\37\50")
239+checkerror("\105\110\118\97\108\105\100\32\99\97\112\116\117\114\101\32\105\110\100\101\120\32\37\37\48",string.gsub,"\97\108\111","\40\37\48\41","\97")
240+checkerror("\105\110\118\97\108\105\100\32\99\97\112\116\117\114\101\32\105\110\100\101\120\32\37\37\49",string.gsub,"\97\108\111","\40\37\49\41","\97")
241+checkerror("\105\110\118\97\108\105\100\32\117\115\101\32\111\102\32\39\37\37\39",string.gsub,"\97\108\111","\46","\37\120")
248242if not _soft then
249−print("big strings")
250−local a = string.rep("a",3e5)
251−assert(string.find(a,"^a*.?$"))
252−assert(not string.find(a,"^a*.?b$"))
253−assert(string.find(a,"^a-.?$"))
254−a=string.rep("a",1e4) .. string.rep("b",1e4)
255−assert(not pcall(string.gsub,a,"b"))
243+print("\98\105\103\32\115\116\114\105\110\103\115")
244+local a = string.rep("\97",300000)
245+assert(string.find(a,"\94\97\42\46\63\36"))
246+assert(not string.find(a,"\94\97\42\46\63\98\36"))
247+assert(string.find(a,"\94\97\45\46\63\36"))
248+a=string.rep("\97",10000) .. string.rep("\98",10000)
249+assert(not pcall(string.gsub,a,"\98"))
256250end
257251local function rev
258252(s)
259−return string.gsub(s,"(.)(.+)",(c,s1)
253+return string.gsub(s,"\40\46\41\40\46\43\41",function (c,s1)
260254return rev(s1) .. c
261255end)
262256end
263−local x = "abcdef"
257+local x = "\97\98\99\100\101\102"
264258assert(rev(rev(x)) == x)
265−assert(string.gsub("alo alo",".",{}) == "alo alo")
266−assert(string.gsub("alo alo","(.)",{["a"] = "AA",["l"] = ""}) == "AAo AAo")
267−assert(string.gsub("alo alo","(.).",{["a"] = "AA",["l"] = "K"}) == "AAo AAo")
268−assert(string.gsub("alo alo","((.)(.?))",{["al"] = "AA",["o"] = false}) == "AAo AAo")
269−assert(string.gsub("alo alo","().",{"x","yy","zzz"}) == "xyyzzz alo")
259+assert(string.gsub("\97\108\111\32\97\108\111","\46",{}) == "\97\108\111\32\97\108\111")
260+assert(string.gsub("\97\108\111\32\97\108\111","\40\46\41",{["\97"] = "\65\65",["\108"] = ""}) == "\65\65\111\32\65\65\111")
261+assert(string.gsub("\97\108\111\32\97\108\111","\40\46\41\46",{["\97"] = "\65\65",["\108"] = "\75"}) == "\65\65\111\32\65\65\111")
262+assert(string.gsub("\97\108\111\32\97\108\111","\40\40\46\41\40\46\63\41\41",{["\97\108"] = "\65\65",["\111"] = false}) == "\65\65\111\32\65\65\111")
263+assert(string.gsub("\97\108\111\32\97\108\111","\40\41\46",{"\120","\121\121","\122\122\122"}) == "\120\121\121\122\122\122\32\97\108\111")
270264t={}
271265;
272−setmetatable(t,{["__index"] = (t,s)
266+setmetatable(t,{["\95\95\105\110\100\101\120"] = function (t,s)
273267return string.upper(s)
274268end})
275−assert(string.gsub("a alo b hi","%w%w+",t) == "a ALO b HI")
269+assert(string.gsub("\97\32\97\108\111\32\98\32\104\105","\37\119\37\119\43",t) == "\97\32\65\76\79\32\98\32\72\73")
276270local a = 0
277−for i in string.gmatch("abcde","()")
271+for i in string.gmatch("\97\98\99\100\101","\40\41")
278272do
279273assert(i == a + 1)
280274;
281275a=i
282276end
283277assert(a == 6)
284−t={["n"] = 0}
285−for w in string.gmatch("first second word","%w+")
278+t={["\110"] = 0}
279+for w in string.gmatch("\102\105\114\115\116\32\115\101\99\111\110\100\32\119\111\114\100","\37\119\43")
286280do
287281t.n=t.n + 1
288282;
289283t[t.n]=w
290284end
291−assert(t[1] == "first" and t[2] == "second" and t[3] == "word")
285+assert(t[1] == "\102\105\114\115\116" and t[2] == "\115\101\99\111\110\100" and t[3] == "\119\111\114\100")
292286t={3,6,9}
293−for i in string.gmatch("xuxx uu ppar r","()(.)%2")
287+for i in string.gmatch("\120\117\120\120\32\117\117\32\112\112\97\114\32\114","\40\41\40\46\41\37\50")
294288do
295289assert(i == table.remove(t,1))
296290end
297291assert(# t == 0)
298292t={}
299−for i,j in string.gmatch("13 14 10 = 11, 15= 16, 22=23","(%d+)%s*=%s*(%d+)")
293+for i,j in string.gmatch("\49\51\32\49\52\32\49\48\32\61\32\49\49\44\32\49\53\61\32\49\54\44\32\50\50\61\50\51","\40\37\100\43\41\37\115\42\61\37\115\42\40\37\100\43\41")
300294do
301295t[tonumber(i)]=tonumber(j)
302296end
@@ -308,99 +302,103 @@ assert(k + 1 == v + 0)
308302a=a + 1
309303end
310304assert(a == 3)
305+do
311306local s = 0
312−for k in string.gmatch("10 20 30","%d+",3)
307+for k in string.gmatch("\49\48\32\50\48\32\51\48","\37\100\43",3)
313308do
314309s=s + tonumber(k)
315310end
316311assert(s == 50)
317312s=0
318−for k in string.gmatch("11 21 31","%d+",- 4)
313+for k in string.gmatch("\49\49\32\50\49\32\51\49","\37\100\43",- 4)
319314do
320315s=s + tonumber(k)
321316end
322317assert(s == 32)
323318s=0
324−for k in string.gmatch("11 21 31","%w*",9)
319+for k in string.gmatch("\49\49\32\50\49\32\51\49","\37\119\42",9)
325320do
326321s=s + 1
327322end
328323assert(s == 1)
329324s=0
330−for k in string.gmatch("11 21 31","%w*",10)
325+for k in string.gmatch("\49\49\32\50\49\32\51\49","\37\119\42",10)
331326do
332327s=s + 1
333328end
334329assert(s == 0)
335−assert(string.gsub("aaa aa a aaa a","%f[%w]a","x") == "xaa xa x xaa x")
336−assert(string.gsub("[[]] [][] [[[[","%f[[].","x") == "x[]] x]x] x[[[")
337−assert(string.gsub("01abc45de3","%f[%d]",".") == ".01abc.45de.3")
338−assert(string.gsub("01abc45 de3x","%f[%D]%w",".") == "01.bc45 de3.")
339−assert(string.gsub("function","%f[-�]%w",".") == ".unction")
340−assert(string.gsub("function","%f[^-�]",".") == "function.")
341−assert(string.find("a","%f[a]") == 1)
342−assert(string.find("a","%f[^%z]") == 1)
343−assert(string.find("a","%f[^%l]") == 2)
344−assert(string.find("aba","%f[a%z]") == 3)
345−assert(string.find("aba","%f[%z]") == 4)
346−assert(not string.find("aba","%f[%l%z]"))
347−assert(not string.find("aba","%f[^%l%z]"))
348−local i,e = string.find(" alo aalo allo","%f[%S].-%f[%s].-%f[%S]")
330+end
331+assert(string.gsub("\97\97\97\32\97\97\32\97\32\97\97\97\32\97","\37\102\91\37\119\93\97","\120") == "\120\97\97\32\120\97\32\120\32\120\97\97\32\120")
332+assert(string.gsub("\91\91\93\93\32\91\93\91\93\32\91\91\91\91","\37\102\91\91\93\46","\120") == "\120\91\93\93\32\120\93\120\93\32\120\91\91\91")
333+assert(string.gsub("\48\49\97\98\99\52\53\100\101\51","\37\102\91\37\100\93","\46") == "\46\48\49\97\98\99\46\52\53\100\101\46\51")
334+assert(string.gsub("\48\49\97\98\99\52\53\32\100\101\51\120","\37\102\91\37\68\93\37\119","\46") == "\48\49\46\98\99\52\53\32\100\101\51\46")
335+assert(string.gsub("\102\117\110\99\116\105\111\110","\37\102\91\1\45\255\93\37\119","\46") == "\46\117\110\99\116\105\111\110")
336+assert(string.gsub("\102\117\110\99\116\105\111\110","\37\102\91\94\1\45\255\93","\46") == "\102\117\110\99\116\105\111\110\46")
337+assert(string.find("\97","\37\102\91\97\93") == 1)
338+assert(string.find("\97","\37\102\91\94\37\122\93") == 1)
339+assert(string.find("\97","\37\102\91\94\37\108\93") == 2)
340+assert(string.find("\97\98\97","\37\102\91\97\37\122\93") == 3)
341+assert(string.find("\97\98\97","\37\102\91\37\122\93") == 4)
342+assert(not string.find("\97\98\97","\37\102\91\37\108\37\122\93"))
343+assert(not string.find("\97\98\97","\37\102\91\94\37\108\37\122\93"))
344+local i,e = string.find("\32\97\108\111\32\97\97\108\111\32\97\108\108\111","\37\102\91\37\83\93\46\45\37\102\91\37\115\93\46\45\37\102\91\37\83\93")
349345assert(i == 2 and e == 5)
350−local k = string.match(" alo aalo allo","%f[%S](.-%f[%s].-%f[%S])")
351−assert(k == "alo ")
346+local k = string.match("\32\97\108\111\32\97\97\108\111\32\97\108\108\111","\37\102\91\37\83\93\40\46\45\37\102\91\37\115\93\46\45\37\102\91\37\83\93\41")
347+assert(k == "\97\108\111\32")
352348local a = {1,5,9,14,17}
353−for k in string.gmatch("alo alo th02 is 1hat","()%f[%w%d]")
349+for k in string.gmatch("\97\108\111\32\97\108\111\32\116\104\48\50\32\105\115\32\49\104\97\116","\40\41\37\102\91\37\119\37\100\93")
354350do
355351assert(table.remove(a,1) == k)
356352end
357353assert(# a == 0)
358354local function malform
359355(p,m)
360−m=m or "malformed"
361−local r,msg = pcall(string.find,"a",p)
356+m=m or "\109\97\108\102\111\114\109\101\100"
357+local r,msg = pcall(string.find,"\97",p)
362358assert(not r and string.find(msg,m))
363359end
364−malform("(.","unfinished capture")
365−malform(".)","invalid pattern capture")
366−malform("[a")
367−malform("[]")
368−malform("[^]")
369−malform("[a%]")
370−malform("[a%")
371−malform("%b")
372−malform("%ba")
373−malform("%")
374−malform("%f","missing")
375−assert(string.match("abc","[-]+") == "")
376−assert(string.match("abc","[-]+") == "")
377−assert(string.find("b$a","$?") == 2)
378−assert(string.find("abcefg","%") == 4)
379−assert(string.match("abcefgeg","%b") == "efge")
380−assert(string.match("abc","%+") == "")
381−assert(string.match("abc","%%?") == "")
382−assert(string.find("abc",".") == 4)
383−assert(string.find("abcxabcabc","xabca.") == 4)
384−local s = string.rep("a",100)
385−local r = string.gsub(s,"b","c")
386−assert(string.format("%p",s) == string.format("%p",r))
387−r=string.gsub(s,".",{["x"] = "y"})
388−assert(string.format("%p",s) == string.format("%p",r))
360+malform("\40\46","\117\110\102\105\110\105\115\104\101\100\32\99\97\112\116\117\114\101")
361+malform("\46\41","\105\110\118\97\108\105\100\32\112\97\116\116\101\114\110\32\99\97\112\116\117\114\101")
362+malform("\91\97")
363+malform("\91\93")
364+malform("\91\94\93")
365+malform("\91\97\37\93")
366+malform("\91\97\37")
367+malform("\37\98")
368+malform("\37\98\97")
369+malform("\37")
370+malform("\37\102","\109\105\115\115\105\110\103")
371+assert(string.match("\97\98\1\2\99","\91\45\2\93\43") == "\1\2")
372+assert(string.match("\97\98\1\2\99","\91\45\93\43") == "")
373+assert(string.find("\98\36\97","\36\63") == 2)
374+assert(string.find("\97\98\99\101\102\103","\37") == 4)
375+assert(string.match("\97\98\99\101\102\103\1\101\1\103","\37\98\1") == "\101\102\103\1\101\1")
376+assert(string.match("\97\98\99","\37\43") == "")
377+assert(string.match("\97\98\99","\37\37\63") == "")
378+assert(string.find("\97\98\99","\46") == 4)
379+assert(string.find("\97\98\99\120\97\98\99\97\98\99","\120\97\98\99\97\46") == 4)
380+do
381+local s = string.rep("\97",100)
382+local r = string.gsub(s,"\98","\99")
383+assert(string.format("\37\112",s) == string.format("\37\112",r))
384+r=string.gsub(s,"\46",{["\120"] = "\121"})
385+assert(string.format("\37\112",s) == string.format("\37\112",r))
389386local count = 0
390−r=string.gsub(s,".",(x)
391−assert(x == "a")
387+r=string.gsub(s,"\46",function (x)
388+assert(x == "\97")
392389count=count + 1
393390return nil
394391end)
395−r=string.gsub(r,".",{["b"] = "x"})
392+r=string.gsub(r,"\46",{["\98"] = "\120"})
396393assert(count == 100)
397−assert(string.format("%p",s) == string.format("%p",r))
394+assert(string.format("\37\112",s) == string.format("\37\112",r))
398395count=0
399−r=string.gsub(s,".",(x)
400−assert(x == "a")
396+r=string.gsub(s,"\46",function (x)
397+assert(x == "\97")
401398count=count + 1
402399return x
403400end)
404401assert(count == 100)
405−assert(r == s and string.format("%p",s) ~= string.format("%p",r))
406−print("OK")
402+assert(r == s and string.format("\37\112",s) ~= string.format("\37\112",r))
403+end
404+print("\79\75")
zod/luau/res/lua/cycled/sort.lua+67−59
@@ -1,5 +1,5 @@
1−print("testing (parts of) table library")
2−print("testing unpack")
1+print("\116\101\115\116\105\110\103\32\40\112\97\114\116\115\32\111\102\41\32\116\97\98\108\101\32\108\105\98\114\97\114\121")
2+print("\116\101\115\116\105\110\103\32\117\110\112\97\99\107")
33local unpack = table.unpack
44local maxI = math.maxinteger
55local minI = math.mininteger
@@ -8,16 +8,16 @@ local function checkerror
88local s,err = pcall(f,...)
99assert(not s and string.find(err,msg))
1010end
11−checkerror("wrong number of arguments",table.insert,{},2,3,4)
12−local x,y,z,a,n =
11+checkerror("\119\114\111\110\103\32\110\117\109\98\101\114\32\111\102\32\97\114\103\117\109\101\110\116\115",table.insert,{},2,3,4)
12+local x,y,z,a,n
1313a={}
1414;
15−local lim = _soft and 200 or 2e3
15+local lim = _soft and 200 or 2000
1616for i = 1, lim
1717do
1818a[i]=i
1919end
20−assert(select(lim,unpack(a)) == lim and select("#",unpack(a)) == lim)
20+assert(select(lim,unpack(a)) == lim and select("\35",unpack(a)) == lim)
2121x=unpack(a)
2222assert(x == 1)
2323x={unpack(a)}
@@ -36,15 +36,16 @@ a,x=unpack({1})
3636assert(a == 1 and x == nil)
3737a,x=unpack({1,2},1,1)
3838assert(a == 1 and x == nil)
39+do
3940local maxi = (1 << 31) - 1
4041local mini = - (1 << 31)
41−checkerror("too many results",unpack,{},0,maxi)
42−checkerror("too many results",unpack,{},1,maxi)
43−checkerror("too many results",unpack,{},0,maxI)
44−checkerror("too many results",unpack,{},1,maxI)
45−checkerror("too many results",unpack,{},mini,maxi)
46−checkerror("too many results",unpack,{},- maxi,maxi)
47−checkerror("too many results",unpack,{},minI,maxI)
42+checkerror("\116\111\111\32\109\97\110\121\32\114\101\115\117\108\116\115",unpack,{},0,maxi)
43+checkerror("\116\111\111\32\109\97\110\121\32\114\101\115\117\108\116\115",unpack,{},1,maxi)
44+checkerror("\116\111\111\32\109\97\110\121\32\114\101\115\117\108\116\115",unpack,{},0,maxI)
45+checkerror("\116\111\111\32\109\97\110\121\32\114\101\115\117\108\116\115",unpack,{},1,maxI)
46+checkerror("\116\111\111\32\109\97\110\121\32\114\101\115\117\108\116\115",unpack,{},mini,maxi)
47+checkerror("\116\111\111\32\109\97\110\121\32\114\101\115\117\108\116\115",unpack,{},- maxi,maxi)
48+checkerror("\116\111\111\32\109\97\110\121\32\114\101\115\117\108\116\115",unpack,{},minI,maxI)
4849unpack({},maxi,0)
4950unpack({},maxi,1)
5051unpack({},maxI,minI)
@@ -73,19 +74,23 @@ assert(a == 12.3 and b == nil)
7374a,b=unpack(t,minI + 1,minI)
7475;
7576assert(a == nil and b == nil)
76−local t = setmetatable({},{["__len"] = ()
77−return "abc"
77+end
78+do
79+local t = setmetatable({},{["\95\95\108\101\110"] = function ()
80+return "\97\98\99"
7881end})
79−assert(# t == "abc")
80−checkerror("object length is not an integer",table.insert,t,1)
81−print("testing pack")
82+assert(# t == "\97\98\99")
83+checkerror("\111\98\106\101\99\116\32\108\101\110\103\116\104\32\105\115\32\110\111\116\32\97\110\32\105\110\116\101\103\101\114",table.insert,t,1)
84+end
85+print("\116\101\115\116\105\110\103\32\112\97\99\107")
8286a=table.pack()
8387assert(a[1] == undef and a.n == 0)
8488a=table.pack(table)
8589assert(a[1] == table and a.n == 1)
8690a=table.pack(nil,nil,nil,nil)
8791assert(a[1] == nil and a.n == 4)
88−checkerror("table expected",table.move,1,2,3,4)
92+do
93+checkerror("\116\97\98\108\101\32\101\120\112\101\99\116\101\100",table.move,1,2,3,4)
8994local function eqT
9095(a,b)
9196for k,v in pairs(a)
@@ -124,25 +129,27 @@ a=table.move({[maxI] = 100},maxI,maxI,minI)
124129eqT(a,{[minI] = 100,[maxI] = 100})
125130a=table.move({[minI] = 100},minI,minI,maxI)
126131eqT(a,{[minI] = 100,[maxI] = 100})
127−a=setmetatable({},{["__index"] = (_,k)
132+a=setmetatable({},{["\95\95\105\110\100\101\120"] = function (_,k)
128133return k * 10
129−end,["__newindex"] = error})
134+end,["\95\95\110\101\119\105\110\100\101\120"] = error})
130135local b = table.move(a,1,10,3,{})
131136eqT(a,{})
132137eqT(b,{nil,nil,10,20,30,40,50,60,70,80,90,100})
133−b=setmetatable({""},{["__index"] = error,["__newindex"] = (t,k,v)
134−t[1]=string.format("%s(%d,%d)",t[1],k,v)
138+b=setmetatable({""},{["\95\95\105\110\100\101\120"] = error,["\95\95\110\101\119\105\110\100\101\120"] = function (t,k,v)
139+t[1]=string.format("\37\115\40\37\100\44\37\100\41",t[1],k,v)
135140end})
136141table.move(a,10,13,3,b)
137−assert(b[1] == "(3,100)(4,110)(5,120)(6,130)")
142+assert(b[1] == "\40\51\44\49\48\48\41\40\52\44\49\49\48\41\40\53\44\49\50\48\41\40\54\44\49\51\48\41")
138143local stat,msg = pcall(table.move,b,10,13,3,b)
139144assert(not stat and msg == b)
145+end
146+do
140147local function checkmove
141148(f,e,t,x,y)
142−local pos1,pos2 =
143−local a = setmetatable({},{["__index"] = (_,k)
149+local pos1,pos2
150+local a = setmetatable({},{["\95\95\105\110\100\101\120"] = function (_,k)
144151pos1=k
145−end,["__newindex"] = (_,k)
152+end,["\95\95\110\101\119\105\110\100\101\120"] = function (_,k)
146153pos2=k
147154;
148155error()
@@ -156,23 +163,24 @@ checkmove(minI,- 2,- 5,- 2,maxI - 6)
156163checkmove(minI + 1,- 1,- 2,- 1,maxI - 3)
157164checkmove(minI,- 2,0,minI,0)
158165checkmove(minI + 1,- 1,1,minI + 1,1)
159−checkerror("too many",table.move,{},0,maxI,1)
160−checkerror("too many",table.move,{},- 1,maxI - 1,1)
161−checkerror("too many",table.move,{},minI,- 1,1)
162−checkerror("too many",table.move,{},minI,maxI,1)
163−checkerror("wrap around",table.move,{},1,maxI,2)
164−checkerror("wrap around",table.move,{},1,2,maxI)
165−checkerror("wrap around",table.move,{},minI,- 2,2)
166−print("testing sort")
167−local a = setmetatable({},{["__len"] = ()
166+end
167+checkerror("\116\111\111\32\109\97\110\121",table.move,{},0,maxI,1)
168+checkerror("\116\111\111\32\109\97\110\121",table.move,{},- 1,maxI - 1,1)
169+checkerror("\116\111\111\32\109\97\110\121",table.move,{},minI,- 1,1)
170+checkerror("\116\111\111\32\109\97\110\121",table.move,{},minI,maxI,1)
171+checkerror("\119\114\97\112\32\97\114\111\117\110\100",table.move,{},1,maxI,2)
172+checkerror("\119\114\97\112\32\97\114\111\117\110\100",table.move,{},1,2,maxI)
173+checkerror("\119\114\97\112\32\97\114\111\117\110\100",table.move,{},minI,- 2,2)
174+print("\116\101\115\116\105\110\103\32\115\111\114\116")
175+local a = setmetatable({},{["\95\95\108\101\110"] = function ()
168176return - 1
169177end})
170178assert(# a == - 1)
171179table.sort(a,error)
172−a=setmetatable({},{["__len"] = ()
180+a=setmetatable({},{["\95\95\108\101\110"] = function ()
173181return maxI
174182end})
175−checkerror("too big",table.sort,a)
183+checkerror("\116\111\111\32\98\105\103",table.sort,a)
176184local function check
177185(t)
178186local function f
@@ -181,13 +189,13 @@ assert(a and b)
181189;
182190return true
183191end
184−checkerror("invalid order function",table.sort,t,f)
192+checkerror("\105\110\118\97\108\105\100\32\111\114\100\101\114\32\102\117\110\99\116\105\111\110",table.sort,t,f)
185193end
186194check({1,2,3,4})
187195check({1,2,3,4,5})
188196check({1,2,3,4,5,6})
189197function check(a,f)
190−f=f or (x,y)
198+f=f or function (x,y)
191199return x < y
192200end
193201;
@@ -196,7 +204,7 @@ do
196204assert(not f(a[n],a[n - 1]))
197205end
198206end
199−a={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}
207+a={"\74\97\110","\70\101\98","\77\97\114","\65\112\114","\77\97\121","\74\117\110","\74\117\108","\65\117\103","\83\101\112","\79\99\116","\78\111\118","\68\101\99"}
200208table.sort(a)
201209check(a)
202210local function perm
@@ -229,22 +237,22 @@ local function timesort
229237(a,n,func,msg,pre)
230238local x = os.clock()
231239table.sort(a,func)
232−x=(os.clock() - x) * 1e3
240+x=(os.clock() - x) * 1000
233241pre=pre or ""
234−print(string.format("%ssorting %d %s elements in %.2f msec.",pre,n,msg,x))
242+print(string.format("\37\115\115\111\114\116\105\110\103\32\37\100\32\37\115\32\101\108\101\109\101\110\116\115\32\105\110\32\37\46\50\102\32\109\115\101\99\46",pre,n,msg,x))
235243check(a,func)
236244end
237−local limit = 5e4
245+local limit = 50000
238246if _soft then
239−limit=5e3
247+limit=5000
240248end
241249a={}
242250for i = 1, limit
243251do
244252a[i]=math.random()
245253end
246−timesort(a,limit,nil,"random")
247−timesort(a,limit,nil,"sorted","re-")
254+timesort(a,limit,nil,"\114\97\110\100\111\109")
255+timesort(a,limit,nil,"\115\111\114\116\101\100","\114\101\45")
248256a={}
249257for i = 1, limit
250258do
@@ -253,14 +261,14 @@ end
253261local x = os.clock()
254262;
255263local i = 0
256−table.sort(a,(x,y)
264+table.sort(a,function (x,y)
257265i=i + 1
258266;
259267return y < x
260268end)
261−x=(os.clock() - x) * 1e3
262−print(string.format("Invert-sorting other %d elements in %.2f msec., with %i comparisons",limit,x,i))
263−check(a,(x,y)
269+x=(os.clock() - x) * 1000
270+print(string.format("\73\110\118\101\114\116\45\115\111\114\116\105\110\103\32\111\116\104\101\114\32\37\100\32\101\108\101\109\101\110\116\115\32\105\110\32\37\46\50\102\32\109\115\101\99\46\44\32\119\105\116\104\32\37\105\32\99\111\109\112\97\114\105\115\111\110\115",limit,x,i))
271+check(a,function (x,y)
264272return y < x
265273end)
266274table.sort({})
@@ -268,29 +276,29 @@ for i = 1, limit
268276do
269277a[i]=false
270278end
271−timesort(a,limit,(x,y)
279+timesort(a,limit,function (x,y)
272280return nil
273−end,"equal")
281+end,"\101\113\117\97\108")
274282for i,v in pairs(a)
275283do
276284assert(v == false)
277285end
278−AA={"�lo","first :-)","alo","then this one","45","and a new"}
286+AA={"\225\108\111","\102\105\114\115\116\32\58\45\41","\97\108\111","\116\104\101\110\32\116\104\105\115\32\111\110\101","\52\53","\97\110\100\32\97\32\110\101\119"}
279287table.sort(AA)
280288check(AA)
281−table.sort(AA,(x,y)
282−load(string.format("AA[%q] = ''",x),"")()
289+table.sort(AA,function (x,y)
290+load(string.format("\65\65\91\37\113\93\32\61\32\39\39",x),"")()
283291collectgarbage()
284292return x < y
285293end)
286294_G.AA=nil
287−local tt = {["__lt"] = (a,b)
295+local tt = {["\95\95\108\116"] = function (a,b)
288296return a.val < b.val
289297end}
290298a={}
291299for i = 1, 10
292300do
293−a[i]={["val"] = math.random(100)}
301+a[i]={["\118\97\108"] = math.random(100)}
294302;
295303setmetatable(a[i],tt)
296304;
@@ -298,4 +306,4 @@ end
298306table.sort(a)
299307check(a,tt.__lt)
300308check(a)
301−print("OK")
309+print("\79\75")
zod/luau/res/lua/cycled/strings.lua+313−306
@@ -1,4 +1,4 @@
1−print("testing strings and string library")
1+print("\116\101\115\116\105\110\103\32\115\116\114\105\110\103\115\32\97\110\100\32\115\116\114\105\110\103\32\108\105\98\114\97\114\121")
22local maxi <const> = math.maxinteger
33local mini <const> = math.mininteger
44local function checkerror
@@ -6,185 +6,187 @@ local function checkerror
66local s,err = pcall(f,...)
77assert(not s and string.find(err,msg))
88end
9−assert("alo" < "alo1")
10−assert("" < "a")
11−assert("aloalo" < "alob")
12−assert("aloalo" > "aloalo")
13−assert("alo" < "alo")
14−assert("alo" > "alo")
15−assert("" < "")
16−assert("" < "")
17−assert("aa" <= "aa")
18−assert(not ("ab" <= "aa"))
9+assert("\97\108\111" < "\97\108\111\49")
10+assert("" < "\97")
11+assert("\97\108\111\97\108\111" < "\97\108\111\98")
12+assert("\97\108\111\97\108\111" > "\97\108\111\97\108\111")
13+assert("\97\108\111" < "\97\108\111")
14+assert("\97\108\111" > "\97\108\111")
15+assert("" < "\1")
16+assert("" < "\1")
17+assert("\1\97\97" <= "\1\97\97")
18+assert(not ("\1\97\98" <= "\1\97\97"))
1919assert("" < "")
2020assert(not ("" < ""))
2121assert("" <= "")
2222assert(not ("" <= ""))
2323assert("" <= "")
2424assert("" >= "")
25−assert(not ("b" < "a"))
26−assert(string.sub("123456789",2,4) == "234")
27−assert(string.sub("123456789",7) == "789")
28−assert(string.sub("123456789",7,6) == "")
29−assert(string.sub("123456789",7,7) == "7")
30−assert(string.sub("123456789",0,0) == "")
31−assert(string.sub("123456789",- 10,10) == "123456789")
32−assert(string.sub("123456789",1,9) == "123456789")
33−assert(string.sub("123456789",- 10,- 20) == "")
34−assert(string.sub("123456789",- 1) == "9")
35−assert(string.sub("123456789",- 4) == "6789")
36−assert(string.sub("123456789",- 6,- 4) == "456")
37−assert(string.sub("123456789",mini,- 4) == "123456")
38−assert(string.sub("123456789",mini,maxi) == "123456789")
39−assert(string.sub("123456789",mini,mini) == "")
40−assert(string.sub("123456789",3,5) == "234")
41−assert(("123456789"):sub(8) == "789")
42−assert(string.find("123456789","345") == 3)
43−local a,b = string.find("123456789","345")
44−assert(string.sub("123456789",a,b) == "345")
45−assert(string.find("1234567890123456789","345",3) == 3)
46−assert(string.find("1234567890123456789","345",4) == 13)
47−assert(not string.find("1234567890123456789","346",4))
48−assert(string.find("1234567890123456789",".45",- 9) == 13)
49−assert(not string.find("abcdefg","",5,1))
25+assert(not ("\98" < "\97"))
26+assert(string.sub("\49\50\51\52\53\54\55\56\57",2,4) == "\50\51\52")
27+assert(string.sub("\49\50\51\52\53\54\55\56\57",7) == "\55\56\57")
28+assert(string.sub("\49\50\51\52\53\54\55\56\57",7,6) == "")
29+assert(string.sub("\49\50\51\52\53\54\55\56\57",7,7) == "\55")
30+assert(string.sub("\49\50\51\52\53\54\55\56\57",0,0) == "")
31+assert(string.sub("\49\50\51\52\53\54\55\56\57",- 10,10) == "\49\50\51\52\53\54\55\56\57")
32+assert(string.sub("\49\50\51\52\53\54\55\56\57",1,9) == "\49\50\51\52\53\54\55\56\57")
33+assert(string.sub("\49\50\51\52\53\54\55\56\57",- 10,- 20) == "")
34+assert(string.sub("\49\50\51\52\53\54\55\56\57",- 1) == "\57")
35+assert(string.sub("\49\50\51\52\53\54\55\56\57",- 4) == "\54\55\56\57")
36+assert(string.sub("\49\50\51\52\53\54\55\56\57",- 6,- 4) == "\52\53\54")
37+assert(string.sub("\49\50\51\52\53\54\55\56\57",mini,- 4) == "\49\50\51\52\53\54")
38+assert(string.sub("\49\50\51\52\53\54\55\56\57",mini,maxi) == "\49\50\51\52\53\54\55\56\57")
39+assert(string.sub("\49\50\51\52\53\54\55\56\57",mini,mini) == "")
40+assert(string.sub("\49\50\51\52\53\54\55\56\57",3,5) == "\50\51\52")
41+assert(("\49\50\51\52\53\54\55\56\57"):sub(8) == "\55\56\57")
42+assert(string.find("\49\50\51\52\53\54\55\56\57","\51\52\53") == 3)
43+local a,b = string.find("\49\50\51\52\53\54\55\56\57","\51\52\53")
44+assert(string.sub("\49\50\51\52\53\54\55\56\57",a,b) == "\51\52\53")
45+assert(string.find("\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57","\51\52\53",3) == 3)
46+assert(string.find("\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57","\51\52\53",4) == 13)
47+assert(not string.find("\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57","\51\52\54",4))
48+assert(string.find("\49\50\51\52\53\54\55\56\57\48\49\50\51\52\53\54\55\56\57","\46\52\53",- 9) == 13)
49+assert(not string.find("\97\98\99\100\101\102\103","",5,1))
5050assert(string.find("","") == 1)
5151assert(string.find("","",1) == 1)
5252assert(not string.find("","",2))
53−assert(not string.find("","aaa",1))
54−assert(("alo(.)alo"):find("(.)",1,1) == 4)
53+assert(not string.find("","\97\97\97",1))
54+assert(("\97\108\111\40\46\41\97\108\111"):find("\40\46\41",1,1) == 4)
5555assert(string.len("") == 0)
5656assert(string.len("") == 3)
57−assert(string.len("1234567890") == 10)
57+assert(string.len("\49\50\51\52\53\54\55\56\57\48") == 10)
5858assert(# "" == 0)
5959assert(# "" == 3)
60−assert(# "1234567890" == 10)
61−assert(string.byte("a") == 97)
62−assert(string.byte("�") > 127)
60+assert(# "\49\50\51\52\53\54\55\56\57\48" == 10)
61+assert(string.byte("\97") == 97)
62+assert(string.byte("\228") > 127)
6363assert(string.byte(string.char(255)) == 255)
6464assert(string.byte(string.char(0)) == 0)
6565assert(string.byte("") == 0)
66−assert(string.byte("alox",- 1) == string.byte("x"))
67−assert(string.byte("ba",2) == 97)
68−assert(string.byte("
69−
70−",2,- 1) == 10)
71−assert(string.byte("
72−
73−",2,2) == 10)
66+assert(string.byte("\97\108\111\120",- 1) == string.byte("\120"))
67+assert(string.byte("\98\97",2) == 97)
68+assert(string.byte("\10\10",2,- 1) == 10)
69+assert(string.byte("\10\10",2,2) == 10)
7470assert(string.byte("") == nil)
75−assert(string.byte("hi",- 3) == nil)
76−assert(string.byte("hi",3) == nil)
77−assert(string.byte("hi",9,10) == nil)
78−assert(string.byte("hi",2,1) == nil)
71+assert(string.byte("\104\105",- 3) == nil)
72+assert(string.byte("\104\105",3) == nil)
73+assert(string.byte("\104\105",9,10) == nil)
74+assert(string.byte("\104\105",2,1) == nil)
7975assert(string.char() == "")
80−assert(string.char(0,255,0) == "�")
81−assert(string.char(0,string.byte("�"),0) == "�")
82−assert(string.char(string.byte("�l�u",1,- 1)) == "�l�u")
83−assert(string.char(string.byte("�l�u",1,0)) == "")
84−assert(string.char(string.byte("�l�u",- 10,100)) == "�l�u")
85−checkerror("out of range",string.char,256)
86−checkerror("out of range",string.char,- 1)
87−checkerror("out of range",string.char,math.maxinteger)
88−checkerror("out of range",string.char,math.mininteger)
89−assert(string.upper("abc") == "ABC")
90−assert(string.lower("ABCc%$") == "abcc%$")
91−assert(string.rep("teste",0) == "")
92−assert(string.rep("t�st�",2) == "t�st�t�st�")
76+assert(string.char(0,255,0) == "\255")
77+assert(string.char(0,string.byte("\228"),0) == "\228")
78+assert(string.char(string.byte("\228\108\243\117",1,- 1)) == "\228\108\243\117")
79+assert(string.char(string.byte("\228\108\243\117",1,0)) == "")
80+assert(string.char(string.byte("\228\108\243\117",- 10,100)) == "\228\108\243\117")
81+checkerror("\111\117\116\32\111\102\32\114\97\110\103\101",string.char,256)
82+checkerror("\111\117\116\32\111\102\32\114\97\110\103\101",string.char,- 1)
83+checkerror("\111\117\116\32\111\102\32\114\97\110\103\101",string.char,math.maxinteger)
84+checkerror("\111\117\116\32\111\102\32\114\97\110\103\101",string.char,math.mininteger)
85+assert(string.upper("\97\98\99") == "\65\66\67")
86+assert(string.lower("\65\66\67\99\37\36") == "\97\98\99\99\37\36")
87+assert(string.rep("\116\101\115\116\101",0) == "")
88+assert(string.rep("\116\233\115\116\234",2) == "\116\233\115\116\234\116\233\115\116\234")
9389assert(string.rep("",10) == "")
94−if string.packsize("i") == 4 then
95−checkerror("too large",string.rep,"aa",(1 << 30))
96−checkerror("too large",string.rep,"a",(1 << 30),",")
97−end
98−assert(string.rep("teste",0,"xuxu") == "")
99−assert(string.rep("teste",1,"xuxu") == "teste")
100−assert(string.rep("",2,"") == "")
101−assert(string.rep("",10,".") == string.rep(".",9))
102−assert(not pcall(string.rep,"aa",maxi // 2 + 10))
103−assert(not pcall(string.rep,"",maxi // 2 + 10,"aa"))
90+if string.packsize("\105") == 4 then
91+checkerror("\116\111\111\32\108\97\114\103\101",string.rep,"\97\97",(1 << 30))
92+checkerror("\116\111\111\32\108\97\114\103\101",string.rep,"\97",(1 << 30),"\44")
93+end
94+assert(string.rep("\116\101\115\116\101",0,"\120\117\120\117") == "")
95+assert(string.rep("\116\101\115\116\101",1,"\120\117\120\117") == "\116\101\115\116\101")
96+assert(string.rep("\1\1",2,"") == "\1\1\1\1")
97+assert(string.rep("",10,"\46") == string.rep("\46",9))
98+assert(not pcall(string.rep,"\97\97",maxi // 2 + 10))
99+assert(not pcall(string.rep,"",maxi // 2 + 10,"\97\97"))
104100assert(string.reverse("") == "")
105−assert(string.reverse("") == "")
106−assert(string.reverse("1234") == "4321")
101+assert(string.reverse("\1\2\3") == "\3\2\1")
102+assert(string.reverse("\49\50\51\52") == "\52\51\50\49")
107103for i = 0, 30
108104do
109−assert(string.len(string.rep("a",i)) == i)
105+assert(string.len(string.rep("\97",i)) == i)
110106end
111−assert(type(tostring(nil)) == "string")
112−assert(type(tostring(12)) == "string")
113−assert(string.find(tostring({}),"table:"))
114−assert(string.find(tostring(print),"function:"))
107+assert(type(tostring(nil)) == "\115\116\114\105\110\103")
108+assert(type(tostring(12)) == "\115\116\114\105\110\103")
109+assert(string.find(tostring({}),"\116\97\98\108\101\58"))
110+assert(string.find(tostring(print),"\102\117\110\99\116\105\111\110\58"))
115111assert(# tostring("") == 1)
116−assert(tostring(true) == "true")
117−assert(tostring(false) == "false")
118−assert(tostring(- 1203) == "-1203")
119−assert(tostring(1203.125) == "1203.125")
120−assert(tostring(- 0.5) == "-0.5")
121−assert(tostring(- 32767) == "-32767")
112+assert(tostring(true) == "\116\114\117\101")
113+assert(tostring(false) == "\102\97\108\115\101")
114+assert(tostring(- 1203) == "\45\49\50\48\51")
115+assert(tostring(1203.125) == "\49\50\48\51\46\49\50\53")
116+assert(tostring(- 0.5) == "\45\48\46\53")
117+assert(tostring(- 32767) == "\45\51\50\55\54\55")
122118if math.tointeger(2147483647) then
123−assert(tostring(- 2147483647) == "-2147483647")
119+assert(tostring(- 2147483647) == "\45\50\49\52\55\52\56\51\54\52\55")
124120end
125−if math.tointeger(4.611686018427388e18) then
126−assert(tostring(4.611686018427388e18) == "4611686018427387904")
127−assert(tostring(- 4.611686018427388e18) == "-4611686018427387904")
121+if math.tointeger(4611686018427387904) then
122+assert(tostring(4611686018427387904) == "\52\54\49\49\54\56\54\48\49\56\52\50\55\51\56\55\57\48\52")
123+assert(tostring(- 4611686018427387904) == "\45\52\54\49\49\54\56\54\48\49\56\52\50\55\51\56\55\57\48\52")
128124end
129−if tostring(0) == "0.0" then
130−assert("" .. 12 == "12" and 12 .. "" == "12.0")
131−assert(tostring(- 1203 + 0) == "-1203.0")
125+if tostring(0.0) == "\48\46\48" then
126+assert("" .. 12 == "\49\50" and 12.0 .. "" == "\49\50\46\48")
127+assert(tostring(- 1203 + 0.0) == "\45\49\50\48\51\46\48")
132128else
133−assert(tostring(0) == "0")
134−assert("" .. 12 == "12" and 12 .. "" == "12")
135−assert(tostring(- 1203 + 0) == "-1203")
136−end
137−local null = "(null)"
138−assert(string.format("%p",4) == null)
139−assert(string.format("%p",true) == null)
140−assert(string.format("%p",nil) == null)
141−assert(string.format("%p",{}) ~= null)
142−assert(string.format("%p",print) ~= null)
143−assert(string.format("%p",coroutine.running()) ~= null)
144−assert(string.format("%p",io.stdin) ~= null)
145−assert(string.format("%p",io.stdin) == string.format("%p",io.stdin))
146−assert(string.format("%p",print) == string.format("%p",print))
147−assert(string.format("%p",print) ~= string.format("%p",assert))
148−assert(# string.format("%90p",{}) == 90)
149−assert(# string.format("%-60p",{}) == 60)
150−assert(string.format("%10p",false) == string.rep(" ",10 - # null) .. null)
151−assert(string.format("%-12p",1.5) == null .. string.rep(" ",12 - # null))
129+assert(tostring(0.0) == "\48")
130+assert("" .. 12 == "\49\50" and 12.0 .. "" == "\49\50")
131+assert(tostring(- 1203 + 0.0) == "\45\49\50\48\51")
132+end
133+do
134+local null = "\40\110\117\108\108\41"
135+assert(string.format("\37\112",4) == null)
136+assert(string.format("\37\112",true) == null)
137+assert(string.format("\37\112",nil) == null)
138+assert(string.format("\37\112",{}) ~= null)
139+assert(string.format("\37\112",print) ~= null)
140+assert(string.format("\37\112",coroutine.running()) ~= null)
141+assert(string.format("\37\112",io.stdin) ~= null)
142+assert(string.format("\37\112",io.stdin) == string.format("\37\112",io.stdin))
143+assert(string.format("\37\112",print) == string.format("\37\112",print))
144+assert(string.format("\37\112",print) ~= string.format("\37\112",assert))
145+assert(# string.format("\37\57\48\112",{}) == 90)
146+assert(# string.format("\37\45\54\48\112",{}) == 60)
147+assert(string.format("\37\49\48\112",false) == string.rep("\32",10 - # null) .. null)
148+assert(string.format("\37\45\49\50\112",1.5) == null .. string.rep("\32",12 - # null))
149+do
152150local t1 = {}
153151;
154152local t2 = {}
155−assert(string.format("%p",t1) ~= string.format("%p",t2))
156−local s1 = string.rep("a",10)
157−local s2 = string.rep("aa",5)
158−assert(string.format("%p",s1) == string.format("%p",s2))
159−local s1 = string.rep("a",300)
153+assert(string.format("\37\112",t1) ~= string.format("\37\112",t2))
154+end
155+do
156+local s1 = string.rep("\97",10)
157+local s2 = string.rep("\97\97",5)
158+assert(string.format("\37\112",s1) == string.format("\37\112",s2))
159+end
160+do
161+local s1 = string.rep("\97",300)
160162;
161−local s2 = string.rep("a",300)
162−assert(string.format("%p",s1) ~= string.format("%p",s2))
163−local x = ""�lo"
164−\"
165−assert(string.format("%q%s",x,x) == ""\"�lo\"\
166−\\""�lo"
167−\")
168−assert(string.format("%q","") == ""\0"")
169−assert(load(string.format("return %q",x))() == x)
170−x="39"
171−assert(load(string.format("return %q",x))() == x)
172−assert(string.format("%c%c%x",string.byte("�"),string.byte("b"),140) == "�b8c")
163+local s2 = string.rep("\97",300)
164+assert(string.format("\37\112",s1) ~= string.format("\37\112",s2))
165+end
166+end
167+local x = "\34\237\108\111\34\10\92"
168+assert(string.format("\37\113\37\115",x,x) == "\34\92\34\237\108\111\92\34\92\10\92\92\34\34\237\108\111\34\10\92")
169+assert(string.format("\37\113","") == "\34\92\48\34")
170+assert(load(string.format("\114\101\116\117\114\110\32\37\113",x))() == x)
171+x="\1\2\51\5\57"
172+assert(load(string.format("\114\101\116\117\114\110\32\37\113",x))() == x)
173+assert(string.format("\37\99\37\99\37\120",string.byte("\228"),string.byte("\98"),140) == "\228\98\56\99")
173174assert(string.format("") == "")
174−assert(string.format("%c",34) .. string.format("%c",48) .. string.format("%c",90) .. string.format("%c",100) == string.format("%1c%-c%-1c%c",34,48,90,100))
175−assert(string.format("%s is not %s","not be","be") == "not be is not be")
176−assert(string.format("%%%d %010d",10,23) == "%10 0000000023")
177−assert(tonumber(string.format("%f",10.3)) == 10.3)
178−assert(string.format(""%-50s"","a") == ""a" .. string.rep(" ",49) .. """)
179−assert(string.format("-%.20s.20s",string.rep("%",2e3)) == "-" .. string.rep("%",20) .. ".20s")
180−assert(string.format(""-%20s.20s"",string.rep("%",2e3)) == string.format("%q","-" .. string.rep("%",2e3) .. ".20s"))
175+assert(string.format("\37\99",34) .. string.format("\37\99",48) .. string.format("\37\99",90) .. string.format("\37\99",100) == string.format("\37\49\99\37\45\99\37\45\49\99\37\99",34,48,90,100))
176+assert(string.format("\37\115\32\105\115\32\110\111\116\32\37\115","\110\111\116\32\98\101","\98\101") == "\110\111\116\32\98\101\32\105\115\32\110\111\116\32\98\101")
177+assert(string.format("\37\37\37\100\32\37\48\49\48\100",10,23) == "\37\49\48\32\48\48\48\48\48\48\48\48\50\51")
178+assert(tonumber(string.format("\37\102",10.3)) == 10.3)
179+assert(string.format("\34\37\45\53\48\115\34","\97") == "\34\97" .. string.rep("\32",49) .. "\34")
180+assert(string.format("\45\37\46\50\48\115\46\50\48\115",string.rep("\37",2000)) == "\45" .. string.rep("\37",20) .. "\46\50\48\115")
181+assert(string.format("\34\45\37\50\48\115\46\50\48\115\34",string.rep("\37",2000)) == string.format("\37\113","\45" .. string.rep("\37",2000) .. "\46\50\48\115"))
182+do
181183local function checkQ
182184(v)
183−local s = string.format("%q",v)
184−local nv = load("return " .. s)()
185+local s = string.format("\37\113",v)
186+local nv = load("\114\101\116\117\114\110\32" .. s)()
185187assert(v == nv and math.type(v) == math.type(nv))
186188end
187−checkQ("�4")
189+checkQ("\1\255\52\2")
188190checkQ(math.maxinteger)
189191checkQ(math.mininteger)
190192checkQ(math.pi)
@@ -194,30 +196,32 @@ checkQ(nil)
194196checkQ(false)
195197checkQ(math.huge)
196198checkQ(- math.huge)
197−assert(string.format("%q",0 / 0) == "(0/0)")
198−checkerror("no literal",string.format,"%q",{})
199−assert(string.format("%s","") == "")
200−checkerror("contains zeros",string.format,"%10s","")
201−assert(string.format("%s %s",nil,true) == "nil true")
202−assert(string.format("%s %.4s",false,true) == "false true")
203−assert(string.format("%.3s %.3s",false,true) == "fal tru")
204−local m = setmetatable({},{["__tostring"] = ()
205−return "hello"
206−end,["__name"] = "hi"})
207−assert(string.format("%s %.10s",m,m) == "hello hello")
199+assert(string.format("\37\113",0 / 0) == "\40\48\47\48\41")
200+checkerror("\110\111\32\108\105\116\101\114\97\108",string.format,"\37\113",{})
201+end
202+assert(string.format("\37\115","\1") == "\1")
203+checkerror("\99\111\110\116\97\105\110\115\32\122\101\114\111\115",string.format,"\37\49\48\115","")
204+assert(string.format("\37\115\32\37\115",nil,true) == "\110\105\108\32\116\114\117\101")
205+assert(string.format("\37\115\32\37\46\52\115",false,true) == "\102\97\108\115\101\32\116\114\117\101")
206+assert(string.format("\37\46\51\115\32\37\46\51\115",false,true) == "\102\97\108\32\116\114\117")
207+local m = setmetatable({},{["\95\95\116\111\115\116\114\105\110\103"] = function ()
208+return "\104\101\108\108\111"
209+end,["\95\95\110\97\109\101"] = "\104\105"})
210+assert(string.format("\37\115\32\37\46\49\48\115",m,m) == "\104\101\108\108\111\32\104\101\108\108\111")
208211getmetatable(m).__tostring=nil
209−assert(string.format("%.4s",m) == "hi: ")
210−getmetatable(m).__tostring=()
212+assert(string.format("\37\46\52\115",m) == "\104\105\58\32")
213+getmetatable(m).__tostring=function ()
211214return {}
212215end
213−checkerror("'__tostring' must return a string",tostring,m)
214−assert(string.format("%x",0) == "0")
215−assert(string.format("%02x",0) == "00")
216−assert(string.format("%08X",4294967295) == "FFFFFFFF")
217−assert(string.format("%+08d",31501) == "+0031501")
218−assert(string.format("%+08d",- 30927) == "-0030927")
216+checkerror("\39\95\95\116\111\115\116\114\105\110\103\39\32\109\117\115\116\32\114\101\116\117\114\110\32\97\32\115\116\114\105\110\103",tostring,m)
217+assert(string.format("\37\120",0.0) == "\48")
218+assert(string.format("\37\48\50\120",0.0) == "\48\48")
219+assert(string.format("\37\48\56\88",4294967295) == "\70\70\70\70\70\70\70\70")
220+assert(string.format("\37\43\48\56\100",31501) == "\43\48\48\51\49\53\48\49")
221+assert(string.format("\37\43\48\56\100",- 30927) == "\45\48\48\51\48\57\50\55")
222+do
219223local i = 1
220−local j = 1e4
224+local j = 10000
221225while i + 1 < j do
222226local m = (i + j) // 2
223227if 10 ^ m < math.huge then
@@ -225,171 +229,174 @@ i=m
225229else
226230j=m
227231end
232+end
228233assert(10 ^ i < math.huge and 10 ^ j == math.huge)
229−local s = string.format("%.99f",- (10 ^ i))
234+local s = string.format("\37\46\57\57\102",- (10 ^ i))
230235assert(string.len(s) >= i + 101)
231236assert(tonumber(s) == - (10 ^ i))
232237assert(10 ^ 38 < math.huge)
233−local s = string.format("%.99f",- (10 ^ 38))
238+local s = string.format("\37\46\57\57\102",- (10 ^ 38))
234239assert(string.len(s) >= 38 + 101)
235240assert(tonumber(s) == - (10 ^ 38))
241+end
242+do
236243local max,min = 2147483647,- 2147483648
237−assert(string.sub(string.format("%8x",- 1),- 8) == "ffffffff")
238−assert(string.format("%x",max) == "7fffffff")
239−assert(string.sub(string.format("%x",min),- 8) == "80000000")
240−assert(string.format("%d",max) == "2147483647")
241−assert(string.format("%d",min) == "-2147483648")
242−assert(string.format("%u",4294967295) == "4294967295")
243−assert(string.format("%o",43981) == "125715")
244+assert(string.sub(string.format("\37\56\120",- 1),- 8) == "\102\102\102\102\102\102\102\102")
245+assert(string.format("\37\120",max) == "\55\102\102\102\102\102\102\102")
246+assert(string.sub(string.format("\37\120",min),- 8) == "\56\48\48\48\48\48\48\48")
247+assert(string.format("\37\100",max) == "\50\49\52\55\52\56\51\54\52\55")
248+assert(string.format("\37\100",min) == "\45\50\49\52\55\52\56\51\54\52\56")
249+assert(string.format("\37\117",4294967295) == "\52\50\57\52\57\54\55\50\57\53")
250+assert(string.format("\37\111",43981) == "\49\50\53\55\49\53")
244251max,min=9223372036854775807,- 9223372036854775808
245−if max > 2 ^ 53 then
246−assert(string.format("%x",(2 ^ 52 | 0) - 1) == "fffffffffffff")
247−assert(string.format("0x%8X",2399141891) == "0x8F000003")
248−assert(string.format("%d",2 ^ 53) == "9007199254740992")
249−assert(string.format("%i",- 2 ^ 53) == "-9007199254740992")
250−assert(string.format("%x",max) == "7fffffffffffffff")
251−assert(string.format("%x",min) == "8000000000000000")
252−assert(string.format("%d",max) == "9223372036854775807")
253−assert(string.format("%d",min) == "-9223372036854775808")
254−assert(string.format("%u",~ (- 1 << 64)) == "18446744073709551615")
255−assert(tostring(1234567890123) == "1234567890123")
256−end
257−print("testing 'format %a %A'")
252+if max > 2.0 ^ 53 then
253+assert(string.format("\37\120",(2 ^ 52 | 0) - 1) == "\102\102\102\102\102\102\102\102\102\102\102\102\102")
254+assert(string.format("\48\120\37\56\88",2399141891) == "\48\120\56\70\48\48\48\48\48\51")
255+assert(string.format("\37\100",2 ^ 53) == "\57\48\48\55\49\57\57\50\53\52\55\52\48\57\57\50")
256+assert(string.format("\37\105",- 2 ^ 53) == "\45\57\48\48\55\49\57\57\50\53\52\55\52\48\57\57\50")
257+assert(string.format("\37\120",max) == "\55\102\102\102\102\102\102\102\102\102\102\102\102\102\102\102")
258+assert(string.format("\37\120",min) == "\56\48\48\48\48\48\48\48\48\48\48\48\48\48\48\48")
259+assert(string.format("\37\100",max) == "\57\50\50\51\51\55\50\48\51\54\56\53\52\55\55\53\56\48\55")
260+assert(string.format("\37\100",min) == "\45\57\50\50\51\51\55\50\48\51\54\56\53\52\55\55\53\56\48\56")
261+assert(string.format("\37\117",~ (- 1 << 64)) == "\49\56\52\52\54\55\52\52\48\55\51\55\48\57\53\53\49\54\49\53")
262+assert(tostring(1234567890123) == "\49\50\51\52\53\54\55\56\57\48\49\50\51")
263+end
264+end
265+do
266+print("\116\101\115\116\105\110\103\32\39\102\111\114\109\97\116\32\37\97\32\37\65\39")
258267local function matchhexa
259268(n)
260−local s = string.format("%a",n)
261−assert(string.find(s,"^%-?0x[1-9a-f]%.?[0-9a-f]*p[-+]?%d+$"))
269+local s = string.format("\37\97",n)
270+assert(string.find(s,"\94\37\45\63\48\120\91\49\45\57\97\45\102\93\37\46\63\91\48\45\57\97\45\102\93\42\112\91\45\43\93\63\37\100\43\36"))
262271assert(tonumber(s) == n)
263−s=string.format("%A",n)
264−assert(string.find(s,"^%-?0X[1-9A-F]%.?[0-9A-F]*P[-+]?%d+$"))
272+s=string.format("\37\65",n)
273+assert(string.find(s,"\94\37\45\63\48\88\91\49\45\57\65\45\70\93\37\46\63\91\48\45\57\65\45\70\93\42\80\91\45\43\93\63\37\100\43\36"))
265274assert(tonumber(s) == n)
266275end
267−for _,n in ipairs({0.1,- 0.1,1 / 3,- 1 / 3,1e30,- 1e30,- 45 / 247,1,- 1,2,- 2,3e-20,- 3e-20})
276+for _,n in ipairs({0.1,- 0.1,1 / 3,- 1 / 3,1e30.0,- 1e30.0,- 45 / 247,1,- 1,2,- 2,3e-20.0,- 3e-20.0})
268277do
269278matchhexa(n)
270279end
271−assert(string.find(string.format("%A",0),"^0X0%.?0*P%+?0$"))
272−assert(string.find(string.format("%a",- 0),"^%-0x0%.?0*p%+?0$"))
280+assert(string.find(string.format("\37\65",0.0),"\94\48\88\48\37\46\63\48\42\80\37\43\63\48\36"))
281+assert(string.find(string.format("\37\97",- 0.0),"\94\37\45\48\120\48\37\46\63\48\42\112\37\43\63\48\36"))
273282if not _port then
274−assert(string.find(string.format("%a",1 / 0),"^inf"))
275−assert(string.find(string.format("%A",- 1 / 0),"^%-INF"))
276−assert(string.find(string.format("%a",0 / 0),"^%-?nan"))
277−assert(string.find(string.format("%a",- 0),"^%-0x0"))
278−end
279−if not pcall(string.format,"%.3a",0) then
280−(Message or print)("
281− >>> modifiers for format '%a' not available <<<
282−")
283+assert(string.find(string.format("\37\97",1 / 0),"\94\105\110\102"))
284+assert(string.find(string.format("\37\65",- 1 / 0),"\94\37\45\73\78\70"))
285+assert(string.find(string.format("\37\97",0 / 0),"\94\37\45\63\110\97\110"))
286+assert(string.find(string.format("\37\97",- 0.0),"\94\37\45\48\120\48"))
287+end
288+if not pcall(string.format,"\37\46\51\97",0) then
289+(Message or print)("\10\32\62\62\62\32\109\111\100\105\102\105\101\114\115\32\102\111\114\32\102\111\114\109\97\116\32\39\37\97\39\32\110\111\116\32\97\118\97\105\108\97\98\108\101\32\60\60\60\10")
283290else
284−assert(string.find(string.format("%+.2A",12),"^%+0X%x%.%x0P%+?%d$"))
285−assert(string.find(string.format("%.4A",- 12),"^%-0X%x%.%x000P%+?%d$"))
286−end
287−assert(string.format("%#12o",10) == " 012")
288−assert(string.format("%#10x",100) == " 0x64")
289−assert(string.format("%#-17X",100) == "0X64 ")
290−assert(string.format("%013i",- 100) == "-000000000100")
291−assert(string.format("%2.5d",- 100) == "-00100")
292−assert(string.format("%.u",0) == "")
293−assert(string.format("%+#014.0f",100) == "+000000000100.")
294−assert(string.format("%-16c",97) == "a ")
295−assert(string.format("%+.3G",1.5) == "+1.5")
296−assert(string.format("%.0s","alo") == "")
297−assert(string.format("%.s","alo") == "")
298−assert(string.match(string.format("% 1.0E",100),"^ 1E%+0+2$"))
299−assert(string.match(string.format("% .1g",2 ^ 10),"^ 1e%+0+3$"))
291+assert(string.find(string.format("\37\43\46\50\65",12),"\94\37\43\48\88\37\120\37\46\37\120\48\80\37\43\63\37\100\36"))
292+assert(string.find(string.format("\37\46\52\65",- 12),"\94\37\45\48\88\37\120\37\46\37\120\48\48\48\80\37\43\63\37\100\36"))
293+end
294+end
295+assert(string.format("\37\35\49\50\111",10) == "\32\32\32\32\32\32\32\32\32\48\49\50")
296+assert(string.format("\37\35\49\48\120",100) == "\32\32\32\32\32\32\48\120\54\52")
297+assert(string.format("\37\35\45\49\55\88",100) == "\48\88\54\52\32\32\32\32\32\32\32\32\32\32\32\32\32")
298+assert(string.format("\37\48\49\51\105",- 100) == "\45\48\48\48\48\48\48\48\48\48\49\48\48")
299+assert(string.format("\37\50\46\53\100",- 100) == "\45\48\48\49\48\48")
300+assert(string.format("\37\46\117",0) == "")
301+assert(string.format("\37\43\35\48\49\52\46\48\102",100) == "\43\48\48\48\48\48\48\48\48\48\49\48\48\46")
302+assert(string.format("\37\45\49\54\99",97) == "\97\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32")
303+assert(string.format("\37\43\46\51\71",1.5) == "\43\49\46\53")
304+assert(string.format("\37\46\48\115","\97\108\111") == "")
305+assert(string.format("\37\46\115","\97\108\111") == "")
306+assert(string.match(string.format("\37\32\49\46\48\69",100),"\94\32\49\69\37\43\48\43\50\36"))
307+assert(string.match(string.format("\37\32\46\49\103",2 ^ 10),"\94\32\49\101\37\43\48\43\51\36"))
300308local function check
301309(fmt,msg)
302310checkerror(msg,string.format,fmt,10)
303311end
304−local aux = string.rep("0",600)
305−check("%100.3d","invalid conversion")
306−check("%1" .. aux .. ".3d","too long")
307−check("%1.100d","invalid conversion")
308−check("%10.1" .. aux .. "004d","too long")
309−check("%t","invalid conversion")
310−check("%" .. aux .. "d","too long")
311−check("%d %d","no value")
312−check("%010c","invalid conversion")
313−check("%.10c","invalid conversion")
314−check("%0.34s","invalid conversion")
315−check("%#i","invalid conversion")
316−check("%3.1p","invalid conversion")
317−check("%0.s","invalid conversion")
318−check("%10q","cannot have modifiers")
319−check("%F","invalid conversion")
320−assert(load("return 1
321−--comment without ending EOL")() == 1)
322−checkerror("table expected",table.concat,3)
323−checkerror("at index " .. maxi,table.concat,{}," ",maxi,maxi)
324−checkerror("at index %" .. mini,table.concat,{}," ",mini,mini)
312+local aux = string.rep("\48",600)
313+check("\37\49\48\48\46\51\100","\105\110\118\97\108\105\100\32\99\111\110\118\101\114\115\105\111\110")
314+check("\37\49" .. aux .. "\46\51\100","\116\111\111\32\108\111\110\103")
315+check("\37\49\46\49\48\48\100","\105\110\118\97\108\105\100\32\99\111\110\118\101\114\115\105\111\110")
316+check("\37\49\48\46\49" .. aux .. "\48\48\52\100","\116\111\111\32\108\111\110\103")
317+check("\37\116","\105\110\118\97\108\105\100\32\99\111\110\118\101\114\115\105\111\110")
318+check("\37" .. aux .. "\100","\116\111\111\32\108\111\110\103")
319+check("\37\100\32\37\100","\110\111\32\118\97\108\117\101")
320+check("\37\48\49\48\99","\105\110\118\97\108\105\100\32\99\111\110\118\101\114\115\105\111\110")
321+check("\37\46\49\48\99","\105\110\118\97\108\105\100\32\99\111\110\118\101\114\115\105\111\110")
322+check("\37\48\46\51\52\115","\105\110\118\97\108\105\100\32\99\111\110\118\101\114\115\105\111\110")
323+check("\37\35\105","\105\110\118\97\108\105\100\32\99\111\110\118\101\114\115\105\111\110")
324+check("\37\51\46\49\112","\105\110\118\97\108\105\100\32\99\111\110\118\101\114\115\105\111\110")
325+check("\37\48\46\115","\105\110\118\97\108\105\100\32\99\111\110\118\101\114\115\105\111\110")
326+check("\37\49\48\113","\99\97\110\110\111\116\32\104\97\118\101\32\109\111\100\105\102\105\101\114\115")
327+check("\37\70","\105\110\118\97\108\105\100\32\99\111\110\118\101\114\115\105\111\110")
328+assert(load("\114\101\116\117\114\110\32\49\10\45\45\99\111\109\109\101\110\116\32\119\105\116\104\111\117\116\32\101\110\100\105\110\103\32\69\79\76")() == 1)
329+checkerror("\116\97\98\108\101\32\101\120\112\101\99\116\101\100",table.concat,3)
330+checkerror("\97\116\32\105\110\100\101\120\32" .. maxi,table.concat,{},"\32",maxi,maxi)
331+checkerror("\97\116\32\105\110\100\101\120\32\37" .. mini,table.concat,{},"\32",mini,mini)
325332assert(table.concat({}) == "")
326−assert(table.concat({},"x") == "")
327−assert(table.concat({"","",""},"..") == "....")
333+assert(table.concat({},"\120") == "")
334+assert(table.concat({"","\1","\1\2"},"\46\46") == "\46\46\1\46\46\1\2")
328335local a = {}
329336;
330337for i = 1, 300
331338do
332−a[i]="xuxu"
333−end
334−assert(table.concat(a,"123") .. "123" == string.rep("xuxu123",300))
335−assert(table.concat(a,"b",20,20) == "xuxu")
336−assert(table.concat(a,"",20,21) == "xuxuxuxu")
337−assert(table.concat(a,"x",22,21) == "")
338−assert(table.concat(a,"3",299) == "xuxu3xuxu")
339−assert(table.concat({},"x",maxi,maxi - 1) == "")
340−assert(table.concat({},"x",mini + 1,mini) == "")
341−assert(table.concat({},"x",maxi,mini) == "")
342−assert(table.concat({[maxi] = "alo"},"x",maxi,maxi) == "alo")
343−assert(table.concat({[maxi] = "alo",[maxi - 1] = "y"},"-",maxi - 1,maxi) == "y-alo")
344−assert(not pcall(table.concat,{"a","b",{}}))
345−a={"a","b","c"}
346−assert(table.concat(a,",",1,0) == "")
347−assert(table.concat(a,",",1,1) == "a")
348−assert(table.concat(a,",",1,2) == "a,b")
349−assert(table.concat(a,",",2) == "b,c")
350−assert(table.concat(a,",",3) == "c")
351−assert(table.concat(a,",",4) == "")
339+a[i]="\120\117\120\117"
340+end
341+assert(table.concat(a,"\49\50\51") .. "\49\50\51" == string.rep("\120\117\120\117\49\50\51",300))
342+assert(table.concat(a,"\98",20,20) == "\120\117\120\117")
343+assert(table.concat(a,"",20,21) == "\120\117\120\117\120\117\120\117")
344+assert(table.concat(a,"\120",22,21) == "")
345+assert(table.concat(a,"\51",299) == "\120\117\120\117\51\120\117\120\117")
346+assert(table.concat({},"\120",maxi,maxi - 1) == "")
347+assert(table.concat({},"\120",mini + 1,mini) == "")
348+assert(table.concat({},"\120",maxi,mini) == "")
349+assert(table.concat({[maxi] = "\97\108\111"},"\120",maxi,maxi) == "\97\108\111")
350+assert(table.concat({[maxi] = "\97\108\111",[maxi - 1] = "\121"},"\45",maxi - 1,maxi) == "\121\45\97\108\111")
351+assert(not pcall(table.concat,{"\97","\98",{}}))
352+a={"\97","\98","\99"}
353+assert(table.concat(a,"\44",1,0) == "")
354+assert(table.concat(a,"\44",1,1) == "\97")
355+assert(table.concat(a,"\44",1,2) == "\97\44\98")
356+assert(table.concat(a,"\44",2) == "\98\44\99")
357+assert(table.concat(a,"\44",3) == "\99")
358+assert(table.concat(a,"\44",4) == "")
352359if not _port then
353−local locales = {"ptb","pt_BR.iso88591","ISO-8859-1"}
360+local locales = {"\112\116\98","\112\116\95\66\82\46\105\115\111\56\56\53\57\49","\73\83\79\45\56\56\53\57\45\49"}
354361local function trylocale
355362(w)
356363for i = 1, # locales
357364do
358365if os.setlocale(locales[i],w) then
359−print(string.format("'%s' locale set to '%s'",w,locales[i]))
366+print(string.format("\39\37\115\39\32\108\111\99\97\108\101\32\115\101\116\32\116\111\32\39\37\115\39",w,locales[i]))
360367return locales[i]
361368end
362369end
363−print(string.format("'%s' locale not found",w))
370+print(string.format("\39\37\115\39\32\108\111\99\97\108\101\32\110\111\116\32\102\111\117\110\100",w))
364371return false
365372end
366−if trylocale("collate") then
367−assert("alo" < "�lo" and "�lo" < "amo")
373+if trylocale("\99\111\108\108\97\116\101") then
374+assert("\97\108\111" < "\225\108\111" and "\225\108\111" < "\97\109\111")
368375end
369−if trylocale("ctype") then
370−assert(string.gsub("�����","%a","x") == "xxxxx")
371−assert(string.gsub("����","%l","x") == "x�x�")
372−assert(string.gsub("����","%u","x") == "�x�x")
373−assert(string.upper("���{xuxu}��o") == "���{XUXU}��O")
376+if trylocale("\99\116\121\112\101") then
377+assert(string.gsub("\225\233\237\243\250","\37\97","\120") == "\120\120\120\120\120")
378+assert(string.gsub("\225\193\233\201","\37\108","\120") == "\120\193\120\201")
379+assert(string.gsub("\225\193\233\201","\37\117","\120") == "\225\120\233\120")
380+assert(string.upper("\225\193\233\123\120\117\120\117\125\231\227\111") == "\193\193\201\123\88\85\88\85\125\199\195\79")
374381end
375−os.setlocale("C")
376−assert(os.setlocale() == "C")
377−assert(os.setlocale(nil,"numeric") == "C")
382+os.setlocale("\67")
383+assert(os.setlocale() == "\67")
384+assert(os.setlocale(nil,"\110\117\109\101\114\105\99") == "\67")
378385end
379−local f = string.gmatch("1 2 3 4 5","%d+")
380−assert(f() == "1")
386+do
387+local f = string.gmatch("\49\32\50\32\51\32\52\32\53","\37\100\43")
388+assert(f() == "\49")
381389local co = coroutine.wrap(f)
382−assert(co() == "2")
390+assert(co() == "\50")
391+end
383392if T == nil then
384−(Message or print)("
385− >>> testC not active: skipping 'pushfstring' tests <<<
386−")
393+(Message or print)("\10\32\62\62\62\32\116\101\115\116\67\32\110\111\116\32\97\99\116\105\118\101\58\32\115\107\105\112\112\105\110\103\32\39\112\117\115\104\102\115\116\114\105\110\103\39\32\116\101\115\116\115\32\60\60\60\10")
387394else
388−print("testing 'pushfstring'")
395+print("\116\101\115\116\105\110\103\32\39\112\117\115\104\102\115\116\114\105\110\103\39")
389396local blen = 200
390397local function callpfs
391398(op,fmt,n)
392−local x = {T.testC("pushfstring" .. op .. "; return *",fmt,n)}
399+local x = {T.testC("\112\117\115\104\102\115\116\114\105\110\103" .. op .. "\59\32\114\101\116\117\114\110\32\42",fmt,n)}
393400assert(# x == 4)
394401return x[4]
395402end
@@ -397,38 +404,38 @@ local function testpfs
397404(op,fmt,n)
398405assert(callpfs(op,fmt,n) == string.format(fmt,n))
399406end
400−testpfs("I","",0)
401−testpfs("I",string.rep("a",blen - 1),0)
402−testpfs("I",string.rep("a",blen),0)
403−testpfs("I",string.rep("a",blen + 1),0)
404−local str = string.rep("ab",blen) .. "%d" .. string.rep("d",blen / 2)
405−testpfs("I",str,2 ^ 14)
406−testpfs("I",str,- 2 ^ 15)
407−str="%d" .. string.rep("cd",blen)
408−testpfs("I",str,2 ^ 14)
409−testpfs("I",str,- 2 ^ 15)
410−str=string.rep("c",blen - 2) .. "%d"
411−testpfs("I",str,2 ^ 14)
412−testpfs("I",str,- 2 ^ 15)
407+testpfs("\73","",0)
408+testpfs("\73",string.rep("\97",blen - 1),0)
409+testpfs("\73",string.rep("\97",blen),0)
410+testpfs("\73",string.rep("\97",blen + 1),0)
411+local str = string.rep("\97\98",blen) .. "\37\100" .. string.rep("\100",blen / 2)
412+testpfs("\73",str,2 ^ 14)
413+testpfs("\73",str,- 2 ^ 15)
414+str="\37\100" .. string.rep("\99\100",blen)
415+testpfs("\73",str,2 ^ 14)
416+testpfs("\73",str,- 2 ^ 15)
417+str=string.rep("\99",blen - 2) .. "\37\100"
418+testpfs("\73",str,2 ^ 14)
419+testpfs("\73",str,- 2 ^ 15)
413420for l = 12, 14
414421do
415−local str1 = string.rep("a",l)
422+local str1 = string.rep("\97",l)
416423for i = 0, 500, 13
417424do
418425for j = 0, 500, 13
419426do
420−str=string.rep("a",i) .. "%s" .. string.rep("d",j)
421−testpfs("S",str,str1)
422−testpfs("S",str,str)
427+str=string.rep("\97",i) .. "\37\115" .. string.rep("\100",j)
428+testpfs("\83",str,str1)
429+testpfs("\83",str,str)
423430end
424431end
425432end
426−str="abc %c def"
427−testpfs("I",str,string.byte("A"))
428−testpfs("I",str,255)
429−str=string.rep("a",blen - 1) .. "%p" .. string.rep("cd",blen)
430−testpfs("P",str,{})
431−str=string.rep("%%",3 * blen) .. "%p" .. string.rep("%%",2 * blen)
432−testpfs("P",str,{})
433+str="\97\98\99\32\37\99\32\100\101\102"
434+testpfs("\73",str,string.byte("\65"))
435+testpfs("\73",str,255)
436+str=string.rep("\97",blen - 1) .. "\37\112" .. string.rep("\99\100",blen)
437+testpfs("\80",str,{})
438+str=string.rep("\37\37",3 * blen) .. "\37\112" .. string.rep("\37\37",2 * blen)
439+testpfs("\80",str,{})
433440end
434−print("OK")
441+print("\79\75")
zod/luau/res/lua/cycled/tpack.lua+185−171
@@ -1,106 +1,108 @@
11local pack = string.pack
22local packsize = string.packsize
33local unpack = string.unpack
4−print("testing pack/unpack")
4+print("\116\101\115\116\105\110\103\32\112\97\99\107\47\117\110\112\97\99\107")
55local NB = 16
6−local sizeshort = packsize("h")
7−local sizeint = packsize("i")
8−local sizelong = packsize("l")
9−local sizesize_t = packsize("T")
10−local sizeLI = packsize("j")
11−local sizefloat = packsize("f")
12−local sizedouble = packsize("d")
13−local sizenumber = packsize("n")
14−local little = (pack("i2",1) == "")
15−local align = packsize("!xXi16")
6+local sizeshort = packsize("\104")
7+local sizeint = packsize("\105")
8+local sizelong = packsize("\108")
9+local sizesize_t = packsize("\84")
10+local sizeLI = packsize("\106")
11+local sizefloat = packsize("\102")
12+local sizedouble = packsize("\100")
13+local sizenumber = packsize("\110")
14+local little = (pack("\105\50",1) == "\1")
15+local align = packsize("\33\120\88\105\49\54")
1616assert(1 <= sizeshort and sizeshort <= sizeint and sizeint <= sizelong and sizefloat <= sizedouble)
17−print("platform:")
18−print(string.format(" short %d, int %d, long %d, size_t %d, float %d, double %d,
19− lua Integer %d, lua Number %d",sizeshort,sizeint,sizelong,sizesize_t,sizefloat,sizedouble,sizeLI,sizenumber))
20−print(" " .. (little and "little" or "big") .. " endian")
21−print(" alignment: " .. align)
17+print("\112\108\97\116\102\111\114\109\58")
18+print(string.format("\9\115\104\111\114\116\32\37\100\44\32\105\110\116\32\37\100\44\32\108\111\110\103\32\37\100\44\32\115\105\122\101\95\116\32\37\100\44\32\102\108\111\97\116\32\37\100\44\32\100\111\117\98\108\101\32\37\100\44\10\9\108\117\97\32\73\110\116\101\103\101\114\32\37\100\44\32\108\117\97\32\78\117\109\98\101\114\32\37\100",sizeshort,sizeint,sizelong,sizesize_t,sizefloat,sizedouble,sizeLI,sizenumber))
19+print("\9" .. (little and "\108\105\116\116\108\101" or "\98\105\103") .. "\32\101\110\100\105\97\110")
20+print("\9\97\108\105\103\110\109\101\110\116\58\32" .. align)
2221local function checkerror
2322(msg,f, ...)
2423local status,err = pcall(f,...)
2524assert(not status and string.find(err,msg))
2625end
27−assert(unpack("B",pack("B",255)) == 255)
28−assert(unpack("b",pack("b",127)) == 127)
29−assert(unpack("b",pack("b",- 128)) == - 128)
30−assert(unpack("H",pack("H",65535)) == 65535)
31−assert(unpack("h",pack("h",32767)) == 32767)
32−assert(unpack("h",pack("h",- 32768)) == - 32768)
33−assert(unpack("L",pack("L",4294967295)) == 4294967295)
34−assert(unpack("l",pack("l",2147483647)) == 2147483647)
35−assert(unpack("l",pack("l",- 2147483648)) == - 2147483648)
26+assert(unpack("\66",pack("\66",255)) == 255)
27+assert(unpack("\98",pack("\98",127)) == 127)
28+assert(unpack("\98",pack("\98",- 128)) == - 128)
29+assert(unpack("\72",pack("\72",65535)) == 65535)
30+assert(unpack("\104",pack("\104",32767)) == 32767)
31+assert(unpack("\104",pack("\104",- 32768)) == - 32768)
32+assert(unpack("\76",pack("\76",4294967295)) == 4294967295)
33+assert(unpack("\108",pack("\108",2147483647)) == 2147483647)
34+assert(unpack("\108",pack("\108",- 2147483648)) == - 2147483648)
3635for i = 1, NB
3736do
38−local s = string.rep("�",i)
39−assert(pack("i" .. i,- 1) == s)
40−assert(packsize("i" .. i) == # s)
41−assert(unpack("i" .. i,s) == - 1)
42−s="�" .. string.rep("",i - 1)
43−assert(pack("<I" .. i,170) == s)
44−assert(unpack("<I" .. i,s) == 170)
45−assert(pack(">I" .. i,170) == s:reverse())
46−assert(unpack(">I" .. i,s:reverse()) == 170)
37+local s = string.rep("\255",i)
38+assert(pack("\105" .. i,- 1) == s)
39+assert(packsize("\105" .. i) == # s)
40+assert(unpack("\105" .. i,s) == - 1)
41+s="\170" .. string.rep("",i - 1)
42+assert(pack("\60\73" .. i,170) == s)
43+assert(unpack("\60\73" .. i,s) == 170)
44+assert(pack("\62\73" .. i,170) == s:reverse())
45+assert(unpack("\62\73" .. i,s:reverse()) == 170)
4746end
47+do
4848local lnum = 1510926445411202934483812811265
49−local s = pack("<j",lnum)
50−assert(unpack("<j",s) == lnum)
51−assert(unpack("<i" .. sizeLI + 1,s .. "") == lnum)
52−assert(unpack("<i" .. sizeLI + 1,s .. "") == lnum)
49+local s = pack("\60\106",lnum)
50+assert(unpack("\60\106",s) == lnum)
51+assert(unpack("\60\105" .. sizeLI + 1,s .. "") == lnum)
52+assert(unpack("\60\105" .. sizeLI + 1,s .. "") == lnum)
5353for i = sizeLI + 1, NB
5454do
55−local s = pack("<j",- lnum)
56−assert(unpack("<j",s) == - lnum)
57−assert(unpack("<i" .. i,s .. ("�"):rep(i - sizeLI)) == - lnum)
58−assert(unpack(">i" .. i,("�"):rep(i - sizeLI) .. s:reverse()) == - lnum)
59−assert(unpack("<I" .. i,s .. (""):rep(i - sizeLI)) == - lnum)
60−checkerror("does not fit",unpack,"<I" .. i,(""):rep(i - 1) .. "")
61−checkerror("does not fit",unpack,">i" .. i,"" .. (""):rep(i - 1))
55+local s = pack("\60\106",- lnum)
56+assert(unpack("\60\106",s) == - lnum)
57+assert(unpack("\60\105" .. i,s .. ("\255"):rep(i - sizeLI)) == - lnum)
58+assert(unpack("\62\105" .. i,("\255"):rep(i - sizeLI) .. s:reverse()) == - lnum)
59+assert(unpack("\60\73" .. i,s .. (""):rep(i - sizeLI)) == - lnum)
60+checkerror("\100\111\101\115\32\110\111\116\32\102\105\116",unpack,"\60\73" .. i,(""):rep(i - 1) .. "\1")
61+checkerror("\100\111\101\115\32\110\111\116\32\102\105\116",unpack,"\62\105" .. i,"\1" .. (""):rep(i - 1))
62+end
6263end
6364for i = 1, sizeLI
6465do
65−local lstr = "
66− "
66+local lstr = "\1\2\3\4\5\6\7\8\9\10\11\12\13"
6767local lnum = 1510926445411202934483812811265
6868local n = lnum & (~ (- 1 << (i * 8)))
6969local s = string.sub(lstr,1,i)
70−assert(pack("<i" .. i,n) == s)
71−assert(pack(">i" .. i,n) == s:reverse())
72−assert(unpack(">i" .. i,s:reverse()) == n)
70+assert(pack("\60\105" .. i,n) == s)
71+assert(pack("\62\105" .. i,n) == s:reverse())
72+assert(unpack("\62\105" .. i,s:reverse()) == n)
7373end
74+do
7475local u = 240
7576for i = 1, sizeLI - 1
7677do
77−assert(unpack("<i" .. i,"�" .. ("�"):rep(i - 1)) == - 16)
78−assert(unpack(">I" .. i,"�" .. ("�"):rep(i - 1)) == u)
78+assert(unpack("\60\105" .. i,"\240" .. ("\255"):rep(i - 1)) == - 16)
79+assert(unpack("\62\73" .. i,"\240" .. ("\255"):rep(i - 1)) == u)
7980u=u * 256 + 255
8081end
81−assert(pack(">i2 <i2",10,20) == "
82−")
83−local a,b = unpack("<i2 >i2","
84−")
82+end
83+do
84+assert(pack("\62\105\50\32\60\105\50",10,20) == "\10\20")
85+local a,b = unpack("\60\105\50\32\62\105\50","\10\20")
8586assert(a == 10 and b == 20)
86−assert(pack("=i4",2001) == pack("i4",2001))
87−print("testing invalid formats")
88−checkerror("out of limits",pack,"i0",0)
89−checkerror("out of limits",pack,"i" .. NB + 1,0)
90−checkerror("out of limits",pack,"!" .. NB + 1,0)
91−checkerror("%(17%) out of limits %[1,16%]",pack,"Xi" .. NB + 1)
92−checkerror("invalid format option 'r'",pack,"i3r",0)
93−checkerror("16%-byte integer",unpack,"i16",string.rep("",16))
94−checkerror("not power of 2",pack,"!4i3",0)
87+assert(pack("\61\105\52",2001) == pack("\105\52",2001))
88+end
89+print("\116\101\115\116\105\110\103\32\105\110\118\97\108\105\100\32\102\111\114\109\97\116\115")
90+checkerror("\111\117\116\32\111\102\32\108\105\109\105\116\115",pack,"\105\48",0)
91+checkerror("\111\117\116\32\111\102\32\108\105\109\105\116\115",pack,"\105" .. NB + 1,0)
92+checkerror("\111\117\116\32\111\102\32\108\105\109\105\116\115",pack,"\33" .. NB + 1,0)
93+checkerror("\37\40\49\55\37\41\32\111\117\116\32\111\102\32\108\105\109\105\116\115\32\37\91\49\44\49\54\37\93",pack,"\88\105" .. NB + 1)
94+checkerror("\105\110\118\97\108\105\100\32\102\111\114\109\97\116\32\111\112\116\105\111\110\32\39\114\39",pack,"\105\51\114",0)
95+checkerror("\49\54\37\45\98\121\116\101\32\105\110\116\101\103\101\114",unpack,"\105\49\54",string.rep("\3",16))
96+checkerror("\110\111\116\32\112\111\119\101\114\32\111\102\32\50",pack,"\33\52\105\51",0)
9597;
96−checkerror("missing size",pack,"c","")
97−checkerror("variable%-length format",packsize,"s")
98−checkerror("variable%-length format",packsize,"z")
99−checkerror("invalid format",packsize,"c1" .. string.rep("0",40))
100−if packsize("i") == 4 then
101−local s = string.rep("c268435456",2 ^ 3)
102−checkerror("too large",packsize,s)
103−s=string.rep("c268435456",2 ^ 3 - 1) .. "c268435455"
98+checkerror("\109\105\115\115\105\110\103\32\115\105\122\101",pack,"\99","")
99+checkerror("\118\97\114\105\97\98\108\101\37\45\108\101\110\103\116\104\32\102\111\114\109\97\116",packsize,"\115")
100+checkerror("\118\97\114\105\97\98\108\101\37\45\108\101\110\103\116\104\32\102\111\114\109\97\116",packsize,"\122")
101+checkerror("\105\110\118\97\108\105\100\32\102\111\114\109\97\116",packsize,"\99\49" .. string.rep("\48",40))
102+if packsize("\105") == 4 then
103+local s = string.rep("\99\50\54\56\52\51\53\52\53\54",2 ^ 3)
104+checkerror("\116\111\111\32\108\97\114\103\101",packsize,s)
105+s=string.rep("\99\50\54\56\52\51\53\52\53\54",2 ^ 3 - 1) .. "\99\50\54\56\52\51\53\52\53\53"
104106assert(packsize(s) == 2147483647)
105107end
106108for i = 1, sizeLI - 1
@@ -108,138 +110,150 @@ do
108110local umax = (1 << (i * 8)) - 1
109111local max = umax >> 1
110112local min = ~ max
111−checkerror("overflow",pack,"<I" .. i,- 1)
112−checkerror("overflow",pack,"<I" .. i,min)
113−checkerror("overflow",pack,">I" .. i,umax + 1)
114−checkerror("overflow",pack,">i" .. i,umax)
115−checkerror("overflow",pack,">i" .. i,max + 1)
116−checkerror("overflow",pack,"<i" .. i,min - 1)
117−assert(unpack(">i" .. i,pack(">i" .. i,max)) == max)
118−assert(unpack("<i" .. i,pack("<i" .. i,min)) == min)
119−assert(unpack(">I" .. i,pack(">I" .. i,umax)) == umax)
120−end
121−assert(unpack(">j",pack(">j",math.maxinteger)) == math.maxinteger)
122−assert(unpack("<j",pack("<j",math.mininteger)) == math.mininteger)
123−assert(unpack("<J",pack("<j",- 1)) == - 1)
113+checkerror("\111\118\101\114\102\108\111\119",pack,"\60\73" .. i,- 1)
114+checkerror("\111\118\101\114\102\108\111\119",pack,"\60\73" .. i,min)
115+checkerror("\111\118\101\114\102\108\111\119",pack,"\62\73" .. i,umax + 1)
116+checkerror("\111\118\101\114\102\108\111\119",pack,"\62\105" .. i,umax)
117+checkerror("\111\118\101\114\102\108\111\119",pack,"\62\105" .. i,max + 1)
118+checkerror("\111\118\101\114\102\108\111\119",pack,"\60\105" .. i,min - 1)
119+assert(unpack("\62\105" .. i,pack("\62\105" .. i,max)) == max)
120+assert(unpack("\60\105" .. i,pack("\60\105" .. i,min)) == min)
121+assert(unpack("\62\73" .. i,pack("\62\73" .. i,umax)) == umax)
122+end
123+assert(unpack("\62\106",pack("\62\106",math.maxinteger)) == math.maxinteger)
124+assert(unpack("\60\106",pack("\60\106",math.mininteger)) == math.mininteger)
125+assert(unpack("\60\74",pack("\60\106",- 1)) == - 1)
124126if little then
125−assert(pack("f",24) == pack("<f",24))
127+assert(pack("\102",24) == pack("\60\102",24))
126128else
127−assert(pack("f",24) == pack(">f",24))
129+assert(pack("\102",24) == pack("\62\102",24))
128130end
129−print("testing pack/unpack of floating-point numbers")
130−for _,n in ipairs({0,- 1.1,1.9,1 / 0,- 1 / 0,1e20,- 1e20,0.1,2000.7})
131+print("\116\101\115\116\105\110\103\32\112\97\99\107\47\117\110\112\97\99\107\32\111\102\32\102\108\111\97\116\105\110\103\45\112\111\105\110\116\32\110\117\109\98\101\114\115")
132+for _,n in ipairs({0,- 1.1,1.9,1 / 0,- 1 / 0,1e20.0,- 1e20.0,0.1,2000.7})
131133do
132−assert(unpack("n",pack("n",n)) == n)
133−assert(unpack("<n",pack("<n",n)) == n)
134−assert(unpack(">n",pack(">n",n)) == n)
135−assert(pack("<f",n) == pack(">f",n):reverse())
136−assert(pack(">d",n) == pack("<d",n):reverse())
134+assert(unpack("\110",pack("\110",n)) == n)
135+assert(unpack("\60\110",pack("\60\110",n)) == n)
136+assert(unpack("\62\110",pack("\62\110",n)) == n)
137+assert(pack("\60\102",n) == pack("\62\102",n):reverse())
138+assert(pack("\62\100",n) == pack("\60\100",n):reverse())
137139end
138−for _,n in ipairs({0,- 1.5,1 / 0,- 1 / 0,1e10,- 1e9,0.5,2000.25})
140+for _,n in ipairs({0,- 1.5,1 / 0,- 1 / 0,1e10.0,- 1e9.0,0.5,2000.25})
139141do
140−assert(unpack("<f",pack("<f",n)) == n)
141−assert(unpack(">f",pack(">f",n)) == n)
142−assert(unpack("<d",pack("<d",n)) == n)
143−assert(unpack(">d",pack(">d",n)) == n)
142+assert(unpack("\60\102",pack("\60\102",n)) == n)
143+assert(unpack("\62\102",pack("\62\102",n)) == n)
144+assert(unpack("\60\100",pack("\60\100",n)) == n)
145+assert(unpack("\62\100",pack("\62\100",n)) == n)
144146end
145−print("testing pack/unpack of strings")
146−local s = string.rep("abc",1e3)
147−assert(pack("zB",s,247) == s .. "�")
148−local s1,b = unpack("zB",s .. "�")
147+print("\116\101\115\116\105\110\103\32\112\97\99\107\47\117\110\112\97\99\107\32\111\102\32\115\116\114\105\110\103\115")
148+do
149+local s = string.rep("\97\98\99",1000)
150+assert(pack("\122\66",s,247) == s .. "\247")
151+local s1,b = unpack("\122\66",s .. "\249")
149152assert(b == 249 and s1 == s)
150−s1=pack("s",s)
151−assert(unpack("s",s1) == s)
152−checkerror("does not fit",pack,"s1",s)
153−checkerror("contains zeros",pack,"z","alo")
153+s1=pack("\115",s)
154+assert(unpack("\115",s1) == s)
155+checkerror("\100\111\101\115\32\110\111\116\32\102\105\116",pack,"\115\49",s)
156+checkerror("\99\111\110\116\97\105\110\115\32\122\101\114\111\115",pack,"\122","\97\108\111")
154157;
155−checkerror("unfinished string",unpack,"zc10000000","alo")
158+checkerror("\117\110\102\105\110\105\115\104\101\100\32\115\116\114\105\110\103",unpack,"\122\99\49\48\48\48\48\48\48\48","\97\108\111")
156159for i = 2, NB
157160do
158−local s1 = pack("s" .. i,s)
159−assert(unpack("s" .. i,s1) == s and # s1 == # s + i)
160−end
161−local x = pack("s","alo")
162−checkerror("too short",unpack,"s",x:sub(1,- 2))
163−checkerror("too short",unpack,"c5","abcd")
164−checkerror("out of limits",pack,"s100","alo")
165−assert(pack("c0","") == "")
166−assert(packsize("c0") == 0)
167−assert(unpack("c0","") == "")
168−assert(pack("<! c3","abc") == "abc")
169−assert(packsize("<! c3") == 3)
170−assert(pack(">!4 c6","abcdef") == "abcdef")
171−assert(pack("c3","123") == "123")
172−assert(pack("c0","") == "")
173−assert(pack("c8","123456") == "123456")
174−assert(pack("c88","") == string.rep("",88))
175−assert(pack("c188","ab") == "ab" .. string.rep("",188 - 2))
176−local a,b,c = unpack("!4 z c3","abcdefghixyz")
177−assert(a == "abcdefghi" and b == "xyz" and c == 14)
178−checkerror("longer than",pack,"c3","1234")
179−local x = pack("<b h b f d f n i",1,2,3,4,5,6,7,8)
180−assert(# x == packsize("<b h b f d f n i"))
181−local a,b,c,d,e,f,g,h = unpack("<b h b f d f n i",x)
161+local s1 = pack("\115" .. i,s)
162+assert(unpack("\115" .. i,s1) == s and # s1 == # s + i)
163+end
164+end
165+do
166+local x = pack("\115","\97\108\111")
167+checkerror("\116\111\111\32\115\104\111\114\116",unpack,"\115",x:sub(1,- 2))
168+checkerror("\116\111\111\32\115\104\111\114\116",unpack,"\99\53","\97\98\99\100")
169+checkerror("\111\117\116\32\111\102\32\108\105\109\105\116\115",pack,"\115\49\48\48","\97\108\111")
170+end
171+do
172+assert(pack("\99\48","") == "")
173+assert(packsize("\99\48") == 0)
174+assert(unpack("\99\48","") == "")
175+assert(pack("\60\33\32\99\51","\97\98\99") == "\97\98\99")
176+assert(packsize("\60\33\32\99\51") == 3)
177+assert(pack("\62\33\52\32\99\54","\97\98\99\100\101\102") == "\97\98\99\100\101\102")
178+assert(pack("\99\51","\49\50\51") == "\49\50\51")
179+assert(pack("\99\48","") == "")
180+assert(pack("\99\56","\49\50\51\52\53\54") == "\49\50\51\52\53\54")
181+assert(pack("\99\56\56","") == string.rep("",88))
182+assert(pack("\99\49\56\56","\97\98") == "\97\98" .. string.rep("",188 - 2))
183+local a,b,c = unpack("\33\52\32\122\32\99\51","\97\98\99\100\101\102\103\104\105\120\121\122")
184+assert(a == "\97\98\99\100\101\102\103\104\105" and b == "\120\121\122" and c == 14)
185+checkerror("\108\111\110\103\101\114\32\116\104\97\110",pack,"\99\51","\49\50\51\52")
186+end
187+do
188+local x = pack("\60\98\32\104\32\98\32\102\32\100\32\102\32\110\32\105",1,2,3,4,5,6,7,8)
189+assert(# x == packsize("\60\98\32\104\32\98\32\102\32\100\32\102\32\110\32\105"))
190+local a,b,c,d,e,f,g,h = unpack("\60\98\32\104\32\98\32\102\32\100\32\102\32\110\32\105",x)
182191assert(a == 1 and b == 2 and c == 3 and d == 4 and e == 5 and f == 6 and g == 7 and h == 8)
183−print("testing alignment")
184−assert(pack(" < i1 i2 ",2,3) == "")
185−local x = pack(">!8 b Xh i4 i8 c1 Xi8",- 12,100,200,"�")
186−assert(# x == packsize(">!8 b Xh i4 i8 c1 Xi8"))
187−assert(x == "�" .. "" .. "d" .. "�" .. "�" .. "")
188−local a,b,c,d,pos = unpack(">!8 c1 Xh i4 i8 b Xi8 XI XH",x)
189−assert(a == "�" and b == 100 and c == 200 and d == - 20 and (pos - 1) == # x)
190−x=pack(">!4 c3 c4 c2 z i4 c5 c2 Xi4","abc","abcd","xz","hello",5,"world","xy")
191−assert(x == "abcabcdxzhelloworldxy")
192−local a,b,c,d,e,f,g,pos = unpack(">!4 c3 c4 c2 z i4 c5 c2 Xh Xi4",x)
193−assert(a == "abc" and b == "abcd" and c == "xz" and d == "hello" and e == 5 and f == "world" and g == "xy" and (pos - 1) % 4 == 0)
194−x=pack(" b b Xd b Xb x",1,2,3)
195−assert(packsize(" b b Xd b Xb x") == 4)
196−assert(x == "")
197−a,b,c,pos=unpack("bbXdb",x)
192+end
193+print("\116\101\115\116\105\110\103\32\97\108\105\103\110\109\101\110\116")
194+do
195+assert(pack("\32\60\32\105\49\32\105\50\32",2,3) == "\2\3")
196+local x = pack("\62\33\56\32\98\32\88\104\32\105\52\32\105\56\32\99\49\32\88\105\56",- 12,100,200,"\236")
197+assert(# x == packsize("\62\33\56\32\98\32\88\104\32\105\52\32\105\56\32\99\49\32\88\105\56"))
198+assert(x == "\244" .. "" .. "\100" .. "\200" .. "\236" .. "")
199+local a,b,c,d,pos = unpack("\62\33\56\32\99\49\32\88\104\32\105\52\32\105\56\32\98\32\88\105\56\32\88\73\32\88\72",x)
200+assert(a == "\244" and b == 100 and c == 200 and d == - 20 and (pos - 1) == # x)
201+x=pack("\62\33\52\32\99\51\32\99\52\32\99\50\32\122\32\105\52\32\99\53\32\99\50\32\88\105\52","\97\98\99","\97\98\99\100","\120\122","\104\101\108\108\111",5,"\119\111\114\108\100","\120\121")
202+assert(x == "\97\98\99\97\98\99\100\120\122\104\101\108\108\111\5\119\111\114\108\100\120\121")
203+local a,b,c,d,e,f,g,pos = unpack("\62\33\52\32\99\51\32\99\52\32\99\50\32\122\32\105\52\32\99\53\32\99\50\32\88\104\32\88\105\52",x)
204+assert(a == "\97\98\99" and b == "\97\98\99\100" and c == "\120\122" and d == "\104\101\108\108\111" and e == 5 and f == "\119\111\114\108\100" and g == "\120\121" and (pos - 1) % 4 == 0)
205+x=pack("\32\98\32\98\32\88\100\32\98\32\88\98\32\120",1,2,3)
206+assert(packsize("\32\98\32\98\32\88\100\32\98\32\88\98\32\120") == 4)
207+assert(x == "\1\2\3")
208+a,b,c,pos=unpack("\98\98\88\100\98",x)
198209assert(a == 1 and b == 2 and c == 3 and pos == # x)
199−assert(packsize("!8 xXi8") == 8)
200−local pos = unpack("!8 xXi8","0123456701234567")
210+assert(packsize("\33\56\32\120\88\105\56") == 8)
211+local pos = unpack("\33\56\32\120\88\105\56","\48\49\50\51\52\53\54\55\48\49\50\51\52\53\54\55")
201212;
202213assert(pos == 9)
203−assert(packsize("!8 xXi2") == 2)
204−local pos = unpack("!8 xXi2","0123456701234567")
214+assert(packsize("\33\56\32\120\88\105\50") == 2)
215+local pos = unpack("\33\56\32\120\88\105\50","\48\49\50\51\52\53\54\55\48\49\50\51\52\53\54\55")
205216;
206217assert(pos == 3)
207−assert(packsize("!2 xXi2") == 2)
208−local pos = unpack("!2 xXi2","0123456701234567")
218+assert(packsize("\33\50\32\120\88\105\50") == 2)
219+local pos = unpack("\33\50\32\120\88\105\50","\48\49\50\51\52\53\54\55\48\49\50\51\52\53\54\55")
209220;
210221assert(pos == 3)
211−assert(packsize("!2 xXi8") == 2)
212−local pos = unpack("!2 xXi8","0123456701234567")
222+assert(packsize("\33\50\32\120\88\105\56") == 2)
223+local pos = unpack("\33\50\32\120\88\105\56","\48\49\50\51\52\53\54\55\48\49\50\51\52\53\54\55")
213224;
214225assert(pos == 3)
215−assert(packsize("!16 xXi16") == 16)
216−local pos = unpack("!16 xXi16","0123456701234567")
226+assert(packsize("\33\49\54\32\120\88\105\49\54") == 16)
227+local pos = unpack("\33\49\54\32\120\88\105\49\54","\48\49\50\51\52\53\54\55\48\49\50\51\52\53\54\55")
217228;
218229assert(pos == 17)
219−checkerror("invalid next option",pack,"X")
220−checkerror("invalid next option",unpack,"XXi","")
221−checkerror("invalid next option",unpack,"X i","")
222−checkerror("invalid next option",pack,"Xc1")
223−local x = pack("i4i4i4i4",1,2,3,4)
230+checkerror("\105\110\118\97\108\105\100\32\110\101\120\116\32\111\112\116\105\111\110",pack,"\88")
231+checkerror("\105\110\118\97\108\105\100\32\110\101\120\116\32\111\112\116\105\111\110",unpack,"\88\88\105","")
232+checkerror("\105\110\118\97\108\105\100\32\110\101\120\116\32\111\112\116\105\111\110",unpack,"\88\32\105","")
233+checkerror("\105\110\118\97\108\105\100\32\110\101\120\116\32\111\112\116\105\111\110",pack,"\88\99\49")
234+end
235+do
236+local x = pack("\105\52\105\52\105\52\105\52",1,2,3,4)
224237for pos = 1, 16, 4
225238do
226−local i,p = unpack("i4",x,pos)
239+local i,p = unpack("\105\52",x,pos)
227240assert(i == pos // 4 + 1 and p == pos + 4)
228241end
229242for pos = 0, 12
230243do
231−local i,p = unpack("!4 i4",x,pos + 1)
244+local i,p = unpack("\33\52\32\105\52",x,pos + 1)
232245assert(i == (pos + 3) // 4 + 1 and p == i * 4 + 1)
233246end
234−local i,p = unpack("!4 i4",x,- 4)
247+local i,p = unpack("\33\52\32\105\52",x,- 4)
235248assert(i == 4 and p == 17)
236−local i,p = unpack("!4 i4",x,- 7)
249+local i,p = unpack("\33\52\32\105\52",x,- 7)
237250assert(i == 4 and p == 17)
238−local i,p = unpack("!4 i4",x,- # x)
251+local i,p = unpack("\33\52\32\105\52",x,- # x)
239252assert(i == 1 and p == 5)
240253for i = 1, # x + 1
241254do
242−assert(unpack("c0",x,i) == "")
255+assert(unpack("\99\48",x,i) == "")
256+end
257+checkerror("\111\117\116\32\111\102\32\115\116\114\105\110\103",unpack,"\99\48",x,# x + 2)
243258end
244−checkerror("out of string",unpack,"c0",x,# x + 2)
245−print("OK")
259+print("\79\75")
zod/luau/res/lua/cycled/tracegc.lua+1−1
@@ -4,7 +4,7 @@ _ENV=nil
44local active = false
55local mt = {}
66function mt.__gc(o)
7−stderr:write(".")
7+stderr:write("\46")
88if active then
99setmetatable(o,mt)
1010end
zod/luau/res/lua/cycled/utf8.lua+78−70
@@ -1,5 +1,5 @@
1−print("testing UTF-8 library")
2−local utf8 = require("utf8")
1+print("\116\101\115\116\105\110\103\32\85\84\70\45\56\32\108\105\98\114\97\114\121")
2+local utf8 = require("\117\116\102\56")
33local function checkerror
44(msg,f, ...)
55local s,err = pcall(f,...)
@@ -7,22 +7,22 @@ assert(not s and string.find(err,msg))
77end
88local function len
99(s)
10−return # string.gsub(s,"[�-�]","")
10+return # string.gsub(s,"\91\128\45\191\93","")
1111end
12−local justone = "^" .. utf8.charpattern .. "$"
12+local justone = "\94" .. utf8.charpattern .. "\36"
1313local function checksyntax
1414(s,t)
15−local ts = {"return '"}
15+local ts = {"\114\101\116\117\114\110\32\39"}
1616for i = 1, # t
1717do
18−ts[i + 1]=string.format("\u{%x}",t[i])
18+ts[i + 1]=string.format("\92\117\123\37\120\125",t[i])
1919end
20−ts[# t + 2]="'"
20+ts[# t + 2]="\39"
2121ts=table.concat(ts)
2222assert(assert(load(ts))() == s)
2323end
24−assert(not utf8.offset("alo",5))
25−assert(not utf8.offset("alo",- 4))
24+assert(not utf8.offset("\97\108\111",5))
25+assert(not utf8.offset("\97\108\111",- 4))
2626local function check
2727(s,t,nonstrict)
2828local l = utf8.len(s,1,- 1,nonstrict)
@@ -78,110 +78,118 @@ do
7878assert(utf8.offset(s,i) == utf8.offset(s,i - l - 1,# s + 1))
7979end
8080end
81+do
8182local function check
8283(s,p)
8384local a,b = utf8.len(s)
8485assert(not a and b == p)
8586end
86−check("abc�def",4)
87−check("���",1)
88−check("����",1)
89−check("汉字�",# ("汉字") + 1)
90−check("�hello",1)
91−check("hel�lo",4)
92−check("汉字�",# ("汉字") + 1)
93−check("�hello",1)
94−check("hel�lo",4)
87+check("\97\98\99\227\100\101\102",4)
88+check("\244\159\191",1)
89+check("\244\159\191\191",1)
90+check("\230\177\137\229\173\151\128",# ("\230\177\137\229\173\151") + 1)
91+check("\128\104\101\108\108\111",1)
92+check("\104\101\108\128\108\111",4)
93+check("\230\177\137\229\173\151\191",# ("\230\177\137\229\173\151") + 1)
94+check("\191\104\101\108\108\111",1)
95+check("\104\101\108\191\108\111",4)
96+end
97+do
9598local function errorcodes
9699(s)
97−checkerror("invalid UTF%-8 code",()
100+checkerror("\105\110\118\97\108\105\100\32\85\84\70\37\45\56\32\99\111\100\101",function ()
98101for c in utf8.codes(s)
99102do
100103assert(c)
101104end
102105end)
103106end
104−errorcodes("ab�")
105−errorcodes("")
106−errorcodes("in�valid")
107−errorcodes("�invalid")
108−errorcodes("αλφ�α")
107+errorcodes("\97\98\255")
108+errorcodes("\0\0\17")
109+errorcodes("\105\110\128\118\97\108\105\100")
110+errorcodes("\191\105\110\118\97\108\105\100")
111+errorcodes("\206\177\206\187\207\134\191\206\177")
109112local f = utf8.codes("")
110113assert(f("",2) == nil)
111114assert(f("",- 1) == nil)
112115assert(f("",math.mininteger) == nil)
113−checkerror("position out of bounds",utf8.offset,"abc",1,5)
114−checkerror("position out of bounds",utf8.offset,"abc",1,- 4)
115−checkerror("position out of bounds",utf8.offset,"",1,2)
116−checkerror("position out of bounds",utf8.offset,"",1,- 1)
117−checkerror("continuation byte",utf8.offset,"𦧺",1,2)
118−checkerror("continuation byte",utf8.offset,"𦧺",1,2)
119−checkerror("continuation byte",utf8.offset,"�",1)
120−checkerror("out of bounds",utf8.len,"abc",0,2)
121−checkerror("out of bounds",utf8.len,"abc",1,4)
122−local s = "hello World"
116+end
117+checkerror("\112\111\115\105\116\105\111\110\32\111\117\116\32\111\102\32\98\111\117\110\100\115",utf8.offset,"\97\98\99",1,5)
118+checkerror("\112\111\115\105\116\105\111\110\32\111\117\116\32\111\102\32\98\111\117\110\100\115",utf8.offset,"\97\98\99",1,- 4)
119+checkerror("\112\111\115\105\116\105\111\110\32\111\117\116\32\111\102\32\98\111\117\110\100\115",utf8.offset,"",1,2)
120+checkerror("\112\111\115\105\116\105\111\110\32\111\117\116\32\111\102\32\98\111\117\110\100\115",utf8.offset,"",1,- 1)
121+checkerror("\99\111\110\116\105\110\117\97\116\105\111\110\32\98\121\116\101",utf8.offset,"\240\166\167\186",1,2)
122+checkerror("\99\111\110\116\105\110\117\97\116\105\111\110\32\98\121\116\101",utf8.offset,"\240\166\167\186",1,2)
123+checkerror("\99\111\110\116\105\110\117\97\116\105\111\110\32\98\121\116\101",utf8.offset,"\128",1)
124+checkerror("\111\117\116\32\111\102\32\98\111\117\110\100\115",utf8.len,"\97\98\99",0,2)
125+checkerror("\111\117\116\32\111\102\32\98\111\117\110\100\115",utf8.len,"\97\98\99",1,4)
126+local s = "\104\101\108\108\111\32\87\111\114\108\100"
123127local t = {string.byte(s,1,- 1)}
124128for i = 1, utf8.len(s)
125129do
126130assert(t[i] == string.byte(s,i))
127131end
128132check(s,t)
129−check("汉字/漢字",{27721,23383,47,28450,23383})
130−local s = "áéí�"
133+check("\230\177\137\229\173\151\47\230\188\162\229\173\151",{27721,23383,47,28450,23383})
134+do
135+local s = "\195\161\195\169\195\173\128"
131136local t = {utf8.codepoint(s,1,# s - 1)}
132137assert(# t == 3 and t[1] == 225 and t[2] == 233 and t[3] == 237)
133−checkerror("invalid UTF%-8 code",utf8.codepoint,s,1,# s)
134−checkerror("out of bounds",utf8.codepoint,s,# s + 1)
138+checkerror("\105\110\118\97\108\105\100\32\85\84\70\37\45\56\32\99\111\100\101",utf8.codepoint,s,1,# s)
139+checkerror("\111\117\116\32\111\102\32\98\111\117\110\100\115",utf8.codepoint,s,# s + 1)
135140t={utf8.codepoint(s,4,3)}
136141assert(# t == 0)
137−checkerror("out of bounds",utf8.codepoint,s,- (# s + 1),1)
138−checkerror("out of bounds",utf8.codepoint,s,1,# s + 1)
139−assert(utf8.codepoint("��") == 55296 - 1)
140−assert(utf8.codepoint("�") == 57343 + 1)
141−assert(utf8.codepoint("�",1,1,true) == 55296)
142−assert(utf8.codepoint("��",1,1,true) == 57343)
143−assert(utf8.codepoint("���",1,1,true) == 2147483647)
142+checkerror("\111\117\116\32\111\102\32\98\111\117\110\100\115",utf8.codepoint,s,- (# s + 1),1)
143+checkerror("\111\117\116\32\111\102\32\98\111\117\110\100\115",utf8.codepoint,s,1,# s + 1)
144+assert(utf8.codepoint("\255\215") == 55296 - 1)
145+assert(utf8.codepoint("\0\224") == 57343 + 1)
146+assert(utf8.codepoint("\0\216",1,1,true) == 55296)
147+assert(utf8.codepoint("\255\223",1,1,true) == 57343)
148+assert(utf8.codepoint("\255\255\255\127",1,1,true) == 2147483647)
149+end
144150assert(utf8.char() == "")
145−assert(utf8.char(0,97,98,99,1) == "abc")
151+assert(utf8.char(0,97,98,99,1) == "\97\98\99\1")
146152assert(utf8.codepoint(utf8.char(1114111)) == 1114111)
147153assert(utf8.codepoint(utf8.char(2147483647),1,1,true) == (1 << 31) - 1)
148−checkerror("value out of range",utf8.char,2147483647 + 1)
149−checkerror("value out of range",utf8.char,- 1)
154+checkerror("\118\97\108\117\101\32\111\117\116\32\111\102\32\114\97\110\103\101",utf8.char,2147483647 + 1)
155+checkerror("\118\97\108\117\101\32\111\117\116\32\111\102\32\114\97\110\103\101",utf8.char,- 1)
150156local function invalid
151157(s)
152−checkerror("invalid UTF%-8 code",utf8.codepoint,s)
158+checkerror("\105\110\118\97\108\105\100\32\85\84\70\37\45\56\32\99\111\100\101",utf8.codepoint,s)
153159assert(not utf8.len(s))
154160end
155−invalid("����")
156−invalid("�")
157−invalid("��")
158−invalid("��")
159−invalid("��")
160−invalid("���")
161−invalid("����")
162−invalid("�")
163−invalid("�")
164−invalid("�")
165−invalid("�")
161+invalid("\244\159\191\191")
162+invalid("\0\216")
163+invalid("\255\223")
164+invalid("\192\128")
165+invalid("\193\191")
166+invalid("\224\159\191")
167+invalid("\240\143\191\191")
168+invalid("\128")
169+invalid("\191")
170+invalid("\254")
171+invalid("\255")
166172check("",{})
167−s=" € ߿ࠀ ￿𐀀 􏿿"
168−s=string.gsub(s," ","")
173+s="\32\127\194\128\32\223\191\224\160\128\32\239\191\191\240\144\128\128\32\32\244\143\191\191"
174+s=string.gsub(s,"\32","")
169175check(s,{0,127,128,2047,2048,65535,65536,1114111})
170−local s = "���"
176+do
177+local s = "\0\0\0\4\255\255\255\127"
171178assert(# s == 12)
172179check(s,{67108864,2147483647},true)
173−s=" ���"
180+s="\0\0\32\255\255\255\3"
174181assert(# s == 10)
175182check(s,{2097152,67108863},true)
176−s="��"
183+s="\0\0\1\255\255\31"
177184assert(# s == 8)
178185check(s,{65536,2097151},true)
179−local x = "日本語a-4éó"
186+end
187+local x = "\230\151\165\230\156\172\232\170\158\97\45\52\195\169\195\179"
180188check(x,{26085,26412,35486,97,45,52,0,233,243})
181−check("𣲷𠜎𠱓𡁻𠵼ab𠺢",{146615,132878,134227,135291,134524,97,98,134818})
182−check("𨳊𩶘𦧺𨳒𥄫𤓓􏿿",{167114,171416,158202,167122,151851,148691,1114111})
189+check("\240\163\178\183\240\160\156\142\240\160\177\147\240\161\129\187\240\160\181\188\97\98\240\160\186\162",{146615,132878,134227,135291,134524,97,98,134818})
190+check("\240\168\179\138\240\169\182\152\240\166\167\186\240\168\179\146\240\165\132\171\240\164\147\147\244\143\191\191",{167114,171416,158202,167122,151851,148691,1114111})
183191local i = 0
184−for p,c in string.gmatch(x,"()(" .. utf8.charpattern .. ")")
192+for p,c in string.gmatch(x,"\40\41\40" .. utf8.charpattern .. "\41")
185193do
186194i=i + 1
187195assert(utf8.offset(x,i) == p)
@@ -192,4 +200,4 @@ do
192200assert(utf8.offset(x,0,p + j - 1) == p)
193201end
194202end
195−print("ok")
203+print("\111\107")
zod/luau/res/lua/cycled/vararg.lua+24−24
@@ -1,7 +1,7 @@
1−print("testing vararg")
1+print("\116\101\115\116\105\110\103\32\118\97\114\97\114\103")
22local function f
33(a, ...)
4−local x = {["n"] = select("#",...),...}
4+local x = {["\110"] = select("\35",...),...}
55for i = 1, x.n
66do
77assert(a[i] == x[i])
@@ -22,30 +22,30 @@ return res,2
2222end
2323local function vararg
2424(...)
25−return {["n"] = select("#",...),...}
25+return {["\110"] = select("\35",...),...}
2626end
27−local call = (f,args)
27+local call = function (f,args)
2828return f(table.unpack(args,1,args.n))
2929end
3030assert(f() == 0)
3131assert(f({1,2,3},1,2,3) == 3)
32−assert(f({"alo",nil,45,f,nil},"alo",nil,45,f,nil) == 5)
32+assert(f({"\97\108\111",nil,45,f,nil},"\97\108\111",nil,45,f,nil) == 5)
3333assert(vararg().n == 0)
3434assert(vararg(nil,nil).n == 2)
3535assert(c12(1,2) == 55)
3636local a,b = assert(call(c12,{1,2}))
3737assert(a == 55 and b == 2)
38−a=call(c12,{1,2,["n"] = 2})
38+a=call(c12,{1,2,["\110"] = 2})
3939assert(a == 55 and b == 2)
40−a=call(c12,{1,2,["n"] = 1})
40+a=call(c12,{1,2,["\110"] = 1})
4141assert(not a)
4242assert(c12(1,2,3) == false)
43−local a = vararg(call(next,{_G,nil,["n"] = 2}))
43+local a = vararg(call(next,{_G,nil,["\110"] = 2}))
4444local b,c = next(_G)
4545assert(a[1] == b and a[2] == c and a.n == 2)
4646a=vararg(call(call,{c12,{1,2}}))
4747assert(a.n == 2 and a[1] == 55 and a[2] == 2)
48−a=call(print,{"+"})
48+a=call(print,{"\43"})
4949assert(a == nil)
5050local t = {1,10}
5151function t:f(...)
@@ -54,13 +54,14 @@ local arg = {...}
5454return self[...] + # arg
5555end
5656assert(t:f(1,4) == 3 and t:f(2) == 11)
57−print("+")
57+print("\43")
5858local lim = 20
5959local i,a = 1,{}
6060while i <= lim do
6161a[i]=i + 0.3
6262;
6363i=i + 1
64+end
6465function f(a,b,c,d, ...)
6566local more = {...}
6667assert(a == 1.3 and more[1] == 5.3 and more[lim - 4] == lim + 0.3 and not more[lim - 3])
@@ -77,14 +78,15 @@ while i <= lim do
7778a[i]=i
7879;
7980i=i + 1
81+end
8082assert(call(math.max,a) == lim)
81−print("+")
83+print("\43")
8284local function oneless
8385(a, ...)
8486return ...
8587end
8688function f(n,a, ...)
87−local b =
89+local b
8890assert(arg == _G.arg)
8991if n == 0 then
9092local b,c,d = ...
@@ -99,15 +101,11 @@ a,b,c,d,e=assert(f(10,5,4,3,2,1))
99101assert(a == 5 and b == 4 and c == 3 and d == 2 and e == 1)
100102a,b,c,d,e=f(4)
101103assert(a == nil and b == nil and c == nil and d == nil and e == nil)
102−local f = load(" return {...} ")
104+local f = load("\32\114\101\116\117\114\110\32\123\46\46\46\125\32")
103105local x = f(2,3)
104106assert(x[1] == 2 and x[2] == 3 and x[3] == undef)
105−f=load(" local x = {...}
106− for i=1,select('#', ...) do assert(x[i] == select(i, ...)) end
107− assert(x[select('#', ...)+1] == undef)
108− return true
109−")
110−assert(f("a","b",nil,{},assert))
107+f=load("\32\32\108\111\99\97\108\32\120\32\61\32\123\46\46\46\125\10\32\32\102\111\114\32\105\61\49\44\115\101\108\101\99\116\40\39\35\39\44\32\46\46\46\41\32\100\111\32\97\115\115\101\114\116\40\120\91\105\93\32\61\61\32\115\101\108\101\99\116\40\105\44\32\46\46\46\41\41\32\101\110\100\10\32\32\97\115\115\101\114\116\40\120\91\115\101\108\101\99\116\40\39\35\39\44\32\46\46\46\41\43\49\93\32\61\61\32\117\110\100\101\102\41\10\32\32\114\101\116\117\114\110\32\116\114\117\101\10")
108+assert(f("\97","\98",nil,{},assert))
111109assert(f())
112110a={select(3,table.unpack({10,20,30,40}))}
113111assert(# a == 2 and a[1] == 30 and a[2] == 40)
@@ -117,13 +115,14 @@ a={select(- 1,3,5,7)}
117115assert(a[1] == 7 and a[2] == undef)
118116a={select(- 2,3,5,7)}
119117assert(a[1] == 5 and a[2] == 7 and a[3] == undef)
120−pcall(select,1e4)
121−pcall(select,- 1e4)
118+pcall(select,10000)
119+pcall(select,- 10000)
122120function f(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23,p24,p25,p26,p27,p28,p29,p30,p31,p32,p33,p34,p35,p36,p37,p38,p39,p40,p41,p42,p43,p44,p45,p46,p48,p49,p50, ...)
123−local a1,a2,a3,a4,a5,a6,a7 =
124−local a8,a9,a10,a11,a12,a13,a14 =
121+local a1,a2,a3,a4,a5,a6,a7
122+local a8,a9,a10,a11,a12,a13,a14
125123end
126124f()
125+do
127126local function f
128127(a,b,c)
129128return c,b
@@ -134,4 +133,5 @@ return f(1,2)
134133end
135134local a,b = g()
136135assert(a == nil and b == 2)
137−print("OK")
136+end
137+print("\79\75")
zod/luau/res/lua/cycled/verybig.lua+15−76
@@ -1,16 +1,16 @@
1−print("testing RK")
1+print("\116\101\115\116\105\110\103\32\82\75")
22local function foo
33()
44local dummy = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256}
55assert(24.5 + 0.6 == 25.1)
6−local t = {["foo"] = (self,x)
6+local t = {["\102\111\111"] = function (self,x)
77return x + self.x
8−end,["x"] = 10}
8+end,["\120"] = 10}
99t.t=t
1010assert(t:foo(1.5) == 11.5)
1111assert(t.t:foo(0.5) == 10.5)
1212assert(24.3 == 24.3)
13−assert((()
13+assert((function ()
1414return t.x
1515end)() == 10)
1616end
@@ -19,92 +19,31 @@ foo=nil
1919if _soft then
2020return 10
2121end
22−print("testing large programs (>64k)")
23−local prog = "$
24−
25−local a,b
26−
27−b = {$1$
28− b30009 = 65534,
29− b30010 = 65535,
30− b30011 = 65536,
31− b30012 = 65537,
32− b30013 = 16777214,
33− b30014 = 16777215,
34− b30015 = 16777216,
35− b30016 = 16777217,
36− b30017 = 0x7fffff,
37− b30018 = -0x7fffff,
38− b30019 = 0x1ffffff,
39− b30020 = -0x1ffffd,
40− b30021 = -65534,
41− b30022 = -65535,
42− b30023 = -65536,
43− b30024 = -0xffffff,
44− b30025 = 15012.5,
45− $2$
46−};
47−
48−assert(b.a50008 == 25004 and b["a11"] == -5.5)
49−assert(b.a33007 == -16503.5 and b.a50009 == -25004.5)
50−assert(b["b"..30024] == -0xffffff)
51−
52−function b:xxx (a,b) return a+b end
53−assert(b:xxx(10, 12) == 22) -- pushself with non-constant index
54−b["xxx"] = undef
55−
56−local s = 0; local n=0
57−for a,b in pairs(b) do s=s+b; n=n+1 end
58−-- with 32-bit floats, exact value of 's' depends on summation order
59−assert(81800000.0 < s and s < 81860000 and n == 70001)
60−
61−a = nil; b = nil
62−print'+'
63−
64−local function f(x) b=x end
65−
66−a = f{$3$} or 10
67−
68−assert(a==10)
69−assert(b[1] == "a10" and b[2] == 5 and b[#b-1] == "a50009")
70−
71−
72−function xxxx (x) return b[x] end
73−
74−assert(xxxx(3) == "a11")
75−
76−a = nil; b=nil
77−xxxx = nil
78−
79−return 10
80−
81−"
22+print("\116\101\115\116\105\110\103\32\108\97\114\103\101\32\112\114\111\103\114\97\109\115\32\40\62\54\52\107\41")
23+local prog = "\36\10\10\108\111\99\97\108\32\97\44\98\10\10\98\32\61\32\123\36\49\36\10\32\32\98\51\48\48\48\57\32\61\32\54\53\53\51\52\44\10\32\32\98\51\48\48\49\48\32\61\32\54\53\53\51\53\44\10\32\32\98\51\48\48\49\49\32\61\32\54\53\53\51\54\44\10\32\32\98\51\48\48\49\50\32\61\32\54\53\53\51\55\44\10\32\32\98\51\48\48\49\51\32\61\32\49\54\55\55\55\50\49\52\44\10\32\32\98\51\48\48\49\52\32\61\32\49\54\55\55\55\50\49\53\44\10\32\32\98\51\48\48\49\53\32\61\32\49\54\55\55\55\50\49\54\44\10\32\32\98\51\48\48\49\54\32\61\32\49\54\55\55\55\50\49\55\44\10\32\32\98\51\48\48\49\55\32\61\32\48\120\55\102\102\102\102\102\44\10\32\32\98\51\48\48\49\56\32\61\32\45\48\120\55\102\102\102\102\102\44\10\32\32\98\51\48\48\49\57\32\61\32\48\120\49\102\102\102\102\102\102\44\10\32\32\98\51\48\48\50\48\32\61\32\45\48\120\49\102\102\102\102\100\44\10\32\32\98\51\48\48\50\49\32\61\32\45\54\53\53\51\52\44\10\32\32\98\51\48\48\50\50\32\61\32\45\54\53\53\51\53\44\10\32\32\98\51\48\48\50\51\32\61\32\45\54\53\53\51\54\44\10\32\32\98\51\48\48\50\52\32\61\32\45\48\120\102\102\102\102\102\102\44\10\32\32\98\51\48\48\50\53\32\61\32\49\53\48\49\50\46\53\44\10\32\32\36\50\36\10\125\59\10\10\97\115\115\101\114\116\40\98\46\97\53\48\48\48\56\32\61\61\32\50\53\48\48\52\32\97\110\100\32\98\91\34\97\49\49\34\93\32\61\61\32\45\53\46\53\41\10\97\115\115\101\114\116\40\98\46\97\51\51\48\48\55\32\61\61\32\45\49\54\53\48\51\46\53\32\97\110\100\32\98\46\97\53\48\48\48\57\32\61\61\32\45\50\53\48\48\52\46\53\41\10\97\115\115\101\114\116\40\98\91\34\98\34\46\46\51\48\48\50\52\93\32\61\61\32\45\48\120\102\102\102\102\102\102\41\10\10\102\117\110\99\116\105\111\110\32\98\58\120\120\120\32\40\97\44\98\41\32\114\101\116\117\114\110\32\97\43\98\32\101\110\100\10\97\115\115\101\114\116\40\98\58\120\120\120\40\49\48\44\32\49\50\41\32\61\61\32\50\50\41\32\32\32\45\45\32\112\117\115\104\115\101\108\102\32\119\105\116\104\32\110\111\110\45\99\111\110\115\116\97\110\116\32\105\110\100\101\120\10\98\91\34\120\120\120\34\93\32\61\32\117\110\100\101\102\10\10\108\111\99\97\108\32\115\32\61\32\48\59\32\108\111\99\97\108\32\110\61\48\10\102\111\114\32\97\44\98\32\105\110\32\112\97\105\114\115\40\98\41\32\100\111\32\115\61\115\43\98\59\32\110\61\110\43\49\32\101\110\100\10\45\45\32\119\105\116\104\32\51\50\45\98\105\116\32\102\108\111\97\116\115\44\32\101\120\97\99\116\32\118\97\108\117\101\32\111\102\32\39\115\39\32\100\101\112\101\110\100\115\32\111\110\32\115\117\109\109\97\116\105\111\110\32\111\114\100\101\114\10\97\115\115\101\114\116\40\56\49\56\48\48\48\48\48\46\48\32\60\32\115\32\97\110\100\32\115\32\60\32\56\49\56\54\48\48\48\48\32\97\110\100\32\110\32\61\61\32\55\48\48\48\49\41\10\10\97\32\61\32\110\105\108\59\32\98\32\61\32\110\105\108\10\112\114\105\110\116\39\43\39\10\10\108\111\99\97\108\32\102\117\110\99\116\105\111\110\32\102\40\120\41\32\98\61\120\32\101\110\100\10\10\97\32\61\32\102\123\36\51\36\125\32\111\114\32\49\48\10\10\97\115\115\101\114\116\40\97\61\61\49\48\41\10\97\115\115\101\114\116\40\98\91\49\93\32\61\61\32\34\97\49\48\34\32\97\110\100\32\98\91\50\93\32\61\61\32\53\32\97\110\100\32\98\91\35\98\45\49\93\32\61\61\32\34\97\53\48\48\48\57\34\41\10\10\10\102\117\110\99\116\105\111\110\32\120\120\120\120\32\40\120\41\32\114\101\116\117\114\110\32\98\91\120\93\32\101\110\100\10\10\97\115\115\101\114\116\40\120\120\120\120\40\51\41\32\61\61\32\34\97\49\49\34\41\10\10\97\32\61\32\110\105\108\59\32\98\61\110\105\108\10\120\120\120\120\32\61\32\110\105\108\10\10\114\101\116\117\114\110\32\49\48\10\10"
8224local function sig
8325(x)
84−return (x % 2 == 0) and "" or "-"
26+return (x % 2 == 0) and "" or "\45"
8527end
86−local F = {()
28+local F = {function ()
8729for i = 10, 50009
8830do
89−io.write("a",i," = ",sig(i),5 + ((i - 10) / 2),",
90−")
31+io.write("\97",i,"\32\61\32",sig(i),5 + ((i - 10) / 2),"\44\10")
9132end
92−end,()
33+end,function ()
9334for i = 30026, 50009
9435do
95−io.write("b",i," = ",sig(i),15013 + ((i - 30026) / 2),",
96−")
36+io.write("\98",i,"\32\61\32",sig(i),15013 + ((i - 30026) / 2),"\44\10")
9737end
98−end,()
38+end,function ()
9939for i = 10, 50009
10040do
101−io.write(""a",i,"", ",sig(i),5 + ((i - 10) / 2),",
102−")
41+io.write("\34\97",i,"\34\44\32",sig(i),5 + ((i - 10) / 2),"\44\10")
10342end
10443end}
10544local file = os.tmpname()
10645io.output(file)
107−for s in string.gmatch(prog,"$([^$]+)")
46+for s in string.gmatch(prog,"\36\40\91\94\36\93\43\41")
10847do
10948local n = tonumber(s)
11049if not n then
@@ -116,5 +55,5 @@ end
11655io.close()
11756local result = dofile(file)
11857assert(os.remove(file))
119−print("OK")
58+print("\79\75")
12059return result
zod/luau/ted/test-lua.hoon+42−10
@@ -2,17 +2,45 @@
22/+ *strandio
33/+ lua-parser
44/+ lua-printer
5−=<
5+=>
6+|%
7++$ test-result $?(%ok %err)
8++$ flag
9+ $?
10+ %crash-parser
11+ %print-asts
12+ $%
13+ [%restrict @tas]
14+ ==
15+ ==
16+--
617=/ m (strand:spider ,vase)
718^- thread:spider
819|= arg=vase
920^- form:m
21+=/ arg=(list flag) (fall !<((unit (list flag)) arg) ~)
22+=/ has-flag
23+ |= f=flag
24+ ?=(^ (find ~[f] arg))
25+=/ restricts=(list @tas)
26+ %- zing
27+ %+ turn arg
28+ |= =flag
29+ ?@ flag ~
30+ ?- -.flag
31+ %restrict ~[+.flag]
32+ ==
1033;< bek=beak bind:m get-beak
1134;< lua-files=(list path) bind:m (list-tree [bek /res/lua])
1235=/ lua-files %+ skim lua-files
1336 |= =path
1437 ^- ?
15− .=(4 (lent path))
38+ ?&
39+ .=(4 (lent path))
40+ ::
41+ ?~ restricts &
42+ ?=(^ (find ~[(snag 2 path)] restricts))
43+ ==
1644;< results=(list test-result) bind:m
1745 =/ m (strand:spider ,(list test-result))
1846 =/ res=(list test-result) ~
@@ -23,11 +51,15 @@
2351 ;< =cage bind:m (read-file [bek current-file])
2452 =/ lua-code=@t (of-wain:format !<(wain +.cage))
2553 ~& %parsing
26− =/ ast-unit (rush lua-code lua-parser)
54+ =/ ast-unit
55+ ?: (has-flag %crash-parser)
56+ (some (rash lua-code lua-parser))
57+ (rush lua-code lua-parser)
2758 ;< parse-result=test-result bind:m
2859 =/ m (strand:spider ,test-result)
2960 ?~ ast-unit (pure:m %err)
3061 =/ ast u.ast-unit
62+ ~? (has-flag %print-asts) ast
3163 ~& %printing
3264 =/ printed (lua-printer ast)
3365 ;< * bind:m %- send-raw-card
@@ -36,10 +68,15 @@
3668 %& [(into current-file 2 ~.cycled) %ins %lua !>((to-wain:format (crip printed)))]~
3769 ==
3870 ~& %parsing-printed
39− =/ cycled-ast-unit (rust printed lua-parser)
71+ =/ cycled-ast-unit
72+ ?: (has-flag %crash-parser)
73+ (some (scan printed lua-parser))
74+ (rust printed lua-parser)
4075 ?~ cycled-ast-unit (pure:m %err)
76+ =/ ast u.cycled-ast-unit
77+ ~? (has-flag %print-asts) ast
4178 ~& %comparing-asts
42− ?. =(ast u.cycled-ast-unit) (pure:m %err)
79+ ?. =(^ast ast) (pure:m %err)
4380 (pure:m %ok)
4481 ~& parse-result
4582 $(lua-files t.lua-files, res [parse-result res])
@@ -49,8 +86,3 @@
4986 passed=(lent (skim results |=(=test-result =(%ok test-result))))
5087 errored=(lent (skim results |=(=test-result =(%err test-result))))
5188 ==
52−|%
53−+$ test-result $?(%ok %err)
54−:: ++ rename-file
55−
56−--