on master help sign in
105 files changed+35077−783
since splitsnapshots
unifiedsplit
README.md+9 TODO.md+11 desk/desk.ship+1 desk/lib/interlist.hoon+79 desk/lib/lua.hoon+1 desk/lib/lua/interpreter.hoon+554 desk/lib/lua/parser.hoon+1066 desk/lib/lua/printer.hoon+526 desk/lib/lua/utils.hoon+2 desk/lib/st.hoon+64 desk/lib/strand.hoon+1 desk/lib/strandio.hoon+832 zod/luau/mar/atom.hoon → desk/mar/atom.hoon zod/luau/mar/bill.hoon → desk/mar/bill.hoon zod/luau/mar/docket-0.hoon → desk/mar/docket-0.hoon zod/luau/mar/hoon.hoon → desk/mar/hoon.hoon zod/luau/mar/kelvin.hoon → desk/mar/kelvin.hoon desk/mar/lua.hoon+17 zod/luau/mar/mime.hoon → desk/mar/mime.hoon zod/luau/mar/noun.hoon → desk/mar/noun.hoon zod/luau/mar/ship.hoon → desk/mar/ship.hoon zod/luau/mar/txt.hoon → desk/mar/txt.hoon desk/res/lua/all.lua+312 desk/res/lua/api.lua+1543 desk/res/lua/attrib.lua+527 desk/res/lua/bar.lua+23 desk/res/lua/baz.lua+6 desk/res/lua/big.lua+82 desk/res/lua/bitwise.lua+363 desk/res/lua/bwcoercion.lua+78 desk/res/lua/calls.lua+497 desk/res/lua/closure.lua+272 desk/res/lua/code.lua+449 desk/res/lua/constructs.lua+406 desk/res/lua/coroutine.lua+1156 desk/res/lua/cstack.lua+197 desk/res/lua/cycled/all.lua+203 desk/res/lua/cycled/api.lua+1167 desk/res/lua/cycled/attrib.lua+431 desk/res/lua/cycled/bar.lua+2 desk/res/lua/cycled/big.lua+67 desk/res/lua/cycled/bitwise.lua+309 desk/res/lua/cycled/bwcoercion.lua+59 desk/res/lua/cycled/calls.lua+492 desk/res/lua/cycled/closure.lua+327 desk/res/lua/cycled/code.lua+586 desk/res/lua/cycled/constructs.lua+469 desk/res/lua/cycled/coroutine.lua+1119 desk/res/lua/cycled/cstack.lua+166 desk/res/lua/cycled/db.lua+947 desk/res/lua/cycled/errors.lua+493 desk/res/lua/cycled/events.lua+610 desk/res/lua/cycled/files.lua+818 desk/res/lua/cycled/foo.lua+82 desk/res/lua/cycled/gc.lua+790 desk/res/lua/cycled/gengc.lua+108 desk/res/lua/cycled/goto.lua+275 desk/res/lua/cycled/heavy.lua+126 desk/res/lua/cycled/literals.lua+199 desk/res/lua/cycled/locals.lua+1050 desk/res/lua/cycled/main.lua+312 desk/res/lua/cycled/math.lua+879 desk/res/lua/cycled/nextvar.lua+1055 desk/res/lua/cycled/pm.lua+404 desk/res/lua/cycled/sort.lua+309 desk/res/lua/cycled/strings.lua+441 desk/res/lua/cycled/tpack.lua+259 desk/res/lua/cycled/tracegc.lua+24 desk/res/lua/cycled/utf8.lua+203 desk/res/lua/cycled/vararg.lua+137 desk/res/lua/cycled/verybig.lua+59 desk/res/lua/db.lua+1054 desk/res/lua/errors.lua+696 desk/res/lua/events.lua+491 desk/res/lua/files.lua+951 desk/res/lua/foo.lua+122 desk/res/lua/gc.lua+695 desk/res/lua/gengc.lua+172 desk/res/lua/goto.lua+271 desk/res/lua/heavy.lua+173 desk/res/lua/literals.lua+343 desk/res/lua/locals.lua+1181 desk/res/lua/main.lua+563 desk/res/lua/math.lua+1024 desk/res/lua/nextvar.lua+825 desk/res/lua/pm.lua+440 desk/res/lua/sort.lua+311 desk/res/lua/strings.lua+526 desk/res/lua/tpack.lua+322 desk/res/lua/tracegc.lua+40 desk/res/lua/utf8.lua+259 desk/res/lua/vararg.lua+151 desk/res/lua/verybig.lua+152 desk/sur/interlist.hoon+8 desk/sur/lua.hoon+123 desk/sur/spider.hoon+27 zod/luau/sys.kelvin → desk/sys.kelvin desk/ted/eval-lua.hoon+19 desk/ted/test-lua.hoon+87 zod/luau/TODO.md−5 zod/luau/lib/interlist.hoon−32 zod/luau/lib/lua.hoon−671 zod/luau/mar/lua.hoon−20 zod/luau/tests/foo.lua−46 zod/luau/tmp.hoon−9
README.mdnew file+9
@@ -0,0 +1,9 @@
1+# Luau
2+
3+A lua interpreter for urbit.
4+
5+## Running tests
6+
7+```
8+-luau!test-lua
9+```
TODO.mdnew file+11
@@ -0,0 +1,11 @@
1+# Parser
2+
3+- [x] functioncall
4+- [x] any string apart from the basic string with no escapes
5+- [x] check if int fits in int or make it a float
6+- [x] should `print-blok` have `do`-`end`? This is fucked.
7+- [x] binary operator priority
8+- [x] ^ should be higher priority than unary ops
9+- [x] Unifiy parened exprs
10+- [ ] pow
11+- [ ] attributes
desk/desk.shipnew file+1
@@ -0,0 +1 @@
1+~racfer-hattes
desk/lib/interlist.hoonnew file+79
@@ -0,0 +1,79 @@
1+/- *interlist
2+=<
3+|%
4+++ new
5+ |* [a=* b=(list [* *])]
6+ ^- (interlist _?<(?=(~ b) -.i.b) _a)
7+ ?~ b single+a
8+ double+[a -.i.b (new +.i.b t.b)]
9+++ turn-inter
10+ |* [l=(interlist) f=$-(* *)]
11+ ^- (interlist _$:f _?>(?=(%single -.l) +.l))
12+ ?- -.l
13+ %single [%single +.l]
14+ %double [%double val.l (f sep.l) $(l tail.l)]
15+ ==
16+++ turn
17+ |* [l=(interlist) f=$-(* *)]
18+ ^- (interlist _?>(?=(%double -.l) sep.l) _$:f)
19+ ?- -.l
20+ %single single+(f +.l)
21+ %double double+[(f val.l) sep.l $(l tail.l)]
22+ ==
23+++ reverse
24+ |* l=(interlist)
25+ ^+ l
26+ =/ tmp=(unit _?>(?=(%double -.l) +>.l)) ~
27+ |-
28+ ^+ l
29+ ?- -.l
30+ %single
31+ ?~ tmp l [%double +.l u.tmp]
32+ %double
33+ %= $
34+ l +>+.l
35+ tmp
36+ ?~ tmp `[+>-.l [%single +<.l]]
37+ `[+>-.l [%double +<.l u.tmp]]
38+ ==
39+ ==
40+++ parse
41+ |* [s=rule v=rule]
42+ =/ val (rule-type v)
43+ =/ sep (rule-type s)
44+ %+ cook
45+ |* [v=* rest=(list [* *])]
46+ ^- (interlist sep val)
47+ =/ rrest (flop rest)
48+ ?~ rrest [%single v]
49+ =/ tail
50+ %+ roll t.rrest
51+ |* [[s=* v=*] _[acc=`(interlist sep val)`[%single +.i.rrest] last-sep=-.i.rrest]]
52+ [[%double v last-sep acc] s]
53+ [%double v +.tail -.tail]
54+ ;~(plug v (star ;~(plug s v)))
55+++ split-left-on
56+ |* [is-pivot=$-(* ?) l=(interlist)]
57+ ^- (unit _[lhs=l pivot=+<.is-pivot rhs=l])
58+ ?- -.l
59+ %single ~
60+ %double
61+ ?: (is-pivot sep.l) `[[%single val.l] sep.l tail.l]
62+ =/ rest $(l tail.l)
63+ ?~ rest ~
64+ `[[%double val.l sep.l lhs.u.rest] pivot.u.rest rhs.u.rest]
65+ ==
66+++ split-right-on
67+ |* [is-pivot=$-(* ?) l=(interlist * *)]
68+ ^- (unit _[lhs=l pivot=+<.is-pivot rhs=l])
69+ %+ bind (split-left-on is-pivot (reverse l))
70+ |* [a=(interlist * *) b=* c=(interlist * *)] [(reverse c) b (reverse a)]
71+--
72+|%
73+++ rule-type
74+ |* =rule
75+ $_
76+ =/ ret q:$:rule
77+ ?> ?=(^ ret)
78+ p.u.ret
79+--
desk/lib/lua.hoonnew file+1
@@ -0,0 +1 @@
1+/+ lua-interpreter
desk/lib/lua/interpreter.hoonnew file+554
@@ -0,0 +1,554 @@
1+/- *lua
2+/+ st
3+=<
4+|= =chunk
5+((eval-chunk chunk) *state)
6+|%
7+++ eval-chunk
8+ |= =chunk
9+ ^- (eval-m value)
10+ ?- -.chunk
11+ %blok (eval-blok +.chunk)
12+ ==
13+++ object-id |$ obj @
14+++ objects
15+ |$ obj [objs=(map (object-id obj) obj) next-id=(object-id obj)]
16++$ value
17+ $%
18+ [%table val=(object-id table) meta=(unit (object-id table))]
19+ [%string string]
20+ [%num numeral]
21+ [%multires (lest value)]
22+ [%true ~]
23+ [%false ~]
24+ [%nil ~]
25+ ==
26++$ lval
27+ $%
28+ [%var name]
29+ [%table-field (object-id table) value]
30+ ==
31++$ table (map value value)
32++$ state
33+ $:
34+ tables=$~([(malt ~[[0 *table]]) 1] (objects table))
35+ global-env=table
36+ local-envs=$~(~[(malt ~[['_ENV' table+[0 ~]]])] (lest (map name value)))
37+ ==
38+++ eval-m
39+ |$ [val]
40+ $-(state [st=state val=val])
41+++ pure
42+ |* x=*
43+ ^- (eval-m _x)
44+ |=(st=state [st x])
45+++ bind
46+ |* =mold
47+ |* [prev=(eval-m) cont=$-(* (eval-m mold))]
48+ ^+ $:cont
49+ |= st=state
50+ =/ [st=state val=_val:$:prev] (prev st)
51+ ((cont val) st)
52+++ get-state
53+ ^- (eval-m state)
54+ |= st=state
55+ [st st]
56+++ set-state
57+ |= st=state
58+ ^- (eval-m ~)
59+ |= state
60+ [st ~]
61+++ eval-blok
62+ =<
63+ |= =blok
64+ ^- (eval-m value)
65+ %- with-local
66+ =/ body body.blok
67+ |-
68+ ^- (eval-m value)
69+ ?~ body
70+ ?~ ret.blok (pure nil+~)
71+ ?~ u.ret.blok (pure nil+~)
72+ ;< rets=(lest value) bind (eval-exprlist u.u.ret.blok)
73+ (pure (multires rets))
74+ ;< ~ bind (eval-stat i.body)
75+ ;< ret=value bind $(body t.body)
76+ (pure ret)
77+ |%
78+ ++ with-local
79+ |* act=(eval-m)
80+ ^- _act
81+ ;< ~ bind push-local
82+ ;< res=_val:$:act bind act
83+ ;< ~ bind pop-local
84+ (pure res)
85+ ++ push-local
86+ ^- (eval-m ~)
87+ |= st=state
88+ =. local-envs.st [*(map name value) local-envs.st]
89+ [st ~]
90+ ++ pop-local
91+ ^- (eval-m ~)
92+ |= st=state
93+ =. local-envs.st
94+ ?~ t.local-envs.st !!
95+ t.local-envs.st
96+ [st ~]
97+ --
98+++ multires
99+ |= vals=(lest value)
100+ ^- value
101+ ?~ t.vals i.vals
102+ multires+vals
103+++ eval-exprlist
104+ |= vals=exprlist
105+ ^- (eval-m (lest value))
106+ ;< val=value bind (eval-expr i.vals)
107+ ?~ t.vals (pure [val ~])
108+ ;< tail=(list value) bind $(vals t.vals)
109+ (pure [val tail])
110+++ eval-stat
111+ |= =stat
112+ ^- (eval-m ~)
113+ ?+ -.stat !!
114+ %asmnt
115+ ;< lhs=(lest lval) bind (process-varlist +<.stat)
116+ ;< rhs=(lest value) bind (eval-exprlist +>.stat)
117+ =/ asmnts (zip lhs (normalize-multires-exprlist rhs))
118+ |-
119+ ?~ asmnts (pure ~)
120+ ;< * bind
121+ ?- -<.i.asmnts
122+ %var ((set-var ->.i.asmnts) +.i.asmnts)
123+ %table-field
124+ ;< tabl=table bind (get-table ->-.i.asmnts)
125+ (set-table ->-.i.asmnts (~(put by tabl) ->+.i.asmnts +.i.asmnts))
126+ ==
127+ $(asmnts t.asmnts)
128+ %local-asmnt
129+ =/ lhs=(list name)
130+ %+ turn attrnamelist.stat
131+ |= [=name attr=(unit attrib)]
132+ ?> ?=(~ attr)
133+ name
134+ ;< actual-values=(list [name value]) bind
135+ ?~ rhs.stat (pure ~)
136+ ;< rhs=(list value) bind (eval-exprlist u.rhs.stat)
137+ (pure (zip lhs rhs))
138+ ;< st=state bind get-state
139+ =. i.local-envs.st
140+ %- ~(uni by i.local-envs.st)
141+ %- malt
142+ (weld (turn lhs |=(=name [name `value`nil+~])) actual-values)
143+ (set-state st)
144+ ==
145+++ set-var
146+ |= var=name
147+ |= val=value
148+ ^- (eval-m ~)
149+ ;< envs=(list (map name value)) bind get-local-envs
150+ =/ new-envs=(unit (lest (map name value)))
151+ |-
152+ ^- (unit (lest (map name value)))
153+ ?~ envs ~
154+ ?. (~(has by i.envs) var)
155+ =/ rest $(envs t.envs)
156+ ?~ rest ~
157+ `[i.envs u.rest]
158+ `[(~(put by i.envs) var val) t.envs]
159+ ^- (eval-m ~)
160+ ?. ?=(~ new-envs)
161+ |= st=state
162+ =. local-envs.st u.new-envs
163+ [st ~]
164+ =/ global-env (need ((get-from-local-envs envs) '_ENV'))
165+ :: TODO: proper error
166+ ?+ -.global-env !!
167+ %table
168+ ;< tabl=table bind (get-table +<.global-env)
169+ (set-table +<.global-env (~(put by tabl) (string-val var) val))
170+ ==
171+++ normalize-multires-exprlist
172+ |= vals=(list value)
173+ ^- (list value)
174+ ?~ vals ~
175+ ?~ t.vals ~[(normalize-multires i.vals)]
176+ [i.vals $(vals t.vals)]
177+++ normalize-multires
178+ |= val=value
179+ ^- value
180+ ?+ -.val val
181+ %multires
182+ =/ res=(lest value)
183+ =/ vals=(lest value) +.val
184+ |-
185+ ?~ t.vals
186+ =/ tail=value (normalize-multires i.vals)
187+ ?: ?=(%multires -.tail) +.tail [tail ~]
188+ [i.vals $(vals t.vals)]
189+ ?~ t.res i.res
190+ multires+res
191+ ==
192+++ process-varlist
193+ =<
194+ |= =varlist
195+ ^- (eval-m (lest lval))
196+ ;< val=lval bind (process-var i.varlist)
197+ ?~ t.varlist (pure ~[val])
198+ ;< tail=(list lval) bind $(varlist t.varlist)
199+ (pure [val tail])
200+ |%
201+ ++ process-var
202+ |= =var
203+ ^- (eval-m lval)
204+ ?- -.var
205+ %name (pure var++.var)
206+ %indexed
207+ ;< prefix=value bind (eval-prefix-expr +<.var)
208+ ;< idx=value bind (eval-expr +>.var)
209+ :: TODO: proper error
210+ ?. ?=(%table -.prefix) !!
211+ (pure table-field+[val.prefix idx])
212+ %dot
213+ ;< prefix=value bind (eval-prefix-expr +<.var)
214+ :: TODO: proper error
215+ ?. ?=(%table -.prefix) !!
216+ (pure table-field+[val.prefix (string-val +>.var)])
217+ ==
218+ --
219+++ eval-expr
220+ |= =expr
221+ ^- (eval-m value)
222+ ?+ -.expr !!
223+ %false (pure expr)
224+ %true (pure expr)
225+ %nil (pure expr)
226+ %string (pure expr)
227+ %num (pure expr)
228+ %binop (eval-binop +.expr)
229+ %prefix-expr (eval-prefix-expr +.expr)
230+ %unop (eval-unop +.expr)
231+ %table
232+ ;< tabl-id=(object-id table) bind (eval-table +.expr)
233+ (pure table+[tabl-id ~])
234+ ==
235+++ eval-table
236+ |= tabl=^table
237+ =<
238+ ^- (eval-m (object-id table))
239+ ;< felds=(list [value value]) bind
240+ =/ counter 1
241+ |-
242+ ?~ tabl (pure ~)
243+ ?- -.i.tabl
244+ %keyed
245+ ;< k=value bind (eval-expr +<.i.tabl)
246+ ;< v=value bind (eval-expr +>.i.tabl)
247+ ;< tail=(list [value value]) bind $(tabl t.tabl)
248+ (pure [[k v] tail])
249+ %unkeyed
250+ ;< v=value bind (eval-expr +.i.tabl)
251+ ?: &(?=(~ t.tabl) ?=(%multires -.v))
252+ =/ vals=(list value) +.v
253+ %- pure
254+ ^- (list [value value])
255+ |-
256+ ?~ vals ~
257+ [[num+int+(new:st counter) i.vals] $(vals t.vals, counter +(counter))]
258+ ;< tail=(list [value value]) bind $(tabl t.tabl, counter +(counter))
259+ (pure [[num+int+(new:st counter) v] tail])
260+ ==
261+ (new-table (malt felds))
262+ |%
263+ --
264+++ eval-unop
265+ |= [op=unop =expr]
266+ ^- (eval-m value)
267+ ?+ op !!
268+ %minus
269+ ;< val=value bind (eval-expr expr)
270+ ;< num=numeral bind (assert-numeral val)
271+ %- pure
272+ ?- -.num
273+ %int num+int+(neg:st +.num)
274+ %float num+float+(sub:rd *@rd +.num)
275+ ==
276+ %not
277+ ;< val=value bind (eval-expr expr)
278+ %- pure
279+ ?: (falsy val) [%false ~] [%true ~]
280+ %sig
281+ ;< val=value bind (eval-expr expr)
282+ ;< n=numeral bind (assert-numeral val)
283+ ;< i=@st bind (to-int n)
284+ %- pure
285+ num+int+(mix i mask:st)
286+ ==
287+++ eval-binop
288+ |= [lhs=expr op=binop rhs=expr]
289+ ^- (eval-m value)
290+ =<
291+ ?+ op !!
292+ %add
293+ ;< lhs=value bind (eval-expr lhs)
294+ ;< rhs=value bind (eval-expr rhs)
295+ ;< unified=unified-numerals bind (unify-numeral-values lhs rhs)
296+ %- pure
297+ :- %num
298+ ?- -.unified
299+ %i :- %int (add:st a.unified b.unified)
300+ %f :- %float (add:rd a.unified b.unified)
301+ ==
302+ %sub
303+ ;< lhs=value bind (eval-expr lhs)
304+ ;< rhs=value bind (eval-expr rhs)
305+ ;< unified=unified-numerals bind (unify-numeral-values lhs rhs)
306+ %- pure
307+ :- %num
308+ ?- -.unified
309+ %i :- %int (sub:st a.unified b.unified)
310+ %f :- %float (sub:rd a.unified b.unified)
311+ ==
312+ %mul
313+ ;< lhs=value bind (eval-expr lhs)
314+ ;< rhs=value bind (eval-expr rhs)
315+ ;< unified=unified-numerals bind (unify-numeral-values lhs rhs)
316+ %- pure
317+ :- %num
318+ ?- -.unified
319+ %i :- %int (mul:st a.unified b.unified)
320+ %f :- %float (mul:rd a.unified b.unified)
321+ ==
322+ %int-div
323+ ;< lhs=value bind (eval-expr lhs)
324+ ;< rhs=value bind (eval-expr rhs)
325+ ;< unified=unified-numerals bind (unify-numeral-values lhs rhs)
326+ %- pure
327+ :- %num
328+ ?- -.unified
329+ %i :- %int (div:st +.unified)
330+ %f :- %float (int-div-float +.unified)
331+ ==
332+ %mod
333+ ;< lhs=value bind (eval-expr lhs)
334+ ;< rhs=value bind (eval-expr rhs)
335+ ;< unified=unified-numerals bind (unify-numeral-values lhs rhs)
336+ %- pure
337+ :- %num
338+ ?- -.unified
339+ %i :- %int (mod:st +.unified)
340+ %f
341+ :- %float
342+ (sub:rd a.unified (mul:rd (int-div-float +.unified) b.unified))
343+ ==
344+ %div
345+ ;< lhs=value bind (eval-expr lhs)
346+ ;< rhs=value bind (eval-expr rhs)
347+ ;< lhs=numeral bind (assert-numeral lhs)
348+ ;< rhs=numeral bind (assert-numeral rhs)
349+ %- pure num+float+(div:rd (to-float lhs) (to-float rhs))
350+ %exp !!
351+ %band
352+ ;< lhs=value bind (eval-expr lhs)
353+ ;< rhs=value bind (eval-expr rhs)
354+ ;< lhs=numeral bind (assert-numeral lhs)
355+ ;< rhs=numeral bind (assert-numeral rhs)
356+ ;< lhs=@st bind (to-int lhs)
357+ ;< rhs=@st bind (to-int rhs)
358+ %- pure
359+ num+int+(dis lhs rhs)
360+ %bor
361+ ;< lhs=value bind (eval-expr lhs)
362+ ;< rhs=value bind (eval-expr rhs)
363+ ;< lhs=numeral bind (assert-numeral lhs)
364+ ;< rhs=numeral bind (assert-numeral rhs)
365+ ;< lhs=@st bind (to-int lhs)
366+ ;< rhs=@st bind (to-int rhs)
367+ %- pure
368+ num+int+(con lhs rhs)
369+ %bxor
370+ ;< lhs=value bind (eval-expr lhs)
371+ ;< rhs=value bind (eval-expr rhs)
372+ ;< lhs=numeral bind (assert-numeral lhs)
373+ ;< rhs=numeral bind (assert-numeral rhs)
374+ ;< lhs=@st bind (to-int lhs)
375+ ;< rhs=@st bind (to-int rhs)
376+ %- pure
377+ num+int+(mix lhs rhs)
378+ %rshft
379+ ;< lhs=value bind (eval-expr lhs)
380+ ;< rhs=value bind (eval-expr rhs)
381+ ;< lhs=numeral bind (assert-numeral lhs)
382+ ;< rhs=numeral bind (assert-numeral rhs)
383+ ;< lhs=@st bind (to-int lhs)
384+ ;< rhs=@st bind (to-int rhs)
385+ %- pure
386+ num+int+(dis mask:st (?:((sig:st rhs) lsh rsh) [0 (abs:st rhs)] lhs))
387+ %lshft
388+ ;< lhs=value bind (eval-expr lhs)
389+ ;< rhs=value bind (eval-expr rhs)
390+ ;< lhs=numeral bind (assert-numeral lhs)
391+ ;< rhs=numeral bind (assert-numeral rhs)
392+ ;< lhs=@st bind (to-int lhs)
393+ ;< rhs=@st bind (to-int rhs)
394+ %- pure
395+ num+int+(dis mask:st (?:((sig:st rhs) rsh lsh) [0 (abs:st rhs)] lhs))
396+ %or
397+ ;< lhs=value bind (eval-expr lhs)
398+ ?. (falsy lhs) (pure lhs)
399+ (eval-expr rhs)
400+ %and
401+ ;< lhs=value bind (eval-expr lhs)
402+ ?: (falsy lhs) (pure lhs)
403+ (eval-expr rhs)
404+ ==
405+ |%
406+ ++ show-numeral
407+ |= n=numeral
408+ ^- tape
409+ ?- -.n
410+ %int (scow %s (to-s:st +.n))
411+ %float (scow %rd +.n)
412+ ==
413+ ++ int-div-float
414+ |= [a=@rd b=@rd]
415+ =/ whole=(unit @s) (~(toi rd %d) (div:rd a b))
416+ ?~ whole (div:rd .~0 .~0)
417+ (san:rd u.whole)
418+ +$ unified-numerals $%([%i a=@st b=@st] [%f a=@rd b=@rd])
419+ ++ unify-numeral-values
420+ |= [a=value b=value]
421+ ^- (eval-m unified-numerals)
422+ ;< a=numeral bind (assert-numeral a)
423+ ;< b=numeral bind (assert-numeral b)
424+ (pure (unify-numerals a b))
425+ ++ unify-numerals
426+ |= [a=numeral b=numeral]
427+ ^- unified-numerals
428+ ?: &(?=(%int -.a) ?=(%int -.b)) [%i +.a +.b]
429+ [%f (to-float a) (to-float b)]
430+ ++ to-float
431+ |= n=numeral
432+ ^- @rd
433+ ?: ?=(%float -.n) +.n
434+ (san:rd (to-s:st +.n))
435+ --
436+++ to-int
437+ |= n=numeral
438+ ^- (eval-m @st)
439+ ?: ?=(%int -.n) (pure +.n)
440+ =/ i=(unit @s) (toi:rd +.n)
441+ :: TODO: proper error
442+ ?~ i !!
443+ =/ i u.i
444+ =/ cycled (san:rd i)
445+ :: TODO: proper error
446+ :: checks that we don't lose any information
447+ ?. =(+.n cycled) !!
448+ (pure (from-s:st i))
449+++ falsy
450+ |= v=value
451+ ^- ?
452+ ?+ -.v |
453+ %false &
454+ %nil &
455+ ==
456+++ assert-numeral
457+ |= [a=value]
458+ ^- (eval-m numeral)
459+ :: TODO: throw a proper error
460+ ?. ?=(%num -.a) !!
461+ (pure +.a)
462+++ eval-prefix-expr
463+ |= =prefix-expr
464+ ^- (eval-m value)
465+ ?- -.prefix-expr
466+ %expr (eval-expr +.prefix-expr)
467+ %call (eval-functioncall +.prefix-expr)
468+ %var
469+ ?- +<.prefix-expr
470+ %name (lookup-var +>.prefix-expr)
471+ %dot
472+ ;< tabl=value bind (eval-prefix-expr +>-.prefix-expr)
473+ (lookup-table-field tabl (string-val +>+.prefix-expr))
474+ %indexed
475+ ;< tabl=value bind (eval-prefix-expr +>-.prefix-expr)
476+ ;< idx=value bind (eval-expr +>+.prefix-expr)
477+ (lookup-table-field tabl idx)
478+ ==
479+ ==
480+++ lookup-table-field
481+ |= [val=value fild=value]
482+ ^- (eval-m value)
483+ :: TODO: proper error
484+ ?+ -.val !!
485+ %table
486+ ;< tabl=table bind (get-table val.val)
487+ =/ res (~(get by tabl) fild)
488+ :: TODO: error
489+ ?~ res !!
490+ (pure u.res)
491+ ==
492+++ lookup-var
493+ |= =name
494+ ^- (eval-m value)
495+ ;< envs=(list (map ^name value)) bind get-local-envs
496+ =/ get-local (get-from-local-envs envs)
497+ =/ local=(unit value) (get-local name)
498+ ?. ?=(~ local) (pure u.local)
499+ =/ global-env (get-local '_ENV')
500+ ?~ global-env !!
501+ (lookup-table-field u.global-env (string-val name))
502+++ get-from-local-envs
503+ |= envs=(list (map name value))
504+ |= =name
505+ ^- (unit value)
506+ ?~ envs ~
507+ =/ val=(unit value) (~(get by i.envs) name)
508+ ?~ val $(envs t.envs)
509+ val
510+++ string-val
511+ |= val=@t
512+ ^- value
513+ string+(trip val)
514+++ get
515+ |* f=$-(state *)
516+ ^- (eval-m _$:f)
517+ |= st=state
518+ [st (f st)]
519+++ get-table
520+ |= id=(object-id table)
521+ ^- (eval-m table)
522+ ;< tables=(objects table) bind
523+ %- get |=(st=state tables.st)
524+ =/ table (~(get by objs.tables) id)
525+ :: TODO: proper error
526+ ?~ table !!
527+ (pure u.table)
528+++ set-table
529+ |= [id=(object-id table) tabl=table]
530+ ^- (eval-m ~)
531+ |= st=state
532+ =. objs.tables.st (~(put by objs.tables.st) id tabl)
533+ [st ~]
534+++ get-local-envs
535+ ^- (eval-m (list (map name value)))
536+ %- get |=(st=state local-envs.st)
537+++ eval-functioncall
538+ |= =functioncall
539+ ^- (eval-m value)
540+ !!
541+++ new-table
542+ |= tabl=table
543+ ^- (eval-m (object-id table))
544+ |= st=state
545+ =/ id next-id.tables.st
546+ =. next-id.tables.st +(id)
547+ =. objs.tables.st (~(put by objs.tables.st) id tabl)
548+ [st id]
549+++ zip
550+ |* [lhs=(list) rhs=(list)]
551+ ^- (list [_?<(?=(~ lhs) i.lhs) _?<(?=(~ rhs) i.rhs)])
552+ ?: |(?=(~ lhs) ?=(~ rhs)) ~
553+ [[i.lhs i.rhs] $(lhs t.lhs, rhs t.rhs)]
554+--
desk/lib/lua/parser.hoonnew file+1066
@@ -0,0 +1,1066 @@
1+/- *lua
2+/- *interlist
3+/+ st
4+/+ inter=interlist
5+=<
6+apex
7+|%
8+++ apex
9+ %^ tnee %apex chunk
10+ ;~ pfix
11+ %- punt
12+ ;~ plug
13+ hax
14+ (star ;~(less (just '\0a') next))
15+ ==
16+ ::
17+ %+ ifix [ws ws]
18+ (cook |=(=blok [%blok blok]) parse-blok)
19+ ==
20+:: The expressions that are separated by binary operators
21+::
22+++ parse-atomic-expr
23+ %^ tnee %parse-atomic-expr expr
24+ ;~ pose
25+ (cold [%nil ~] (jest 'nil'))
26+ ::
27+ (cold [%true ~] (jest 'true'))
28+ ::
29+ (cold [%false ~] (jest 'false'))
30+ ::
31+ %+ cook
32+ |=(=numeral [%num numeral])
33+ parse-numeral
34+ ::
35+ %+ cook
36+ |=(=prefix-expr (unwrap-prefix [%prefix-expr prefix-expr]))
37+ (knee *prefix-expr |.(parse-prefix-expr))
38+ ::
39+ %+ cook
40+ |=(=table [%table table])
41+ parse-table
42+ ::
43+ %+ cook
44+ |=(=string [%string string])
45+ parse-string
46+ ::
47+ (cold [%wildcard ~] (jest '...'))
48+ ::
49+ %+ cook
50+ |=(=funcbody [%functiondef funcbody])
51+ ;~ pfix
52+ (jest 'function')
53+ ws
54+ parse-funcbody
55+ ==
56+ ::
57+ ==
58+:: Parse expressions separated by binary operators
59+::
60+++ parse-expr-list
61+ %^ tnee %parse-expr-list ,(interlist binop [(list unop) expr])
62+ %+ parse:inter (ifix [ws ws] parse-binop)
63+ ;~ plug
64+ %- star
65+ ;~ pose
66+ ;~ sfix
67+ ;~ pose
68+ (cold %minus (just '-'))
69+ (cold %sig (just '~'))
70+ (cold %hax (just '#'))
71+ ==
72+ ws
73+ ==
74+ ;~ sfix
75+ (cold %not (jest 'not'))
76+ ;~(less parse-name ws)
77+ ==
78+ ==
79+ ::
80+ parse-atomic-expr
81+ ==
82+++ process-expr-list
83+ =<
84+ |= l=(interlist binop [(list unop) expr])
85+ ^- expr
86+ %- strip-tree
87+ %- (process-right-assoc ~[%pow])
88+ %- process-unops
89+ %- (process-left-assoc ~[%mul %div %int-div %mod])
90+ %- (process-left-assoc ~[%add %sub])
91+ %- (process-right-assoc ~[%concat])
92+ %- (process-left-assoc ~[%rshft %lshft])
93+ %- (process-left-assoc ~[%band])
94+ %- (process-left-assoc ~[%bxor])
95+ %- (process-left-assoc ~[%bor])
96+ %- (process-left-assoc ~[%lt %gt %lteq %gteq %neq %eq])
97+ %- (process-left-assoc ~[%and])
98+ %- (process-left-assoc ~[%or])
99+ (preprocess-tree l)
100+ |%
101+ +$ working-tree
102+ $%
103+ [%node l=working-tree n=binop r=working-tree]
104+ [%branch b=unop t=working-tree]
105+ [%tbd-unop l=(list [=expr =binop]) =unop r=working-tree]
106+ [%unoped l=(list [=expr =binop]) r=working-tree]
107+ [%leaf (interlist binop expr)]
108+ ==
109+ ++ preprocess-tree
110+ |= l=(interlist binop [(list unop) expr])
111+ ^- working-tree
112+ =/ splitted (find-unop l)
113+ ?~ splitted leaf+(turn:inter l |=([* =expr] expr))
114+ tbd-unop+[l.u.splitted unop.u.splitted $(l r.u.splitted)]
115+ ++ apply-unops
116+ |= [unops=(list unop) =expr]
117+ ^+ expr
118+ ?~ unops expr
119+ [%unop i.unops $(unops t.unops)]
120+ ++ strip-tree
121+ |= tree=working-tree
122+ ^- expr
123+ ?- -.tree
124+ %leaf ?> ?=(%single +<.tree) +>.tree
125+ %node [%binop $(tree l.tree) n.tree $(tree r.tree)]
126+ %branch [%unop b.tree $(tree t.tree)]
127+ %tbd-unop !!
128+ %unoped ?> =(~ l.tree) $(tree r.tree)
129+ ==
130+ ++ find-unop
131+ |= l=(interlist binop [(list unop) expr])
132+ ^- (unit [l=(list [=expr =binop]) =unop r=(interlist binop [(list unop) expr])])
133+ ?- -.l
134+ %single
135+ ?~ +<.l ~
136+ %- some
137+ [~ i.-.val.l single+[t.-.val.l +.val.l]]
138+ %double
139+ ?~ -.val.l
140+ %+ ^^bind $(l tail.l)
141+ |= [k=(list [expr binop]) =unop tail=(interlist binop [(list unop) expr])]
142+ [[[+.val.l sep.l] k] unop tail]
143+ %- some
144+ [~ i.-.val.l double+[[t.-.val.l +.val.l] sep.l tail.l]]
145+ ==
146+ ++ process-unops
147+ |= tree=working-tree
148+ ^- working-tree
149+ ?- -.tree
150+ %node node+[$(tree l.tree) n.tree $(tree r.tree)]
151+ %branch branch+[b.tree $(tree t.tree)]
152+ %tbd-unop unoped+[l.tree branch+[unop.tree $(tree r.tree)]]
153+ %leaf tree
154+ %unoped unoped+[l.tree $(tree r.tree)]
155+ ==
156+ ++ split-left-unop-list
157+ |= [is-pivot=$-(binop ?) l=(list [=expr =binop])]
158+ ^- (unit [l=(interlist binop expr) =binop r=(list [=expr =binop])])
159+ ?~ l ~
160+ ?: (is-pivot binop.i.l) `[single+expr.i.l binop.i.l t.l]
161+ =/ rest $(l t.l)
162+ ?~ rest ~
163+ `[double+[expr.i.l binop.i.l -.u.rest] +.u.rest]
164+ ++ split-right-unop-list
165+ |= [is-pivot=$-(binop ?) l=(list [=expr =binop])]
166+ ^- (unit [l=(interlist binop expr) =binop r=(list [=expr =binop])])
167+ =/ reversed=(unit [l=(list [=binop =expr]) =binop r=(interlist binop expr)])
168+ =/ l=(list [=binop =expr]) (flop (turn l swap))
169+ |-
170+ ?~ l ~
171+ ?: (is-pivot binop.i.l) `[~ binop.i.l (new:inter expr.i.l t.l)]
172+ =/ rest=(unit [l=(list [=binop =expr]) =binop r=(interlist binop expr)]) $(l t.l)
173+ ?~ rest ~
174+ `[[i.l l.u.rest] +.u.rest]
175+ ?~ reversed ~
176+ `[(reverse:inter r.u.reversed) binop.u.reversed (turn (flop l.u.reversed) swap)]
177+ ++ swap |*([a=* b=*] [b a])
178+ ++ process-right-assoc
179+ |= ops=(lest binop)
180+ |= tree=working-tree
181+ ^- working-tree
182+ ?- -.tree
183+ %leaf
184+ =/ l +.tree
185+ |-
186+ =/ splitted (split-left-on:inter |=(op=binop (elem op ops)) l)
187+ ?~ splitted [%leaf l]
188+ [%node $(l lhs.u.splitted) pivot.u.splitted $(l rhs.u.splitted)]
189+ %branch branch+[b.tree $(tree t.tree)]
190+ %tbd-unop
191+ =/ splitted
192+ (split-left-unop-list |=(op=binop (elem op ops)) l.tree)
193+ ?~ splitted tbd-unop+[l.tree unop.tree $(tree r.tree)]
194+ $(tree [%node $(tree leaf+l.u.splitted) binop.u.splitted tbd-unop+[r.u.splitted +>.tree]])
195+ %node
196+ [%node $(tree l.tree) n.tree $(tree r.tree)]
197+ %unoped
198+ =/ splitted
199+ (split-left-unop-list |=(op=binop (elem op ops)) l.tree)
200+ ?~ splitted unoped+[l.tree $(tree r.tree)]
201+ [%node $(tree leaf+l.u.splitted) binop.u.splitted $(tree unoped+[r.u.splitted r.tree])]
202+ ==
203+ ++ process-left-assoc
204+ |= ops=(lest binop)
205+ |= tree=working-tree
206+ ^- working-tree
207+ ?- -.tree
208+ %leaf
209+ =/ l +.tree
210+ |-
211+ ^- working-tree
212+ =/ splitted (split-right-on:inter |=(op=binop (elem op ops)) l)
213+ ?~ splitted [%leaf l]
214+ [%node $(l lhs.u.splitted) pivot.u.splitted $(l rhs.u.splitted)]
215+ %tbd-unop
216+ =/ splitted
217+ (split-right-unop-list |=(op=binop (elem op ops)) l.tree)
218+ ?~ splitted tbd-unop+[l.tree unop.tree $(tree r.tree)]
219+ $(tree [%node $(tree leaf+l.u.splitted) binop.u.splitted tbd-unop+[r.u.splitted +>.tree]])
220+ %node
221+ [%node $(tree l.tree) n.tree $(tree r.tree)]
222+ %branch
223+ [%branch b.tree $(tree t.tree)]
224+ %unoped
225+ =/ splitted
226+ (split-right-unop-list |=(op=binop (elem op ops)) l.tree)
227+ ?~ splitted unoped+[l.tree $(tree r.tree)]
228+ [%node $(tree leaf+l.u.splitted) binop.u.splitted $(tree unoped+[r.u.splitted +>.tree])]
229+ ==
230+ --
231+++ parse-expr
232+ %^ tnee %parse-expr expr
233+ %+ cook unwrap-prefix
234+ ;~ pose
235+ %+ cook process-expr-list parse-expr-list
236+ (ifix [;~(plug (just '(') ws) ;~(plug ws (just ')'))] (knee *expr |.(parse-expr)))
237+ ==
238+++ parse-parened-expr
239+ %^ tnee %parse-parened-expr prefix-expr
240+ %+ cook
241+ |=([=expr] [%expr expr])
242+ (ifix [(just '(') (just ')')] (knee *expr |.(parse-expr)))
243+++ parse-string
244+ %^ tnee %parse-string string
245+ =>
246+ |%
247+ ++ parse-string
248+ |= quot=char
249+ =/ quot (just quot)
250+ %+ cook
251+ |=([* =tape *] tape)
252+ ;~ plug
253+ quot
254+ %+ cook zing
255+ %- star
256+ ;~ less quot
257+ ;~ pose
258+ %+ cold ~['\07'] (jest '\\a')
259+ %+ cold ~['\08'] (jest '\\b')
260+ %+ cold ~['\0c'] (jest '\\f')
261+ %+ cold ~['\0a'] (jest '\\n')
262+ %+ cold ~['\0d'] (jest '\\r')
263+ %+ cold ~['\09'] (jest '\\t')
264+ %+ cold ~['\0b'] (jest '\\v')
265+ %+ cold ~['\\'] (jest '\\\\')
266+ %+ cold ~['"'] (jest '\\"')
267+ %+ cold ~['\''] (jest '\\\'')
268+ %+ cold ~['\0a'] (jest '\\\0a')
269+ %+ cold ~ ;~(plug (jest '\\z') gaw)
270+ ::
271+ ;~ pfix
272+ (jest '\\x')
273+ ;< hex-digits=tape bind ;~(plug next next (easy ~))
274+ =/ digit=(unit @) (rust hex-digits hex)
275+ ?~ digit fail (easy ~[`@`u.digit])
276+ ==
277+ ::
278+ ;~ pfix
279+ (jest '\\')
280+ ;< digits=tape bind (stun [1 3] (shim '0' '9'))
281+ =/ digit=(unit @) (rust digits dem)
282+ ?~ digit fail (easy ~[`@`u.digit])
283+ ==
284+ ::
285+ %+ cook
286+ |= [* point=@ *] ~[point]
287+ ;~ plug
288+ (jest '\\u{')
289+ hex
290+ (just '}')
291+ ==
292+ ::
293+ %+ cook |=(char=@ ~[char])
294+ next
295+ ==
296+ ==
297+ quot
298+ ==
299+ --
300+ ;~ pose
301+ (parse-string '"')
302+ (parse-string '\'')
303+ ::
304+ %- long-brackets
305+ |* closing=rule
306+ ;~ pfix
307+ (punt nl)
308+ %- star
309+ ;~ less closing next
310+ ==
311+ ==
312+ ==
313+++ parse-table
314+ %^ tnee %parse-table table
315+ %+ cook
316+ |=([* =table *] table)
317+ ;~ (glue ws)
318+ (just '{')
319+ parse-field-list
320+ (just '}')
321+ ==
322+++ parse-field-list
323+ %^ tnee %parse-field-list field-list
324+ =>
325+ |%
326+ ++ field-sep
327+ ;~ pose
328+ com
329+ mic
330+ ==
331+ --
332+ %+ cook
333+ |=([=field-list *] field-list)
334+ ;~ (glue ws)
335+ (more (ifix [ws ws] field-sep) parse-field)
336+ (punt field-sep)
337+ ==
338+++ parse-field
339+ %+ knee *field
340+ |.
341+ %^ tnee %parse-field field
342+ ;~ pose
343+ %+ cook
344+ |=([* key=expr * * val=expr] [%keyed key val])
345+ ;~ (glue ws)
346+ (just '[')
347+ parse-expr
348+ (just ']')
349+ tis
350+ parse-expr
351+ ==
352+ ::
353+ %+ cook
354+ |=([=name * =expr] [%keyed [%string (trip name)] expr])
355+ ;~ (glue ws)
356+ parse-name
357+ tis
358+ parse-expr
359+ ==
360+ ::
361+ %+ cook
362+ |=(=expr [%unkeyed expr])
363+ parse-expr
364+ ==
365+++ parse-binop
366+ %^ tnee %parse-binop binop
367+ ;~ pose
368+ (cold %add (jest '+'))
369+ (cold %sub (jest '-'))
370+ (cold %mul (jest '*'))
371+ (cold %int-div (jest '//'))
372+ (cold %div (jest '/'))
373+ (cold %pow (jest '^'))
374+ (cold %mod (jest '%'))
375+ (cold %band (jest '&'))
376+ (cold %bor (jest '|'))
377+ (cold %eq (jest '=='))
378+ (cold %rshft (jest '>>'))
379+ (cold %lshft (jest '<<'))
380+ (cold %lteq (jest '<='))
381+ (cold %gteq (jest '>='))
382+ (cold %neq (jest '~='))
383+ (cold %bxor (jest '~'))
384+ (cold %and (jest 'and'))
385+ (cold %or (jest 'or'))
386+ (cold %lt (jest '<'))
387+ (cold %gt (jest '>'))
388+ (cold %concat (jest '..'))
389+ ==
390+++ parse-numeral
391+ %^ tnee %parse-numeral numeral
392+ ;~ pose
393+ %+ cook
394+ |= x=@rd [%float x]
395+ parse-hex-float
396+ ::
397+ %+ cook
398+ |= x=@u [%int (new:st x)]
399+ ;~ pfix
400+ (just '0')
401+ (mask "xX")
402+ hex
403+ ==
404+ ::
405+ %+ cook
406+ |= x=@rd [%float x]
407+ parse-float
408+ ::
409+ %+ cook
410+ |= x=@u
411+ ?: (gth x max-int)
412+ [%float (sun:rd x)]
413+ [%int (new:st x)]
414+ (bass 10 (plus dit))
415+ ==
416+++ parse-exprlist
417+ %^ tnee %parse-exprlist exprlist
418+ %+ most (ifix [ws ws] com) parse-expr
419+++ parse-var
420+ %^ tnee %parse-var var
421+ ;< prefix=prefix-expr bind parse-prefix-expr
422+ ?: ?=(%var -.prefix) (easy +.prefix) fail
423+++ parse-varlist
424+ %^ tnee %parse-varlist varlist
425+ %+ most (ifix [ws ws] com) parse-var
426+++ parse-prefix-expr
427+ %^ tnee %parse-prefix-expr prefix-expr
428+ =<
429+ ;< prefix=prefix-expr bind
430+ ;~ pose
431+ %+ cook |=(=name [%var %name name])
432+ parse-name
433+ ::
434+ parse-parened-expr
435+ ==
436+ (recurse-prefix-var prefix)
437+ |%
438+ :: Takes a prefix (initially [%var ...]) and applies variable access and function calls.
439+ :: This completely sidesteps calling the var parser.
440+ ::
441+ ++ recurse-prefix-var
442+ |= prefix=prefix-expr
443+ %^ tnee %recurse-prefix-var prefix-expr
444+ ;~ pose
445+ ;< =var bind
446+ ;~ pose
447+ (parse-access prefix)
448+ (parse-dot prefix)
449+ ==
450+ (recurse-prefix-var [%var var])
451+ ::
452+ ;< prefix=prefix-expr bind
453+ %+ cook |=(=functioncall [%call functioncall])
454+ (parse-functioncall-args prefix)
455+ (recurse-prefix-var prefix)
456+ ::
457+ (easy prefix)
458+ ==
459+ ++ parse-access
460+ |= =prefix-expr
461+ %+ cook
462+ |=([* =expr *] [%indexed prefix-expr expr])
463+ ;~ (glue ws)
464+ (just '[')
465+ parse-expr
466+ (just ']')
467+ ==
468+ ++ parse-dot
469+ |= =prefix-expr
470+ %+ cook
471+ |=([* =name] [%dot prefix-expr name])
472+ ;~ (glue ws)
473+ dot
474+ parse-name
475+ ==
476+ --
477+++ parse-stat
478+ %+ knee *stat
479+ |.
480+ %^ tnee %parse-stat stat
481+ ;~ pose
482+ (cold [%empty ~] (just ';'))
483+ ::
484+ (cold [%break ~] (jest 'break'))
485+ ::
486+ %+ cook
487+ |= [* cond=expr * body=blok] [%while cond body]
488+ ;~ (glue wss)
489+ (jest 'while')
490+ parse-expr
491+ (jest 'do')
492+ ;< body=blok bind parse-blok
493+ ;~ pfix
494+ ?: (blok-is-empty body) ws wss
495+ (jest 'end')
496+ (easy body)
497+ ==
498+ ==
499+ ::
500+ %+ cook
501+ |= [* body=blok cond=expr] [%repeat body cond]
502+ ;~ (glue wss)
503+ (jest 'repeat')
504+ ;< body=blok bind parse-blok
505+ ;~ pfix
506+ ?: (blok-is-empty body) ws wss
507+ (jest 'until')
508+ (easy body)
509+ ==
510+ parse-expr
511+ ==
512+ ::
513+ %+ cook
514+ |= [* =label] [%goto label]
515+ ;~ (glue ws)
516+ (jest 'goto')
517+ parse-name
518+ ==
519+ ::
520+ %+ cook
521+ |= =if [%if if]
522+ parse-if
523+ ::
524+ %+ cook
525+ |= =label [%label label]
526+ parse-label
527+ ::
528+ %+ cook
529+ |=([* =blok *] [%blok blok])
530+ ;~ (glue wss)
531+ (jest 'do')
532+ (knee *blok |.(parse-blok))
533+ (jest 'end')
534+ ==
535+ ::
536+ %+ cook
537+ |=([=varlist * =exprlist] [%asmnt varlist exprlist])
538+ ;~ (glue ws)
539+ parse-varlist
540+ (just '=')
541+ parse-exprlist
542+ ==
543+ ::
544+ %+ cook
545+ |= =functioncall [%func-call functioncall]
546+ parse-functioncall
547+ ::
548+ %+ cook
549+ |= =for-range [%for-range for-range]
550+ parse-for-range
551+ ::
552+ %+ cook
553+ |= =for-in [%for-in for-in]
554+ parse-for-in
555+ ::
556+ %+ cook
557+ |= =function [%function function]
558+ parse-function
559+ ::
560+ %+ cook
561+ |= =local-function [%local-function local-function]
562+ parse-local-function
563+ ::
564+ %+ cook
565+ |= =local-asmnt [%local-asmnt local-asmnt]
566+ parse-local-asmnt
567+ ==
568+++ parse-local-asmnt
569+ %^ tnee %parse-local-asmnt local-asmnt
570+ %+ cook
571+ |= [* * =attrnamelist rhs=(unit explist)] [attrnamelist rhs]
572+ ;~ plug
573+ (jest 'local')
574+ wss
575+ parse-attnamelist
576+ %- punt
577+ ;~ pfix
578+ ws
579+ (just '=')
580+ ws
581+ parse-explist
582+ ==
583+ ==
584+++ parse-attnamelist
585+ %^ tnee %parse-attnamelist attrnamelist
586+ %+ most (ifix [ws ws] com)
587+ ;~ plug
588+ parse-name
589+ ::
590+ %- punt
591+ %+ cook |= [* * =attrib *] attrib
592+ ;~ plug
593+ ws
594+ (just '<')
595+ ;~ pose
596+ %+ cold %const (jest 'const')
597+ %+ cold %close (jest 'close')
598+ ==
599+ (just '>')
600+ ==
601+ ==
602+++ parse-for-range
603+ %^ tnee %for-range for-range
604+ %+ cook
605+ |= [* * var=name * * * from=expr * * * to=expr by=(unit expr) * * * body=blok *]
606+ [var from to by body]
607+ ;~ plug
608+ (jest 'for')
609+ wss
610+ parse-name
611+ ws
612+ (jest '=')
613+ ws
614+ parse-expr
615+ ws
616+ (jest ',')
617+ ws
618+ parse-expr
619+ %- punt
620+ %+ cook |=([* * * =expr] expr)
621+ ;~ plug
622+ ws
623+ (jest ',')
624+ ws
625+ parse-expr
626+ ==
627+ wss
628+ (jest 'do')
629+ wss
630+ ;< body=blok bind parse-blok
631+ ;~ pfix
632+ ?: (blok-is-empty body) ws wss
633+ (easy body)
634+ ==
635+ (jest 'end')
636+ ==
637+++ parse-function
638+ %^ tnee %parse-function function
639+ %+ cook
640+ |= [* * name=funcname * body=funcbody]
641+ [name body]
642+ ;~ plug
643+ (jest 'function')
644+ wss
645+ parse-funcname
646+ ws
647+ parse-funcbody
648+ ==
649+++ parse-local-function
650+ %^ tnee %parse-local-function local-function
651+ %+ cook
652+ |= [* * * * =name * body=funcbody]
653+ [name body]
654+ ;~ plug
655+ (jest 'local')
656+ wss
657+ (jest 'function')
658+ wss
659+ parse-name
660+ ws
661+ parse-funcbody
662+ ==
663+++ parse-funcname
664+ %^ tnee %parse-funcname funcname
665+ ;~ plug
666+ %+ most dot parse-name
667+ ::
668+ %- punt
669+ ;~ pfix
670+ col
671+ parse-name
672+ ==
673+ ==
674+++ parse-funcbody
675+ %^ tnee %parse-funcbody funcbody
676+ %+ cook
677+ |= [* * pars=parlist * * * body=blok *] [pars body]
678+ ;~ plug
679+ (just '(')
680+ ws
681+ parse-parlist
682+ ws
683+ (just ')')
684+ ws
685+ ::
686+ ;< body=blok bind parse-blok
687+ ;~ pfix
688+ ?: (blok-is-empty body) ws wss
689+ (easy body)
690+ ==
691+ ::
692+ (jest 'end')
693+ ==
694+++ parse-parlist
695+ %^ tnee %parse-parlist parlist
696+ ;~ pose
697+ %+ cold [~ &]
698+ (jest '...')
699+ ::
700+ ;~ plug
701+ %+ most (ifix [ws ws] com) parse-name
702+ ::
703+ %+ cook
704+ |= wildcard=(unit *) !.=(~ wildcard)
705+ %- punt
706+ ;~ plug
707+ ws
708+ com
709+ ws
710+ (jest '...')
711+ ==
712+ ==
713+ ::
714+ (easy [~ |])
715+ ==
716+++ parse-for-in
717+ %^ tnee %parse-for-in for-in
718+ %+ cook
719+ |= [* vars=namelist * src=explist * body=blok] [vars src body]
720+ ;~ (glue wss)
721+ (jest 'for')
722+ parse-namelist
723+ (jest 'in')
724+ parse-explist
725+ (jest 'do')
726+ ::
727+ ;< body=blok bind parse-blok
728+ ;~ pfix
729+ ?: (blok-is-empty) ws wss
730+ (jest 'end')
731+ (easy body)
732+ ==
733+ ==
734+++ parse-explist
735+ %^ tnee %parse-explist explist
736+ %+ most (ifix [ws ws] com) parse-expr
737+++ parse-namelist
738+ %^ tnee %parse-namelist namelist
739+ %+ most (ifix [ws ws] com) parse-name
740+++ parse-if
741+ %^ tnee %parse-if if
742+ %+ cook
743+ |= [[* cond=expr * body=blok] elsa=(list [cond=expr body=blok]) else=(unit blok) *]
744+ [cond body elsa else]
745+ ;~ plug
746+ ;~ (glue wss)
747+ (jest 'if')
748+ parse-expr
749+ (jest 'then')
750+ parse-blok
751+ ==
752+ ::
753+ %- star
754+ %+ cook
755+ |= [* cond=expr * body=blok] [cond body]
756+ ;~ pfix
757+ wss
758+ ;~ (glue wss)
759+ (jest 'elseif')
760+ parse-expr
761+ (jest 'then')
762+ parse-blok
763+ ==
764+ ==
765+ ::
766+ ;< else-body=(unit blok) bind
767+ %- punt
768+ %+ cook
769+ |= [* =blok] blok
770+ ;~ pfix
771+ wss
772+ ;~ (glue wss)
773+ (jest 'else')
774+ parse-blok
775+ ==
776+ ==
777+ ;~ pfix
778+ ?~ else-body wss
779+ ?: (blok-is-empty u.else-body) ws wss
780+ (easy else-body)
781+ ==
782+ ::
783+ (jest 'end')
784+ ==
785+++ parse-functioncall
786+ %^ tnee %parse-functioncall functioncall
787+ ;< prefix=prefix-expr bind parse-prefix-expr
788+ ;~ pose
789+ (parse-functioncall-args prefix)
790+ ::
791+ ?: ?=(%call -.prefix) (easy +.prefix) fail
792+ ==
793+++ parse-functioncall-args
794+ |= =prefix-expr
795+ %^ tnee %parse-functioncall-args functioncall
796+ ;~ pfix
797+ ws
798+ ;~ pose
799+ %+ cook
800+ |= =args [%call prefix-expr args]
801+ parse-args
802+ ::
803+ %+ cook
804+ |= [* method=name =args]
805+ [%method prefix-expr method args]
806+ ;~ (glue ws)
807+ (just ':')
808+ parse-name
809+ parse-args
810+ ==
811+ ==
812+ ==
813+++ parse-args
814+ %^ tnee %parse-args args
815+ ;~ pose
816+ %+ cook
817+ |= [* args=(unit exprlist) *] args
818+ ;~ (glue ws)
819+ (just '(')
820+ (punt parse-exprlist)
821+ (just ')')
822+ ==
823+ ::
824+ %+ cook
825+ |= =table `~[[%table table]]
826+ parse-table
827+ ::
828+ %+ cook
829+ |= =string `~[[%string string]]
830+ parse-string
831+ ==
832+++ parse-label
833+ %^ tnee %parse-label label
834+ %+ cook
835+ |= [* =label *] label
836+ ;~ (glue ws)
837+ (jest '::')
838+ parse-name
839+ (jest '::')
840+ ==
841+++ parse-blok
842+ %^ tnee %parse-blok blok
843+ ;< stats=(list stat) bind (more ws parse-stat)
844+ %+ cook
845+ |= ret=(unit ret) [stats ret]
846+ %- punt
847+ ;~ pfix
848+ ?~ stats ws wss
849+ parse-ret
850+ ==
851+++ parse-ret
852+ %^ tnee %parse-ret ret
853+ %+ cook
854+ |= [* ret=(unit exprlist) *] ret
855+ ;~ plug
856+ (jest 'return')
857+ (punt ;~(pfix wss parse-exprlist))
858+ (punt ;~(plug ws (just ';')))
859+ ==
860+++ parse-name
861+ =>
862+ |%
863+ ++ name-char ;~(pose name-fst-char (shim '0' '9'))
864+ ++ name-fst-char ;~(pose alf:ab (just '_'))
865+ --
866+ %+ cook |= =tape (crip tape)
867+ ;~(less keyword ;~(plug name-fst-char (star name-char)))
868+++ bind
869+ |* =mold
870+ |* [prev=rule cont=$-(* rule)]
871+ |= =nail
872+ =/ prev-edge (prev nail)
873+ ?~ q.prev-edge prev-edge
874+ ((cont p.u.q.prev-edge) q.u.q.prev-edge)
875+++ comment
876+ ;~ pose
877+ %+ cold ~
878+ ;~ plug
879+ (jest '--')
880+ (long-brackets |*(closing=rule (star ;~(less closing next))))
881+ ==
882+ %+ cold ~
883+ ;~ plug
884+ (jest '--')
885+ (star ;~(less nl next))
886+ ==
887+ ==
888+++ nl (just '\0a')
889+++ w
890+ ;~ pose
891+ comment
892+ gah
893+ (just '\09')
894+ ==
895+++ ws
896+ %+ cold ~
897+ %- star w
898+++ wss
899+ %+ cold ~
900+ %- plus w
901+++ parse-float
902+ %^ tnee %parse-float @rd
903+ %+ cook ryld
904+ %+ cook royl-cell:so
905+ %+ sear
906+ |= [leading-zeros=tape int=(unit @) frac=(unit (unit [@ @])) exp=(unit [exp-sign=? exp=@])]
907+ =/ int=(unit @) ?~(int ?:(?=(~ leading-zeros) ~ `0) int)
908+ ?: ?=([~ ~ ~] [int frac exp]) ~
909+ ?: ?=([~ [~ ~]] [int frac]) ~
910+ :: If there is no fractional or exponential part it should just be an int.
911+ ?: ?=([~ ~] [frac exp]) ~
912+ %- some
913+ :*
914+ %d
915+ &
916+ (fall int 0)
917+ (fall (fall frac `[0 0]) [0 0])
918+ (fall exp [& 0])
919+ ==
920+ =/ moo
921+ |= a=tape
922+ :- (lent a)
923+ (scan a (bass 10 (plus sid:ab)))
924+ ;~ plug
925+ (star (just '0'))
926+ (punt dim:ag)
927+ ::
928+ (punt ;~(pfix dot (punt (cook moo (plus (shim '0' '9'))))))
929+ ::
930+ %- punt
931+ ;~ pfix
932+ (mask "eE")
933+ ;~(plug ;~(pose (cold | hep) (cold & lus) (easy &)) dum:ag)
934+ ==
935+ ==
936+++ parse-hex-float
937+ %^ tnee %parse-hex-float @rd
938+ =<
939+ %+ sear
940+ |= [* * int=tape frac=(unit tape) exp=(unit [exp-sign=? exp=@])]
941+ ?: ?=([~ ~] [frac exp]) ~
942+ ?: ?=([~ ~] [int frac]) ~
943+ %- some
944+ =/ frac (fall frac "")
945+ =/ whole=@rd (sun:rd (scan (weld int frac) hex))
946+ =/ frac-exp=@rd (sun:rd (pow 16 (lent frac)))
947+ =/ without-exp (div:rd whole frac-exp)
948+ ?~ exp without-exp
949+ =/ exp-exp (sun:rd (pow 2 exp.u.exp))
950+ ?: exp-sign.u.exp
951+ (mul:rd without-exp exp-exp)
952+ (div:rd without-exp exp-exp)
953+ ;~ plug
954+ (just '0')
955+ ::
956+ (mask "xX")
957+ ::
958+ (star hex-digit)
959+ ::
960+ %- punt
961+ ;~ pfix
962+ dot
963+ (plus hex-digit)
964+ ==
965+ ::
966+ %- punt
967+ ;~ pfix
968+ (mask "pP")
969+ ;~(plug ;~(pose (cold | hep) (cold & lus) (easy &)) dim:ag)
970+ ==
971+ ==
972+ |%
973+ ++ hex-digit
974+ %^ tnee %hex-digit char
975+ ;~ pose
976+ (shim '0' '9')
977+ (shim 'a' 'f')
978+ (shim 'A' 'F')
979+ ==
980+ --
981+++ long-brackets
982+ |* inner=$-(rule rule)
983+ ;< longness=@t bind
984+ %+ cook
985+ |= [* =tape *] (crip tape)
986+ ;~ plug
987+ (just '[')
988+ (star (just '='))
989+ (just '[')
990+ ==
991+ =/ closing
992+ %+ cold ~
993+ ;~ plug
994+ (just ']')
995+ (jest longness)
996+ (just ']')
997+ ==
998+ ;< res=_p:(need q:$:$:inner) bind (inner closing)
999+ %+ cold res closing
1000+++ keyword
1001+ =<
1002+ %+ sear
1003+ |= word=tape
1004+ ^- (unit ~)
1005+ ?: (elem word keyword-names) `~ ~
1006+ (plus alf:ab)
1007+ |%
1008+ ++ keyword-names
1009+ :~
1010+ "and"
1011+ "break"
1012+ "do"
1013+ "else"
1014+ "elseif"
1015+ "end"
1016+ "false"
1017+ "for"
1018+ "function"
1019+ "goto"
1020+ "if"
1021+ "in"
1022+ "local"
1023+ "nil"
1024+ "not"
1025+ "or"
1026+ "repeat"
1027+ "return"
1028+ "then"
1029+ "true"
1030+ "until"
1031+ "while"
1032+ ==
1033+ --
1034+++ tnee
1035+ |* [=term gar=mold sef=rule]
1036+ |= tub=nail
1037+ ^- (like gar)
1038+ =/ trace |
1039+ ~? trace [p.p.tub term `tape`(scag 40 q.tub)]
1040+ =/ res (sef tub)
1041+ ?. trace res
1042+ ?~ q.res
1043+ ~& [term %nope] res
1044+ ~& > [term %ok] res
1045+++ neg
1046+ |* =rule
1047+ |= =nail
1048+ ^- (like ~)
1049+ =/ x (rule nail)
1050+ :- p.nail
1051+ ?~ q.x `[~ nail] ~
1052+++ blok-is-empty
1053+ |= =blok
1054+ ^- ?
1055+ &(?=(~ body.blok) ?=(~ ret.blok))
1056+++ max-int 9.223.372.036.854.775.807
1057+++ elem
1058+ |= [nedl=* stak=(list *)]
1059+ ^- ?
1060+ ?=(^ (find ~[nedl] stak))
1061+++ unwrap-prefix
1062+ |= x=expr
1063+ ^- expr
1064+ ?: ?=([%prefix-expr %expr *] x) $(x +>.x)
1065+ x
1066+--
desk/lib/lua/printer.hoonnew file+526
@@ -0,0 +1,526 @@
1+/- *lua
2+/+ st
3+=<
4+print
5+|%
6+:: AST
7+::
8+++ print
9+ |= [=chunk]
10+ ^- tape
11+ ?- -.chunk
12+ %blok (print-blok +.chunk)
13+ ==
14+:: Expr
15+::
16+++ print-expr
17+ |= [=expr]
18+ ^- tape
19+ ?- -.expr
20+ %prefix-expr (print-prefix-expr +.expr)
21+ %nil "nil"
22+ %true "true"
23+ %false "false"
24+ %binop
25+ %- zing
26+ :~
27+ "("
28+ (print-expr +<.expr)
29+ " "
30+ (print-binop +>-.expr)
31+ " "
32+ (print-expr +>+.expr)
33+ ")"
34+ ==
35+ %num (print-numeral +.expr)
36+ %table (print-table +.expr)
37+ %string (print-string +.expr)
38+ %wildcard "..."
39+ %functiondef (zing ~["function " (print-funcbody +.expr)])
40+ %unop
41+ %- zing
42+ :~
43+ "("
44+ (print-unop +<.expr)
45+ " "
46+ (print-expr +>.expr)
47+ ")"
48+ ==
49+ ==
50+:: unop
51+::
52+++ print-unop
53+ |= =unop
54+ ^- tape
55+ ?- unop
56+ %minus "-"
57+ %not "not"
58+ %hax "#"
59+ %sig "~"
60+ ==
61+:: string
62+::
63+++ print-string
64+ |= =string
65+ %- zing
66+ :~
67+ "\""
68+ ::
69+ ^- tape
70+ %- zing
71+ %+ turn string
72+ |= char=@t
73+ ^- tape
74+ %- zing
75+ :~
76+ "\\u\{"
77+ ((x-co:co 1) char)
78+ "}"
79+ ==
80+ "\""
81+ ==
82+:: table
83+::
84+++ print-table
85+ |= =table
86+ ^- tape
87+ %- zing
88+ :~
89+ "\{"
90+ (print-field-list table)
91+ "}"
92+ ==
93+:: field-list
94+::
95+++ print-field-list
96+ |= =field-list
97+ ^- tape
98+ %- commaed
99+ %+ turn field-list print-field
100+:: field
101+::
102+++ print-field
103+ |= =field
104+ ^- tape
105+ ?- -.field
106+ %keyed
107+ %- zing
108+ :~
109+ "["
110+ (print-expr +<.field)
111+ "] = "
112+ (print-expr +>.field)
113+ ==
114+ %unkeyed
115+ (print-expr +.field)
116+ ==
117+:: binop
118+::
119+++ print-binop
120+ |= [=binop]
121+ ?- binop
122+ %add "+"
123+ %sub "-"
124+ %mul "*"
125+ %div "/"
126+ %int-div "//"
127+ %pow "^"
128+ %mod "%"
129+ %band "&"
130+ %bor "|"
131+ %bxor "~"
132+ %rshft ">>"
133+ %lshft "<<"
134+ %and "and"
135+ %or "or"
136+ %lt "<"
137+ %lteq "<="
138+ %eq "=="
139+ %gt ">"
140+ %gteq ">="
141+ %neq "~="
142+ %concat ".."
143+ ==
144+:: numeral
145+::
146+++ print-numeral
147+ |= [num=numeral]
148+ ^- tape
149+ ?- -.num
150+ %int (z-co:co +.num)
151+ %float (show-float +.num)
152+ ==
153+:: exprlist
154+::
155+++ print-exprlist
156+ |= [=exprlist]
157+ %- commaed
158+ %+ turn exprlist print-expr
159+:: Var
160+::
161+++ print-var
162+ |= [=var]
163+ ^- tape
164+ ?- -.var
165+ %name (trip +.var)
166+ %indexed
167+ %- zing
168+ :~
169+ (print-prefix-expr +<.var)
170+ "["
171+ (print-expr +>.var)
172+ "]"
173+ ==
174+ %dot
175+ %- zing
176+ :~
177+ (print-prefix-expr +<.var)
178+ "."
179+ (trip +>.var)
180+ ==
181+ ==
182+:: varlist
183+::
184+++ print-varlist
185+ |= [=varlist]
186+ %- commaed
187+ %+ turn varlist print-var
188+:: Prefix Expr
189+::
190+++ print-prefix-expr
191+ |= [=prefix-expr]
192+ ?- -.prefix-expr
193+ %var (print-var +.prefix-expr)
194+ %expr
195+ :: since binops already have parens
196+ ?: ?=(%binop +<.prefix-expr) (print-expr +.prefix-expr)
197+ %- zing
198+ :~
199+ "("
200+ (print-expr +.prefix-expr)
201+ ")"
202+ ==
203+ %call (print-functioncall +.prefix-expr)
204+ ==
205+:: stat
206+::
207+++ print-stat
208+ |= [=stat]
209+ ^- tape
210+ ?- -.stat
211+ %empty ";"
212+ %blok
213+ %- zing
214+ :~
215+ "do\0a"
216+ (print-blok +.stat)
217+ "\0aend"
218+ ==
219+ %asmnt
220+ %- zing
221+ :~
222+ (commaed (turn +<.stat print-var))
223+ "="
224+ (commaed (turn +>.stat print-expr))
225+ ==
226+ %label (print-label +.stat)
227+ %func-call (print-functioncall +.stat)
228+ %break "break"
229+ %goto
230+ %- zing
231+ :~
232+ "goto "
233+ (trip +.stat)
234+ ==
235+ %while
236+ %- zing
237+ :~
238+ "while "
239+ (print-expr cond.stat)
240+ " do\0a"
241+ (print-blok body.stat)
242+ "\0aend"
243+ ==
244+ %repeat
245+ %- zing
246+ :~
247+ "repeat\0a"
248+ (print-blok body.stat)
249+ "\0auntil "
250+ (print-expr cond.stat)
251+ ==
252+ %if (print-if +.stat)
253+ %for-range (print-for-range +.stat)
254+ %for-in (print-for-in +.stat)
255+ %function (print-function +.stat)
256+ %local-function (print-local-function +.stat)
257+ %local-asmnt (print-local-asmnt +.stat)
258+ ==
259+:: local-asmnt
260+::
261+++ print-local-asmnt
262+ |= =local-asmnt
263+ ^- tape
264+ %- zing
265+ :~
266+ "local "
267+ (print-attrnamelist attrnamelist.local-asmnt)
268+ ?~ rhs.local-asmnt ""
269+ %- zing
270+ :~
271+ " = "
272+ (print-explist u.rhs.local-asmnt)
273+ ==
274+ ==
275+:: attrnamelist
276+::
277+++ print-attrnamelist
278+ |= =attrnamelist
279+ ^- tape
280+ %- commaed
281+ %+ turn attrnamelist
282+ |= [=name attr=(unit attrib)]
283+ %- zing
284+ :~
285+ (trip name)
286+ ?~ attr ""
287+ %- zing
288+ :~
289+ " <"
290+ (trip `@t`u.attr)
291+ ">"
292+ ==
293+ ==
294+:: for-in
295+::
296+++ print-for-in
297+ |= =for-in
298+ ^- tape
299+ %- zing
300+ :~
301+ "for "
302+ (print-namelist vars.for-in)
303+ " in "
304+ (print-explist src.for-in)
305+ "\0ado\0a"
306+ (print-blok body.for-in)
307+ "\0aend"
308+ ==
309+:: explist
310+::
311+++ print-explist
312+ |= =explist
313+ ^- tape
314+ (commaed (turn explist print-expr))
315+:: namelist
316+::
317+++ print-namelist
318+ |= =namelist
319+ ^- tape
320+ (commaed (turn namelist trip))
321+:: for-range
322+::
323+++ print-for-range
324+ |= =for-range
325+ ^- tape
326+ %- zing
327+ :~
328+ "for "
329+ (trip var.for-range)
330+ " = "
331+ (print-expr from.for-range)
332+ ", "
333+ (print-expr to.for-range)
334+ ?~ by.for-range "" (zing ~[", " (print-expr u.by.for-range)])
335+ "\0ado\0a"
336+ (print-blok body.for-range)
337+ "\0aend"
338+ ==
339+:: local-function
340+::
341+++ print-local-function
342+ |= =local-function
343+ ^- tape
344+ %- zing
345+ :~
346+ "local function "
347+ (trip name.local-function)
348+ "\0a"
349+ (print-funcbody body.local-function)
350+ ==
351+:: function
352+::
353+++ print-function
354+ |= =function
355+ ^- tape
356+ %- zing
357+ :~
358+ "function "
359+ (print-funcname name.function)
360+ (print-funcbody body.function)
361+ ==
362+:: funcname
363+::
364+++ print-funcname
365+ |= =funcname
366+ ^- tape
367+ %- zing
368+ :~
369+ (dotted (turn nested.funcname trip))
370+ ::
371+ ?~ with-self.funcname ""
372+ %- zing ~[":" (trip u.with-self.funcname)]
373+ ==
374+:: funcbody
375+::
376+++ print-funcbody
377+ |= =funcbody
378+ ^- tape
379+ %- zing
380+ :~
381+ "("
382+ (print-parlist pars.funcbody)
383+ ")\0a"
384+ (print-blok body.funcbody)
385+ "\0aend"
386+ ==
387+:: parlist
388+::
389+++ print-parlist
390+ |= =parlist
391+ ^- tape
392+ %- zing
393+ :~
394+ (commaed (turn pars.parlist trip))
395+ ::
396+ ?. wildcard.parlist ""
397+ ?~ pars.parlist "..."
398+ ", ..."
399+ ==
400+:: if
401+::
402+++ print-if
403+ |= =if
404+ ^- tape
405+ %- zing
406+ :~
407+ "if "
408+ (print-expr cond.if)
409+ " then\0a"
410+ (print-blok body.if)
411+ ::
412+ ^- tape
413+ %- zing
414+ %+ turn elsa.if
415+ |= [cond=expr body=blok]
416+ %- zing
417+ :~
418+ "\0aelseif "
419+ (print-expr cond)
420+ " then\0a"
421+ (print-blok body)
422+ ==
423+ ::
424+ ?~ else.if ""
425+ ^- tape
426+ %- zing
427+ :~
428+ "\0aelse\0a"
429+ (print-blok u.else.if)
430+ ==
431+ ::
432+ "\0aend"
433+ ==
434+:: functioncall
435+::
436+++ print-functioncall
437+ |= call=functioncall
438+ ^- tape
439+ ?- -.call
440+ %call
441+ %- zing
442+ :~
443+ (print-prefix-expr func.call)
444+ (print-args args.call)
445+ ==
446+ %method
447+ %- zing
448+ :~
449+ (print-prefix-expr obj.call)
450+ ":"
451+ (trip method.call)
452+ (print-args args.call)
453+ ==
454+ ==
455+:: args
456+::
457+++ print-args
458+ |= =args
459+ ^- tape
460+ %- zing
461+ :~
462+ "("
463+ ?~ args "" (print-exprlist u.args)
464+ ")"
465+ ==
466+::
467+:: label
468+::
469+++ print-label
470+ |= =label
471+ ^- tape
472+ %- zing
473+ :~
474+ "::"
475+ (trip label)
476+ "::"
477+ ==
478+:: Blok
479+::
480+++ print-blok
481+ |= [=blok]
482+ ^- tape
483+ %- zing
484+ %+ join "\0a"
485+ %+ weld
486+ (turn body.blok print-stat)
487+ ?~ ret.blok ~
488+ ~[(print-ret u.ret.blok)]
489+:: ret
490+::
491+++ print-ret
492+ |= =ret
493+ ^- tape
494+ %- zing
495+ :~
496+ "return "
497+ ?~ ret "" (print-exprlist u.ret)
498+ ==
499+:: Helpers
500+::
501+++ commaed
502+ |= [l=(list tape)]
503+ ^- tape
504+ %- zing
505+ %+ join "," l
506+++ dotted
507+ |= [l=(list tape)]
508+ ^- tape
509+ %- zing
510+ %+ join "." l
511+++ show-s
512+ |=(s=@s `tape`(zing [?:((syn:si s) "" "-") ~[(slag 2 (scow %ui (abs:si s)))]]))
513+++ show-u
514+ |=(u=@u `tape`(slag 2 (scow %ui u)))
515+++ show-float
516+ |= x=@rd
517+ ^- tape
518+ =/ res
519+ %- r-co:co
520+ %- rlyd
521+ x
522+ :: if there is no dot then it will be interpreted as an int. add `.0` to force a float.
523+ ?: ?&(=(~ (find ~['.'] res)) =(~ (find ~['e'] res)))
524+ (weld res ".0")
525+ res
526+ --
desk/lib/lua/utils.hoonnew file+2
@@ -0,0 +1,2 @@
1+|%
2+--
desk/lib/st.hoonnew file+64
@@ -0,0 +1,64 @@
1+:: Two's complement encoded 64-bit signed integer
2+=<
3+|%
4+:: coerce an unsigned int to a signed int
5+::
6+++ new
7+ |= x=@u
8+ ^- @st
9+ (dis mask x)
10+++ to-s
11+ |= x=@st
12+ ^- @s
13+ (new:si ?!((sig x)) (abs x))
14+++ from-s
15+ |= x=@s
16+ ^- @st
17+ %- ?. (syn:si x) neg |=(x=@st x)
18+ (dis abs-mask (abs:si x))
19+++ neg
20+ |= x=@st
21+ ^- @st
22+ (dis mask +((mix mask x)))
23+++ sig
24+ |= x=@st
25+ ^- ?
26+ ?! =(0 (dis sign-mask x))
27+++ abs
28+ |= x=@st
29+ ^- @u
30+ ?. (sig x) `@u`x `@u`(neg x)
31+++ inc
32+ |= x=@st
33+ ^- @st
34+ (dis mask +(x))
35+++ add
36+ |= [x=@st y=@st]
37+ ^- @st
38+ (dis mask (^add x y))
39+++ sub
40+ |= [x=@st y=@st]
41+ ^- @st
42+ (from-s (dif:si (to-s x) (to-s y)))
43+++ mul
44+ |= [x=@st y=@st]
45+ ^- @st
46+ (from-s (pro:si (to-s x) (to-s y)))
47+++ div
48+ |= [x=@st y=@st]
49+ ^- @st
50+ =/ [x=@s y=@s] [(to-s x) (to-s y)]
51+ =/ fra (fra:si x y)
52+ =/ res (from-s fra)
53+ ?: |(=(0 (rem:si x y)) (syn:si fra)) res
54+ (dec res)
55+++ mod
56+ |= [x=@st y=@st]
57+ ^- @st
58+ (sub x (mul (div x y) y))
59+++ mask 0xffff.ffff.ffff.ffff
60+--
61+|%
62+++ abs-mask 0x7fff.ffff.ffff.ffff
63+++ sign-mask 0x8000.0000.0000.0000
64+--
desk/lib/strand.hoonnew file+1
@@ -0,0 +1 @@
1+rand
desk/lib/strandio.hoonnew file+832
@@ -0,0 +1,832 @@
1+/- spider
2+/+ libstrand=strand
3+=, strand=strand:libstrand
4+=, strand-fail=strand-fail:libstrand
5+|%
6+++ send-raw-cards
7+ |= cards=(list =card:agent:gall)
8+ =/ m (strand ,~)
9+ ^- form:m
10+ |= strand-input:strand
11+ [cards %done ~]
12+::
13+++ send-raw-card
14+ |= =card:agent:gall
15+ =/ m (strand ,~)
16+ ^- form:m
17+ (send-raw-cards card ~)
18+::
19+++ ignore
20+ |= tin=strand-input:strand
21+ `[%fail %ignore ~]
22+::
23+++ get-bowl
24+ =/ m (strand ,bowl:strand)
25+ ^- form:m
26+ |= tin=strand-input:strand
27+ `[%done bowl.tin]
28+::
29+++ get-beak
30+ =/ m (strand ,beak)
31+ ^- form:m
32+ |= tin=strand-input:strand
33+ `[%done [our q.byk da+now]:bowl.tin]
34+::
35+++ get-time
36+ =/ m (strand ,@da)
37+ ^- form:m
38+ |= tin=strand-input:strand
39+ `[%done now.bowl.tin]
40+::
41+++ get-our
42+ =/ m (strand ,ship)
43+ ^- form:m
44+ |= tin=strand-input:strand
45+ `[%done our.bowl.tin]
46+::
47+++ get-entropy
48+ =/ m (strand ,@uvJ)
49+ ^- form:m
50+ |= tin=strand-input:strand
51+ `[%done eny.bowl.tin]
52+::
53+:: Convert skips to %ignore failures.
54+::
55+:: This tells the main loop to try the next handler.
56+::
57+++ handle
58+ |* a=mold
59+ =/ m (strand ,a)
60+ |= =form:m
61+ ^- form:m
62+ |= tin=strand-input:strand
63+ =/ res (form tin)
64+ =? next.res ?=(%skip -.next.res)
65+ [%fail %ignore ~]
66+ res
67+::
68+:: Wait for a poke with a particular mark
69+::
70+++ take-poke
71+ |= =mark
72+ =/ m (strand ,vase)
73+ ^- form:m
74+ |= tin=strand-input:strand
75+ ?+ in.tin `[%skip ~]
76+ ~
77+ `[%wait ~]
78+ ::
79+ [~ %poke @ *]
80+ ?. =(mark p.cage.u.in.tin)
81+ `[%skip ~]
82+ `[%done q.cage.u.in.tin]
83+ ==
84+::
85+++ take-sign-arvo
86+ =/ m (strand ,[wire sign-arvo])
87+ ^- form:m
88+ |= tin=strand-input:strand
89+ ?+ in.tin `[%skip ~]
90+ ~
91+ `[%wait ~]
92+ ::
93+ [~ %sign *]
94+ `[%done [wire sign-arvo]:u.in.tin]
95+ ==
96+::
97+:: Wait for a subscription update on a wire
98+::
99+++ take-fact-prefix
100+ |= =wire
101+ =/ m (strand ,[path cage])
102+ ^- form:m
103+ |= tin=strand-input:strand
104+ ?+ in.tin `[%skip ~]
105+ ~ `[%wait ~]
106+ [~ %agent * %fact *]
107+ ?. =(watch+wire (scag +((lent wire)) wire.u.in.tin))
108+ `[%skip ~]
109+ `[%done (slag (lent wire) wire.u.in.tin) cage.sign.u.in.tin]
110+ ==
111+::
112+:: Wait for a subscription update on a wire
113+::
114+++ take-fact
115+ |= =wire
116+ =/ m (strand ,cage)
117+ ^- form:m
118+ |= tin=strand-input:strand
119+ ?+ in.tin `[%skip ~]
120+ ~ `[%wait ~]
121+ [~ %agent * %fact *]
122+ ?. =(watch+wire wire.u.in.tin)
123+ `[%skip ~]
124+ `[%done cage.sign.u.in.tin]
125+ ==
126+::
127+:: Wait for a subscription close
128+::
129+++ take-kick
130+ |= =wire
131+ =/ m (strand ,~)
132+ ^- form:m
133+ |= tin=strand-input:strand
134+ ?+ in.tin `[%skip ~]
135+ ~ `[%wait ~]
136+ [~ %agent * %kick *]
137+ ?. =(watch+wire wire.u.in.tin)
138+ `[%skip ~]
139+ `[%done ~]
140+ ==
141+::
142+++ echo
143+ =/ m (strand ,~)
144+ ^- form:m
145+ %- (main-loop ,~)
146+ :~ |= ~
147+ ^- form:m
148+ ;< =vase bind:m ((handle ,vase) (take-poke %echo))
149+ =/ message=tape !<(tape vase)
150+ %- (slog leaf+"{message}..." ~)
151+ ;< ~ bind:m (sleep ~s2)
152+ %- (slog leaf+"{message}.." ~)
153+ (pure:m ~)
154+ ::
155+ |= ~
156+ ^- form:m
157+ ;< =vase bind:m ((handle ,vase) (take-poke %over))
158+ %- (slog leaf+"over..." ~)
159+ (pure:m ~)
160+ ==
161+::
162+++ take-watch
163+ =/ m (strand ,path)
164+ |= tin=strand-input:strand
165+ ?+ in.tin `[%skip ~]
166+ ~ `[%wait ~]
167+ [~ %watch *]
168+ `[%done path.u.in.tin]
169+ ==
170+::
171+++ take-wake
172+ |= until=(unit @da)
173+ =/ m (strand ,~)
174+ ^- form:m
175+ |= tin=strand-input:strand
176+ ?+ in.tin `[%skip ~]
177+ ~ `[%wait ~]
178+ [~ %sign [%wait @ ~] %behn %wake *]
179+ ?. |(?=(~ until) =(`u.until (slaw %da i.t.wire.u.in.tin)))
180+ `[%skip ~]
181+ ?~ error.sign-arvo.u.in.tin
182+ `[%done ~]
183+ `[%fail %timer-error u.error.sign-arvo.u.in.tin]
184+ ==
185+::
186+++ take-tune
187+ |= =wire
188+ =/ m (strand ,[spar:ames (unit roar:ames)])
189+ ^- form:m
190+ |= tin=strand-input:strand
191+ ?+ in.tin `[%skip ~]
192+ ~ `[%wait ~]
193+ ::
194+ [~ %sign * %ames %tune ^ *]
195+ ?. =(wire wire.u.in.tin)
196+ `[%skip ~]
197+ `[%done +>.sign-arvo.u.in.tin]
198+ ==
199+::
200+++ take-near
201+ |= =wire
202+ =/ m (strand ,[spar:ames (unit (unit page))])
203+ ^- form:m
204+ |= tin=strand-input:strand
205+ ?+ in.tin `[%skip ~]
206+ ~ `[%wait ~]
207+ ::
208+ [~ %sign * %ames %near ^ *]
209+ ?. =(wire wire.u.in.tin)
210+ `[%skip ~]
211+ `[%done +>.sign-arvo.u.in.tin]
212+ ==
213+::
214+++ take-poke-ack
215+ |= =wire
216+ =/ m (strand ,~)
217+ ^- form:m
218+ |= tin=strand-input:strand
219+ ?+ in.tin `[%skip ~]
220+ ~ `[%wait ~]
221+ [~ %agent * %poke-ack *]
222+ ?. =(wire wire.u.in.tin)
223+ `[%skip ~]
224+ ?~ p.sign.u.in.tin
225+ `[%done ~]
226+ `[%fail %poke-fail u.p.sign.u.in.tin]
227+ ==
228+::
229+++ take-watch-ack
230+ |= =wire
231+ =/ m (strand ,~)
232+ ^- form:m
233+ |= tin=strand-input:strand
234+ ?+ in.tin `[%skip ~]
235+ ~ `[%wait ~]
236+ [~ %agent * %watch-ack *]
237+ ?. =(watch+wire wire.u.in.tin)
238+ `[%skip ~]
239+ ?~ p.sign.u.in.tin
240+ `[%done ~]
241+ `[%fail %watch-ack-fail u.p.sign.u.in.tin]
242+ ==
243+::
244+++ poke
245+ |= [=dock =cage]
246+ =/ m (strand ,~)
247+ ^- form:m
248+ =/ =card:agent:gall [%pass /poke %agent dock %poke cage]
249+ ;< ~ bind:m (send-raw-card card)
250+ (take-poke-ack /poke)
251+::
252+++ raw-poke
253+ |= [=dock =cage]
254+ =/ m (strand ,~)
255+ ^- form:m
256+ =/ =card:agent:gall [%pass /poke %agent dock %poke cage]
257+ ;< ~ bind:m (send-raw-card card)
258+ =/ m (strand ,~)
259+ ^- form:m
260+ |= tin=strand-input:strand
261+ ?+ in.tin `[%skip ~]
262+ ~
263+ `[%wait ~]
264+ ::
265+ [~ %agent * %poke-ack *]
266+ ?. =(/poke wire.u.in.tin)
267+ `[%skip ~]
268+ `[%done ~]
269+ ==
270+::
271+++ raw-poke-our
272+ |= [app=term =cage]
273+ =/ m (strand ,~)
274+ ^- form:m
275+ ;< =bowl:spider bind:m get-bowl
276+ (raw-poke [our.bowl app] cage)
277+::
278+++ poke-our
279+ |= [=term =cage]
280+ =/ m (strand ,~)
281+ ^- form:m
282+ ;< our=@p bind:m get-our
283+ (poke [our term] cage)
284+::
285+++ watch
286+ |= [=wire =dock =path]
287+ =/ m (strand ,~)
288+ ^- form:m
289+ =/ =card:agent:gall [%pass watch+wire %agent dock %watch path]
290+ ;< ~ bind:m (send-raw-card card)
291+ (take-watch-ack wire)
292+::
293+++ watch-one
294+ |= [=wire =dock =path]
295+ =/ m (strand ,cage)
296+ ^- form:m
297+ ;< ~ bind:m (watch wire dock path)
298+ ;< =cage bind:m (take-fact wire)
299+ ;< ~ bind:m (take-kick wire)
300+ (pure:m cage)
301+::
302+++ watch-our
303+ |= [=wire =term =path]
304+ =/ m (strand ,~)
305+ ^- form:m
306+ ;< our=@p bind:m get-our
307+ (watch wire [our term] path)
308+::
309+++ scry
310+ |* [=mold =path]
311+ =/ m (strand ,mold)
312+ ^- form:m
313+ ?> ?=(^ path)
314+ ?> ?=(^ t.path)
315+ ;< =bowl:spider bind:m get-bowl
316+ %- pure:m
317+ .^(mold i.path (scot %p our.bowl) i.t.path (scot %da now.bowl) t.t.path)
318+::
319+++ leave
320+ |= [=wire =dock]
321+ =/ m (strand ,~)
322+ ^- form:m
323+ =/ =card:agent:gall [%pass watch+wire %agent dock %leave ~]
324+ (send-raw-card card)
325+::
326+++ leave-our
327+ |= [=wire =term]
328+ =/ m (strand ,~)
329+ ^- form:m
330+ ;< our=@p bind:m get-our
331+ (leave wire [our term])
332+::
333+++ rewatch
334+ |= [=wire =dock =path]
335+ =/ m (strand ,~)
336+ ;< ~ bind:m ((handle ,~) (take-kick wire))
337+ ;< ~ bind:m (flog-text "rewatching {<dock>} {<path>}")
338+ ;< ~ bind:m (watch wire dock path)
339+ (pure:m ~)
340+::
341+++ wait
342+ |= until=@da
343+ =/ m (strand ,~)
344+ ^- form:m
345+ ;< ~ bind:m (send-wait until)
346+ (take-wake `until)
347+::
348+++ keen
349+ |= [=wire =spar:ames]
350+ =/ m (strand ,~)
351+ ^- form:m
352+ (send-raw-card %pass wire %arvo %a %keen ~ spar)
353+::
354+++ keen-shut
355+ |= [=wire =spar:ames]
356+ =/ m (strand ,~)
357+ ^- form:m
358+ (send-raw-card %pass wire %keen & spar)
359+::
360+++ sleep
361+ |= for=@dr
362+ =/ m (strand ,~)
363+ ^- form:m
364+ ;< now=@da bind:m get-time
365+ (wait (add now for))
366+::
367+++ send-wait
368+ |= until=@da
369+ =/ m (strand ,~)
370+ ^- form:m
371+ =/ =card:agent:gall
372+ [%pass /wait/(scot %da until) %arvo %b %wait until]
373+ (send-raw-card card)
374+::
375+++ map-err
376+ |* computation-result=mold
377+ =/ m (strand ,computation-result)
378+ |= [f=$-([term tang] [term tang]) computation=form:m]
379+ ^- form:m
380+ |= tin=strand-input:strand
381+ =* loop $
382+ =/ c-res (computation tin)
383+ ?: ?=(%cont -.next.c-res)
384+ c-res(self.next ..loop(computation self.next.c-res))
385+ ?. ?=(%fail -.next.c-res)
386+ c-res
387+ c-res(err.next (f err.next.c-res))
388+::
389+++ set-timeout
390+ |* computation-result=mold
391+ =/ m (strand ,computation-result)
392+ |= [time=@dr computation=form:m]
393+ ^- form:m
394+ ;< now=@da bind:m get-time
395+ =/ when (add now time)
396+ =/ =card:agent:gall
397+ [%pass /timeout/(scot %da when) %arvo %b %wait when]
398+ ;< ~ bind:m (send-raw-card card)
399+ |= tin=strand-input:strand
400+ =* loop $
401+ ?: ?& ?=([~ %sign [%timeout @ ~] %behn %wake *] in.tin)
402+ =((scot %da when) i.t.wire.u.in.tin)
403+ ==
404+ `[%fail %timeout ~]
405+ =/ c-res (computation tin)
406+ ?: ?=(%cont -.next.c-res)
407+ c-res(self.next ..loop(computation self.next.c-res))
408+ ?: ?=(%done -.next.c-res)
409+ =/ =card:agent:gall
410+ [%pass /timeout/(scot %da when) %arvo %b %rest when]
411+ c-res(cards [card cards.c-res])
412+ c-res
413+::
414+++ send-request
415+ |= =request:http
416+ =/ m (strand ,~)
417+ ^- form:m
418+ (send-raw-card %pass /request %arvo %i %request request *outbound-config:iris)
419+::
420+++ send-cancel-request
421+ =/ m (strand ,~)
422+ ^- form:m
423+ (send-raw-card %pass /request %arvo %i %cancel-request ~)
424+::
425+++ take-client-response
426+ =/ m (strand ,client-response:iris)
427+ ^- form:m
428+ |= tin=strand-input:strand
429+ ?+ in.tin `[%skip ~]
430+ ~ `[%wait ~]
431+ ::
432+ [~ %sign [%request ~] %iris %http-response %cancel *]
433+ ::NOTE iris does not (yet?) retry after cancel, so it means failure
434+ :- ~
435+ :+ %fail
436+ %http-request-cancelled
437+ ['http request was cancelled by the runtime']~
438+ ::
439+ [~ %sign [%request ~] %iris %http-response %finished *]
440+ `[%done client-response.sign-arvo.u.in.tin]
441+ ==
442+::
443+:: Wait until we get an HTTP response or cancelation and unset contract
444+::
445+++ take-maybe-sigh
446+ =/ m (strand ,(unit httr:eyre))
447+ ^- form:m
448+ ;< rep=(unit client-response:iris) bind:m
449+ take-maybe-response
450+ ?~ rep
451+ (pure:m ~)
452+ :: XX s/b impossible
453+ ::
454+ ?. ?=(%finished -.u.rep)
455+ (pure:m ~)
456+ (pure:m (some (to-httr:iris +.u.rep)))
457+::
458+++ take-maybe-response
459+ =/ m (strand ,(unit client-response:iris))
460+ ^- form:m
461+ |= tin=strand-input:strand
462+ ?+ in.tin `[%skip ~]
463+ ~ `[%wait ~]
464+ [~ %sign [%request ~] %iris %http-response %cancel *]
465+ `[%done ~]
466+ [~ %sign [%request ~] %iris %http-response %finished *]
467+ `[%done `client-response.sign-arvo.u.in.tin]
468+ ==
469+::
470+++ extract-body
471+ |= =client-response:iris
472+ =/ m (strand ,cord)
473+ ^- form:m
474+ ?> ?=(%finished -.client-response)
475+ %- pure:m
476+ ?~ full-file.client-response ''
477+ q.data.u.full-file.client-response
478+::
479+++ fetch-cord
480+ |= url=tape
481+ =/ m (strand ,cord)
482+ ^- form:m
483+ =/ =request:http [%'GET' (crip url) ~ ~]
484+ ;< ~ bind:m (send-request request)
485+ ;< =client-response:iris bind:m take-client-response
486+ (extract-body client-response)
487+::
488+++ fetch-json
489+ |= url=tape
490+ =/ m (strand ,json)
491+ ^- form:m
492+ ;< =cord bind:m (fetch-cord url)
493+ =/ json=(unit json) (de:json:html cord)
494+ ?~ json
495+ (strand-fail %json-parse-error ~)
496+ (pure:m u.json)
497+::
498+++ hiss-request
499+ |= =hiss:eyre
500+ =/ m (strand ,(unit httr:eyre))
501+ ^- form:m
502+ ;< ~ bind:m (send-request (hiss-to-request:html hiss))
503+ take-maybe-sigh
504+::
505+:: +build-file: build the source file at the specified $beam
506+::
507+++ build-file
508+ |= [[=ship =desk =case] =spur]
509+ =* arg +<
510+ =/ m (strand ,(unit vase))
511+ ^- form:m
512+ ;< =riot:clay bind:m
513+ (warp ship desk ~ %sing %a case spur)
514+ ?~ riot
515+ (pure:m ~)
516+ ?> =(%vase p.r.u.riot)
517+ (pure:m (some !<(vase q.r.u.riot)))
518+::
519+++ build-file-hard
520+ |= [[=ship =desk =case] =spur]
521+ =* arg +<
522+ =/ m (strand ,vase)
523+ ^- form:m
524+ ;< =riot:clay
525+ bind:m
526+ (warp ship desk ~ %sing %a case spur)
527+ ?> ?=(^ riot)
528+ ?> ?=(%vase p.r.u.riot)
529+ (pure:m !<(vase q.r.u.riot))
530+:: +build-mark: build a mark definition to a $dais
531+::
532+++ build-mark
533+ |= [[=ship =desk =case] mak=mark]
534+ =* arg +<
535+ =/ m (strand ,dais:clay)
536+ ^- form:m
537+ ;< =riot:clay bind:m
538+ (warp ship desk ~ %sing %b case /[mak])
539+ ?~ riot
540+ (strand-fail %build-mark >arg< ~)
541+ ?> =(%dais p.r.u.riot)
542+ (pure:m !<(dais:clay q.r.u.riot))
543+:: +build-tube: build a mark conversion gate ($tube)
544+::
545+++ build-tube
546+ |= [[=ship =desk =case] =mars:clay]
547+ =* arg +<
548+ =/ m (strand ,tube:clay)
549+ ^- form:m
550+ ;< =riot:clay bind:m
551+ (warp ship desk ~ %sing %c case /[a.mars]/[b.mars])
552+ ?~ riot
553+ (strand-fail %build-tube >arg< ~)
554+ ?> =(%tube p.r.u.riot)
555+ (pure:m !<(tube:clay q.r.u.riot))
556+::
557+:: +build-nave: build a mark definition to a $nave
558+::
559+++ build-nave
560+ |= [[=ship =desk =case] mak=mark]
561+ =* arg +<
562+ =/ m (strand ,vase)
563+ ^- form:m
564+ ;< =riot:clay bind:m
565+ (warp ship desk ~ %sing %e case /[mak])
566+ ?~ riot
567+ (strand-fail %build-nave >arg< ~)
568+ ?> =(%nave p.r.u.riot)
569+ (pure:m q.r.u.riot)
570+:: +build-cast: build a mark conversion gate (static)
571+::
572+++ build-cast
573+ |= [[=ship =desk =case] =mars:clay]
574+ =* arg +<
575+ =/ m (strand ,vase)
576+ ^- form:m
577+ ;< =riot:clay bind:m
578+ (warp ship desk ~ %sing %f case /[a.mars]/[b.mars])
579+ ?~ riot
580+ (strand-fail %build-cast >arg< ~)
581+ ?> =(%cast p.r.u.riot)
582+ (pure:m q.r.u.riot)
583+::
584+:: Read from Clay
585+::
586+++ warp
587+ |= [=ship =riff:clay]
588+ =/ m (strand ,riot:clay)
589+ ;< ~ bind:m (send-raw-card %pass /warp %arvo %c %warp ship riff)
590+ (take-writ /warp)
591+::
592+++ read-file
593+ |= [[=ship =desk =case] =spur]
594+ =* arg +<
595+ =/ m (strand ,cage)
596+ ;< =riot:clay bind:m (warp ship desk ~ %sing %x case spur)
597+ ?~ riot
598+ (strand-fail %read-file >arg< ~)
599+ (pure:m r.u.riot)
600+::
601+++ check-for-file
602+ |= [[=ship =desk =case] =spur]
603+ =/ m (strand ,?)
604+ ;< =riot:clay bind:m (warp ship desk ~ %sing %u case spur)
605+ ?> ?=(^ riot)
606+ (pure:m !<(? q.r.u.riot))
607+::
608+++ list-tree
609+ |= [[=ship =desk =case] =spur]
610+ =* arg +<
611+ =/ m (strand ,(list path))
612+ ;< =riot:clay bind:m (warp ship desk ~ %sing %t case spur)
613+ ?~ riot
614+ (strand-fail %list-tree >arg< ~)
615+ (pure:m !<((list path) q.r.u.riot))
616+::
617+:: Take Clay read result
618+::
619+++ take-writ
620+ |= =wire
621+ =/ m (strand ,riot:clay)
622+ ^- form:m
623+ |= tin=strand-input:strand
624+ ?+ in.tin `[%skip ~]
625+ ~ `[%wait ~]
626+ [~ %sign * ?(%behn %clay) %writ *]
627+ ?. =(wire wire.u.in.tin)
628+ `[%skip ~]
629+ `[%done +>.sign-arvo.u.in.tin]
630+ ==
631+:: +check-online: require that peer respond before timeout
632+::
633+++ check-online
634+ |= [who=ship lag=@dr]
635+ =/ m (strand ,~)
636+ ^- form:m
637+ %+ (map-err ,~) |=(* [%offline *tang])
638+ %+ (set-timeout ,~) lag
639+ ;< ~ bind:m
640+ (poke [who %hood] %helm-hi !>(~))
641+ (pure:m ~)
642+::
643+++ eval-hoon
644+ |= [gen=hoon bez=(list beam)]
645+ =/ m (strand ,vase)
646+ ^- form:m
647+ =/ sut=vase !>(..zuse)
648+ |-
649+ ?~ bez
650+ (pure:m (slap sut gen))
651+ ;< vax=vase bind:m (build-file-hard i.bez)
652+ $(bez t.bez, sut (slop vax sut))
653+::
654+++ send-thread
655+ |= [=bear:khan =shed:khan =wire]
656+ =/ m (strand ,~)
657+ ^- form:m
658+ (send-raw-card %pass wire %arvo %k %lard bear shed)
659+::
660+:: Queue on skip, try next on fail %ignore
661+::
662+++ main-loop
663+ |* a=mold
664+ =/ m (strand ,~)
665+ =/ m-a (strand ,a)
666+ =| queue=(qeu (unit input:strand))
667+ =| active=(unit [in=(unit input:strand) =form:m-a forms=(list $-(a form:m-a))])
668+ =| state=a
669+ |= forms=(lest $-(a form:m-a))
670+ ^- form:m
671+ |= tin=strand-input:strand
672+ =* top `form:m`..$
673+ =. queue (~(put to queue) in.tin)
674+ |^ (continue bowl.tin)
675+ ::
676+ ++ continue
677+ |= =bowl:strand
678+ ^- output:m
679+ ?> =(~ active)
680+ ?: =(~ queue)
681+ `[%cont top]
682+ =^ in=(unit input:strand) queue ~(get to queue)
683+ ^- output:m
684+ =. active `[in (i.forms state) t.forms]
685+ ^- output:m
686+ (run bowl in)
687+ ::
688+ ++ run
689+ ^- form:m
690+ |= tin=strand-input:strand
691+ ^- output:m
692+ ?> ?=(^ active)
693+ =/ res (form.u.active tin)
694+ =/ =output:m
695+ ?- -.next.res
696+ %wait `[%wait ~]
697+ %skip `[%cont ..$(queue (~(put to queue) in.tin))]
698+ %cont `[%cont ..$(active `[in.u.active self.next.res forms.u.active])]
699+ %done (continue(active ~, state value.next.res) bowl.tin)
700+ %fail
701+ ?: &(?=(^ forms.u.active) ?=(%ignore p.err.next.res))
702+ %= $
703+ active `[in.u.active (i.forms.u.active state) t.forms.u.active]
704+ in.tin in.u.active
705+ ==
706+ `[%fail err.next.res]
707+ ==
708+ [(weld cards.res cards.output) next.output]
709+ --
710+::
711+++ retry
712+ |* result=mold
713+ |= [crash-after=(unit @ud) computation=_*form:(strand (unit result))]
714+ =/ m (strand ,result)
715+ =| try=@ud
716+ |- ^- form:m
717+ =* loop $
718+ ?: =(crash-after `try)
719+ (strand-fail %retry-too-many ~)
720+ ;< ~ bind:m (backoff try ~m1)
721+ ;< res=(unit result) bind:m computation
722+ ?^ res
723+ (pure:m u.res)
724+ loop(try +(try))
725+::
726+++ backoff
727+ |= [try=@ud limit=@dr]
728+ =/ m (strand ,~)
729+ ^- form:m
730+ ;< eny=@uvJ bind:m get-entropy
731+ %- sleep
732+ %+ min limit
733+ ?: =(0 try) ~s0
734+ %+ add
735+ (mul ~s1 (bex (dec try)))
736+ (mul ~s0..0001 (~(rad og eny) 1.000))
737+::
738+:: ----
739+::
740+:: Output
741+::
742+++ flog
743+ |= =flog:dill
744+ =/ m (strand ,~)
745+ ^- form:m
746+ (send-raw-card %pass / %arvo %d %flog flog)
747+::
748+++ flog-text
749+ |= =tape
750+ =/ m (strand ,~)
751+ ^- form:m
752+ (flog %text tape)
753+::
754+++ flog-tang
755+ |= =tang
756+ =/ m (strand ,~)
757+ ^- form:m
758+ =/ =wall
759+ (zing (turn (flop tang) (cury wash [0 80])))
760+ |- ^- form:m
761+ =* loop $
762+ ?~ wall
763+ (pure:m ~)
764+ ;< ~ bind:m (flog-text i.wall)
765+ loop(wall t.wall)
766+::
767+++ trace
768+ |= =tang
769+ =/ m (strand ,~)
770+ ^- form:m
771+ (pure:m ((slog tang) ~))
772+::
773+++ app-message
774+ |= [app=term =cord =tang]
775+ =/ m (strand ,~)
776+ ^- form:m
777+ =/ msg=tape :(weld (trip app) ": " (trip cord))
778+ ;< ~ bind:m (flog-text msg)
779+ (flog-tang tang)
780+::
781+:: ----
782+::
783+:: Handle domains
784+::
785+++ install-domain
786+ |= =turf
787+ =/ m (strand ,~)
788+ ^- form:m
789+ (send-raw-card %pass / %arvo %e %rule %turf %put turf)
790+::
791+:: ----
792+::
793+:: Threads
794+::
795+++ start-thread
796+ |= file=term
797+ =/ m (strand ,tid:spider)
798+ ;< =bowl:spider bind:m get-bowl
799+ (start-thread-with-args byk.bowl file *vase)
800+::
801+++ start-thread-with-args
802+ |= [=beak file=term args=vase]
803+ =/ m (strand ,tid:spider)
804+ ^- form:m
805+ ;< =bowl:spider bind:m get-bowl
806+ =/ tid
807+ (scot %ta (cat 3 (cat 3 'strand_' file) (scot %uv (sham file eny.bowl))))
808+ =/ poke-vase !>(`start-args:spider`[`tid.bowl `tid beak file args])
809+ ;< ~ bind:m (poke-our %spider %spider-start poke-vase)
810+ ;< ~ bind:m (sleep ~s0) :: wait for thread to start
811+ (pure:m tid)
812+::
813++$ thread-result
814+ (each vase [term tang])
815+::
816+++ await-thread
817+ |= [file=term args=vase]
818+ =/ m (strand ,thread-result)
819+ ^- form:m
820+ ;< =bowl:spider bind:m get-bowl
821+ =/ tid (scot %ta (cat 3 'strand_' (scot %uv (sham file eny.bowl))))
822+ =/ poke-vase !>(`start-args:spider`[`tid.bowl `tid byk.bowl file args])
823+ ;< ~ bind:m (watch-our /awaiting/[tid] %spider /thread-result/[tid])
824+ ;< ~ bind:m (poke-our %spider %spider-start poke-vase)
825+ ;< ~ bind:m (sleep ~s0) :: wait for thread to start
826+ ;< =cage bind:m (take-fact /awaiting/[tid])
827+ ;< ~ bind:m (take-kick /awaiting/[tid])
828+ ?+ p.cage ~|([%strange-thread-result p.cage file tid] !!)
829+ %thread-done (pure:m %& q.cage)
830+ %thread-fail (pure:m %| ;;([term tang] q.q.cage))
831+ ==
832+--
zod/luau/mar/atom.hoon → desk/mar/atom.hoonrenamed

The content is the same.

zod/luau/mar/bill.hoon → desk/mar/bill.hoonrenamed

The content is the same.

zod/luau/mar/docket-0.hoon → desk/mar/docket-0.hoonrenamed

The content is the same.

zod/luau/mar/hoon.hoon → desk/mar/hoon.hoonrenamed

The content is the same.

zod/luau/mar/kelvin.hoon → desk/mar/kelvin.hoonrenamed

The content is the same.

desk/mar/lua.hoonnew file+17
@@ -0,0 +1,17 @@
1+|_ txt=wain
2+++ grad %mime
3+++ grow
4+ |%
5+ ++ mime
6+ ^- ^mime
7+ [/text/lua (as-octs:mimes:html (of-wain:format txt))]
8+ --
9+++ grab
10+ |%
11+ ++ noun wain
12+ ++ mime
13+ |= [=mite len=@ tex=@]
14+ (to-wain:format tex)
15+ --
16+--
17+
zod/luau/mar/mime.hoon → desk/mar/mime.hoonrenamed

The content is the same.

zod/luau/mar/noun.hoon → desk/mar/noun.hoonrenamed

The content is the same.

zod/luau/mar/ship.hoon → desk/mar/ship.hoonrenamed

The content is the same.

zod/luau/mar/txt.hoon → desk/mar/txt.hoonrenamed

The content is the same.

desk/res/lua/all.luanew file+312
@@ -0,0 +1,312 @@
1+#!../lua
2+-- $Id: testes/all.lua $
3+-- See Copyright Notice at the end of this file
4+
5+
6+local version = "Lua 5.4"
7+if _VERSION ~= version then
8+ io.stderr:write("This test suite is for ", version,
9+ ", not for ", _VERSION, "\nExiting tests")
10+ return
11+end
12+
13+
14+_G.ARG = arg -- save arg for other tests
15+
16+
17+-- next variables control the execution of some tests
18+-- true means no test (so an undefined variable does not skip a test)
19+-- defaults are for Linux; test everything.
20+-- Make true to avoid long or memory consuming tests
21+_soft = rawget(_G, "_soft") or false
22+-- Make true to avoid non-portable tests
23+_port = rawget(_G, "_port") or false
24+-- Make true to avoid messages about tests not performed
25+_nomsg = rawget(_G, "_nomsg") or false
26+
27+
28+local usertests = rawget(_G, "_U")
29+
30+if usertests then
31+ -- tests for sissies ;) Avoid problems
32+ _soft = true
33+ _port = true
34+ _nomsg = true
35+end
36+
37+-- tests should require debug when needed
38+debug = nil
39+
40+
41+if usertests then
42+ T = nil -- no "internal" tests for user tests
43+else
44+ T = rawget(_G, "T") -- avoid problems with 'strict' module
45+end
46+
47+
48+--[=[
49+ example of a long [comment],
50+ [[spanning several [lines]]]
51+
52+]=]
53+
54+print("\n\tStarting Tests")
55+
56+do
57+ -- set random seed
58+ local random_x, random_y = math.randomseed()
59+ print(string.format("random seeds: %d, %d", random_x, random_y))
60+end
61+
62+print("current path:\n****" .. package.path .. "****\n")
63+
64+
65+local initclock = os.clock()
66+local lastclock = initclock
67+local walltime = os.time()
68+
69+local collectgarbage = collectgarbage
70+
71+do -- (
72+
73+-- track messages for tests not performed
74+local msgs = {}
75+function Message (m)
76+ if not _nomsg then
77+ print(m)
78+ msgs[#msgs+1] = string.sub(m, 3, -3)
79+ end
80+end
81+
82+assert(os.setlocale"C")
83+
84+local T,print,format,write,assert,type,unpack,floor =
85+ T,print,string.format,io.write,assert,type,table.unpack,math.floor
86+
87+-- use K for 1000 and M for 1000000 (not 2^10 -- 2^20)
88+local function F (m)
89+ local function round (m)
90+ m = m + 0.04999
91+ return format("%.1f", m) -- keep one decimal digit
92+ end
93+ if m < 1000 then return m
94+ else
95+ m = m / 1000
96+ if m < 1000 then return round(m).."K"
97+ else
98+ return round(m/1000).."M"
99+ end
100+ end
101+end
102+
103+local Cstacklevel
104+
105+local showmem
106+if not T then
107+ local max = 0
108+ showmem = function ()
109+ local m = collectgarbage("count") * 1024
110+ max = (m > max) and m or max
111+ print(format(" ---- total memory: %s, max memory: %s ----\n",
112+ F(m), F(max)))
113+ end
114+ Cstacklevel = function () return 0 end -- no info about stack level
115+else
116+ showmem = function ()
117+ T.checkmemory()
118+ local total, numblocks, maxmem = T.totalmem()
119+ local count = collectgarbage("count")
120+ print(format(
121+ "\n ---- total memory: %s (%.0fK), max use: %s, blocks: %d\n",
122+ F(total), count, F(maxmem), numblocks))
123+ print(format("\t(strings: %d, tables: %d, functions: %d, "..
124+ "\n\tudata: %d, threads: %d)",
125+ T.totalmem"string", T.totalmem"table", T.totalmem"function",
126+ T.totalmem"userdata", T.totalmem"thread"))
127+ end
128+
129+ Cstacklevel = function ()
130+ local _, _, ncalls = T.stacklevel()
131+ return ncalls -- number of C calls
132+ end
133+end
134+
135+
136+local Cstack = Cstacklevel()
137+
138+--
139+-- redefine dofile to run files through dump/undump
140+--
141+local function report (n) print("\n***** FILE '"..n.."'*****") end
142+local olddofile = dofile
143+local dofile = function (n, strip)
144+ showmem()
145+ local c = os.clock()
146+ print(string.format("time: %g (+%g)", c - initclock, c - lastclock))
147+ lastclock = c
148+ report(n)
149+ local f = assert(loadfile(n))
150+ local b = string.dump(f, strip)
151+ f = assert(load(b))
152+ return f()
153+end
154+
155+dofile('main.lua')
156+
157+-- trace GC cycles
158+require"tracegc".start()
159+
160+report"gc.lua"
161+local f = assert(loadfile('gc.lua'))
162+f()
163+
164+dofile('db.lua')
165+assert(dofile('calls.lua') == deep and deep)
166+_G.deep = nil
167+olddofile('strings.lua')
168+olddofile('literals.lua')
169+dofile('tpack.lua')
170+assert(dofile('attrib.lua') == 27)
171+dofile('gengc.lua')
172+assert(dofile('locals.lua') == 5)
173+dofile('constructs.lua')
174+dofile('code.lua', true)
175+if not _G._soft then
176+ report('big.lua')
177+ local f = coroutine.wrap(assert(loadfile('big.lua')))
178+ assert(f() == 'b')
179+ assert(f() == 'a')
180+end
181+dofile('cstack.lua')
182+dofile('nextvar.lua')
183+dofile('pm.lua')
184+dofile('utf8.lua')
185+dofile('api.lua')
186+assert(dofile('events.lua') == 12)
187+dofile('vararg.lua')
188+dofile('closure.lua')
189+dofile('coroutine.lua')
190+dofile('goto.lua', true)
191+dofile('errors.lua')
192+dofile('math.lua')
193+dofile('sort.lua', true)
194+dofile('bitwise.lua')
195+assert(dofile('verybig.lua', true) == 10); collectgarbage()
196+dofile('files.lua')
197+
198+if #msgs > 0 then
199+ local m = table.concat(msgs, "\n ")
200+ warn("#tests not performed:\n ", m, "\n")
201+end
202+
203+print("(there should be two warnings now)")
204+warn("@on")
205+warn("#This is ", "an expected", " warning")
206+warn("@off")
207+warn("******** THIS WARNING SHOULD NOT APPEAR **********")
208+warn("******** THIS WARNING ALSO SHOULD NOT APPEAR **********")
209+warn("@on")
210+warn("#This is", " another one")
211+
212+-- no test module should define 'debug'
213+assert(debug == nil)
214+
215+local debug = require "debug"
216+
217+print(string.format("%d-bit integers, %d-bit floats",
218+ string.packsize("j") * 8, string.packsize("n") * 8))
219+
220+debug.sethook(function (a) assert(type(a) == 'string') end, "cr")
221+
222+-- to survive outside block
223+_G.showmem = showmem
224+
225+
226+assert(Cstack == Cstacklevel(),
227+ "should be at the same C-stack level it was when started the tests")
228+
229+end --)
230+
231+local _G, showmem, print, format, clock, time, difftime,
232+ assert, open, warn =
233+ _G, showmem, print, string.format, os.clock, os.time, os.difftime,
234+ assert, io.open, warn
235+
236+-- file with time of last performed test
237+local fname = T and "time-debug.txt" or "time.txt"
238+local lasttime
239+
240+if not usertests then
241+ -- open file with time of last performed test
242+ local f = io.open(fname)
243+ if f then
244+ lasttime = assert(tonumber(f:read'a'))
245+ f:close();
246+ else -- no such file; assume it is recording time for first time
247+ lasttime = nil
248+ end
249+end
250+
251+-- erase (almost) all globals
252+print('cleaning all!!!!')
253+for n in pairs(_G) do
254+ if not ({___Glob = 1, tostring = 1})[n] then
255+ _G[n] = undef
256+ end
257+end
258+
259+
260+collectgarbage()
261+collectgarbage()
262+collectgarbage()
263+collectgarbage()
264+collectgarbage()
265+collectgarbage();showmem()
266+
267+local clocktime = clock() - initclock
268+walltime = difftime(time(), walltime)
269+
270+print(format("\n\ntotal time: %.2fs (wall time: %gs)\n", clocktime, walltime))
271+
272+if not usertests then
273+ lasttime = lasttime or clocktime -- if no last time, ignore difference
274+ -- check whether current test time differs more than 5% from last time
275+ local diff = (clocktime - lasttime) / lasttime
276+ local tolerance = 0.05 -- 5%
277+ if (diff >= tolerance or diff <= -tolerance) then
278+ warn(format("#time difference from previous test: %+.1f%%",
279+ diff * 100))
280+ end
281+ assert(open(fname, "w")):write(clocktime):close()
282+end
283+
284+print("final OK !!!")
285+
286+
287+
288+--[[
289+*****************************************************************************
290+* Copyright (C) 1994-2016 Lua.org, PUC-Rio.
291+*
292+* Permission is hereby granted, free of charge, to any person obtaining
293+* a copy of this software and associated documentation files (the
294+* "Software"), to deal in the Software without restriction, including
295+* without limitation the rights to use, copy, modify, merge, publish,
296+* distribute, sublicense, and/or sell copies of the Software, and to
297+* permit persons to whom the Software is furnished to do so, subject to
298+* the following conditions:
299+*
300+* The above copyright notice and this permission notice shall be
301+* included in all copies or substantial portions of the Software.
302+*
303+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
304+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
305+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
306+* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
307+* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
308+* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
309+* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
310+*****************************************************************************
311+]]
312+
desk/res/lua/api.luanew file+1543
@@ -0,0 +1,1543 @@
1+-- $Id: testes/api.lua $
2+-- See Copyright Notice in file all.lua
3+
4+if T==nil then
5+ (Message or print)('\n >>> testC not active: skipping API tests <<<\n')
6+ return
7+end
8+
9+local debug = require "debug"
10+
11+local pack = table.pack
12+
13+
14+-- standard error message for memory errors
15+local MEMERRMSG = "not enough memory"
16+
17+local function tcheck (t1, t2)
18+ assert(t1.n == (t2.n or #t2) + 1)
19+ for i = 2, t1.n do assert(t1[i] == t2[i - 1]) end
20+end
21+
22+
23+local function checkerr (msg, f, ...)
24+ local stat, err = pcall(f, ...)
25+ assert(not stat and string.find(err, msg))
26+end
27+
28+
29+print('testing C API')
30+
31+local a = T.testC("pushvalue R; return 1")
32+assert(a == debug.getregistry())
33+
34+
35+-- absindex
36+assert(T.testC("settop 10; absindex -1; return 1") == 10)
37+assert(T.testC("settop 5; absindex -5; return 1") == 1)
38+assert(T.testC("settop 10; absindex 1; return 1") == 1)
39+assert(T.testC("settop 10; absindex R; return 1") < -10)
40+
41+-- testing alignment
42+a = T.d2s(12458954321123.0)
43+assert(a == string.pack("d", 12458954321123.0))
44+assert(T.s2d(a) == 12458954321123.0)
45+
46+local a,b,c = T.testC("pushnum 1; pushnum 2; pushnum 3; return 2")
47+assert(a == 2 and b == 3 and not c)
48+
49+local f = T.makeCfunc("pushnum 1; pushnum 2; pushnum 3; return 2")
50+a,b,c = f()
51+assert(a == 2 and b == 3 and not c)
52+
53+-- test that all trues are equal
54+a,b,c = T.testC("pushbool 1; pushbool 2; pushbool 0; return 3")
55+assert(a == b and a == true and c == false)
56+a,b,c = T.testC"pushbool 0; pushbool 10; pushnil;\
57+ tobool -3; tobool -3; tobool -3; return 3"
58+assert(a==false and b==true and c==false)
59+
60+
61+a,b,c = T.testC("gettop; return 2", 10, 20, 30, 40)
62+assert(a == 40 and b == 5 and not c)
63+
64+local t = pack(T.testC("settop 5; return *", 2, 3))
65+tcheck(t, {n=4,2,3})
66+
67+t = pack(T.testC("settop 0; settop 15; return 10", 3, 1, 23))
68+assert(t.n == 10 and t[1] == nil and t[10] == nil)
69+
70+t = pack(T.testC("remove -2; return *", 2, 3, 4))
71+tcheck(t, {n=2,2,4})
72+
73+t = pack(T.testC("insert -1; return *", 2, 3))
74+tcheck(t, {n=2,2,3})
75+
76+t = pack(T.testC("insert 3; return *", 2, 3, 4, 5))
77+tcheck(t, {n=4,2,5,3,4})
78+
79+t = pack(T.testC("replace 2; return *", 2, 3, 4, 5))
80+tcheck(t, {n=3,5,3,4})
81+
82+t = pack(T.testC("replace -2; return *", 2, 3, 4, 5))
83+tcheck(t, {n=3,2,3,5})
84+
85+t = pack(T.testC("remove 3; return *", 2, 3, 4, 5))
86+tcheck(t, {n=3,2,4,5})
87+
88+t = pack(T.testC("copy 3 4; return *", 2, 3, 4, 5))
89+tcheck(t, {n=4,2,3,3,5})
90+
91+t = pack(T.testC("copy -3 -1; return *", 2, 3, 4, 5))
92+tcheck(t, {n=4,2,3,4,3})
93+
94+do -- testing 'rotate'
95+ local t = {10, 20, 30, 40, 50, 60}
96+ for i = -6, 6 do
97+ local s = string.format("rotate 2 %d; return 7", i)
98+ local t1 = pack(T.testC(s, 10, 20, 30, 40, 50, 60))
99+ tcheck(t1, t)
100+ table.insert(t, 1, table.remove(t))
101+ end
102+
103+ t = pack(T.testC("rotate -2 1; return *", 10, 20, 30, 40))
104+ tcheck(t, {10, 20, 40, 30})
105+ t = pack(T.testC("rotate -2 -1; return *", 10, 20, 30, 40))
106+ tcheck(t, {10, 20, 40, 30})
107+
108+ -- some corner cases
109+ t = pack(T.testC("rotate -1 0; return *", 10, 20, 30, 40))
110+ tcheck(t, {10, 20, 30, 40})
111+ t = pack(T.testC("rotate -1 1; return *", 10, 20, 30, 40))
112+ tcheck(t, {10, 20, 30, 40})
113+ t = pack(T.testC("rotate 5 -1; return *", 10, 20, 30, 40))
114+ tcheck(t, {10, 20, 30, 40})
115+end
116+
117+
118+-- testing warnings
119+T.testC([[
120+ warningC "#This shold be a"
121+ warningC " single "
122+ warning "warning"
123+ warningC "#This should be "
124+ warning "another one"
125+]])
126+
127+
128+-- testing message handlers
129+do
130+ local f = T.makeCfunc[[
131+ getglobal error
132+ pushstring bola
133+ pcall 1 1 1 # call 'error' with given handler
134+ pushstatus
135+ return 2 # return error message and status
136+ ]]
137+
138+ local msg, st = f(string.upper) -- function handler
139+ assert(st == "ERRRUN" and msg == "BOLA")
140+ local msg, st = f(string.len) -- function handler
141+ assert(st == "ERRRUN" and msg == 4)
142+
143+end
144+
145+t = pack(T.testC("insert 3; pushvalue 3; remove 3; pushvalue 2; remove 2; \
146+ insert 2; pushvalue 1; remove 1; insert 1; \
147+ insert -2; pushvalue -2; remove -3; return *",
148+ 2, 3, 4, 5, 10, 40, 90))
149+tcheck(t, {n=7,2,3,4,5,10,40,90})
150+
151+t = pack(T.testC("concat 5; return *", "alo", 2, 3, "joao", 12))
152+tcheck(t, {n=1,"alo23joao12"})
153+
154+-- testing MULTRET
155+t = pack(T.testC("call 2,-1; return *",
156+ function (a,b) return 1,2,3,4,a,b end, "alo", "joao"))
157+tcheck(t, {n=6,1,2,3,4,"alo", "joao"})
158+
159+do -- test returning more results than fit in the caller stack
160+ local a = {}
161+ for i=1,1000 do a[i] = true end; a[999] = 10
162+ local b = T.testC([[pcall 1 -1 0; pop 1; tostring -1; return 1]],
163+ table.unpack, a)
164+ assert(b == "10")
165+end
166+
167+
168+-- testing globals
169+_G.AA = 14; _G.BB = "a31"
170+local a = {T.testC[[
171+ getglobal AA;
172+ getglobal BB;
173+ getglobal BB;
174+ setglobal AA;
175+ return *
176+]]}
177+assert(a[2] == 14 and a[3] == "a31" and a[4] == nil and _G.AA == "a31")
178+
179+_G.AA, _G.BB = nil
180+
181+-- testing arith
182+assert(T.testC("pushnum 10; pushnum 20; arith /; return 1") == 0.5)
183+assert(T.testC("pushnum 10; pushnum 20; arith -; return 1") == -10)
184+assert(T.testC("pushnum 10; pushnum -20; arith *; return 1") == -200)
185+assert(T.testC("pushnum 10; pushnum 3; arith ^; return 1") == 1000)
186+assert(T.testC("pushnum 10; pushstring 20; arith /; return 1") == 0.5)
187+assert(T.testC("pushstring 10; pushnum 20; arith -; return 1") == -10)
188+assert(T.testC("pushstring 10; pushstring -20; arith *; return 1") == -200)
189+assert(T.testC("pushstring 10; pushstring 3; arith ^; return 1") == 1000)
190+assert(T.testC("arith /; return 1", 2, 0) == 10.0/0)
191+a = T.testC("pushnum 10; pushint 3; arith \\; return 1")
192+assert(a == 3.0 and math.type(a) == "float")
193+a = T.testC("pushint 10; pushint 3; arith \\; return 1")
194+assert(a == 3 and math.type(a) == "integer")
195+a = assert(T.testC("pushint 10; pushint 3; arith +; return 1"))
196+assert(a == 13 and math.type(a) == "integer")
197+a = assert(T.testC("pushnum 10; pushint 3; arith +; return 1"))
198+assert(a == 13 and math.type(a) == "float")
199+a,b,c = T.testC([[pushnum 1;
200+ pushstring 10; arith _;
201+ pushstring 5; return 3]])
202+assert(a == 1 and b == -10 and c == "5")
203+local mt = {
204+ __add = function (a,b) return setmetatable({a[1] + b[1]}, mt) end,
205+ __mod = function (a,b) return setmetatable({a[1] % b[1]}, mt) end,
206+ __unm = function (a) return setmetatable({a[1]* 2}, mt) end}
207+a,b,c = setmetatable({4}, mt),
208+ setmetatable({8}, mt),
209+ setmetatable({-3}, mt)
210+local x,y,z = T.testC("arith +; return 2", 10, a, b)
211+assert(x == 10 and y[1] == 12 and z == nil)
212+assert(T.testC("arith %; return 1", a, c)[1] == 4%-3)
213+assert(T.testC("arith _; arith +; arith %; return 1", b, a, c)[1] ==
214+ 8 % (4 + (-3)*2))
215+
216+-- errors in arithmetic
217+checkerr("divide by zero", T.testC, "arith \\", 10, 0)
218+checkerr("%%0", T.testC, "arith %", 10, 0)
219+
220+
221+-- testing lessthan and lessequal
222+assert(T.testC("compare LT 2 5, return 1", 3, 2, 2, 4, 2, 2))
223+assert(T.testC("compare LE 2 5, return 1", 3, 2, 2, 4, 2, 2))
224+assert(not T.testC("compare LT 3 4, return 1", 3, 2, 2, 4, 2, 2))
225+assert(T.testC("compare LE 3 4, return 1", 3, 2, 2, 4, 2, 2))
226+assert(T.testC("compare LT 5 2, return 1", 4, 2, 2, 3, 2, 2))
227+assert(not T.testC("compare LT 2 -3, return 1", "4", "2", "2", "3", "2", "2"))
228+assert(not T.testC("compare LT -3 2, return 1", "3", "2", "2", "4", "2", "2"))
229+
230+-- non-valid indices produce false
231+assert(not T.testC("compare LT 1 4, return 1"))
232+assert(not T.testC("compare LE 9 1, return 1"))
233+assert(not T.testC("compare EQ 9 9, return 1"))
234+
235+local b = {__lt = function (a,b) return a[1] < b[1] end}
236+local a1,a3,a4 = setmetatable({1}, b),
237+ setmetatable({3}, b),
238+ setmetatable({4}, b)
239+assert(T.testC("compare LT 2 5, return 1", a3, 2, 2, a4, 2, 2))
240+assert(T.testC("compare LE 2 5, return 1", a3, 2, 2, a4, 2, 2))
241+assert(T.testC("compare LT 5 -6, return 1", a4, 2, 2, a3, 2, 2))
242+a,b = T.testC("compare LT 5 -6, return 2", a1, 2, 2, a3, 2, 20)
243+assert(a == 20 and b == false)
244+a,b = T.testC("compare LE 5 -6, return 2", a1, 2, 2, a3, 2, 20)
245+assert(a == 20 and b == false)
246+a,b = T.testC("compare LE 5 -6, return 2", a1, 2, 2, a1, 2, 20)
247+assert(a == 20 and b == true)
248+
249+
250+do -- testing lessthan and lessequal with metamethods
251+ local mt = {__lt = function (a,b) return a[1] < b[1] end,
252+ __le = function (a,b) return a[1] <= b[1] end,
253+ __eq = function (a,b) return a[1] == b[1] end}
254+ local function O (x)
255+ return setmetatable({x}, mt)
256+ end
257+
258+ local a, b = T.testC("compare LT 2 3; pushint 10; return 2", O(1), O(2))
259+ assert(a == true and b == 10)
260+ local a, b = T.testC("compare LE 2 3; pushint 10; return 2", O(3), O(2))
261+ assert(a == false and b == 10)
262+ local a, b = T.testC("compare EQ 2 3; pushint 10; return 2", O(3), O(3))
263+ assert(a == true and b == 10)
264+end
265+
266+-- testing length
267+local t = setmetatable({x = 20}, {__len = function (t) return t.x end})
268+a,b,c = T.testC([[
269+ len 2;
270+ Llen 2;
271+ objsize 2;
272+ return 3
273+]], t)
274+assert(a == 20 and b == 20 and c == 0)
275+
276+t.x = "234"; t[1] = 20
277+a,b,c = T.testC([[
278+ len 2;
279+ Llen 2;
280+ objsize 2;
281+ return 3
282+]], t)
283+assert(a == "234" and b == 234 and c == 1)
284+
285+t.x = print; t[1] = 20
286+a,c = T.testC([[
287+ len 2;
288+ objsize 2;
289+ return 2
290+]], t)
291+assert(a == print and c == 1)
292+
293+
294+-- testing __concat
295+
296+a = setmetatable({x="u"}, {__concat = function (a,b) return a.x..'.'..b.x end})
297+x,y = T.testC([[
298+ pushnum 5
299+ pushvalue 2;
300+ pushvalue 2;
301+ concat 2;
302+ pushvalue -2;
303+ return 2;
304+]], a, a)
305+assert(x == a..a and y == 5)
306+
307+-- concat with 0 elements
308+assert(T.testC("concat 0; return 1") == "")
309+
310+-- concat with 1 element
311+assert(T.testC("concat 1; return 1", "xuxu") == "xuxu")
312+
313+
314+
315+-- testing lua_is
316+
317+local function B (x) return x and 1 or 0 end
318+
319+local function count (x, n)
320+ n = n or 2
321+ local prog = [[
322+ isnumber %d;
323+ isstring %d;
324+ isfunction %d;
325+ iscfunction %d;
326+ istable %d;
327+ isuserdata %d;
328+ isnil %d;
329+ isnull %d;
330+ return 8
331+ ]]
332+ prog = string.format(prog, n, n, n, n, n, n, n, n)
333+ local a,b,c,d,e,f,g,h = T.testC(prog, x)
334+ return B(a)+B(b)+B(c)+B(d)+B(e)+B(f)+B(g)+(100*B(h))
335+end
336+
337+assert(count(3) == 2)
338+assert(count('alo') == 1)
339+assert(count('32') == 2)
340+assert(count({}) == 1)
341+assert(count(print) == 2)
342+assert(count(function () end) == 1)
343+assert(count(nil) == 1)
344+assert(count(io.stdin) == 1)
345+assert(count(nil, 15) == 100)
346+
347+
348+-- testing lua_to...
349+
350+local function to (s, x, n)
351+ n = n or 2
352+ return T.testC(string.format("%s %d; return 1", s, n), x)
353+end
354+
355+local null = T.pushuserdata(0)
356+local hfunc = string.gmatch("", "") -- a "heavy C function" (with upvalues)
357+assert(debug.getupvalue(hfunc, 1))
358+assert(to("tostring", {}) == nil)
359+assert(to("tostring", "alo") == "alo")
360+assert(to("tostring", 12) == "12")
361+assert(to("tostring", 12, 3) == nil)
362+assert(to("objsize", {}) == 0)
363+assert(to("objsize", {1,2,3}) == 3)
364+assert(to("objsize", "alo\0\0a") == 6)
365+assert(to("objsize", T.newuserdata(0)) == 0)
366+assert(to("objsize", T.newuserdata(101)) == 101)
367+assert(to("objsize", 124) == 0)
368+assert(to("objsize", true) == 0)
369+assert(to("tonumber", {}) == 0)
370+assert(to("tonumber", "12") == 12)
371+assert(to("tonumber", "s2") == 0)
372+assert(to("tonumber", 1, 20) == 0)
373+assert(to("topointer", 10) == null)
374+assert(to("topointer", true) == null)
375+assert(to("topointer", nil) == null)
376+assert(to("topointer", "abc") ~= null)
377+assert(to("topointer", string.rep("x", 10)) ==
378+ to("topointer", string.rep("x", 10))) -- short strings
379+do -- long strings
380+ local s1 = string.rep("x", 300)
381+ local s2 = string.rep("x", 300)
382+ assert(to("topointer", s1) ~= to("topointer", s2))
383+end
384+assert(to("topointer", T.pushuserdata(20)) ~= null)
385+assert(to("topointer", io.read) ~= null) -- light C function
386+assert(to("topointer", hfunc) ~= null) -- "heavy" C function
387+assert(to("topointer", function () end) ~= null) -- Lua function
388+assert(to("topointer", io.stdin) ~= null) -- full userdata
389+assert(to("func2num", 20) == 0)
390+assert(to("func2num", T.pushuserdata(10)) == 0)
391+assert(to("func2num", io.read) ~= 0) -- light C function
392+assert(to("func2num", hfunc) ~= 0) -- "heavy" C function (with upvalue)
393+a = to("tocfunction", math.deg)
394+assert(a(3) == math.deg(3) and a == math.deg)
395+
396+
397+print("testing panic function")
398+do
399+ -- trivial error
400+ assert(T.checkpanic("pushstring hi; error") == "hi")
401+
402+ -- using the stack inside panic
403+ assert(T.checkpanic("pushstring hi; error;",
404+ [[checkstack 5 XX
405+ pushstring ' alo'
406+ pushstring ' mundo'
407+ concat 3]]) == "hi alo mundo")
408+
409+ -- "argerror" without frames
410+ assert(T.checkpanic("loadstring 4") ==
411+ "bad argument #4 (string expected, got no value)")
412+
413+
414+ -- memory error
415+ T.totalmem(T.totalmem()+10000) -- set low memory limit (+10k)
416+ assert(T.checkpanic("newuserdata 20000") == MEMERRMSG)
417+ T.totalmem(0) -- restore high limit
418+
419+ -- stack error
420+ if not _soft then
421+ local msg = T.checkpanic[[
422+ pushstring "function f() f() end"
423+ loadstring -1; call 0 0
424+ getglobal f; call 0 0
425+ ]]
426+ assert(string.find(msg, "stack overflow"))
427+ end
428+
429+ -- exit in panic still close to-be-closed variables
430+ assert(T.checkpanic([[
431+ pushstring "return {__close = function () Y = 'ho'; end}"
432+ newtable
433+ loadstring -2
434+ call 0 1
435+ setmetatable -2
436+ toclose -1
437+ pushstring "hi"
438+ error
439+ ]],
440+ [[
441+ getglobal Y
442+ concat 2 # concat original error with global Y
443+ ]]) == "hiho")
444+
445+
446+end
447+
448+-- testing deep C stack
449+if not _soft then
450+ print("testing stack overflow")
451+ collectgarbage("stop")
452+ checkerr("XXXX", T.testC, "checkstack 1000023 XXXX") -- too deep
453+ -- too deep (with no message)
454+ checkerr("^stack overflow$", T.testC, "checkstack 1000023 ''")
455+ local s = string.rep("pushnil;checkstack 1 XX;", 1000000)
456+ checkerr("overflow", T.testC, s)
457+ collectgarbage("restart")
458+ print'+'
459+end
460+
461+local lim = _soft and 500 or 12000
462+local prog = {"checkstack " .. (lim * 2 + 100) .. "msg", "newtable"}
463+for i = 1,lim do
464+ prog[#prog + 1] = "pushnum " .. i
465+ prog[#prog + 1] = "pushnum " .. i * 10
466+end
467+
468+prog[#prog + 1] = "rawgeti R 2" -- get global table in registry
469+prog[#prog + 1] = "insert " .. -(2*lim + 2)
470+
471+for i = 1,lim do
472+ prog[#prog + 1] = "settable " .. -(2*(lim - i + 1) + 1)
473+end
474+
475+prog[#prog + 1] = "return 2"
476+
477+prog = table.concat(prog, ";")
478+local g, t = T.testC(prog)
479+assert(g == _G)
480+for i = 1,lim do assert(t[i] == i*10); t[i] = undef end
481+assert(next(t) == nil)
482+prog, g, t = nil
483+
484+-- testing errors
485+
486+a = T.testC([[
487+ loadstring 2; pcall 0 1 0;
488+ pushvalue 3; insert -2; pcall 1 1 0;
489+ pcall 0 0 0;
490+ return 1
491+]], "XX=150", function (a) assert(a==nil); return 3 end)
492+
493+assert(type(a) == 'string' and XX == 150)
494+_G.XX = nil
495+
496+local function check3(p, ...)
497+ local arg = {...}
498+ assert(#arg == 3)
499+ assert(string.find(arg[3], p))
500+end
501+check3(":1:", T.testC("loadstring 2; return *", "x="))
502+check3("%.", T.testC("loadfile 2; return *", "."))
503+check3("xxxx", T.testC("loadfile 2; return *", "xxxx"))
504+
505+-- test errors in non protected threads
506+local function checkerrnopro (code, msg)
507+ local th = coroutine.create(function () end) -- create new thread
508+ local stt, err = pcall(T.testC, th, code) -- run code there
509+ assert(not stt and string.find(err, msg))
510+end
511+
512+if not _soft then
513+ collectgarbage("stop") -- avoid __gc with full stack
514+ checkerrnopro("pushnum 3; call 0 0", "attempt to call")
515+ print"testing stack overflow in unprotected thread"
516+ function F () F() end
517+ checkerrnopro("getglobal 'F'; call 0 0;", "stack overflow")
518+ F = nil
519+ collectgarbage("restart")
520+end
521+print"+"
522+
523+
524+-- testing table access
525+
526+do -- getp/setp
527+ local a = {}
528+ local a1 = T.testC("rawsetp 2 1; return 1", a, 20)
529+ assert(a == a1)
530+ assert(a[T.pushuserdata(1)] == 20)
531+ local a1, res = T.testC("rawgetp -1 1; return 2", a)
532+ assert(a == a1 and res == 20)
533+end
534+
535+
536+do -- using the table itself as index
537+ local a = {}
538+ a[a] = 10
539+ local prog = "gettable -1; return *"
540+ local res = {T.testC(prog, a)}
541+ assert(#res == 2 and res[1] == prog and res[2] == 10)
542+
543+ local prog = "settable -2; return *"
544+ local res = {T.testC(prog, a, 20)}
545+ assert(a[a] == 20)
546+ assert(#res == 1 and res[1] == prog)
547+
548+ -- raw
549+ a[a] = 10
550+ local prog = "rawget -1; return *"
551+ local res = {T.testC(prog, a)}
552+ assert(#res == 2 and res[1] == prog and res[2] == 10)
553+
554+ local prog = "rawset -2; return *"
555+ local res = {T.testC(prog, a, 20)}
556+ assert(a[a] == 20)
557+ assert(#res == 1 and res[1] == prog)
558+
559+ -- using the table as the value to set
560+ local prog = "rawset -1; return *"
561+ local res = {T.testC(prog, 30, a)}
562+ assert(a[30] == a)
563+ assert(#res == 1 and res[1] == prog)
564+
565+ local prog = "settable -1; return *"
566+ local res = {T.testC(prog, 40, a)}
567+ assert(a[40] == a)
568+ assert(#res == 1 and res[1] == prog)
569+
570+ local prog = "rawseti -1 100; return *"
571+ local res = {T.testC(prog, a)}
572+ assert(a[100] == a)
573+ assert(#res == 1 and res[1] == prog)
574+
575+ local prog = "seti -1 200; return *"
576+ local res = {T.testC(prog, a)}
577+ assert(a[200] == a)
578+ assert(#res == 1 and res[1] == prog)
579+end
580+
581+a = {x=0, y=12}
582+x, y = T.testC("gettable 2; pushvalue 4; gettable 2; return 2",
583+ a, 3, "y", 4, "x")
584+assert(x == 0 and y == 12)
585+T.testC("settable -5", a, 3, 4, "x", 15)
586+assert(a.x == 15)
587+a[a] = print
588+x = T.testC("gettable 2; return 1", a) -- table and key are the same object!
589+assert(x == print)
590+T.testC("settable 2", a, "x") -- table and key are the same object!
591+assert(a[a] == "x")
592+
593+b = setmetatable({p = a}, {})
594+getmetatable(b).__index = function (t, i) return t.p[i] end
595+local k, x = T.testC("gettable 3, return 2", 4, b, 20, 35, "x")
596+assert(x == 15 and k == 35)
597+k = T.testC("getfield 2 y, return 1", b)
598+assert(k == 12)
599+getmetatable(b).__index = function (t, i) return a[i] end
600+getmetatable(b).__newindex = function (t, i,v ) a[i] = v end
601+y = T.testC("insert 2; gettable -5; return 1", 2, 3, 4, "y", b)
602+assert(y == 12)
603+k = T.testC("settable -5, return 1", b, 3, 4, "x", 16)
604+assert(a.x == 16 and k == 4)
605+a[b] = 'xuxu'
606+y = T.testC("gettable 2, return 1", b)
607+assert(y == 'xuxu')
608+T.testC("settable 2", b, 19)
609+assert(a[b] == 19)
610+
611+--
612+do -- testing getfield/setfield with long keys
613+ local t = {_012345678901234567890123456789012345678901234567890123456789 = 32}
614+ local a = T.testC([[
615+ getfield 2 _012345678901234567890123456789012345678901234567890123456789
616+ return 1
617+ ]], t)
618+ assert(a == 32)
619+ local a = T.testC([[
620+ pushnum 33
621+ setglobal _012345678901234567890123456789012345678901234567890123456789
622+ ]])
623+ assert(_012345678901234567890123456789012345678901234567890123456789 == 33)
624+ _012345678901234567890123456789012345678901234567890123456789 = nil
625+end
626+
627+-- testing next
628+a = {}
629+t = pack(T.testC("next; return *", a, nil))
630+tcheck(t, {n=1,a})
631+a = {a=3}
632+t = pack(T.testC("next; return *", a, nil))
633+tcheck(t, {n=3,a,'a',3})
634+t = pack(T.testC("next; pop 1; next; return *", a, nil))
635+tcheck(t, {n=1,a})
636+
637+
638+
639+-- testing upvalues
640+
641+do
642+ local A = T.testC[[ pushnum 10; pushnum 20; pushcclosure 2; return 1]]
643+ t, b, c = A([[pushvalue U0; pushvalue U1; pushvalue U2; return 3]])
644+ assert(b == 10 and c == 20 and type(t) == 'table')
645+ a, b = A([[tostring U3; tonumber U4; return 2]])
646+ assert(a == nil and b == 0)
647+ A([[pushnum 100; pushnum 200; replace U2; replace U1]])
648+ b, c = A([[pushvalue U1; pushvalue U2; return 2]])
649+ assert(b == 100 and c == 200)
650+ A([[replace U2; replace U1]], {x=1}, {x=2})
651+ b, c = A([[pushvalue U1; pushvalue U2; return 2]])
652+ assert(b.x == 1 and c.x == 2)
653+ T.checkmemory()
654+end
655+
656+
657+-- testing absent upvalues from C-function pointers
658+assert(T.testC[[isnull U1; return 1]] == true)
659+assert(T.testC[[isnull U100; return 1]] == true)
660+assert(T.testC[[pushvalue U1; return 1]] == nil)
661+
662+local f = T.testC[[ pushnum 10; pushnum 20; pushcclosure 2; return 1]]
663+assert(T.upvalue(f, 1) == 10 and
664+ T.upvalue(f, 2) == 20 and
665+ T.upvalue(f, 3) == nil)
666+T.upvalue(f, 2, "xuxu")
667+assert(T.upvalue(f, 2) == "xuxu")
668+
669+
670+-- large closures
671+do
672+ local A = "checkstack 300 msg;" ..
673+ string.rep("pushnum 10;", 255) ..
674+ "pushcclosure 255; return 1"
675+ A = T.testC(A)
676+ for i=1,255 do
677+ assert(A(("pushvalue U%d; return 1"):format(i)) == 10)
678+ end
679+ assert(A("isnull U256; return 1"))
680+ assert(not A("isnil U256; return 1"))
681+end
682+
683+
684+
685+-- testing get/setuservalue
686+-- bug in 5.1.2
687+checkerr("got number", debug.setuservalue, 3, {})
688+checkerr("got nil", debug.setuservalue, nil, {})
689+checkerr("got light userdata", debug.setuservalue, T.pushuserdata(1), {})
690+
691+-- testing multiple user values
692+local b = T.newuserdata(0, 10)
693+for i = 1, 10 do
694+ local v, p = debug.getuservalue(b, i)
695+ assert(v == nil and p)
696+end
697+do -- indices out of range
698+ local v, p = debug.getuservalue(b, -2)
699+ assert(v == nil and not p)
700+ local v, p = debug.getuservalue(b, 11)
701+ assert(v == nil and not p)
702+end
703+local t = {true, false, 4.56, print, {}, b, "XYZ"}
704+for k, v in ipairs(t) do
705+ debug.setuservalue(b, v, k)
706+end
707+for k, v in ipairs(t) do
708+ local v1, p = debug.getuservalue(b, k)
709+ assert(v1 == v and p)
710+end
711+
712+assert(not debug.getuservalue(4))
713+
714+debug.setuservalue(b, function () return 10 end, 10)
715+collectgarbage() -- function should not be collected
716+assert(debug.getuservalue(b, 10)() == 10)
717+
718+debug.setuservalue(b, 134)
719+collectgarbage() -- number should not be a problem for collector
720+assert(debug.getuservalue(b) == 134)
721+
722+
723+-- test barrier for uservalues
724+do
725+ local oldmode = collectgarbage("incremental")
726+ T.gcstate("atomic")
727+ assert(T.gccolor(b) == "black")
728+ debug.setuservalue(b, {x = 100})
729+ T.gcstate("pause") -- complete collection
730+ assert(debug.getuservalue(b).x == 100) -- uvalue should be there
731+ collectgarbage(oldmode)
732+end
733+
734+-- long chain of userdata
735+for i = 1, 1000 do
736+ local bb = T.newuserdata(0, 1)
737+ debug.setuservalue(bb, b)
738+ b = bb
739+end
740+collectgarbage() -- nothing should not be collected
741+for i = 1, 1000 do
742+ b = debug.getuservalue(b)
743+end
744+assert(debug.getuservalue(b).x == 100)
745+b = nil
746+
747+
748+-- testing locks (refs)
749+
750+-- reuse of references
751+local i = T.ref{}
752+T.unref(i)
753+assert(T.ref{} == i)
754+
755+local Arr = {}
756+local Lim = 100
757+for i=1,Lim do -- lock many objects
758+ Arr[i] = T.ref({})
759+end
760+
761+assert(T.ref(nil) == -1 and T.getref(-1) == nil)
762+T.unref(-1); T.unref(-1)
763+
764+for i=1,Lim do -- unlock all them
765+ T.unref(Arr[i])
766+end
767+
768+local function printlocks ()
769+ local f = T.makeCfunc("gettable R; return 1")
770+ local n = f("n")
771+ print("n", n)
772+ for i=0,n do
773+ print(i, f(i))
774+ end
775+end
776+
777+
778+for i=1,Lim do -- lock many objects
779+ Arr[i] = T.ref({})
780+end
781+
782+for i=1,Lim,2 do -- unlock half of them
783+ T.unref(Arr[i])
784+end
785+
786+assert(type(T.getref(Arr[2])) == 'table')
787+
788+
789+assert(T.getref(-1) == nil)
790+
791+
792+a = T.ref({})
793+
794+collectgarbage()
795+
796+assert(type(T.getref(a)) == 'table')
797+
798+
799+-- colect in cl the `val' of all collected userdata
800+local tt = {}
801+local cl = {n=0}
802+A = nil; B = nil
803+local F
804+F = function (x)
805+ local udval = T.udataval(x)
806+ table.insert(cl, udval)
807+ local d = T.newuserdata(100) -- create garbage
808+ d = nil
809+ assert(debug.getmetatable(x).__gc == F)
810+ assert(load("table.insert({}, {})"))() -- create more garbage
811+ assert(not collectgarbage()) -- GC during GC (no op)
812+ local dummy = {} -- create more garbage during GC
813+ if A ~= nil then
814+ assert(type(A) == "userdata")
815+ assert(T.udataval(A) == B)
816+ debug.getmetatable(A) -- just access it
817+ end
818+ A = x -- ressurect userdata
819+ B = udval
820+ return 1,2,3
821+end
822+tt.__gc = F
823+
824+
825+-- test whether udate collection frees memory in the right time
826+do
827+ collectgarbage();
828+ collectgarbage();
829+ local x = collectgarbage("count");
830+ local a = T.newuserdata(5001)
831+ assert(T.testC("objsize 2; return 1", a) == 5001)
832+ assert(collectgarbage("count") >= x+4)
833+ a = nil
834+ collectgarbage();
835+ assert(collectgarbage("count") <= x+1)
836+ -- udata without finalizer
837+ x = collectgarbage("count")
838+ collectgarbage("stop")
839+ for i=1,1000 do T.newuserdata(0) end
840+ assert(collectgarbage("count") > x+10)
841+ collectgarbage()
842+ assert(collectgarbage("count") <= x+1)
843+ -- udata with finalizer
844+ collectgarbage()
845+ x = collectgarbage("count")
846+ collectgarbage("stop")
847+ a = {__gc = function () end}
848+ for i=1,1000 do debug.setmetatable(T.newuserdata(0), a) end
849+ assert(collectgarbage("count") >= x+10)
850+ collectgarbage() -- this collection only calls TM, without freeing memory
851+ assert(collectgarbage("count") >= x+10)
852+ collectgarbage() -- now frees memory
853+ assert(collectgarbage("count") <= x+1)
854+ collectgarbage("restart")
855+end
856+
857+
858+collectgarbage("stop")
859+
860+-- create 3 userdatas with tag `tt'
861+a = T.newuserdata(0); debug.setmetatable(a, tt); local na = T.udataval(a)
862+b = T.newuserdata(0); debug.setmetatable(b, tt); local nb = T.udataval(b)
863+c = T.newuserdata(0); debug.setmetatable(c, tt); local nc = T.udataval(c)
864+
865+-- create userdata without meta table
866+x = T.newuserdata(4)
867+y = T.newuserdata(0)
868+
869+checkerr("FILE%* expected, got userdata", io.input, a)
870+checkerr("FILE%* expected, got userdata", io.input, x)
871+
872+assert(debug.getmetatable(x) == nil and debug.getmetatable(y) == nil)
873+
874+local d = T.ref(a);
875+local e = T.ref(b);
876+local f = T.ref(c);
877+t = {T.getref(d), T.getref(e), T.getref(f)}
878+assert(t[1] == a and t[2] == b and t[3] == c)
879+
880+t=nil; a=nil; c=nil;
881+T.unref(e); T.unref(f)
882+
883+collectgarbage()
884+
885+-- check that unref objects have been collected
886+assert(#cl == 1 and cl[1] == nc)
887+
888+x = T.getref(d)
889+assert(type(x) == 'userdata' and debug.getmetatable(x) == tt)
890+x =nil
891+tt.b = b -- create cycle
892+tt=nil -- frees tt for GC
893+A = nil
894+b = nil
895+T.unref(d);
896+local n5 = T.newuserdata(0)
897+debug.setmetatable(n5, {__gc=F})
898+n5 = T.udataval(n5)
899+collectgarbage()
900+assert(#cl == 4)
901+-- check order of collection
902+assert(cl[2] == n5 and cl[3] == nb and cl[4] == na)
903+
904+collectgarbage"restart"
905+
906+
907+a, na = {}, {}
908+for i=30,1,-1 do
909+ a[i] = T.newuserdata(0)
910+ debug.setmetatable(a[i], {__gc=F})
911+ na[i] = T.udataval(a[i])
912+end
913+cl = {}
914+a = nil; collectgarbage()
915+assert(#cl == 30)
916+for i=1,30 do assert(cl[i] == na[i]) end
917+na = nil
918+
919+
920+for i=2,Lim,2 do -- unlock the other half
921+ T.unref(Arr[i])
922+end
923+
924+x = T.newuserdata(41); debug.setmetatable(x, {__gc=F})
925+assert(T.testC("objsize 2; return 1", x) == 41)
926+cl = {}
927+a = {[x] = 1}
928+x = T.udataval(x)
929+collectgarbage()
930+-- old `x' cannot be collected (`a' still uses it)
931+assert(#cl == 0)
932+for n in pairs(a) do a[n] = undef end
933+collectgarbage()
934+assert(#cl == 1 and cl[1] == x) -- old `x' must be collected
935+
936+-- testing lua_equal
937+assert(T.testC("compare EQ 2 4; return 1", print, 1, print, 20))
938+assert(T.testC("compare EQ 3 2; return 1", 'alo', "alo"))
939+assert(T.testC("compare EQ 2 3; return 1", nil, nil))
940+assert(not T.testC("compare EQ 2 3; return 1", {}, {}))
941+assert(not T.testC("compare EQ 2 3; return 1"))
942+assert(not T.testC("compare EQ 2 3; return 1", 3))
943+
944+-- testing lua_equal with fallbacks
945+do
946+ local map = {}
947+ local t = {__eq = function (a,b) return map[a] == map[b] end}
948+ local function f(x)
949+ local u = T.newuserdata(0)
950+ debug.setmetatable(u, t)
951+ map[u] = x
952+ return u
953+ end
954+ assert(f(10) == f(10))
955+ assert(f(10) ~= f(11))
956+ assert(T.testC("compare EQ 2 3; return 1", f(10), f(10)))
957+ assert(not T.testC("compare EQ 2 3; return 1", f(10), f(20)))
958+ t.__eq = nil
959+ assert(f(10) ~= f(10))
960+end
961+
962+print'+'
963+
964+
965+
966+-- testing changing hooks during hooks
967+_G.TT = {}
968+T.sethook([[
969+ # set a line hook after 3 count hooks
970+ sethook 4 0 '
971+ getglobal TT;
972+ pushvalue -3; append -2
973+ pushvalue -2; append -2
974+ ']], "c", 3)
975+local a = 1 -- counting
976+a = 1 -- counting
977+a = 1 -- count hook (set line hook)
978+a = 1 -- line hook
979+a = 1 -- line hook
980+debug.sethook()
981+local t = _G.TT
982+assert(t[1] == "line")
983+local line = t[2]
984+assert(t[3] == "line" and t[4] == line + 1)
985+assert(t[5] == "line" and t[6] == line + 2)
986+assert(t[7] == nil)
987+_G.TT = nil
988+
989+
990+-------------------------------------------------------------------------
991+do -- testing errors during GC
992+ warn("@off")
993+ collectgarbage("stop")
994+ local a = {}
995+ for i=1,20 do
996+ a[i] = T.newuserdata(i) -- creates several udata
997+ end
998+ for i=1,20,2 do -- mark half of them to raise errors during GC
999+ debug.setmetatable(a[i],
1000+ {__gc = function (x) error("@expected error in gc") end})
1001+ end
1002+ for i=2,20,2 do -- mark the other half to count and to create more garbage
1003+ debug.setmetatable(a[i], {__gc = function (x) load("A=A+1")() end})
1004+ end
1005+ a = nil
1006+ _G.A = 0
1007+ collectgarbage()
1008+ assert(A == 10) -- number of normal collections
1009+ collectgarbage("restart")
1010+ warn("@on")
1011+end
1012+_G.A = nil
1013+-------------------------------------------------------------------------
1014+-- test for userdata vals
1015+do
1016+ local a = {}; local lim = 30
1017+ for i=0,lim do a[i] = T.pushuserdata(i) end
1018+ for i=0,lim do assert(T.udataval(a[i]) == i) end
1019+ for i=0,lim do assert(T.pushuserdata(i) == a[i]) end
1020+ for i=0,lim do a[a[i]] = i end
1021+ for i=0,lim do a[T.pushuserdata(i)] = i end
1022+ assert(type(tostring(a[1])) == "string")
1023+end
1024+
1025+
1026+-------------------------------------------------------------------------
1027+-- testing multiple states
1028+T.closestate(T.newstate());
1029+L1 = T.newstate()
1030+assert(L1)
1031+
1032+assert(T.doremote(L1, "X='a'; return 'a'") == 'a')
1033+
1034+
1035+assert(#pack(T.doremote(L1, "function f () return 'alo', 3 end; f()")) == 0)
1036+
1037+a, b = T.doremote(L1, "return f()")
1038+assert(a == 'alo' and b == '3')
1039+
1040+T.doremote(L1, "_ERRORMESSAGE = nil")
1041+-- error: `sin' is not defined
1042+a, b, c = T.doremote(L1, "return sin(1)")
1043+assert(a == nil and c == 2) -- 2 == run-time error
1044+
1045+-- error: syntax error
1046+a, b, c = T.doremote(L1, "return a+")
1047+assert(a == nil and c == 3 and type(b) == "string") -- 3 == syntax error
1048+
1049+T.loadlib(L1)
1050+a, b, c = T.doremote(L1, [[
1051+ string = require'string'
1052+ a = require'_G'; assert(a == _G and require("_G") == a)
1053+ io = require'io'; assert(type(io.read) == "function")
1054+ assert(require("io") == io)
1055+ a = require'table'; assert(type(a.insert) == "function")
1056+ a = require'debug'; assert(type(a.getlocal) == "function")
1057+ a = require'math'; assert(type(a.sin) == "function")
1058+ return string.sub('okinama', 1, 2)
1059+]])
1060+assert(a == "ok")
1061+
1062+T.closestate(L1);
1063+
1064+
1065+L1 = T.newstate()
1066+T.loadlib(L1)
1067+T.doremote(L1, "a = {}")
1068+T.testC(L1, [[getglobal "a"; pushstring "x"; pushint 1;
1069+ settable -3]])
1070+assert(T.doremote(L1, "return a.x") == "1")
1071+
1072+T.closestate(L1)
1073+
1074+L1 = nil
1075+
1076+print('+')
1077+-------------------------------------------------------------------------
1078+-- testing to-be-closed variables
1079+-------------------------------------------------------------------------
1080+print"testing to-be-closed variables"
1081+
1082+do
1083+ local openresource = {}
1084+
1085+ local function newresource ()
1086+ local x = setmetatable({10}, {__close = function(y)
1087+ assert(openresource[#openresource] == y)
1088+ openresource[#openresource] = nil
1089+ y[1] = y[1] + 1
1090+ end})
1091+ openresource[#openresource + 1] = x
1092+ return x
1093+ end
1094+
1095+ local a, b = T.testC([[
1096+ call 0 1 # create resource
1097+ pushnil
1098+ toclose -2 # mark call result to be closed
1099+ toclose -1 # mark nil to be closed (will be ignored)
1100+ return 2
1101+ ]], newresource)
1102+ assert(a[1] == 11 and b == nil)
1103+ assert(#openresource == 0) -- was closed
1104+
1105+ -- repeat the test, but calling function in a 'multret' context
1106+ local a = {T.testC([[
1107+ call 0 1 # create resource
1108+ toclose 2 # mark it to be closed
1109+ return 2
1110+ ]], newresource)}
1111+ assert(type(a[1]) == "string" and a[2][1] == 11)
1112+ assert(#openresource == 0) -- was closed
1113+
1114+ -- closing by error
1115+ local a, b = pcall(T.makeCfunc[[
1116+ call 0 1 # create resource
1117+ toclose -1 # mark it to be closed
1118+ error # resource is the error object
1119+ ]], newresource)
1120+ assert(a == false and b[1] == 11)
1121+ assert(#openresource == 0) -- was closed
1122+
1123+ -- non-closable value
1124+ local a, b = pcall(T.makeCfunc[[
1125+ newtable # create non-closable object
1126+ toclose -1 # mark it to be closed (should raise an error)
1127+ abort # will not be executed
1128+ ]])
1129+ assert(a == false and
1130+ string.find(b, "non%-closable value"))
1131+
1132+ local function check (n)
1133+ assert(#openresource == n)
1134+ end
1135+
1136+ -- closing resources with 'closeslot'
1137+ _ENV.xxx = true
1138+ local a = T.testC([[
1139+ pushvalue 2 # stack: S, NR, CH, NR
1140+ call 0 1 # create resource; stack: S, NR, CH, R
1141+ toclose -1 # mark it to be closed
1142+ pushvalue 2 # stack: S, NR, CH, R, NR
1143+ call 0 1 # create another resource; stack: S, NR, CH, R, R
1144+ toclose -1 # mark it to be closed
1145+ pushvalue 3 # stack: S, NR, CH, R, R, CH
1146+ pushint 2 # there should be two open resources
1147+ call 1 0 # stack: S, NR, CH, R, R
1148+ closeslot -1 # close second resource
1149+ pushvalue 3 # stack: S, NR, CH, R, R, CH
1150+ pushint 1 # there should be one open resource
1151+ call 1 0 # stack: S, NR, CH, R, R
1152+ closeslot 4
1153+ setglobal "xxx" # previous op. erased the slot
1154+ pop 1 # pop other resource from the stack
1155+ pushint *
1156+ return 1 # return stack size
1157+ ]], newresource, check)
1158+ assert(a == 3 and _ENV.xxx == nil) -- no extra items left in the stack
1159+
1160+ -- closing resources with 'pop'
1161+ local a = T.testC([[
1162+ pushvalue 2 # stack: S, NR, CH, NR
1163+ call 0 1 # create resource; stack: S, NR, CH, R
1164+ toclose -1 # mark it to be closed
1165+ pushvalue 2 # stack: S, NR, CH, R, NR
1166+ call 0 1 # create another resource; stack: S, NR, CH, R, R
1167+ toclose -1 # mark it to be closed
1168+ pushvalue 3 # stack: S, NR, CH, R, R, CH
1169+ pushint 2 # there should be two open resources
1170+ call 1 0 # stack: S, NR, CH, R, R
1171+ pop 1 # pop second resource
1172+ pushvalue 3 # stack: S, NR, CH, R, CH
1173+ pushint 1 # there should be one open resource
1174+ call 1 0 # stack: S, NR, CH, R
1175+ pop 1 # pop other resource from the stack
1176+ pushvalue 3 # stack: S, NR, CH, CH
1177+ pushint 0 # there should be no open resources
1178+ call 1 0 # stack: S, NR, CH
1179+ pushint *
1180+ return 1 # return stack size
1181+ ]], newresource, check)
1182+ assert(a == 3) -- no extra items left in the stack
1183+
1184+ -- non-closable value
1185+ local a, b = pcall(T.makeCfunc[[
1186+ pushint 32
1187+ toclose -1
1188+ ]])
1189+ assert(not a and string.find(b, "(C temporary)"))
1190+
1191+end
1192+
1193+
1194+--[[
1195+** {==================================================================
1196+** Testing memory limits
1197+** ===================================================================
1198+--]]
1199+
1200+print("memory-allocation errors")
1201+
1202+checkerr("block too big", T.newuserdata, math.maxinteger)
1203+collectgarbage()
1204+local f = load"local a={}; for i=1,100000 do a[i]=i end"
1205+T.alloccount(10)
1206+checkerr(MEMERRMSG, f)
1207+T.alloccount() -- remove limit
1208+
1209+
1210+-- test memory errors; increase limit for maximum memory by steps,
1211+-- o that we get memory errors in all allocations of a given
1212+-- task, until there is enough memory to complete the task without
1213+-- errors.
1214+local function testbytes (s, f)
1215+ collectgarbage()
1216+ local M = T.totalmem()
1217+ local oldM = M
1218+ local a,b = nil
1219+ while true do
1220+ collectgarbage(); collectgarbage()
1221+ T.totalmem(M)
1222+ a, b = T.testC("pcall 0 1 0; pushstatus; return 2", f)
1223+ T.totalmem(0) -- remove limit
1224+ if a and b == "OK" then break end -- stop when no more errors
1225+ if b ~= "OK" and b ~= MEMERRMSG then -- not a memory error?
1226+ error(a, 0) -- propagate it
1227+ end
1228+ M = M + 7 -- increase memory limit
1229+ end
1230+ print(string.format("minimum memory for %s: %d bytes", s, M - oldM))
1231+ return a
1232+end
1233+
1234+-- test memory errors; increase limit for number of allocations one
1235+-- by one, so that we get memory errors in all allocations of a given
1236+-- task, until there is enough allocations to complete the task without
1237+-- errors.
1238+
1239+local function testalloc (s, f)
1240+ collectgarbage()
1241+ local M = 0
1242+ local a,b = nil
1243+ while true do
1244+ collectgarbage(); collectgarbage()
1245+ T.alloccount(M)
1246+ a, b = T.testC("pcall 0 1 0; pushstatus; return 2", f)
1247+ T.alloccount() -- remove limit
1248+ if a and b == "OK" then break end -- stop when no more errors
1249+ if b ~= "OK" and b ~= MEMERRMSG then -- not a memory error?
1250+ error(a, 0) -- propagate it
1251+ end
1252+ M = M + 1 -- increase allocation limit
1253+ end
1254+ print(string.format("minimum allocations for %s: %d allocations", s, M))
1255+ return a
1256+end
1257+
1258+
1259+local function testamem (s, f)
1260+ testalloc(s, f)
1261+ return testbytes(s, f)
1262+end
1263+
1264+
1265+-- doing nothing
1266+b = testamem("doing nothing", function () return 10 end)
1267+assert(b == 10)
1268+
1269+-- testing memory errors when creating a new state
1270+
1271+testamem("state creation", function ()
1272+ local st = T.newstate()
1273+ if st then T.closestate(st) end -- close new state
1274+ return st
1275+end)
1276+
1277+testamem("empty-table creation", function ()
1278+ return {}
1279+end)
1280+
1281+testamem("string creation", function ()
1282+ return "XXX" .. "YYY"
1283+end)
1284+
1285+testamem("coroutine creation", function()
1286+ return coroutine.create(print)
1287+end)
1288+
1289+
1290+-- testing to-be-closed variables
1291+testamem("to-be-closed variables", function()
1292+ local flag
1293+ do
1294+ local x <close> =
1295+ setmetatable({}, {__close = function () flag = true end})
1296+ flag = false
1297+ local x = {}
1298+ end
1299+ return flag
1300+end)
1301+
1302+
1303+-- testing threads
1304+
1305+-- get main thread from registry (at index LUA_RIDX_MAINTHREAD == 1)
1306+local mt = T.testC("rawgeti R 1; return 1")
1307+assert(type(mt) == "thread" and coroutine.running() == mt)
1308+
1309+
1310+
1311+local function expand (n,s)
1312+ if n==0 then return "" end
1313+ local e = string.rep("=", n)
1314+ return string.format("T.doonnewstack([%s[ %s;\n collectgarbage(); %s]%s])\n",
1315+ e, s, expand(n-1,s), e)
1316+end
1317+
1318+G=0; collectgarbage(); a =collectgarbage("count")
1319+load(expand(20,"G=G+1"))()
1320+assert(G==20); collectgarbage(); -- assert(gcinfo() <= a+1)
1321+G = nil
1322+
1323+testamem("running code on new thread", function ()
1324+ return T.doonnewstack("local x=1") == 0 -- try to create thread
1325+end)
1326+
1327+
1328+-- testing memory x compiler
1329+
1330+testamem("loadstring", function ()
1331+ return load("x=1") -- try to do load a string
1332+end)
1333+
1334+
1335+local testprog = [[
1336+local function foo () return end
1337+local t = {"x"}
1338+AA = "aaa"
1339+for i = 1, #t do AA = AA .. t[i] end
1340+return true
1341+]]
1342+
1343+-- testing memory x dofile
1344+_G.AA = nil
1345+local t =os.tmpname()
1346+local f = assert(io.open(t, "w"))
1347+f:write(testprog)
1348+f:close()
1349+testamem("dofile", function ()
1350+ local a = loadfile(t)
1351+ return a and a()
1352+end)
1353+assert(os.remove(t))
1354+assert(_G.AA == "aaax")
1355+
1356+
1357+-- other generic tests
1358+
1359+testamem("gsub", function ()
1360+ local a, b = string.gsub("alo alo", "(a)", function (x) return x..'b' end)
1361+ return (a == 'ablo ablo')
1362+end)
1363+
1364+testamem("dump/undump", function ()
1365+ local a = load(testprog)
1366+ local b = a and string.dump(a)
1367+ a = b and load(b)
1368+ return a and a()
1369+end)
1370+
1371+_G.AA = nil
1372+
1373+local t = os.tmpname()
1374+testamem("file creation", function ()
1375+ local f = assert(io.open(t, 'w'))
1376+ assert (not io.open"nomenaoexistente")
1377+ io.close(f);
1378+ return not loadfile'nomenaoexistente'
1379+end)
1380+assert(os.remove(t))
1381+
1382+testamem("table creation", function ()
1383+ local a, lim = {}, 10
1384+ for i=1,lim do a[i] = i; a[i..'a'] = {} end
1385+ return (type(a[lim..'a']) == 'table' and a[lim] == lim)
1386+end)
1387+
1388+testamem("constructors", function ()
1389+ local a = {10, 20, 30, 40, 50; a=1, b=2, c=3, d=4, e=5}
1390+ return (type(a) == 'table' and a.e == 5)
1391+end)
1392+
1393+local a = 1
1394+local close = nil
1395+testamem("closure creation", function ()
1396+ function close (b)
1397+ return function (x) return b + x end
1398+ end
1399+ return (close(2)(4) == 6)
1400+end)
1401+
1402+testamem("using coroutines", function ()
1403+ local a = coroutine.wrap(function ()
1404+ coroutine.yield(string.rep("a", 10))
1405+ return {}
1406+ end)
1407+ assert(string.len(a()) == 10)
1408+ return a()
1409+end)
1410+
1411+do -- auxiliary buffer
1412+ local lim = 100
1413+ local a = {}; for i = 1, lim do a[i] = "01234567890123456789" end
1414+ testamem("auxiliary buffer", function ()
1415+ return (#table.concat(a, ",") == 20*lim + lim - 1)
1416+ end)
1417+end
1418+
1419+testamem("growing stack", function ()
1420+ local function foo (n)
1421+ if n == 0 then return 1 else return 1 + foo(n - 1) end
1422+ end
1423+ return foo(100)
1424+end)
1425+
1426+-- }==================================================================
1427+
1428+
1429+do -- testing failing in 'lua_checkstack'
1430+ local res = T.testC([[rawcheckstack 500000; return 1]])
1431+ assert(res == false)
1432+ local L = T.newstate()
1433+ T.alloccount(0) -- will be unable to reallocate the stack
1434+ res = T.testC(L, [[rawcheckstack 5000; return 1]])
1435+ T.alloccount()
1436+ T.closestate(L)
1437+ assert(res == false)
1438+end
1439+
1440+do -- closing state with no extra memory
1441+ local L = T.newstate()
1442+ T.alloccount(0)
1443+ T.closestate(L)
1444+ T.alloccount()
1445+end
1446+
1447+do -- garbage collection with no extra memory
1448+ local L = T.newstate()
1449+ T.loadlib(L)
1450+ local res = (T.doremote(L, [[
1451+ _ENV = require"_G"
1452+ local T = require"T"
1453+ local a = {}
1454+ for i = 1, 1000 do a[i] = 'i' .. i end -- grow string table
1455+ local stsize, stuse = T.querystr()
1456+ assert(stuse > 1000)
1457+ local function foo (n)
1458+ if n > 0 then foo(n - 1) end
1459+ end
1460+ foo(180) -- grow stack
1461+ local _, stksize = T.stacklevel()
1462+ assert(stksize > 180)
1463+ a = nil
1464+ T.alloccount(0)
1465+ collectgarbage()
1466+ T.alloccount()
1467+ -- stack and string table could not be reallocated,
1468+ -- so they kept their sizes (without errors)
1469+ assert(select(2, T.stacklevel()) == stksize)
1470+ assert(T.querystr() == stsize)
1471+ return 'ok'
1472+ ]]))
1473+ assert(res == 'ok')
1474+ T.closestate(L)
1475+end
1476+
1477+print'+'
1478+
1479+-- testing some auxlib functions
1480+local function gsub (a, b, c)
1481+ a, b = T.testC("gsub 2 3 4; gettop; return 2", a, b, c)
1482+ assert(b == 5)
1483+ return a
1484+end
1485+
1486+assert(gsub("alo.alo.uhuh.", ".", "//") == "alo//alo//uhuh//")
1487+assert(gsub("alo.alo.uhuh.", "alo", "//") == "//.//.uhuh.")
1488+assert(gsub("", "alo", "//") == "")
1489+assert(gsub("...", ".", "/.") == "/././.")
1490+assert(gsub("...", "...", "") == "")
1491+
1492+
1493+-- testing luaL_newmetatable
1494+local mt_xuxu, res, top = T.testC("newmetatable xuxu; gettop; return 3")
1495+assert(type(mt_xuxu) == "table" and res and top == 3)
1496+local d, res, top = T.testC("newmetatable xuxu; gettop; return 3")
1497+assert(mt_xuxu == d and not res and top == 3)
1498+d, res, top = T.testC("newmetatable xuxu1; gettop; return 3")
1499+assert(mt_xuxu ~= d and res and top == 3)
1500+
1501+x = T.newuserdata(0);
1502+y = T.newuserdata(0);
1503+T.testC("pushstring xuxu; gettable R; setmetatable 2", x)
1504+assert(getmetatable(x) == mt_xuxu)
1505+
1506+-- testing luaL_testudata
1507+-- correct metatable
1508+local res1, res2, top = T.testC([[testudata -1 xuxu
1509+ testudata 2 xuxu
1510+ gettop
1511+ return 3]], x)
1512+assert(res1 and res2 and top == 4)
1513+
1514+-- wrong metatable
1515+res1, res2, top = T.testC([[testudata -1 xuxu1
1516+ testudata 2 xuxu1
1517+ gettop
1518+ return 3]], x)
1519+assert(not res1 and not res2 and top == 4)
1520+
1521+-- non-existent type
1522+res1, res2, top = T.testC([[testudata -1 xuxu2
1523+ testudata 2 xuxu2
1524+ gettop
1525+ return 3]], x)
1526+assert(not res1 and not res2 and top == 4)
1527+
1528+-- userdata has no metatable
1529+res1, res2, top = T.testC([[testudata -1 xuxu
1530+ testudata 2 xuxu
1531+ gettop
1532+ return 3]], y)
1533+assert(not res1 and not res2 and top == 4)
1534+
1535+-- erase metatables
1536+do
1537+ local r = debug.getregistry()
1538+ assert(r.xuxu == mt_xuxu and r.xuxu1 == d)
1539+ r.xuxu = nil; r.xuxu1 = nil
1540+end
1541+
1542+print'OK'
1543+
desk/res/lua/attrib.luanew file+527
@@ -0,0 +1,527 @@
1+-- $Id: testes/attrib.lua $
2+-- See Copyright Notice in file all.lua
3+
4+print "testing require"
5+
6+assert(require"string" == string)
7+assert(require"math" == math)
8+assert(require"table" == table)
9+assert(require"io" == io)
10+assert(require"os" == os)
11+assert(require"coroutine" == coroutine)
12+
13+assert(type(package.path) == "string")
14+assert(type(package.cpath) == "string")
15+assert(type(package.loaded) == "table")
16+assert(type(package.preload) == "table")
17+
18+assert(type(package.config) == "string")
19+print("package config: "..string.gsub(package.config, "\n", "|"))
20+
21+do
22+ -- create a path with 'max' templates,
23+ -- each with 1-10 repetitions of '?'
24+ local max = _soft and 100 or 2000
25+ local t = {}
26+ for i = 1,max do t[i] = string.rep("?", i%10 + 1) end
27+ t[#t + 1] = ";" -- empty template
28+ local path = table.concat(t, ";")
29+ -- use that path in a search
30+ local s, err = package.searchpath("xuxu", path)
31+ -- search fails; check that message has an occurrence of
32+ -- '??????????' with ? replaced by xuxu and at least 'max' lines
33+ assert(not s and
34+ string.find(err, string.rep("xuxu", 10)) and
35+ #string.gsub(err, "[^\n]", "") >= max)
36+ -- path with one very long template
37+ local path = string.rep("?", max)
38+ local s, err = package.searchpath("xuxu", path)
39+ assert(not s and string.find(err, string.rep('xuxu', max)))
40+end
41+
42+do
43+ local oldpath = package.path
44+ package.path = {}
45+ local s, err = pcall(require, "no-such-file")
46+ assert(not s and string.find(err, "package.path"))
47+ package.path = oldpath
48+end
49+
50+
51+do print"testing 'require' message"
52+ local oldpath = package.path
53+ local oldcpath = package.cpath
54+
55+ package.path = "?.lua;?/?"
56+ package.cpath = "?.so;?/init"
57+
58+ local st, msg = pcall(require, 'XXX')
59+
60+ local expected = [[module 'XXX' not found:
61+ no field package.preload['XXX']
62+ no file 'XXX.lua'
63+ no file 'XXX/XXX'
64+ no file 'XXX.so'
65+ no file 'XXX/init']]
66+
67+ assert(msg == expected)
68+
69+ package.path = oldpath
70+ package.cpath = oldcpath
71+end
72+
73+print('+')
74+
75+
76+-- The next tests for 'require' assume some specific directories and
77+-- libraries.
78+
79+if not _port then --[
80+
81+local dirsep = string.match(package.config, "^([^\n]+)\n")
82+
83+-- auxiliary directory with C modules and temporary files
84+local DIR = "libs" .. dirsep
85+
86+-- prepend DIR to a name and correct directory separators
87+local function D (x)
88+ local x = string.gsub(x, "/", dirsep)
89+ return DIR .. x
90+end
91+
92+-- prepend DIR and pospend proper C lib. extension to a name
93+local function DC (x)
94+ local ext = (dirsep == '\\') and ".dll" or ".so"
95+ return D(x .. ext)
96+end
97+
98+
99+local function createfiles (files, preextras, posextras)
100+ for n,c in pairs(files) do
101+ io.output(D(n))
102+ io.write(string.format(preextras, n))
103+ io.write(c)
104+ io.write(string.format(posextras, n))
105+ io.close(io.output())
106+ end
107+end
108+
109+local function removefiles (files)
110+ for n in pairs(files) do
111+ os.remove(D(n))
112+ end
113+end
114+
115+local files = {
116+ ["names.lua"] = "do return {...} end\n",
117+ ["err.lua"] = "B = 15; a = a + 1;",
118+ ["synerr.lua"] = "B =",
119+ ["A.lua"] = "",
120+ ["B.lua"] = "assert(...=='B');require 'A'",
121+ ["A.lc"] = "",
122+ ["A"] = "",
123+ ["L"] = "",
124+ ["XXxX"] = "",
125+ ["C.lua"] = "package.loaded[...] = 25; require'C'",
126+}
127+
128+AA = nil
129+local extras = [[
130+NAME = '%s'
131+REQUIRED = ...
132+return AA]]
133+
134+createfiles(files, "", extras)
135+
136+-- testing explicit "dir" separator in 'searchpath'
137+assert(package.searchpath("C.lua", D"?", "", "") == D"C.lua")
138+assert(package.searchpath("C.lua", D"?", ".", ".") == D"C.lua")
139+assert(package.searchpath("--x-", D"?", "-", "X") == D"XXxX")
140+assert(package.searchpath("---xX", D"?", "---", "XX") == D"XXxX")
141+assert(package.searchpath(D"C.lua", "?", dirsep) == D"C.lua")
142+assert(package.searchpath(".\\C.lua", D"?", "\\") == D"./C.lua")
143+
144+local oldpath = package.path
145+
146+package.path = string.gsub("D/?.lua;D/?.lc;D/?;D/??x?;D/L", "D/", DIR)
147+
148+local try = function (p, n, r, ext)
149+ NAME = nil
150+ local rr, x = require(p)
151+ assert(NAME == n)
152+ assert(REQUIRED == p)
153+ assert(rr == r)
154+ assert(ext == x)
155+end
156+
157+local a = require"names"
158+assert(a[1] == "names" and a[2] == D"names.lua")
159+
160+local st, msg = pcall(require, "err")
161+assert(not st and string.find(msg, "arithmetic") and B == 15)
162+st, msg = pcall(require, "synerr")
163+assert(not st and string.find(msg, "error loading module"))
164+
165+assert(package.searchpath("C", package.path) == D"C.lua")
166+assert(require"C" == 25)
167+assert(require"C" == 25)
168+AA = nil
169+try('B', 'B.lua', true, "libs/B.lua")
170+assert(package.loaded.B)
171+assert(require"B" == true)
172+assert(package.loaded.A)
173+assert(require"C" == 25)
174+package.loaded.A = nil
175+try('B', nil, true, nil) -- should not reload package
176+try('A', 'A.lua', true, "libs/A.lua")
177+package.loaded.A = nil
178+os.remove(D'A.lua')
179+AA = {}
180+try('A', 'A.lc', AA, "libs/A.lc") -- now must find second option
181+assert(package.searchpath("A", package.path) == D"A.lc")
182+assert(require("A") == AA)
183+AA = false
184+try('K', 'L', false, "libs/L") -- default option
185+try('K', 'L', false, "libs/L") -- default option (should reload it)
186+assert(rawget(_G, "_REQUIREDNAME") == nil)
187+
188+AA = "x"
189+try("X", "XXxX", AA, "libs/XXxX")
190+
191+
192+removefiles(files)
193+NAME, REQUIRED, AA, B = nil
194+
195+
196+-- testing require of sub-packages
197+
198+local _G = _G
199+
200+package.path = string.gsub("D/?.lua;D/?/init.lua", "D/", DIR)
201+
202+files = {
203+ ["P1/init.lua"] = "AA = 10",
204+ ["P1/xuxu.lua"] = "AA = 20",
205+}
206+
207+createfiles(files, "_ENV = {}\n", "\nreturn _ENV\n")
208+AA = 0
209+
210+local m, ext = assert(require"P1")
211+assert(ext == "libs/P1/init.lua")
212+assert(AA == 0 and m.AA == 10)
213+assert(require"P1" == m)
214+assert(require"P1" == m)
215+
216+assert(package.searchpath("P1.xuxu", package.path) == D"P1/xuxu.lua")
217+m.xuxu, ext = assert(require"P1.xuxu")
218+assert(AA == 0 and m.xuxu.AA == 20)
219+assert(ext == "libs/P1/xuxu.lua")
220+assert(require"P1.xuxu" == m.xuxu)
221+assert(require"P1.xuxu" == m.xuxu)
222+assert(require"P1" == m and m.AA == 10)
223+
224+
225+removefiles(files)
226+AA = nil
227+
228+package.path = ""
229+assert(not pcall(require, "file_does_not_exist"))
230+package.path = "??\0?"
231+assert(not pcall(require, "file_does_not_exist1"))
232+
233+package.path = oldpath
234+
235+-- check 'require' error message
236+local fname = "file_does_not_exist2"
237+local m, err = pcall(require, fname)
238+for t in string.gmatch(package.path..";"..package.cpath, "[^;]+") do
239+ t = string.gsub(t, "?", fname)
240+ assert(string.find(err, t, 1, true))
241+end
242+
243+do -- testing 'package.searchers' not being a table
244+ local searchers = package.searchers
245+ package.searchers = 3
246+ local st, msg = pcall(require, 'a')
247+ assert(not st and string.find(msg, "must be a table"))
248+ package.searchers = searchers
249+end
250+
251+local function import(...)
252+ local f = {...}
253+ return function (m)
254+ for i=1, #f do m[f[i]] = _G[f[i]] end
255+ end
256+end
257+
258+-- cannot change environment of a C function
259+assert(not pcall(module, 'XUXU'))
260+
261+
262+
263+-- testing require of C libraries
264+
265+
266+local p = "" -- On Mac OS X, redefine this to "_"
267+
268+-- check whether loadlib works in this system
269+local st, err, when = package.loadlib(DC"lib1", "*")
270+if not st then
271+ local f, err, when = package.loadlib("donotexist", p.."xuxu")
272+ assert(not f and type(err) == "string" and when == "absent")
273+ ;(Message or print)('\n >>> cannot load dynamic library <<<\n')
274+ print(err, when)
275+else
276+ -- tests for loadlib
277+ local f = assert(package.loadlib(DC"lib1", p.."onefunction"))
278+ local a, b = f(15, 25)
279+ assert(a == 25 and b == 15)
280+
281+ f = assert(package.loadlib(DC"lib1", p.."anotherfunc"))
282+ assert(f(10, 20) == "10%20\n")
283+
284+ -- check error messages
285+ local f, err, when = package.loadlib(DC"lib1", p.."xuxu")
286+ assert(not f and type(err) == "string" and when == "init")
287+ f, err, when = package.loadlib("donotexist", p.."xuxu")
288+ assert(not f and type(err) == "string" and when == "open")
289+
290+ -- symbols from 'lib1' must be visible to other libraries
291+ f = assert(package.loadlib(DC"lib11", p.."luaopen_lib11"))
292+ assert(f() == "exported")
293+
294+ -- test C modules with prefixes in names
295+ package.cpath = DC"?"
296+ local lib2, ext = require"lib2-v2"
297+ assert(string.find(ext, "libs/lib2-v2", 1, true))
298+ -- check correct access to global environment and correct
299+ -- parameters
300+ assert(_ENV.x == "lib2-v2" and _ENV.y == DC"lib2-v2")
301+ assert(lib2.id("x") == true) -- a different "id" implementation
302+
303+ -- test C submodules
304+ local fs, ext = require"lib1.sub"
305+ assert(_ENV.x == "lib1.sub" and _ENV.y == DC"lib1")
306+ assert(string.find(ext, "libs/lib1", 1, true))
307+ assert(fs.id(45) == 45)
308+ _ENV.x, _ENV.y = nil
309+end
310+
311+_ENV = _G
312+
313+
314+-- testing preload
315+
316+do
317+ local p = package
318+ package = {}
319+ p.preload.pl = function (...)
320+ local _ENV = {...}
321+ function xuxu (x) return x+20 end
322+ return _ENV
323+ end
324+
325+ local pl, ext = require"pl"
326+ assert(require"pl" == pl)
327+ assert(pl.xuxu(10) == 30)
328+ assert(pl[1] == "pl" and pl[2] == ":preload:" and ext == ":preload:")
329+
330+ package = p
331+ assert(type(package.path) == "string")
332+end
333+
334+print('+')
335+
336+end --]
337+
338+print("testing assignments, logical operators, and constructors")
339+
340+local res, res2 = 27
341+
342+local a, b = 1, 2+3
343+assert(a==1 and b==5)
344+a={}
345+local function f() return 10, 11, 12 end
346+a.x, b, a[1] = 1, 2, f()
347+assert(a.x==1 and b==2 and a[1]==10)
348+a[f()], b, a[f()+3] = f(), a, 'x'
349+assert(a[10] == 10 and b == a and a[13] == 'x')
350+
351+do
352+ local f = function (n) local x = {}; for i=1,n do x[i]=i end;
353+ return table.unpack(x) end;
354+ local a,b,c
355+ a,b = 0, f(1)
356+ assert(a == 0 and b == 1)
357+ a,b = 0, f(1)
358+ assert(a == 0 and b == 1)
359+ a,b,c = 0,5,f(4)
360+ assert(a==0 and b==5 and c==1)
361+ a,b,c = 0,5,f(0)
362+ assert(a==0 and b==5 and c==nil)
363+end
364+
365+local a, b, c, d = 1 and nil, 1 or nil, (1 and (nil or 1)), 6
366+assert(not a and b and c and d==6)
367+
368+d = 20
369+a, b, c, d = f()
370+assert(a==10 and b==11 and c==12 and d==nil)
371+a,b = f(), 1, 2, 3, f()
372+assert(a==10 and b==1)
373+
374+assert(a<b == false and a>b == true)
375+assert((10 and 2) == 2)
376+assert((10 or 2) == 10)
377+assert((10 or assert(nil)) == 10)
378+assert(not (nil and assert(nil)))
379+assert((nil or "alo") == "alo")
380+assert((nil and 10) == nil)
381+assert((false and 10) == false)
382+assert((true or 10) == true)
383+assert((false or 10) == 10)
384+assert(false ~= nil)
385+assert(nil ~= false)
386+assert(not nil == true)
387+assert(not not nil == false)
388+assert(not not 1 == true)
389+assert(not not a == true)
390+assert(not not (6 or nil) == true)
391+assert(not not (nil and 56) == false)
392+assert(not not (nil and true) == false)
393+assert(not 10 == false)
394+assert(not {} == false)
395+assert(not 0.5 == false)
396+assert(not "x" == false)
397+
398+assert({} ~= {})
399+print('+')
400+
401+a = {}
402+a[true] = 20
403+a[false] = 10
404+assert(a[1<2] == 20 and a[1>2] == 10)
405+
406+function f(a) return a end
407+
408+local a = {}
409+for i=3000,-3000,-1 do a[i + 0.0] = i; end
410+a[10e30] = "alo"; a[true] = 10; a[false] = 20
411+assert(a[10e30] == 'alo' and a[not 1] == 20 and a[10<20] == 10)
412+for i=3000,-3000,-1 do assert(a[i] == i); end
413+a[print] = assert
414+a[f] = print
415+a[a] = a
416+assert(a[a][a][a][a][print] == assert)
417+a[print](a[a[f]] == a[print])
418+assert(not pcall(function () local a = {}; a[nil] = 10 end))
419+assert(not pcall(function () local a = {[nil] = 10} end))
420+assert(a[nil] == undef)
421+a = nil
422+
423+local a, b, c
424+a = {10,9,8,7,6,5,4,3,2; [-3]='a', [f]=print, a='a', b='ab'}
425+a, a.x, a.y = a, a[-3]
426+assert(a[1]==10 and a[-3]==a.a and a[f]==print and a.x=='a' and not a.y)
427+a[1], f(a)[2], b, c = {['alo']=assert}, 10, a[1], a[f], 6, 10, 23, f(a), 2
428+a[1].alo(a[2]==10 and b==10 and c==print)
429+
430+a.aVeryLongName012345678901234567890123456789012345678901234567890123456789 = 10
431+local function foo ()
432+ return a.aVeryLongName012345678901234567890123456789012345678901234567890123456789
433+end
434+assert(foo() == 10 and
435+a.aVeryLongName012345678901234567890123456789012345678901234567890123456789 ==
436+10)
437+
438+
439+do
440+ -- _ENV constant
441+ local function foo ()
442+ local _ENV <const> = 11
443+ X = "hi"
444+ end
445+ local st, msg = pcall(foo)
446+ assert(not st and string.find(msg, "number"))
447+end
448+
449+
450+-- test of large float/integer indices
451+
452+-- compute maximum integer where all bits fit in a float
453+local maxint = math.maxinteger
454+
455+-- trim (if needed) to fit in a float
456+while maxint ~= (maxint + 0.0) or (maxint - 1) ~= (maxint - 1.0) do
457+ maxint = maxint // 2
458+end
459+
460+local maxintF = maxint + 0.0 -- float version
461+
462+assert(maxintF == maxint and math.type(maxintF) == "float" and
463+ maxintF >= 2.0^14)
464+
465+-- floats and integers must index the same places
466+a[maxintF] = 10; a[maxintF - 1.0] = 11;
467+a[-maxintF] = 12; a[-maxintF + 1.0] = 13;
468+
469+assert(a[maxint] == 10 and a[maxint - 1] == 11 and
470+ a[-maxint] == 12 and a[-maxint + 1] == 13)
471+
472+a[maxint] = 20
473+a[-maxint] = 22
474+
475+assert(a[maxintF] == 20 and a[maxintF - 1.0] == 11 and
476+ a[-maxintF] == 22 and a[-maxintF + 1.0] == 13)
477+
478+a = nil
479+
480+
481+-- test conflicts in multiple assignment
482+do
483+ local a,i,j,b
484+ a = {'a', 'b'}; i=1; j=2; b=a
485+ i, a[i], a, j, a[j], a[i+j] = j, i, i, b, j, i
486+ assert(i == 2 and b[1] == 1 and a == 1 and j == b and b[2] == 2 and
487+ b[3] == 1)
488+ a = {}
489+ local function foo () -- assigining to upvalues
490+ b, a.x, a = a, 10, 20
491+ end
492+ foo()
493+ assert(a == 20 and b.x == 10)
494+end
495+
496+-- repeat test with upvalues
497+do
498+ local a,i,j,b
499+ a = {'a', 'b'}; i=1; j=2; b=a
500+ local function foo ()
501+ i, a[i], a, j, a[j], a[i+j] = j, i, i, b, j, i
502+ end
503+ foo()
504+ assert(i == 2 and b[1] == 1 and a == 1 and j == b and b[2] == 2 and
505+ b[3] == 1)
506+ local t = {}
507+ (function (a) t[a], a = 10, 20 end)(1);
508+ assert(t[1] == 10)
509+end
510+
511+-- bug in 5.2 beta
512+local function foo ()
513+ local a
514+ return function ()
515+ local b
516+ a, b = 3, 14 -- local and upvalue have same index
517+ return a, b
518+ end
519+end
520+
521+local a, b = foo()()
522+assert(a == 3 and b == 14)
523+
524+print('OK')
525+
526+return res
527+
desk/res/lua/bar.luanew file+23
@@ -0,0 +1,23 @@
1+assert(010 .. 020 .. -030 == "1020-30")
2+x = - 2 ^ - 3^4
3+
4+x = 1
5+
6+print(_ENV)
7+print(_ENV._ENV)
8+
9+local foo = _ENV
10+
11+-- local x = 8
12+
13+do
14+ _ENV = {x = 2, print = print}
15+ -- local x = 3
16+ print(x)
17+ print(_ENV)
18+end
19+
20+print(_ENV)
21+print(_ENV._ENV)
22+
23+print(foo._ENV)
desk/res/lua/baz.luanew file+6
@@ -0,0 +1,6 @@
1+x = 8
2+
3+local y = x + 3
4+
5+
6+return y / 2
desk/res/lua/big.luanew file+82
@@ -0,0 +1,82 @@
1+-- $Id: testes/big.lua $
2+-- See Copyright Notice in file all.lua
3+
4+if _soft then
5+ return 'a'
6+end
7+
8+print "testing large tables"
9+
10+local debug = require"debug"
11+
12+local lim = 2^18 + 1000
13+local prog = { "local y = {0" }
14+for i = 1, lim do prog[#prog + 1] = i end
15+prog[#prog + 1] = "}\n"
16+prog[#prog + 1] = "X = y\n"
17+prog[#prog + 1] = ("assert(X[%d] == %d)"):format(lim - 1, lim - 2)
18+prog[#prog + 1] = "return 0"
19+prog = table.concat(prog, ";")
20+
21+local env = {string = string, assert = assert}
22+local f = assert(load(prog, nil, nil, env))
23+
24+f()
25+assert(env.X[lim] == lim - 1 and env.X[lim + 1] == lim)
26+for k in pairs(env) do env[k] = undef end
27+
28+-- yields during accesses larger than K (in RK)
29+setmetatable(env, {
30+ __index = function (t, n) coroutine.yield('g'); return _G[n] end,
31+ __newindex = function (t, n, v) coroutine.yield('s'); _G[n] = v end,
32+})
33+
34+X = nil
35+local co = coroutine.wrap(f)
36+assert(co() == 's')
37+assert(co() == 'g')
38+assert(co() == 'g')
39+assert(co() == 0)
40+
41+assert(X[lim] == lim - 1 and X[lim + 1] == lim)
42+
43+-- errors in accesses larger than K (in RK)
44+getmetatable(env).__index = function () end
45+getmetatable(env).__newindex = function () end
46+local e, m = pcall(f)
47+assert(not e and m:find("global 'X'"))
48+
49+-- errors in metamethods
50+getmetatable(env).__newindex = function () error("hi") end
51+local e, m = xpcall(f, debug.traceback)
52+assert(not e and m:find("'newindex'"))
53+
54+f, X = nil
55+
56+coroutine.yield'b'
57+
58+if 2^32 == 0 then -- (small integers) {
59+
60+print "testing string length overflow"
61+
62+local repstrings = 192 -- number of strings to be concatenated
63+local ssize = math.ceil(2.0^32 / repstrings) + 1 -- size of each string
64+
65+assert(repstrings * ssize > 2.0^32) -- it should be larger than maximum size
66+
67+local longs = string.rep("\0", ssize) -- create one long string
68+
69+-- create function to concatenate 'repstrings' copies of its argument
70+local rep = assert(load(
71+ "local a = ...; return " .. string.rep("a", repstrings, "..")))
72+
73+local a, b = pcall(rep, longs) -- call that function
74+
75+-- it should fail without creating string (result would be too large)
76+assert(not a and string.find(b, "overflow"))
77+
78+end -- }
79+
80+print'OK'
81+
82+return 'a'
desk/res/lua/bitwise.luanew file+363
@@ -0,0 +1,363 @@
1+-- $Id: testes/bitwise.lua $
2+-- See Copyright Notice in file all.lua
3+
4+print("testing bitwise operations")
5+
6+require "bwcoercion"
7+
8+local numbits = string.packsize('j') * 8
9+
10+assert(~0 == -1)
11+
12+assert((1 << (numbits - 1)) == math.mininteger)
13+
14+-- basic tests for bitwise operators;
15+-- use variables to avoid constant folding
16+local a, b, c, d
17+a = 0xFFFFFFFFFFFFFFFF
18+assert(a == -1 and a & -1 == a and a & 35 == 35)
19+a = 0xF0F0F0F0F0F0F0F0
20+assert(a | -1 == -1)
21+assert(a ~ a == 0 and a ~ 0 == a and a ~ ~a == -1)
22+assert(a >> 4 == ~a)
23+a = 0xF0; b = 0xCC; c = 0xAA; d = 0xFD
24+assert(a | b ~ c & d == 0xF4)
25+
26+a = 0xF0.0; b = 0xCC.0; c = "0xAA.0"; d = "0xFD.0"
27+assert(a | b ~ c & d == 0xF4)
28+
29+a = 0xF0000000; b = 0xCC000000;
30+c = 0xAA000000; d = 0xFD000000
31+assert(a | b ~ c & d == 0xF4000000)
32+assert(~~a == a and ~a == -1 ~ a and -d == ~d + 1)
33+
34+a = a << 32
35+b = b << 32
36+c = c << 32
37+d = d << 32
38+assert(a | b ~ c & d == 0xF4000000 << 32)
39+assert(~~a == a and ~a == -1 ~ a and -d == ~d + 1)
40+
41+
42+do -- constant folding
43+ local code = string.format("return -1 >> %d", math.maxinteger)
44+ assert(load(code)() == 0)
45+ local code = string.format("return -1 >> %d", math.mininteger)
46+ assert(load(code)() == 0)
47+ local code = string.format("return -1 << %d", math.maxinteger)
48+ assert(load(code)() == 0)
49+ local code = string.format("return -1 << %d", math.mininteger)
50+ assert(load(code)() == 0)
51+end
52+
53+assert(-1 >> 1 == (1 << (numbits - 1)) - 1 and 1 << 31 == 0x80000000)
54+assert(-1 >> (numbits - 1) == 1)
55+assert(-1 >> numbits == 0 and
56+ -1 >> -numbits == 0 and
57+ -1 << numbits == 0 and
58+ -1 << -numbits == 0)
59+
60+assert(1 >> math.mininteger == 0)
61+assert(1 >> math.maxinteger == 0)
62+assert(1 << math.mininteger == 0)
63+assert(1 << math.maxinteger == 0)
64+
65+assert((2^30 - 1) << 2^30 == 0)
66+assert((2^30 - 1) >> 2^30 == 0)
67+
68+assert(1 >> -3 == 1 << 3 and 1000 >> 5 == 1000 << -5)
69+
70+
71+-- coercion from strings to integers
72+assert("0xffffffffffffffff" | 0 == -1)
73+assert("0xfffffffffffffffe" & "-1" == -2)
74+assert(" \t-0xfffffffffffffffe\n\t" & "-1" == 2)
75+assert(" \n -45 \t " >> " -2 " == -45 * 4)
76+assert("1234.0" << "5.0" == 1234 * 32)
77+assert("0xffff.0" ~ "0xAAAA" == 0x5555)
78+assert(~"0x0.000p4" == -1)
79+
80+assert(("7" .. 3) << 1 == 146)
81+assert(0xffffffff >> (1 .. "9") == 0x1fff)
82+assert(10 | (1 .. "9") == 27)
83+
84+do
85+ local st, msg = pcall(function () return 4 & "a" end)
86+ assert(string.find(msg, "'band'"))
87+
88+ local st, msg = pcall(function () return ~"a" end)
89+ assert(string.find(msg, "'bnot'"))
90+end
91+
92+
93+-- out of range number
94+assert(not pcall(function () return "0xffffffffffffffff.0" | 0 end))
95+
96+-- embedded zeros
97+assert(not pcall(function () return "0xffffffffffffffff\0" | 0 end))
98+
99+print'+'
100+
101+
102+package.preload.bit32 = function () --{
103+
104+-- no built-in 'bit32' library: implement it using bitwise operators
105+
106+local bit = {}
107+
108+function bit.bnot (a)
109+ return ~a & 0xFFFFFFFF
110+end
111+
112+
113+--
114+-- in all vararg functions, avoid creating 'arg' table when there are
115+-- only 2 (or less) parameters, as 2 parameters is the common case
116+--
117+
118+function bit.band (x, y, z, ...)
119+ if not z then
120+ return ((x or -1) & (y or -1)) & 0xFFFFFFFF
121+ else
122+ local arg = {...}
123+ local res = x & y & z
124+ for i = 1, #arg do res = res & arg[i] end
125+ return res & 0xFFFFFFFF
126+ end
127+end
128+
129+function bit.bor (x, y, z, ...)
130+ if not z then
131+ return ((x or 0) | (y or 0)) & 0xFFFFFFFF
132+ else
133+ local arg = {...}
134+ local res = x | y | z
135+ for i = 1, #arg do res = res | arg[i] end
136+ return res & 0xFFFFFFFF
137+ end
138+end
139+
140+function bit.bxor (x, y, z, ...)
141+ if not z then
142+ return ((x or 0) ~ (y or 0)) & 0xFFFFFFFF
143+ else
144+ local arg = {...}
145+ local res = x ~ y ~ z
146+ for i = 1, #arg do res = res ~ arg[i] end
147+ return res & 0xFFFFFFFF
148+ end
149+end
150+
151+function bit.btest (...)
152+ return bit.band(...) ~= 0
153+end
154+
155+function bit.lshift (a, b)
156+ return ((a & 0xFFFFFFFF) << b) & 0xFFFFFFFF
157+end
158+
159+function bit.rshift (a, b)
160+ return ((a & 0xFFFFFFFF) >> b) & 0xFFFFFFFF
161+end
162+
163+function bit.arshift (a, b)
164+ a = a & 0xFFFFFFFF
165+ if b <= 0 or (a & 0x80000000) == 0 then
166+ return (a >> b) & 0xFFFFFFFF
167+ else
168+ return ((a >> b) | ~(0xFFFFFFFF >> b)) & 0xFFFFFFFF
169+ end
170+end
171+
172+function bit.lrotate (a ,b)
173+ b = b & 31
174+ a = a & 0xFFFFFFFF
175+ a = (a << b) | (a >> (32 - b))
176+ return a & 0xFFFFFFFF
177+end
178+
179+function bit.rrotate (a, b)
180+ return bit.lrotate(a, -b)
181+end
182+
183+local function checkfield (f, w)
184+ w = w or 1
185+ assert(f >= 0, "field cannot be negative")
186+ assert(w > 0, "width must be positive")
187+ assert(f + w <= 32, "trying to access non-existent bits")
188+ return f, ~(-1 << w)
189+end
190+
191+function bit.extract (a, f, w)
192+ local f, mask = checkfield(f, w)
193+ return (a >> f) & mask
194+end
195+
196+function bit.replace (a, v, f, w)
197+ local f, mask = checkfield(f, w)
198+ v = v & mask
199+ a = (a & ~(mask << f)) | (v << f)
200+ return a & 0xFFFFFFFF
201+end
202+
203+return bit
204+
205+end --}
206+
207+
208+print("testing bitwise library")
209+
210+local bit32 = require'bit32'
211+
212+assert(bit32.band() == bit32.bnot(0))
213+assert(bit32.btest() == true)
214+assert(bit32.bor() == 0)
215+assert(bit32.bxor() == 0)
216+
217+assert(bit32.band() == bit32.band(0xffffffff))
218+assert(bit32.band(1,2) == 0)
219+
220+
221+-- out-of-range numbers
222+assert(bit32.band(-1) == 0xffffffff)
223+assert(bit32.band((1 << 33) - 1) == 0xffffffff)
224+assert(bit32.band(-(1 << 33) - 1) == 0xffffffff)
225+assert(bit32.band((1 << 33) + 1) == 1)
226+assert(bit32.band(-(1 << 33) + 1) == 1)
227+assert(bit32.band(-(1 << 40)) == 0)
228+assert(bit32.band(1 << 40) == 0)
229+assert(bit32.band(-(1 << 40) - 2) == 0xfffffffe)
230+assert(bit32.band((1 << 40) - 4) == 0xfffffffc)
231+
232+assert(bit32.lrotate(0, -1) == 0)
233+assert(bit32.lrotate(0, 7) == 0)
234+assert(bit32.lrotate(0x12345678, 0) == 0x12345678)
235+assert(bit32.lrotate(0x12345678, 32) == 0x12345678)
236+assert(bit32.lrotate(0x12345678, 4) == 0x23456781)
237+assert(bit32.rrotate(0x12345678, -4) == 0x23456781)
238+assert(bit32.lrotate(0x12345678, -8) == 0x78123456)
239+assert(bit32.rrotate(0x12345678, 8) == 0x78123456)
240+assert(bit32.lrotate(0xaaaaaaaa, 2) == 0xaaaaaaaa)
241+assert(bit32.lrotate(0xaaaaaaaa, -2) == 0xaaaaaaaa)
242+for i = -50, 50 do
243+ assert(bit32.lrotate(0x89abcdef, i) == bit32.lrotate(0x89abcdef, i%32))
244+end
245+
246+assert(bit32.lshift(0x12345678, 4) == 0x23456780)
247+assert(bit32.lshift(0x12345678, 8) == 0x34567800)
248+assert(bit32.lshift(0x12345678, -4) == 0x01234567)
249+assert(bit32.lshift(0x12345678, -8) == 0x00123456)
250+assert(bit32.lshift(0x12345678, 32) == 0)
251+assert(bit32.lshift(0x12345678, -32) == 0)
252+assert(bit32.rshift(0x12345678, 4) == 0x01234567)
253+assert(bit32.rshift(0x12345678, 8) == 0x00123456)
254+assert(bit32.rshift(0x12345678, 32) == 0)
255+assert(bit32.rshift(0x12345678, -32) == 0)
256+assert(bit32.arshift(0x12345678, 0) == 0x12345678)
257+assert(bit32.arshift(0x12345678, 1) == 0x12345678 // 2)
258+assert(bit32.arshift(0x12345678, -1) == 0x12345678 * 2)
259+assert(bit32.arshift(-1, 1) == 0xffffffff)
260+assert(bit32.arshift(-1, 24) == 0xffffffff)
261+assert(bit32.arshift(-1, 32) == 0xffffffff)
262+assert(bit32.arshift(-1, -1) == bit32.band(-1 * 2, 0xffffffff))
263+
264+assert(0x12345678 << 4 == 0x123456780)
265+assert(0x12345678 << 8 == 0x1234567800)
266+assert(0x12345678 << -4 == 0x01234567)
267+assert(0x12345678 << -8 == 0x00123456)
268+assert(0x12345678 << 32 == 0x1234567800000000)
269+assert(0x12345678 << -32 == 0)
270+assert(0x12345678 >> 4 == 0x01234567)
271+assert(0x12345678 >> 8 == 0x00123456)
272+assert(0x12345678 >> 32 == 0)
273+assert(0x12345678 >> -32 == 0x1234567800000000)
274+
275+print("+")
276+-- some special cases
277+local c = {0, 1, 2, 3, 10, 0x80000000, 0xaaaaaaaa, 0x55555555,
278+ 0xffffffff, 0x7fffffff}
279+
280+for _, b in pairs(c) do
281+ assert(bit32.band(b) == b)
282+ assert(bit32.band(b, b) == b)
283+ assert(bit32.band(b, b, b, b) == b)
284+ assert(bit32.btest(b, b) == (b ~= 0))
285+ assert(bit32.band(b, b, b) == b)
286+ assert(bit32.band(b, b, b, ~b) == 0)
287+ assert(bit32.btest(b, b, b) == (b ~= 0))
288+ assert(bit32.band(b, bit32.bnot(b)) == 0)
289+ assert(bit32.bor(b, bit32.bnot(b)) == bit32.bnot(0))
290+ assert(bit32.bor(b) == b)
291+ assert(bit32.bor(b, b) == b)
292+ assert(bit32.bor(b, b, b) == b)
293+ assert(bit32.bor(b, b, 0, ~b) == 0xffffffff)
294+ assert(bit32.bxor(b) == b)
295+ assert(bit32.bxor(b, b) == 0)
296+ assert(bit32.bxor(b, b, b) == b)
297+ assert(bit32.bxor(b, b, b, b) == 0)
298+ assert(bit32.bxor(b, 0) == b)
299+ assert(bit32.bnot(b) ~= b)
300+ assert(bit32.bnot(bit32.bnot(b)) == b)
301+ assert(bit32.bnot(b) == (1 << 32) - 1 - b)
302+ assert(bit32.lrotate(b, 32) == b)
303+ assert(bit32.rrotate(b, 32) == b)
304+ assert(bit32.lshift(bit32.lshift(b, -4), 4) == bit32.band(b, bit32.bnot(0xf)))
305+ assert(bit32.rshift(bit32.rshift(b, 4), -4) == bit32.band(b, bit32.bnot(0xf)))
306+end
307+
308+-- for this test, use at most 24 bits (mantissa of a single float)
309+c = {0, 1, 2, 3, 10, 0x800000, 0xaaaaaa, 0x555555, 0xffffff, 0x7fffff}
310+for _, b in pairs(c) do
311+ for i = -40, 40 do
312+ local x = bit32.lshift(b, i)
313+ local y = math.floor(math.fmod(b * 2.0^i, 2.0^32))
314+ assert(math.fmod(x - y, 2.0^32) == 0)
315+ end
316+end
317+
318+assert(not pcall(bit32.band, {}))
319+assert(not pcall(bit32.bnot, "a"))
320+assert(not pcall(bit32.lshift, 45))
321+assert(not pcall(bit32.lshift, 45, print))
322+assert(not pcall(bit32.rshift, 45, print))
323+
324+print("+")
325+
326+
327+-- testing extract/replace
328+
329+assert(bit32.extract(0x12345678, 0, 4) == 8)
330+assert(bit32.extract(0x12345678, 4, 4) == 7)
331+assert(bit32.extract(0xa0001111, 28, 4) == 0xa)
332+assert(bit32.extract(0xa0001111, 31, 1) == 1)
333+assert(bit32.extract(0x50000111, 31, 1) == 0)
334+assert(bit32.extract(0xf2345679, 0, 32) == 0xf2345679)
335+
336+assert(not pcall(bit32.extract, 0, -1))
337+assert(not pcall(bit32.extract, 0, 32))
338+assert(not pcall(bit32.extract, 0, 0, 33))
339+assert(not pcall(bit32.extract, 0, 31, 2))
340+
341+assert(bit32.replace(0x12345678, 5, 28, 4) == 0x52345678)
342+assert(bit32.replace(0x12345678, 0x87654321, 0, 32) == 0x87654321)
343+assert(bit32.replace(0, 1, 2) == 2^2)
344+assert(bit32.replace(0, -1, 4) == 2^4)
345+assert(bit32.replace(-1, 0, 31) == (1 << 31) - 1)
346+assert(bit32.replace(-1, 0, 1, 2) == (1 << 32) - 7)
347+
348+
349+-- testing conversion of floats
350+
351+assert(bit32.bor(3.0) == 3)
352+assert(bit32.bor(-4.0) == 0xfffffffc)
353+
354+-- large floats and large-enough integers?
355+if 2.0^50 < 2.0^50 + 1.0 and 2.0^50 < (-1 >> 1) then
356+ assert(bit32.bor(2.0^32 - 5.0) == 0xfffffffb)
357+ assert(bit32.bor(-2.0^32 - 6.0) == 0xfffffffa)
358+ assert(bit32.bor(2.0^48 - 5.0) == 0xfffffffb)
359+ assert(bit32.bor(-2.0^48 - 6.0) == 0xfffffffa)
360+end
361+
362+print'OK'
363+
desk/res/lua/bwcoercion.luanew file+78
@@ -0,0 +1,78 @@
1+local tonumber, tointeger = tonumber, math.tointeger
2+local type, getmetatable, rawget, error = type, getmetatable, rawget, error
3+local strsub = string.sub
4+
5+local print = print
6+
7+_ENV = nil
8+
9+-- Try to convert a value to an integer, without assuming any coercion.
10+local function toint (x)
11+ x = tonumber(x) -- handle numerical strings
12+ if not x then
13+ return false -- not coercible to a number
14+ end
15+ return tointeger(x)
16+end
17+
18+
19+-- If operation fails, maybe second operand has a metamethod that should
20+-- have been called if not for this string metamethod, so try to
21+-- call it.
22+local function trymt (x, y, mtname)
23+ if type(y) ~= "string" then -- avoid recalling original metamethod
24+ local mt = getmetatable(y)
25+ local mm = mt and rawget(mt, mtname)
26+ if mm then
27+ return mm(x, y)
28+ end
29+ end
30+ -- if any test fails, there is no other metamethod to be called
31+ error("attempt to '" .. strsub(mtname, 3) ..
32+ "' a " .. type(x) .. " with a " .. type(y), 4)
33+end
34+
35+
36+local function checkargs (x, y, mtname)
37+ local xi = toint(x)
38+ local yi = toint(y)
39+ if xi and yi then
40+ return xi, yi
41+ else
42+ return trymt(x, y, mtname), nil
43+ end
44+end
45+
46+
47+local smt = getmetatable("")
48+
49+smt.__band = function (x, y)
50+ local x, y = checkargs(x, y, "__band")
51+ return y and x & y or x
52+end
53+
54+smt.__bor = function (x, y)
55+ local x, y = checkargs(x, y, "__bor")
56+ return y and x | y or x
57+end
58+
59+smt.__bxor = function (x, y)
60+ local x, y = checkargs(x, y, "__bxor")
61+ return y and x ~ y or x
62+end
63+
64+smt.__shl = function (x, y)
65+ local x, y = checkargs(x, y, "__shl")
66+ return y and x << y or x
67+end
68+
69+smt.__shr = function (x, y)
70+ local x, y = checkargs(x, y, "__shr")
71+ return y and x >> y or x
72+end
73+
74+smt.__bnot = function (x)
75+ local x, y = checkargs(x, x, "__bnot")
76+ return y and ~x or x
77+end
78+
desk/res/lua/calls.luanew file+497
@@ -0,0 +1,497 @@
1+-- $Id: testes/calls.lua $
2+-- See Copyright Notice in file all.lua
3+
4+print("testing functions and calls")
5+
6+local debug = require "debug"
7+
8+-- get the opportunity to test 'type' too ;)
9+
10+assert(type(1<2) == 'boolean')
11+assert(type(true) == 'boolean' and type(false) == 'boolean')
12+assert(type(nil) == 'nil'
13+ and type(-3) == 'number'
14+ and type'x' == 'string'
15+ and type{} == 'table'
16+ and type(type) == 'function')
17+
18+assert(type(assert) == type(print))
19+local function f (x) return a:x (x) end
20+assert(type(f) == 'function')
21+assert(not pcall(type))
22+
23+
24+-- testing local-function recursion
25+fact = false
26+do
27+ local res = 1
28+ local function fact (n)
29+ if n==0 then return res
30+ else return n*fact(n-1)
31+ end
32+ end
33+ assert(fact(5) == 120)
34+end
35+assert(fact == false)
36+fact = nil
37+
38+-- testing declarations
39+local a = {i = 10}
40+local self = 20
41+function a:x (x) return x+self.i end
42+function a.y (x) return x+self end
43+
44+assert(a:x(1)+10 == a.y(1))
45+
46+a.t = {i=-100}
47+a["t"].x = function (self, a,b) return self.i+a+b end
48+
49+assert(a.t:x(2,3) == -95)
50+
51+do
52+ local a = {x=0}
53+ function a:add (x) self.x, a.y = self.x+x, 20; return self end
54+ assert(a:add(10):add(20):add(30).x == 60 and a.y == 20)
55+end
56+
57+local a = {b={c={}}}
58+
59+function a.b.c.f1 (x) return x+1 end
60+function a.b.c:f2 (x,y) self[x] = y end
61+assert(a.b.c.f1(4) == 5)
62+a.b.c:f2('k', 12); assert(a.b.c.k == 12)
63+
64+print('+')
65+
66+t = nil -- 'declare' t
67+function f(a,b,c) local d = 'a'; t={a,b,c,d} end
68+
69+f( -- this line change must be valid
70+ 1,2)
71+assert(t[1] == 1 and t[2] == 2 and t[3] == nil and t[4] == 'a')
72+f(1,2, -- this one too
73+ 3,4)
74+assert(t[1] == 1 and t[2] == 2 and t[3] == 3 and t[4] == 'a')
75+
76+t = nil -- delete 't'
77+
78+function fat(x)
79+ if x <= 1 then return 1
80+ else return x*load("return fat(" .. x-1 .. ")", "")()
81+ end
82+end
83+
84+assert(load "load 'assert(fat(6)==720)' () ")()
85+a = load('return fat(5), 3')
86+local a,b = a()
87+assert(a == 120 and b == 3)
88+fat = nil
89+print('+')
90+
91+local function err_on_n (n)
92+ if n==0 then error(); exit(1);
93+ else err_on_n (n-1); exit(1);
94+ end
95+end
96+
97+do
98+ local function dummy (n)
99+ if n > 0 then
100+ assert(not pcall(err_on_n, n))
101+ dummy(n-1)
102+ end
103+ end
104+
105+ dummy(10)
106+end
107+
108+_G.deep = nil -- "declaration" (used by 'all.lua')
109+
110+function deep (n)
111+ if n>0 then deep(n-1) end
112+end
113+deep(10)
114+deep(180)
115+
116+
117+print"testing tail calls"
118+
119+function deep (n) if n>0 then return deep(n-1) else return 101 end end
120+assert(deep(30000) == 101)
121+a = {}
122+function a:deep (n) if n>0 then return self:deep(n-1) else return 101 end end
123+assert(a:deep(30000) == 101)
124+
125+do -- tail calls x varargs
126+ local function foo (x, ...) local a = {...}; return x, a[1], a[2] end
127+
128+ local function foo1 (x) return foo(10, x, x + 1) end
129+
130+ local a, b, c = foo1(-2)
131+ assert(a == 10 and b == -2 and c == -1)
132+
133+ -- tail calls x metamethods
134+ local t = setmetatable({}, {__call = foo})
135+ local function foo2 (x) return t(10, x) end
136+ a, b, c = foo2(100)
137+ assert(a == t and b == 10 and c == 100)
138+
139+ a, b = (function () return foo() end)()
140+ assert(a == nil and b == nil)
141+
142+ local X, Y, A
143+ local function foo (x, y, ...) X = x; Y = y; A = {...} end
144+ local function foo1 (...) return foo(...) end
145+
146+ local a, b, c = foo1()
147+ assert(X == nil and Y == nil and #A == 0)
148+
149+ a, b, c = foo1(10)
150+ assert(X == 10 and Y == nil and #A == 0)
151+
152+ a, b, c = foo1(10, 20)
153+ assert(X == 10 and Y == 20 and #A == 0)
154+
155+ a, b, c = foo1(10, 20, 30)
156+ assert(X == 10 and Y == 20 and #A == 1 and A[1] == 30)
157+end
158+
159+
160+do -- C-stack overflow while handling C-stack overflow
161+ local function loop ()
162+ assert(pcall(loop))
163+ end
164+
165+ local err, msg = xpcall(loop, loop)
166+ assert(not err and string.find(msg, "error"))
167+end
168+
169+
170+
171+do -- tail calls x chain of __call
172+ local n = 10000 -- depth
173+
174+ local function foo ()
175+ if n == 0 then return 1023
176+ else n = n - 1; return foo()
177+ end
178+ end
179+
180+ -- build a chain of __call metamethods ending in function 'foo'
181+ for i = 1, 100 do
182+ foo = setmetatable({}, {__call = foo})
183+ end
184+
185+ -- call the first one as a tail call in a new coroutine
186+ -- (to ensure stack is not preallocated)
187+ assert(coroutine.wrap(function() return foo() end)() == 1023)
188+end
189+
190+print('+')
191+
192+
193+do -- testing chains of '__call'
194+ local N = 20
195+ local u = table.pack
196+ for i = 1, N do
197+ u = setmetatable({i}, {__call = u})
198+ end
199+
200+ local Res = u("a", "b", "c")
201+
202+ assert(Res.n == N + 3)
203+ for i = 1, N do
204+ assert(Res[i][1] == i)
205+ end
206+ assert(Res[N + 1] == "a" and Res[N + 2] == "b" and Res[N + 3] == "c")
207+end
208+
209+
210+a = nil
211+(function (x) a=x end)(23)
212+assert(a == 23 and (function (x) return x*2 end)(20) == 40)
213+
214+
215+-- testing closures
216+
217+-- fixed-point operator
218+local Z = function (le)
219+ local function a (f)
220+ return le(function (x) return f(f)(x) end)
221+ end
222+ return a(a)
223+ end
224+
225+
226+-- non-recursive factorial
227+
228+local F = function (f)
229+ return function (n)
230+ if n == 0 then return 1
231+ else return n*f(n-1) end
232+ end
233+ end
234+
235+local fat = Z(F)
236+
237+assert(fat(0) == 1 and fat(4) == 24 and Z(F)(5)==5*Z(F)(4))
238+
239+local function g (z)
240+ local function f (a,b,c,d)
241+ return function (x,y) return a+b+c+d+a+x+y+z end
242+ end
243+ return f(z,z+1,z+2,z+3)
244+end
245+
246+local f = g(10)
247+assert(f(9, 16) == 10+11+12+13+10+9+16+10)
248+
249+print('+')
250+
251+-- testing multiple returns
252+
253+local function unlpack (t, i)
254+ i = i or 1
255+ if (i <= #t) then
256+ return t[i], unlpack(t, i+1)
257+ end
258+end
259+
260+local function equaltab (t1, t2)
261+ assert(#t1 == #t2)
262+ for i = 1, #t1 do
263+ assert(t1[i] == t2[i])
264+ end
265+end
266+
267+local pack = function (...) return (table.pack(...)) end
268+
269+local function f() return 1,2,30,4 end
270+local function ret2 (a,b) return a,b end
271+
272+local a,b,c,d = unlpack{1,2,3}
273+assert(a==1 and b==2 and c==3 and d==nil)
274+a = {1,2,3,4,false,10,'alo',false,assert}
275+equaltab(pack(unlpack(a)), a)
276+equaltab(pack(unlpack(a), -1), {1,-1})
277+a,b,c,d = ret2(f()), ret2(f())
278+assert(a==1 and b==1 and c==2 and d==nil)
279+a,b,c,d = unlpack(pack(ret2(f()), ret2(f())))
280+assert(a==1 and b==1 and c==2 and d==nil)
281+a,b,c,d = unlpack(pack(ret2(f()), (ret2(f()))))
282+assert(a==1 and b==1 and c==nil and d==nil)
283+
284+a = ret2{ unlpack{1,2,3}, unlpack{3,2,1}, unlpack{"a", "b"}}
285+assert(a[1] == 1 and a[2] == 3 and a[3] == "a" and a[4] == "b")
286+
287+
288+-- testing calls with 'incorrect' arguments
289+rawget({}, "x", 1)
290+rawset({}, "x", 1, 2)
291+assert(math.sin(1,2) == math.sin(1))
292+table.sort({10,9,8,4,19,23,0,0}, function (a,b) return a<b end, "extra arg")
293+
294+
295+-- test for generic load
296+local x = "-- a comment\0\0\0\n x = 10 + \n23; \
297+ local a = function () x = 'hi' end; \
298+ return '\0'"
299+local function read1 (x)
300+ local i = 0
301+ return function ()
302+ collectgarbage()
303+ i=i+1
304+ return string.sub(x, i, i)
305+ end
306+end
307+
308+local function cannotload (msg, a,b)
309+ assert(not a and string.find(b, msg))
310+end
311+
312+a = assert(load(read1(x), "modname", "t", _G))
313+assert(a() == "\0" and _G.x == 33)
314+assert(debug.getinfo(a).source == "modname")
315+-- cannot read text in binary mode
316+cannotload("attempt to load a text chunk", load(read1(x), "modname", "b", {}))
317+cannotload("attempt to load a text chunk", load(x, "modname", "b"))
318+
319+a = assert(load(function () return nil end))
320+a() -- empty chunk
321+
322+assert(not load(function () return true end))
323+
324+
325+-- small bug
326+local t = {nil, "return ", "3"}
327+f, msg = load(function () return table.remove(t, 1) end)
328+assert(f() == nil) -- should read the empty chunk
329+
330+-- another small bug (in 5.2.1)
331+f = load(string.dump(function () return 1 end), nil, "b", {})
332+assert(type(f) == "function" and f() == 1)
333+
334+
335+do -- another bug (in 5.4.0)
336+ -- loading a binary long string interrupted by GC cycles
337+ local f = string.dump(function ()
338+ return '01234567890123456789012345678901234567890123456789'
339+ end)
340+ f = load(read1(f))
341+ assert(f() == '01234567890123456789012345678901234567890123456789')
342+end
343+
344+
345+x = string.dump(load("x = 1; return x"))
346+a = assert(load(read1(x), nil, "b"))
347+assert(a() == 1 and _G.x == 1)
348+cannotload("attempt to load a binary chunk", load(read1(x), nil, "t"))
349+cannotload("attempt to load a binary chunk", load(x, nil, "t"))
350+_G.x = nil
351+
352+assert(not pcall(string.dump, print)) -- no dump of C functions
353+
354+cannotload("unexpected symbol", load(read1("*a = 123")))
355+cannotload("unexpected symbol", load("*a = 123"))
356+cannotload("hhi", load(function () error("hhi") end))
357+
358+-- any value is valid for _ENV
359+assert(load("return _ENV", nil, nil, 123)() == 123)
360+
361+
362+-- load when _ENV is not first upvalue
363+local x; XX = 123
364+local function h ()
365+ local y=x -- use 'x', so that it becomes 1st upvalue
366+ return XX -- global name
367+end
368+local d = string.dump(h)
369+x = load(d, "", "b")
370+assert(debug.getupvalue(x, 2) == '_ENV')
371+debug.setupvalue(x, 2, _G)
372+assert(x() == 123)
373+
374+assert(assert(load("return XX + ...", nil, nil, {XX = 13}))(4) == 17)
375+XX = nil
376+
377+-- test generic load with nested functions
378+x = [[
379+ return function (x)
380+ return function (y)
381+ return function (z)
382+ return x+y+z
383+ end
384+ end
385+ end
386+]]
387+a = assert(load(read1(x), "read", "t"))
388+assert(a()(2)(3)(10) == 15)
389+
390+-- repeat the test loading a binary chunk
391+x = string.dump(a)
392+a = assert(load(read1(x), "read", "b"))
393+assert(a()(2)(3)(10) == 15)
394+
395+
396+-- test for dump/undump with upvalues
397+local a, b = 20, 30
398+x = load(string.dump(function (x)
399+ if x == "set" then a = 10+b; b = b+1 else
400+ return a
401+ end
402+end), "", "b", nil)
403+assert(x() == nil)
404+assert(debug.setupvalue(x, 1, "hi") == "a")
405+assert(x() == "hi")
406+assert(debug.setupvalue(x, 2, 13) == "b")
407+assert(not debug.setupvalue(x, 3, 10)) -- only 2 upvalues
408+x("set")
409+assert(x() == 23)
410+x("set")
411+assert(x() == 24)
412+
413+-- test for dump/undump with many upvalues
414+do
415+ local nup = 200 -- maximum number of local variables
416+ local prog = {"local a1"}
417+ for i = 2, nup do prog[#prog + 1] = ", a" .. i end
418+ prog[#prog + 1] = " = 1"
419+ for i = 2, nup do prog[#prog + 1] = ", " .. i end
420+ local sum = 1
421+ prog[#prog + 1] = "; return function () return a1"
422+ for i = 2, nup do prog[#prog + 1] = " + a" .. i; sum = sum + i end
423+ prog[#prog + 1] = " end"
424+ prog = table.concat(prog)
425+ local f = assert(load(prog))()
426+ assert(f() == sum)
427+
428+ f = load(string.dump(f)) -- main chunk now has many upvalues
429+ local a = 10
430+ local h = function () return a end
431+ for i = 1, nup do
432+ debug.upvaluejoin(f, i, h, 1)
433+ end
434+ assert(f() == 10 * nup)
435+end
436+
437+-- test for long method names
438+do
439+ local t = {x = 1}
440+ function t:_012345678901234567890123456789012345678901234567890123456789 ()
441+ return self.x
442+ end
443+ assert(t:_012345678901234567890123456789012345678901234567890123456789() == 1)
444+end
445+
446+
447+-- test for bug in parameter adjustment
448+assert((function () return nil end)(4) == nil)
449+assert((function () local a; return a end)(4) == nil)
450+assert((function (a) return a end)() == nil)
451+
452+
453+print("testing binary chunks")
454+do
455+ local header = string.pack("c4BBc6BBB",
456+ "\27Lua", -- signature
457+ 0x54, -- version 5.4 (0x54)
458+ 0, -- format
459+ "\x19\x93\r\n\x1a\n", -- data
460+ 4, -- size of instruction
461+ string.packsize("j"), -- sizeof(lua integer)
462+ string.packsize("n") -- sizeof(lua number)
463+ )
464+ local c = string.dump(function ()
465+ local a = 1; local b = 3;
466+ local f = function () return a + b + _ENV.c; end -- upvalues
467+ local s1 = "a constant"
468+ local s2 = "another constant"
469+ return a + b * 3
470+ end)
471+
472+ assert(assert(load(c))() == 10)
473+
474+ -- check header
475+ assert(string.sub(c, 1, #header) == header)
476+ -- check LUAC_INT and LUAC_NUM
477+ local ci, cn = string.unpack("jn", c, #header + 1)
478+ assert(ci == 0x5678 and cn == 370.5)
479+
480+ -- corrupted header
481+ for i = 1, #header do
482+ local s = string.sub(c, 1, i - 1) ..
483+ string.char(string.byte(string.sub(c, i, i)) + 1) ..
484+ string.sub(c, i + 1, -1)
485+ assert(#s == #c)
486+ assert(not load(s))
487+ end
488+
489+ -- loading truncated binary chunks
490+ for i = 1, #c - 1 do
491+ local st, msg = load(string.sub(c, 1, i))
492+ assert(not st and string.find(msg, "truncated"))
493+ end
494+end
495+
496+print('OK')
497+return deep
desk/res/lua/closure.luanew file+272
@@ -0,0 +1,272 @@
1+-- $Id: testes/closure.lua $
2+-- See Copyright Notice in file all.lua
3+
4+print "testing closures"
5+
6+local A,B = 0,{g=10}
7+local function f(x)
8+ local a = {}
9+ for i=1,1000 do
10+ local y = 0
11+ do
12+ a[i] = function () B.g = B.g+1; y = y+x; return y+A end
13+ end
14+ end
15+ local dummy = function () return a[A] end
16+ collectgarbage()
17+ A = 1; assert(dummy() == a[1]); A = 0;
18+ assert(a[1]() == x)
19+ assert(a[3]() == x)
20+ collectgarbage()
21+ assert(B.g == 12)
22+ return a
23+end
24+
25+local a = f(10)
26+-- force a GC in this level
27+local x = {[1] = {}} -- to detect a GC
28+setmetatable(x, {__mode = 'kv'})
29+while x[1] do -- repeat until GC
30+ local a = A..A..A..A -- create garbage
31+ A = A+1
32+end
33+assert(a[1]() == 20+A)
34+assert(a[1]() == 30+A)
35+assert(a[2]() == 10+A)
36+collectgarbage()
37+assert(a[2]() == 20+A)
38+assert(a[2]() == 30+A)
39+assert(a[3]() == 20+A)
40+assert(a[8]() == 10+A)
41+assert(getmetatable(x).__mode == 'kv')
42+assert(B.g == 19)
43+
44+
45+-- testing equality
46+a = {}
47+
48+for i = 1, 5 do a[i] = function (x) return i + a + _ENV end end
49+assert(a[3] ~= a[4] and a[4] ~= a[5])
50+
51+do
52+ local a = function (x) return math.sin(_ENV[x]) end
53+ local function f()
54+ return a
55+ end
56+ assert(f() == f())
57+end
58+
59+
60+-- testing closures with 'for' control variable
61+a = {}
62+for i=1,10 do
63+ a[i] = {set = function(x) i=x end, get = function () return i end}
64+ if i == 3 then break end
65+end
66+assert(a[4] == undef)
67+a[1].set(10)
68+assert(a[2].get() == 2)
69+a[2].set('a')
70+assert(a[3].get() == 3)
71+assert(a[2].get() == 'a')
72+
73+a = {}
74+local t = {"a", "b"}
75+for i = 1, #t do
76+ local k = t[i]
77+ a[i] = {set = function(x, y) i=x; k=y end,
78+ get = function () return i, k end}
79+ if i == 2 then break end
80+end
81+a[1].set(10, 20)
82+local r,s = a[2].get()
83+assert(r == 2 and s == 'b')
84+r,s = a[1].get()
85+assert(r == 10 and s == 20)
86+a[2].set('a', 'b')
87+r,s = a[2].get()
88+assert(r == "a" and s == "b")
89+
90+
91+-- testing closures with 'for' control variable x break
92+local f
93+for i=1,3 do
94+ f = function () return i end
95+ break
96+end
97+assert(f() == 1)
98+
99+for k = 1, #t do
100+ local v = t[k]
101+ f = function () return k, v end
102+ break
103+end
104+assert(({f()})[1] == 1)
105+assert(({f()})[2] == "a")
106+
107+
108+-- testing closure x break x return x errors
109+
110+local b
111+function f(x)
112+ local first = 1
113+ while 1 do
114+ if x == 3 and not first then return end
115+ local a = 'xuxu'
116+ b = function (op, y)
117+ if op == 'set' then
118+ a = x+y
119+ else
120+ return a
121+ end
122+ end
123+ if x == 1 then do break end
124+ elseif x == 2 then return
125+ else if x ~= 3 then error() end
126+ end
127+ first = nil
128+ end
129+end
130+
131+for i=1,3 do
132+ f(i)
133+ assert(b('get') == 'xuxu')
134+ b('set', 10); assert(b('get') == 10+i)
135+ b = nil
136+end
137+
138+pcall(f, 4);
139+assert(b('get') == 'xuxu')
140+b('set', 10); assert(b('get') == 14)
141+
142+
143+local y, w
144+-- testing multi-level closure
145+function f(x)
146+ return function (y)
147+ return function (z) return w+x+y+z end
148+ end
149+end
150+
151+y = f(10)
152+w = 1.345
153+assert(y(20)(30) == 60+w)
154+
155+
156+-- testing closures x break
157+do
158+ local X, Y
159+ local a = math.sin(0)
160+
161+ while a do
162+ local b = 10
163+ X = function () return b end -- closure with upvalue
164+ if a then break end
165+ end
166+
167+ do
168+ local b = 20
169+ Y = function () return b end -- closure with upvalue
170+ end
171+
172+ -- upvalues must be different
173+ assert(X() == 10 and Y() == 20)
174+end
175+
176+
177+-- testing closures x repeat-until
178+
179+local a = {}
180+local i = 1
181+repeat
182+ local x = i
183+ a[i] = function () i = x+1; return x end
184+until i > 10 or a[i]() ~= x
185+assert(i == 11 and a[1]() == 1 and a[3]() == 3 and i == 4)
186+
187+
188+-- testing closures created in 'then' and 'else' parts of 'if's
189+a = {}
190+for i = 1, 10 do
191+ if i % 3 == 0 then
192+ local y = 0
193+ a[i] = function (x) local t = y; y = x; return t end
194+ elseif i % 3 == 1 then
195+ goto L1
196+ error'not here'
197+ ::L1::
198+ local y = 1
199+ a[i] = function (x) local t = y; y = x; return t end
200+ elseif i % 3 == 2 then
201+ local t
202+ goto l4
203+ ::l4a:: a[i] = t; goto l4b
204+ error("should never be here!")
205+ ::l4::
206+ local y = 2
207+ t = function (x) local t = y; y = x; return t end
208+ goto l4a
209+ error("should never be here!")
210+ ::l4b::
211+ end
212+end
213+
214+for i = 1, 10 do
215+ assert(a[i](i * 10) == i % 3 and a[i]() == i * 10)
216+end
217+
218+print'+'
219+
220+
221+-- test for correctly closing upvalues in tail calls of vararg functions
222+local function t ()
223+ local function c(a,b) assert(a=="test" and b=="OK") end
224+ local function v(f, ...) c("test", f() ~= 1 and "FAILED" or "OK") end
225+ local x = 1
226+ return v(function() return x end)
227+end
228+t()
229+
230+
231+-- test for debug manipulation of upvalues
232+local debug = require'debug'
233+
234+local foo1, foo2, foo3
235+do
236+ local a , b, c = 3, 5, 7
237+ foo1 = function () return a+b end;
238+ foo2 = function () return b+a end;
239+ do
240+ local a = 10
241+ foo3 = function () return a+b end;
242+ end
243+end
244+
245+assert(debug.upvalueid(foo1, 1))
246+assert(debug.upvalueid(foo1, 2))
247+assert(not debug.upvalueid(foo1, 3))
248+assert(debug.upvalueid(foo1, 1) == debug.upvalueid(foo2, 2))
249+assert(debug.upvalueid(foo1, 2) == debug.upvalueid(foo2, 1))
250+assert(debug.upvalueid(foo3, 1))
251+assert(debug.upvalueid(foo1, 1) ~= debug.upvalueid(foo3, 1))
252+assert(debug.upvalueid(foo1, 2) == debug.upvalueid(foo3, 2))
253+
254+assert(debug.upvalueid(string.gmatch("x", "x"), 1) ~= nil)
255+
256+assert(foo1() == 3 + 5 and foo2() == 5 + 3)
257+debug.upvaluejoin(foo1, 2, foo2, 2)
258+assert(foo1() == 3 + 3 and foo2() == 5 + 3)
259+assert(foo3() == 10 + 5)
260+debug.upvaluejoin(foo3, 2, foo2, 1)
261+assert(foo3() == 10 + 5)
262+debug.upvaluejoin(foo3, 2, foo2, 2)
263+assert(foo3() == 10 + 3)
264+
265+assert(not pcall(debug.upvaluejoin, foo1, 3, foo2, 1))
266+assert(not pcall(debug.upvaluejoin, foo1, 1, foo2, 3))
267+assert(not pcall(debug.upvaluejoin, foo1, 0, foo2, 1))
268+assert(not pcall(debug.upvaluejoin, print, 1, foo2, 1))
269+assert(not pcall(debug.upvaluejoin, {}, 1, foo2, 1))
270+assert(not pcall(debug.upvaluejoin, foo1, 1, print, 1))
271+
272+print'OK'
desk/res/lua/code.luanew file+449
@@ -0,0 +1,449 @@
1+-- $Id: testes/code.lua $
2+-- See Copyright Notice in file all.lua
3+
4+if T==nil then
5+ (Message or print)('\n >>> testC not active: skipping opcode tests <<<\n')
6+ return
7+end
8+print "testing code generation and optimizations"
9+
10+-- to test constant propagation
11+local k0aux <const> = 0
12+local k0 <const> = k0aux
13+local k1 <const> = 1
14+local k3 <const> = 3
15+local k6 <const> = k3 + (k3 << k0)
16+local kFF0 <const> = 0xFF0
17+local k3_78 <const> = 3.78
18+local x, k3_78_4 <const> = 10, k3_78 / 4
19+assert(x == 10)
20+
21+local kx <const> = "x"
22+
23+local kTrue <const> = true
24+local kFalse <const> = false
25+
26+local kNil <const> = nil
27+
28+-- this code gave an error for the code checker
29+do
30+ local function f (a)
31+ for k,v,w in a do end
32+ end
33+end
34+
35+
36+-- testing reuse in constant table
37+local function checkKlist (func, list)
38+ local k = T.listk(func)
39+ assert(#k == #list)
40+ for i = 1, #k do
41+ assert(k[i] == list[i] and math.type(k[i]) == math.type(list[i]))
42+ end
43+end
44+
45+local function foo ()
46+ local a
47+ a = k3;
48+ a = 0; a = 0.0; a = -7 + 7
49+ a = k3_78/4; a = k3_78_4
50+ a = -k3_78/4; a = k3_78/4; a = -3.78/4
51+ a = -3.79/4; a = 0.0; a = -0;
52+ a = k3; a = 3.0; a = 3; a = 3.0
53+end
54+
55+checkKlist(foo, {3.78/4, -3.78/4, -3.79/4})
56+
57+
58+foo = function (f, a)
59+ f(100 * 1000)
60+ f(100.0 * 1000)
61+ f(-100 * 1000)
62+ f(-100 * 1000.0)
63+ f(100000)
64+ f(100000.0)
65+ f(-100000)
66+ f(-100000.0)
67+ end
68+
69+checkKlist(foo, {100000, 100000.0, -100000, -100000.0})
70+
71+
72+-- floats x integers
73+foo = function (t, a)
74+ t[a] = 1; t[a] = 1.0
75+ t[a] = 1; t[a] = 1.0
76+ t[a] = 2; t[a] = 2.0
77+ t[a] = 0; t[a] = 0.0
78+ t[a] = 1; t[a] = 1.0
79+ t[a] = 2; t[a] = 2.0
80+ t[a] = 0; t[a] = 0.0
81+end
82+
83+checkKlist(foo, {1, 1.0, 2, 2.0, 0, 0.0})
84+
85+
86+-- testing opcodes
87+
88+-- check that 'f' opcodes match '...'
89+local function check (f, ...)
90+ local arg = {...}
91+ local c = T.listcode(f)
92+ for i=1, #arg do
93+ local opcode = string.match(c[i], "%u%w+")
94+ -- print(arg[i], opcode)
95+ assert(arg[i] == opcode)
96+ end
97+ assert(c[#arg+2] == undef)
98+end
99+
100+
101+-- check that 'f' opcodes match '...' and that 'f(p) == r'.
102+local function checkR (f, p, r, ...)
103+ local r1 = f(p)
104+ assert(r == r1 and math.type(r) == math.type(r1))
105+ check(f, ...)
106+end
107+
108+
109+-- check that 'a' and 'b' has the same opcodes
110+local function checkequal (a, b)
111+ a = T.listcode(a)
112+ b = T.listcode(b)
113+ assert(#a == #b)
114+ for i = 1, #a do
115+ a[i] = string.gsub(a[i], '%b()', '') -- remove line number
116+ b[i] = string.gsub(b[i], '%b()', '') -- remove line number
117+ assert(a[i] == b[i])
118+ end
119+end
120+
121+
122+-- some basic instructions
123+check(function () -- function does not create upvalues
124+ (function () end){f()}
125+end, 'CLOSURE', 'NEWTABLE', 'EXTRAARG', 'GETTABUP', 'CALL',
126+ 'SETLIST', 'CALL', 'RETURN0')
127+
128+check(function (x) -- function creates upvalues
129+ (function () return x end){f()}
130+end, 'CLOSURE', 'NEWTABLE', 'EXTRAARG', 'GETTABUP', 'CALL',
131+ 'SETLIST', 'CALL', 'RETURN')
132+
133+
134+-- sequence of LOADNILs
135+check(function ()
136+ local kNil <const> = nil
137+ local a,b,c
138+ local d; local e;
139+ local f,g,h;
140+ d = nil; d=nil; b=nil; a=kNil; c=nil;
141+end, 'LOADNIL', 'RETURN0')
142+
143+check(function ()
144+ local a,b,c,d = 1,1,1,1
145+ d=nil;c=nil;b=nil;a=nil
146+end, 'LOADI', 'LOADI', 'LOADI', 'LOADI', 'LOADNIL', 'RETURN0')
147+
148+do
149+ local a,b,c,d = 1,1,1,1
150+ d=nil;c=nil;b=nil;a=nil
151+ assert(a == nil and b == nil and c == nil and d == nil)
152+end
153+
154+
155+-- single return
156+check (function (a,b,c) return a end, 'RETURN1')
157+
158+
159+-- infinite loops
160+check(function () while kTrue do local a = -1 end end,
161+'LOADI', 'JMP', 'RETURN0')
162+
163+check(function () while 1 do local a = -1 end end,
164+'LOADI', 'JMP', 'RETURN0')
165+
166+check(function () repeat local x = 1 until true end,
167+'LOADI', 'RETURN0')
168+
169+
170+-- concat optimization
171+check(function (a,b,c,d) return a..b..c..d end,
172+ 'MOVE', 'MOVE', 'MOVE', 'MOVE', 'CONCAT', 'RETURN1')
173+
174+-- not
175+check(function () return not not nil end, 'LOADFALSE', 'RETURN1')
176+check(function () return not not kFalse end, 'LOADFALSE', 'RETURN1')
177+check(function () return not not true end, 'LOADTRUE', 'RETURN1')
178+check(function () return not not k3 end, 'LOADTRUE', 'RETURN1')
179+
180+-- direct access to locals
181+check(function ()
182+ local a,b,c,d
183+ a = b*a
184+ c.x, a[b] = -((a + d/b - a[b]) ^ a.x), b
185+end,
186+ 'LOADNIL',
187+ 'MUL', 'MMBIN',
188+ 'DIV', 'MMBIN', 'ADD', 'MMBIN', 'GETTABLE', 'SUB', 'MMBIN',
189+ 'GETFIELD', 'POW', 'MMBIN', 'UNM', 'SETTABLE', 'SETFIELD', 'RETURN0')
190+
191+
192+-- direct access to constants
193+check(function ()
194+ local a,b
195+ local c = kNil
196+ a[kx] = 3.2
197+ a.x = b
198+ a[b] = 'x'
199+end,
200+ 'LOADNIL', 'SETFIELD', 'SETFIELD', 'SETTABLE', 'RETURN0')
201+
202+-- "get/set table" with numeric indices
203+check(function (a)
204+ local k255 <const> = 255
205+ a[1] = a[100]
206+ a[k255] = a[256]
207+ a[256] = 5
208+end,
209+ 'GETI', 'SETI',
210+ 'LOADI', 'GETTABLE', 'SETI',
211+ 'LOADI', 'SETTABLE', 'RETURN0')
212+
213+check(function ()
214+ local a,b
215+ a = a - a
216+ b = a/a
217+ b = 5-4
218+end,
219+ 'LOADNIL', 'SUB', 'MMBIN', 'DIV', 'MMBIN', 'LOADI', 'RETURN0')
220+
221+check(function ()
222+ local a,b
223+ a[kTrue] = false
224+end,
225+ 'LOADNIL', 'LOADTRUE', 'SETTABLE', 'RETURN0')
226+
227+
228+-- equalities
229+checkR(function (a) if a == 1 then return 2 end end, 1, 2,
230+ 'EQI', 'JMP', 'LOADI', 'RETURN1')
231+
232+checkR(function (a) if -4.0 == a then return 2 end end, -4, 2,
233+ 'EQI', 'JMP', 'LOADI', 'RETURN1')
234+
235+checkR(function (a) if a == "hi" then return 2 end end, 10, nil,
236+ 'EQK', 'JMP', 'LOADI', 'RETURN1')
237+
238+checkR(function (a) if a == 10000 then return 2 end end, 1, nil,
239+ 'EQK', 'JMP', 'LOADI', 'RETURN1') -- number too large
240+
241+checkR(function (a) if -10000 == a then return 2 end end, -10000, 2,
242+ 'EQK', 'JMP', 'LOADI', 'RETURN1') -- number too large
243+
244+-- comparisons
245+
246+checkR(function (a) if -10 <= a then return 2 end end, -10, 2,
247+ 'GEI', 'JMP', 'LOADI', 'RETURN1')
248+
249+checkR(function (a) if 128.0 > a then return 2 end end, 129, nil,
250+ 'LTI', 'JMP', 'LOADI', 'RETURN1')
251+
252+checkR(function (a) if -127.0 < a then return 2 end end, -127, nil,
253+ 'GTI', 'JMP', 'LOADI', 'RETURN1')
254+
255+checkR(function (a) if 10 < a then return 2 end end, 11, 2,
256+ 'GTI', 'JMP', 'LOADI', 'RETURN1')
257+
258+checkR(function (a) if 129 < a then return 2 end end, 130, 2,
259+ 'LOADI', 'LT', 'JMP', 'LOADI', 'RETURN1')
260+
261+checkR(function (a) if a >= 23.0 then return 2 end end, 25, 2,
262+ 'GEI', 'JMP', 'LOADI', 'RETURN1')
263+
264+checkR(function (a) if a >= 23.1 then return 2 end end, 0, nil,
265+ 'LOADK', 'LE', 'JMP', 'LOADI', 'RETURN1')
266+
267+checkR(function (a) if a > 2300.0 then return 2 end end, 0, nil,
268+ 'LOADF', 'LT', 'JMP', 'LOADI', 'RETURN1')
269+
270+
271+-- constant folding
272+local function checkK (func, val)
273+ check(func, 'LOADK', 'RETURN1')
274+ checkKlist(func, {val})
275+ assert(func() == val)
276+end
277+
278+local function checkI (func, val)
279+ check(func, 'LOADI', 'RETURN1')
280+ checkKlist(func, {})
281+ assert(func() == val)
282+end
283+
284+local function checkF (func, val)
285+ check(func, 'LOADF', 'RETURN1')
286+ checkKlist(func, {})
287+ assert(func() == val)
288+end
289+
290+checkF(function () return 0.0 end, 0.0)
291+checkI(function () return k0 end, 0)
292+checkI(function () return -k0//1 end, 0)
293+checkK(function () return 3^-1 end, 1/3)
294+checkK(function () return (1 + 1)^(50 + 50) end, 2^100)
295+checkK(function () return (-2)^(31 - 2) end, -0x20000000 + 0.0)
296+checkF(function () return (-k3^0 + 5) // 3.0 end, 1.0)
297+checkI(function () return -k3 % 5 end, 2)
298+checkF(function () return -((2.0^8 + -(-1)) % 8)/2 * 4 - 3 end, -5.0)
299+checkF(function () return -((2^8 + -(-1)) % 8)//2 * 4 - 3 end, -7.0)
300+checkI(function () return 0xF0.0 | 0xCC.0 ~ 0xAA & 0xFD end, 0xF4)
301+checkI(function () return ~(~kFF0 | kFF0) end, 0)
302+checkI(function () return ~~-1024.0 end, -1024)
303+checkI(function () return ((100 << k6) << -4) >> 2 end, 100)
304+
305+-- borders around MAXARG_sBx ((((1 << 17) - 1) >> 1) == 65535)
306+local a = 17; local sbx = ((1 << a) - 1) >> 1 -- avoid folding
307+local border <const> = 65535
308+checkI(function () return border end, sbx)
309+checkI(function () return -border end, -sbx)
310+checkI(function () return border + 1 end, sbx + 1)
311+checkK(function () return border + 2 end, sbx + 2)
312+checkK(function () return -(border + 1) end, -(sbx + 1))
313+
314+local border <const> = 65535.0
315+checkF(function () return border end, sbx + 0.0)
316+checkF(function () return -border end, -sbx + 0.0)
317+checkF(function () return border + 1 end, (sbx + 1.0))
318+checkK(function () return border + 2 end, (sbx + 2.0))
319+checkK(function () return -(border + 1) end, -(sbx + 1.0))
320+
321+
322+-- immediate operands
323+checkR(function (x) return x + k1 end, 10, 11, 'ADDI', 'MMBINI', 'RETURN1')
324+checkR(function (x) return x - 127 end, 10, -117, 'ADDI', 'MMBINI', 'RETURN1')
325+checkR(function (x) return 128 + x end, 0.0, 128.0,
326+ 'ADDI', 'MMBINI', 'RETURN1')
327+checkR(function (x) return x * -127 end, -1.0, 127.0,
328+ 'MULK', 'MMBINK', 'RETURN1')
329+checkR(function (x) return 20 * x end, 2, 40, 'MULK', 'MMBINK', 'RETURN1')
330+checkR(function (x) return x ^ -2 end, 2, 0.25, 'POWK', 'MMBINK', 'RETURN1')
331+checkR(function (x) return x / 40 end, 40, 1.0, 'DIVK', 'MMBINK', 'RETURN1')
332+checkR(function (x) return x // 1 end, 10.0, 10.0,
333+ 'IDIVK', 'MMBINK', 'RETURN1')
334+checkR(function (x) return x % (100 - 10) end, 91, 1,
335+ 'MODK', 'MMBINK', 'RETURN1')
336+checkR(function (x) return k1 << x end, 3, 8, 'SHLI', 'MMBINI', 'RETURN1')
337+checkR(function (x) return x << 127 end, 10, 0, 'SHRI', 'MMBINI', 'RETURN1')
338+checkR(function (x) return x << -127 end, 10, 0, 'SHRI', 'MMBINI', 'RETURN1')
339+checkR(function (x) return x >> 128 end, 8, 0, 'SHRI', 'MMBINI', 'RETURN1')
340+checkR(function (x) return x >> -127 end, 8, 0, 'SHRI', 'MMBINI', 'RETURN1')
341+checkR(function (x) return x & 1 end, 9, 1, 'BANDK', 'MMBINK', 'RETURN1')
342+checkR(function (x) return 10 | x end, 1, 11, 'BORK', 'MMBINK', 'RETURN1')
343+checkR(function (x) return -10 ~ x end, -1, 9, 'BXORK', 'MMBINK', 'RETURN1')
344+
345+-- K operands in arithmetic operations
346+checkR(function (x) return x + 0.0 end, 1, 1.0, 'ADDK', 'MMBINK', 'RETURN1')
347+-- check(function (x) return 128 + x end, 'ADDK', 'MMBINK', 'RETURN1')
348+checkR(function (x) return x * -10000 end, 2, -20000,
349+ 'MULK', 'MMBINK', 'RETURN1')
350+-- check(function (x) return 20 * x end, 'MULK', 'MMBINK', 'RETURN1')
351+checkR(function (x) return x ^ 0.5 end, 4, 2.0, 'POWK', 'MMBINK', 'RETURN1')
352+checkR(function (x) return x / 2.0 end, 4, 2.0, 'DIVK', 'MMBINK', 'RETURN1')
353+checkR(function (x) return x // 10000 end, 10000, 1,
354+ 'IDIVK', 'MMBINK', 'RETURN1')
355+checkR(function (x) return x % (100.0 - 10) end, 91, 1.0,
356+ 'MODK', 'MMBINK', 'RETURN1')
357+
358+-- no foldings (and immediate operands)
359+check(function () return -0.0 end, 'LOADF', 'UNM', 'RETURN1')
360+check(function () return k3/0 end, 'LOADI', 'DIVK', 'MMBINK', 'RETURN1')
361+check(function () return 0%0 end, 'LOADI', 'MODK', 'MMBINK', 'RETURN1')
362+check(function () return -4//0 end, 'LOADI', 'IDIVK', 'MMBINK', 'RETURN1')
363+check(function (x) return x >> 2.0 end, 'LOADF', 'SHR', 'MMBIN', 'RETURN1')
364+check(function (x) return x << 128 end, 'LOADI', 'SHL', 'MMBIN', 'RETURN1')
365+check(function (x) return x & 2.0 end, 'LOADF', 'BAND', 'MMBIN', 'RETURN1')
366+
367+-- basic 'for' loops
368+check(function () for i = -10, 10.5 do end end,
369+'LOADI', 'LOADK', 'LOADI', 'FORPREP', 'FORLOOP', 'RETURN0')
370+check(function () for i = 0xfffffff, 10.0, 1 do end end,
371+'LOADK', 'LOADF', 'LOADI', 'FORPREP', 'FORLOOP', 'RETURN0')
372+
373+-- bug in constant folding for 5.1
374+check(function () return -nil end, 'LOADNIL', 'UNM', 'RETURN1')
375+
376+
377+check(function ()
378+ local a,b,c
379+ b[c], a = c, b
380+ b[a], a = c, b
381+ a, b = c, a
382+ a = a
383+end,
384+ 'LOADNIL',
385+ 'MOVE', 'MOVE', 'SETTABLE',
386+ 'MOVE', 'MOVE', 'MOVE', 'SETTABLE',
387+ 'MOVE', 'MOVE', 'MOVE',
388+ -- no code for a = a
389+ 'RETURN0')
390+
391+
392+-- x == nil , x ~= nil
393+-- checkequal(function (b) if (a==nil) then a=1 end; if a~=nil then a=1 end end,
394+-- function () if (a==9) then a=1 end; if a~=9 then a=1 end end)
395+
396+-- check(function () if a==nil then a='a' end end,
397+-- 'GETTABUP', 'EQ', 'JMP', 'SETTABUP', 'RETURN')
398+
399+do -- tests for table access in upvalues
400+ local t
401+ check(function () t[kx] = t.y end, 'GETTABUP', 'SETTABUP')
402+ check(function (a) t[a()] = t[a()] end,
403+ 'MOVE', 'CALL', 'GETUPVAL', 'MOVE', 'CALL',
404+ 'GETUPVAL', 'GETTABLE', 'SETTABLE')
405+end
406+
407+-- de morgan
408+checkequal(function () local a; if not (a or b) then b=a end end,
409+ function () local a; if (not a and not b) then b=a end end)
410+
411+checkequal(function (l) local a; return 0 <= a and a <= l end,
412+ function (l) local a; return not (not(a >= 0) or not(a <= l)) end)
413+
414+
415+-- if-break optimizations
416+check(function (a, b)
417+ while a do
418+ if b then break else a = a + 1 end
419+ end
420+ end,
421+'TEST', 'JMP', 'TEST', 'JMP', 'ADDI', 'MMBINI', 'JMP', 'RETURN0')
422+
423+checkequal(function () return 6 or true or nil end,
424+ function () return k6 or kTrue or kNil end)
425+
426+checkequal(function () return 6 and true or nil end,
427+ function () return k6 and kTrue or kNil end)
428+
429+
430+do -- string constants
431+ local k0 <const> = "00000000000000000000000000000000000000000000000000"
432+ local function f1 ()
433+ local k <const> = k0
434+ return function ()
435+ return function () return k end
436+ end
437+ end
438+
439+ local f2 = f1()
440+ local f3 = f2()
441+ assert(f3() == k0)
442+ checkK(f3, k0)
443+ -- string is not needed by other functions
444+ assert(T.listk(f1)[1] == nil)
445+ assert(T.listk(f2)[1] == nil)
446+end
447+
448+print 'OK'
449+
desk/res/lua/constructs.luanew file+406
@@ -0,0 +1,406 @@
1+-- $Id: testes/constructs.lua $
2+-- See Copyright Notice in file all.lua
3+
4+;;print "testing syntax";;
5+
6+local debug = require "debug"
7+
8+
9+local function checkload (s, msg)
10+ assert(string.find(select(2, load(s)), msg))
11+end
12+
13+-- testing semicollons
14+local a
15+do ;;; end
16+; do ; a = 3; assert(a == 3) end;
17+;
18+
19+
20+-- invalid operations should not raise errors when not executed
21+if false then a = 3 // 0; a = 0 % 0 end
22+
23+
24+-- testing priorities
25+
26+assert(2^3^2 == 2^(3^2));
27+assert(2^3*4 == (2^3)*4);
28+assert(2.0^-2 == 1/4 and -2^- -2 == - - -4);
29+assert(not nil and 2 and not(2>3 or 3<2));
30+assert(-3-1-5 == 0+0-9);
31+assert(-2^2 == -4 and (-2)^2 == 4 and 2*2-3-1 == 0);
32+assert(-3%5 == 2 and -3+5 == 2)
33+assert(2*1+3/3 == 3 and 1+2 .. 3*1 == "33");
34+assert(not(2+1 > 3*1) and "a".."b" > "a");
35+
36+assert(0xF0 | 0xCC ~ 0xAA & 0xFD == 0xF4)
37+assert(0xFD & 0xAA ~ 0xCC | 0xF0 == 0xF4)
38+assert(0xF0 & 0x0F + 1 == 0x10)
39+
40+assert(3^4//2^3//5 == 2)
41+
42+assert(-3+4*5//2^3^2//9+4%10/3 == (-3)+(((4*5)//(2^(3^2)))//9)+((4%10)/3))
43+
44+assert(not ((true or false) and nil))
45+assert( true or false and nil)
46+
47+-- old bug
48+assert((((1 or false) and true) or false) == true)
49+assert((((nil and true) or false) and true) == false)
50+
51+local a,b = 1,nil;
52+assert(-(1 or 2) == -1 and (1 and 2)+(-1.25 or -4) == 0.75);
53+local x = ((b or a)+1 == 2 and (10 or a)+1 == 11); assert(x);
54+x = (((2<3) or 1) == true and (2<3 and 4) == 4); assert(x);
55+
56+local x, y = 1, 2;
57+assert((x>y) and x or y == 2);
58+x,y=2,1;
59+assert((x>y) and x or y == 2);
60+
61+assert(1234567890 == tonumber('1234567890') and 1234567890+1 == 1234567891)
62+
63+do -- testing operators with diffent kinds of constants
64+ -- operands to consider:
65+ -- * fit in register
66+ -- * constant doesn't fit in register
67+ -- * floats with integral values
68+ local operand = {3, 100, 5.0, -10, -5.0, 10000, -10000}
69+ local operator = {"+", "-", "*", "/", "//", "%", "^",
70+ "&", "|", "^", "<<", ">>",
71+ "==", "~=", "<", ">", "<=", ">=",}
72+ for _, op in ipairs(operator) do
73+ local f = assert(load(string.format([[return function (x,y)
74+ return x %s y
75+ end]], op)))();
76+ for _, o1 in ipairs(operand) do
77+ for _, o2 in ipairs(operand) do
78+ local gab = f(o1, o2)
79+
80+ _ENV.XX = o1
81+ local code = string.format("return XX %s %s", op, o2)
82+ local res = assert(load(code))()
83+ assert(res == gab)
84+
85+ _ENV.XX = o2
86+ code = string.format("return (%s) %s XX", o1, op)
87+ res = assert(load(code))()
88+ assert(res == gab)
89+
90+ code = string.format("return (%s) %s %s", o1, op, o2)
91+ res = assert(load(code))()
92+ assert(res == gab)
93+ end
94+ end
95+ end
96+ _ENV.XX = nil
97+end
98+
99+
100+-- silly loops
101+repeat until 1; repeat until true;
102+while false do end; while nil do end;
103+
104+do -- test old bug (first name could not be an `upvalue')
105+ local a; local function f(x) x={a=1}; x={x=1}; x={G=1} end
106+end
107+
108+
109+do -- bug since 5.4.0
110+ -- create code with a table using more than 256 constants
111+ local code = {"local x = {"}
112+ for i = 1, 257 do
113+ code[#code + 1] = i .. ".1,"
114+ end
115+ code[#code + 1] = "};"
116+ code = table.concat(code)
117+
118+ -- add "ret" to the end of that code and checks that
119+ -- it produces the expected value "val"
120+ local function check (ret, val)
121+ local code = code .. ret
122+ code = load(code)
123+ assert(code() == val)
124+ end
125+
126+ check("return (1 ~ (2 or 3))", 1 ~ 2)
127+ check("return (1 | (2 or 3))", 1 | 2)
128+ check("return (1 + (2 or 3))", 1 + 2)
129+ check("return (1 << (2 or 3))", 1 << 2)
130+end
131+
132+
133+local function f (i)
134+ if type(i) ~= 'number' then return i,'jojo'; end;
135+ if i > 0 then return i, f(i-1); end;
136+end
137+
138+x = {f(3), f(5), f(10);};
139+assert(x[1] == 3 and x[2] == 5 and x[3] == 10 and x[4] == 9 and x[12] == 1);
140+assert(x[nil] == nil)
141+x = {f'alo', f'xixi', nil};
142+assert(x[1] == 'alo' and x[2] == 'xixi' and x[3] == nil);
143+x = {f'alo'..'xixi'};
144+assert(x[1] == 'aloxixi')
145+x = {f{}}
146+assert(x[2] == 'jojo' and type(x[1]) == 'table')
147+
148+
149+local f = function (i)
150+ if i < 10 then return 'a';
151+ elseif i < 20 then return 'b';
152+ elseif i < 30 then return 'c';
153+ end;
154+end
155+
156+assert(f(3) == 'a' and f(12) == 'b' and f(26) == 'c' and f(100) == nil)
157+
158+for i=1,1000 do break; end;
159+local n=100;
160+local i=3;
161+local t = {};
162+local a=nil
163+while not a do
164+ a=0; for i=1,n do for i=i,1,-1 do a=a+1; t[i]=1; end; end;
165+end
166+assert(a == n*(n+1)/2 and i==3);
167+assert(t[1] and t[n] and not t[0] and not t[n+1])
168+
169+function f(b)
170+ local x = 1;
171+ repeat
172+ local a;
173+ if b==1 then local b=1; x=10; break
174+ elseif b==2 then x=20; break;
175+ elseif b==3 then x=30;
176+ else local a,b,c,d=math.sin(1); x=x+1;
177+ end
178+ until x>=12;
179+ return x;
180+end;
181+
182+assert(f(1) == 10 and f(2) == 20 and f(3) == 30 and f(4)==12)
183+
184+
185+local f = function (i)
186+ if i < 10 then return 'a'
187+ elseif i < 20 then return 'b'
188+ elseif i < 30 then return 'c'
189+ else return 8
190+ end
191+end
192+
193+assert(f(3) == 'a' and f(12) == 'b' and f(26) == 'c' and f(100) == 8)
194+
195+local a, b = nil, 23
196+x = {f(100)*2+3 or a, a or b+2}
197+assert(x[1] == 19 and x[2] == 25)
198+x = {f=2+3 or a, a = b+2}
199+assert(x.f == 5 and x.a == 25)
200+
201+a={y=1}
202+x = {a.y}
203+assert(x[1] == 1)
204+
205+local function f (i)
206+ while 1 do
207+ if i>0 then i=i-1;
208+ else return; end;
209+ end;
210+end;
211+
212+local function g(i)
213+ while 1 do
214+ if i>0 then i=i-1
215+ else return end
216+ end
217+end
218+
219+f(10); g(10);
220+
221+do
222+ function f () return 1,2,3; end
223+ local a, b, c = f();
224+ assert(a==1 and b==2 and c==3)
225+ a, b, c = (f());
226+ assert(a==1 and b==nil and c==nil)
227+end
228+
229+local a,b = 3 and f();
230+assert(a==1 and b==nil)
231+
232+function g() f(); return; end;
233+assert(g() == nil)
234+function g() return nil or f() end
235+a,b = g()
236+assert(a==1 and b==nil)
237+
238+print'+';
239+
240+do -- testing constants
241+ local prog <const> = [[local x <XXX> = 10]]
242+ checkload(prog, "unknown attribute 'XXX'")
243+
244+ checkload([[local xxx <const> = 20; xxx = 10]],
245+ ":1: attempt to assign to const variable 'xxx'")
246+
247+ checkload([[
248+ local xx;
249+ local xxx <const> = 20;
250+ local yyy;
251+ local function foo ()
252+ local abc = xx + yyy + xxx;
253+ return function () return function () xxx = yyy end end
254+ end
255+ ]], ":6: attempt to assign to const variable 'xxx'")
256+
257+ checkload([[
258+ local x <close> = nil
259+ x = io.open()
260+ ]], ":2: attempt to assign to const variable 'x'")
261+end
262+
263+f = [[
264+return function ( a , b , c , d , e )
265+ local x = a >= b or c or ( d and e ) or nil
266+ return x
267+end , { a = 1 , b = 2 >= 1 , } or { 1 };
268+]]
269+f = string.gsub(f, "%s+", "\n"); -- force a SETLINE between opcodes
270+f,a = load(f)();
271+assert(a.a == 1 and a.b)
272+
273+function g (a,b,c,d,e)
274+ if not (a>=b or c or d and e or nil) then return 0; else return 1; end;
275+end
276+
277+local function h (a,b,c,d,e)
278+ while (a>=b or c or (d and e) or nil) do return 1; end;
279+ return 0;
280+end;
281+
282+assert(f(2,1) == true and g(2,1) == 1 and h(2,1) == 1)
283+assert(f(1,2,'a') == 'a' and g(1,2,'a') == 1 and h(1,2,'a') == 1)
284+assert(f(1,2,'a')
285+~= -- force SETLINE before nil
286+nil, "")
287+assert(f(1,2,'a') == 'a' and g(1,2,'a') == 1 and h(1,2,'a') == 1)
288+assert(f(1,2,nil,1,'x') == 'x' and g(1,2,nil,1,'x') == 1 and
289+ h(1,2,nil,1,'x') == 1)
290+assert(f(1,2,nil,nil,'x') == nil and g(1,2,nil,nil,'x') == 0 and
291+ h(1,2,nil,nil,'x') == 0)
292+assert(f(1,2,nil,1,nil) == nil and g(1,2,nil,1,nil) == 0 and
293+ h(1,2,nil,1,nil) == 0)
294+
295+assert(1 and 2<3 == true and 2<3 and 'a'<'b' == true)
296+x = 2<3 and not 3; assert(x==false)
297+x = 2<1 or (2>1 and 'a'); assert(x=='a')
298+
299+
300+do
301+ local a; if nil then a=1; else a=2; end; -- this nil comes as PUSHNIL 2
302+ assert(a==2)
303+end
304+
305+local function F (a)
306+ assert(debug.getinfo(1, "n").name == 'F')
307+ return a,2,3
308+end
309+
310+a,b = F(1)~=nil; assert(a == true and b == nil);
311+a,b = F(nil)==nil; assert(a == true and b == nil)
312+
313+----------------------------------------------------------------
314+------------------------------------------------------------------
315+
316+-- sometimes will be 0, sometimes will not...
317+_ENV.GLOB1 = math.random(0, 1)
318+
319+-- basic expressions with their respective values
320+local basiccases = {
321+ {"nil", nil},
322+ {"false", false},
323+ {"true", true},
324+ {"10", 10},
325+ {"(0==_ENV.GLOB1)", 0 == _ENV.GLOB1},
326+}
327+
328+local prog
329+
330+if _ENV.GLOB1 == 0 then
331+ basiccases[2][1] = "F" -- constant false
332+
333+ prog = [[
334+ local F <const> = false
335+ if %s then IX = true end
336+ return %s
337+]]
338+else
339+ basiccases[4][1] = "k10" -- constant 10
340+
341+ prog = [[
342+ local k10 <const> = 10
343+ if %s then IX = true end
344+ return %s
345+ ]]
346+end
347+
348+print('testing short-circuit optimizations (' .. _ENV.GLOB1 .. ')')
349+
350+
351+-- operators with their respective values
352+local binops <const> = {
353+ {" and ", function (a,b) if not a then return a else return b end end},
354+ {" or ", function (a,b) if a then return a else return b end end},
355+}
356+
357+local cases <const> = {}
358+
359+-- creates all combinations of '(cases[i] op cases[n-i])' plus
360+-- 'not(cases[i] op cases[n-i])' (syntax + value)
361+local function createcases (n)
362+ local res = {}
363+ for i = 1, n - 1 do
364+ for _, v1 in ipairs(cases[i]) do
365+ for _, v2 in ipairs(cases[n - i]) do
366+ for _, op in ipairs(binops) do
367+ local t = {
368+ "(" .. v1[1] .. op[1] .. v2[1] .. ")",
369+ op[2](v1[2], v2[2])
370+ }
371+ res[#res + 1] = t
372+ res[#res + 1] = {"not" .. t[1], not t[2]}
373+ end
374+ end
375+ end
376+ end
377+ return res
378+end
379+
380+-- do not do too many combinations for soft tests
381+local level = _soft and 3 or 4
382+
383+cases[1] = basiccases
384+for i = 2, level do cases[i] = createcases(i) end
385+print("+")
386+
387+local i = 0
388+for n = 1, level do
389+ for _, v in pairs(cases[n]) do
390+ local s = v[1]
391+ local p = load(string.format(prog, s, s), "")
392+ IX = false
393+ assert(p() == v[2] and IX == not not v[2])
394+ i = i + 1
395+ if i % 60000 == 0 then print('+') end
396+ end
397+end
398+IX = nil
399+_G.GLOB1 = nil
400+------------------------------------------------------------------
401+
402+-- testing some syntax errors (chosen through 'gcov')
403+checkload("for x do", "expected")
404+checkload("x:call", "expected")
405+
406+print'OK'
desk/res/lua/coroutine.luanew file+1156
@@ -0,0 +1,1156 @@
1+-- $Id: testes/coroutine.lua $
2+-- See Copyright Notice in file all.lua
3+
4+print "testing coroutines"
5+
6+local debug = require'debug'
7+
8+local f
9+
10+local main, ismain = coroutine.running()
11+assert(type(main) == "thread" and ismain)
12+assert(not coroutine.resume(main))
13+assert(not coroutine.isyieldable(main) and not coroutine.isyieldable())
14+assert(not pcall(coroutine.yield))
15+
16+
17+-- trivial errors
18+assert(not pcall(coroutine.resume, 0))
19+assert(not pcall(coroutine.status, 0))
20+
21+
22+-- tests for multiple yield/resume arguments
23+
24+local function eqtab (t1, t2)
25+ assert(#t1 == #t2)
26+ for i = 1, #t1 do
27+ local v = t1[i]
28+ assert(t2[i] == v)
29+ end
30+end
31+
32+_G.x = nil -- declare x
33+_G.f = nil -- declare f
34+local function foo (a, ...)
35+ local x, y = coroutine.running()
36+ assert(x == f and y == false)
37+ -- next call should not corrupt coroutine (but must fail,
38+ -- as it attempts to resume the running coroutine)
39+ assert(coroutine.resume(f) == false)
40+ assert(coroutine.status(f) == "running")
41+ local arg = {...}
42+ assert(coroutine.isyieldable(x))
43+ for i=1,#arg do
44+ _G.x = {coroutine.yield(table.unpack(arg[i]))}
45+ end
46+ return table.unpack(a)
47+end
48+
49+f = coroutine.create(foo)
50+assert(coroutine.isyieldable(f))
51+assert(type(f) == "thread" and coroutine.status(f) == "suspended")
52+assert(string.find(tostring(f), "thread"))
53+local s,a,b,c,d
54+s,a,b,c,d = coroutine.resume(f, {1,2,3}, {}, {1}, {'a', 'b', 'c'})
55+assert(coroutine.isyieldable(f))
56+assert(s and a == nil and coroutine.status(f) == "suspended")
57+s,a,b,c,d = coroutine.resume(f)
58+eqtab(_G.x, {})
59+assert(s and a == 1 and b == nil)
60+assert(coroutine.isyieldable(f))
61+s,a,b,c,d = coroutine.resume(f, 1, 2, 3)
62+eqtab(_G.x, {1, 2, 3})
63+assert(s and a == 'a' and b == 'b' and c == 'c' and d == nil)
64+s,a,b,c,d = coroutine.resume(f, "xuxu")
65+eqtab(_G.x, {"xuxu"})
66+assert(s and a == 1 and b == 2 and c == 3 and d == nil)
67+assert(coroutine.status(f) == "dead")
68+s, a = coroutine.resume(f, "xuxu")
69+assert(not s and string.find(a, "dead") and coroutine.status(f) == "dead")
70+
71+_G.f = nil
72+
73+-- yields in tail calls
74+local function foo (i) return coroutine.yield(i) end
75+local f = coroutine.wrap(function ()
76+ for i=1,10 do
77+ assert(foo(i) == _G.x)
78+ end
79+ return 'a'
80+end)
81+for i=1,10 do _G.x = i; assert(f(i) == i) end
82+_G.x = 'xuxu'; assert(f('xuxu') == 'a')
83+
84+_G.x = nil
85+
86+-- recursive
87+local function pf (n, i)
88+ coroutine.yield(n)
89+ pf(n*i, i+1)
90+end
91+
92+f = coroutine.wrap(pf)
93+local s=1
94+for i=1,10 do
95+ assert(f(1, 1) == s)
96+ s = s*i
97+end
98+
99+-- sieve
100+local function gen (n)
101+ return coroutine.wrap(function ()
102+ for i=2,n do coroutine.yield(i) end
103+ end)
104+end
105+
106+
107+local function filter (p, g)
108+ return coroutine.wrap(function ()
109+ while 1 do
110+ local n = g()
111+ if n == nil then return end
112+ if math.fmod(n, p) ~= 0 then coroutine.yield(n) end
113+ end
114+ end)
115+end
116+
117+local x = gen(80)
118+local a = {}
119+while 1 do
120+ local n = x()
121+ if n == nil then break end
122+ table.insert(a, n)
123+ x = filter(n, x)
124+end
125+
126+assert(#a == 22 and a[#a] == 79)
127+x, a = nil
128+
129+
130+print("to-be-closed variables in coroutines")
131+
132+local function func2close (f)
133+ return setmetatable({}, {__close = f})
134+end
135+
136+do
137+ -- ok to close a dead coroutine
138+ local co = coroutine.create(print)
139+ assert(coroutine.resume(co, "testing 'coroutine.close'"))
140+ assert(coroutine.status(co) == "dead")
141+ local st, msg = coroutine.close(co)
142+ assert(st and msg == nil)
143+ -- also ok to close it again
144+ st, msg = coroutine.close(co)
145+ assert(st and msg == nil)
146+
147+
148+ -- cannot close the running coroutine
149+ local st, msg = pcall(coroutine.close, coroutine.running())
150+ assert(not st and string.find(msg, "running"))
151+
152+ local main = coroutine.running()
153+
154+ -- cannot close a "normal" coroutine
155+ ;(coroutine.wrap(function ()
156+ local st, msg = pcall(coroutine.close, main)
157+ assert(not st and string.find(msg, "normal"))
158+ end))()
159+
160+ -- cannot close a coroutine while closing it
161+ do
162+ local co
163+ co = coroutine.create(
164+ function()
165+ local x <close> = func2close(function()
166+ coroutine.close(co) -- try to close it again
167+ end)
168+ coroutine.yield(20)
169+ end)
170+ local st, msg = coroutine.resume(co)
171+ assert(st and msg == 20)
172+ st, msg = coroutine.close(co)
173+ assert(not st and string.find(msg, "running coroutine"))
174+ end
175+
176+ -- to-be-closed variables in coroutines
177+ local X
178+
179+ -- closing a coroutine after an error
180+ local co = coroutine.create(error)
181+ local st, msg = coroutine.resume(co, 100)
182+ assert(not st and msg == 100)
183+ st, msg = coroutine.close(co)
184+ assert(not st and msg == 100)
185+ -- after closing, no more errors
186+ st, msg = coroutine.close(co)
187+ assert(st and msg == nil)
188+
189+ co = coroutine.create(function ()
190+ local x <close> = func2close(function (self, err)
191+ assert(err == nil); X = false
192+ end)
193+ X = true
194+ coroutine.yield()
195+ end)
196+ coroutine.resume(co)
197+ assert(X)
198+ assert(coroutine.close(co))
199+ assert(not X and coroutine.status(co) == "dead")
200+
201+ -- error closing a coroutine
202+ local x = 0
203+ co = coroutine.create(function()
204+ local y <close> = func2close(function (self,err)
205+ assert(err == 111)
206+ x = 200
207+ error(200)
208+ end)
209+ local x <close> = func2close(function (self, err)
210+ assert(err == nil); error(111)
211+ end)
212+ coroutine.yield()
213+ end)
214+ coroutine.resume(co)
215+ assert(x == 0)
216+ local st, msg = coroutine.close(co)
217+ assert(st == false and coroutine.status(co) == "dead" and msg == 200)
218+ assert(x == 200)
219+ -- after closing, no more errors
220+ st, msg = coroutine.close(co)
221+ assert(st and msg == nil)
222+end
223+
224+do
225+ -- <close> versus pcall in coroutines
226+ local X = false
227+ local Y = false
228+ local function foo ()
229+ local x <close> = func2close(function (self, err)
230+ Y = debug.getinfo(2)
231+ X = err
232+ end)
233+ error(43)
234+ end
235+ local co = coroutine.create(function () return pcall(foo) end)
236+ local st1, st2, err = coroutine.resume(co)
237+ assert(st1 and not st2 and err == 43)
238+ assert(X == 43 and Y.what == "C")
239+
240+ -- recovering from errors in __close metamethods
241+ local track = {}
242+
243+ local function h (o)
244+ local hv <close> = o
245+ return 1
246+ end
247+
248+ local function foo ()
249+ local x <close> = func2close(function(_,msg)
250+ track[#track + 1] = msg or false
251+ error(20)
252+ end)
253+ local y <close> = func2close(function(_,msg)
254+ track[#track + 1] = msg or false
255+ return 1000
256+ end)
257+ local z <close> = func2close(function(_,msg)
258+ track[#track + 1] = msg or false
259+ error(10)
260+ end)
261+ coroutine.yield(1)
262+ h(func2close(function(_,msg)
263+ track[#track + 1] = msg or false
264+ error(2)
265+ end))
266+ end
267+
268+ local co = coroutine.create(pcall)
269+
270+ local st, res = coroutine.resume(co, foo) -- call 'foo' protected
271+ assert(st and res == 1) -- yield 1
272+ local st, res1, res2 = coroutine.resume(co) -- continue
273+ assert(coroutine.status(co) == "dead")
274+ assert(st and not res1 and res2 == 20) -- last error (20)
275+ assert(track[1] == false and track[2] == 2 and track[3] == 10 and
276+ track[4] == 10)
277+end
278+
279+
280+-- yielding across C boundaries
281+
282+local co = coroutine.wrap(function()
283+ assert(not pcall(table.sort,{1,2,3}, coroutine.yield))
284+ assert(coroutine.isyieldable())
285+ coroutine.yield(20)
286+ return 30
287+ end)
288+
289+assert(co() == 20)
290+assert(co() == 30)
291+
292+
293+local f = function (s, i) return coroutine.yield(i) end
294+
295+local f1 = coroutine.wrap(function ()
296+ return xpcall(pcall, function (...) return ... end,
297+ function ()
298+ local s = 0
299+ for i in f, nil, 1 do pcall(function () s = s + i end) end
300+ error({s})
301+ end)
302+ end)
303+
304+f1()
305+for i = 1, 10 do assert(f1(i) == i) end
306+local r1, r2, v = f1(nil)
307+assert(r1 and not r2 and v[1] == (10 + 1)*10/2)
308+
309+
310+local function f (a, b) a = coroutine.yield(a); error{a + b} end
311+local function g(x) return x[1]*2 end
312+
313+co = coroutine.wrap(function ()
314+ coroutine.yield(xpcall(f, g, 10, 20))
315+ end)
316+
317+assert(co() == 10)
318+local r, msg = co(100)
319+assert(not r and msg == 240)
320+
321+
322+-- unyieldable C call
323+do
324+ local function f (c)
325+ assert(not coroutine.isyieldable())
326+ return c .. c
327+ end
328+
329+ local co = coroutine.wrap(function (c)
330+ assert(coroutine.isyieldable())
331+ local s = string.gsub("a", ".", f)
332+ return s
333+ end)
334+ assert(co() == "aa")
335+end
336+
337+
338+
339+do -- testing single trace of coroutines
340+ local X
341+ local co = coroutine.create(function ()
342+ coroutine.yield(10)
343+ return 20;
344+ end)
345+ local trace = {}
346+ local function dotrace (event)
347+ trace[#trace + 1] = event
348+ end
349+ debug.sethook(co, dotrace, "clr")
350+ repeat until not coroutine.resume(co)
351+ local correcttrace = {"call", "line", "call", "return", "line", "return"}
352+ assert(#trace == #correcttrace)
353+ for k, v in pairs(trace) do
354+ assert(v == correcttrace[k])
355+ end
356+end
357+
358+-- errors in coroutines
359+function foo ()
360+ assert(debug.getinfo(1).currentline == debug.getinfo(foo).linedefined + 1)
361+ assert(debug.getinfo(2).currentline == debug.getinfo(goo).linedefined)
362+ coroutine.yield(3)
363+ error(foo)
364+end
365+
366+function goo() foo() end
367+x = coroutine.wrap(goo)
368+assert(x() == 3)
369+local a,b = pcall(x)
370+assert(not a and b == foo)
371+
372+x = coroutine.create(goo)
373+a,b = coroutine.resume(x)
374+assert(a and b == 3)
375+a,b = coroutine.resume(x)
376+assert(not a and b == foo and coroutine.status(x) == "dead")
377+a,b = coroutine.resume(x)
378+assert(not a and string.find(b, "dead") and coroutine.status(x) == "dead")
379+
380+goo = nil
381+
382+-- co-routines x for loop
383+local function all (a, n, k)
384+ if k == 0 then coroutine.yield(a)
385+ else
386+ for i=1,n do
387+ a[k] = i
388+ all(a, n, k-1)
389+ end
390+ end
391+end
392+
393+local a = 0
394+for t in coroutine.wrap(function () all({}, 5, 4) end) do
395+ a = a+1
396+end
397+assert(a == 5^4)
398+
399+
400+-- access to locals of collected corroutines
401+local C = {}; setmetatable(C, {__mode = "kv"})
402+local x = coroutine.wrap (function ()
403+ local a = 10
404+ local function f () a = a+10; return a end
405+ while true do
406+ a = a+1
407+ coroutine.yield(f)
408+ end
409+ end)
410+
411+C[1] = x;
412+
413+local f = x()
414+assert(f() == 21 and x()() == 32 and x() == f)
415+x = nil
416+collectgarbage()
417+assert(C[1] == undef)
418+assert(f() == 43 and f() == 53)
419+
420+
421+-- old bug: attempt to resume itself
422+
423+local function co_func (current_co)
424+ assert(coroutine.running() == current_co)
425+ assert(coroutine.resume(current_co) == false)
426+ coroutine.yield(10, 20)
427+ assert(coroutine.resume(current_co) == false)
428+ coroutine.yield(23)
429+ return 10
430+end
431+
432+local co = coroutine.create(co_func)
433+local a,b,c = coroutine.resume(co, co)
434+assert(a == true and b == 10 and c == 20)
435+a,b = coroutine.resume(co, co)
436+assert(a == true and b == 23)
437+a,b = coroutine.resume(co, co)
438+assert(a == true and b == 10)
439+assert(coroutine.resume(co, co) == false)
440+assert(coroutine.resume(co, co) == false)
441+
442+
443+-- other old bug when attempting to resume itself
444+-- (trigger C-code assertions)
445+do
446+ local A = coroutine.running()
447+ local B = coroutine.create(function() return coroutine.resume(A) end)
448+ local st, res = coroutine.resume(B)
449+ assert(st == true and res == false)
450+
451+ local X = false
452+ A = coroutine.wrap(function()
453+ local _ <close> = func2close(function () X = true end)
454+ return pcall(A, 1)
455+ end)
456+ st, res = A()
457+ assert(not st and string.find(res, "non%-suspended") and X == true)
458+end
459+
460+
461+-- bug in 5.4.1
462+do
463+ -- coroutine ran close metamethods with invalid status during a
464+ -- reset.
465+ local co
466+ co = coroutine.wrap(function()
467+ local x <close> = func2close(function() return pcall(co) end)
468+ error(111)
469+ end)
470+ local st, errobj = pcall(co)
471+ assert(not st and errobj == 111)
472+ st, errobj = pcall(co)
473+ assert(not st and string.find(errobj, "dead coroutine"))
474+end
475+
476+
477+-- attempt to resume 'normal' coroutine
478+local co1, co2
479+co1 = coroutine.create(function () return co2() end)
480+co2 = coroutine.wrap(function ()
481+ assert(coroutine.status(co1) == 'normal')
482+ assert(not coroutine.resume(co1))
483+ coroutine.yield(3)
484+ end)
485+
486+a,b = coroutine.resume(co1)
487+assert(a and b == 3)
488+assert(coroutine.status(co1) == 'dead')
489+
490+-- infinite recursion of coroutines
491+a = function(a) coroutine.wrap(a)(a) end
492+assert(not pcall(a, a))
493+a = nil
494+
495+
496+-- access to locals of erroneous coroutines
497+local x = coroutine.create (function ()
498+ local a = 10
499+ _G.F = function () a=a+1; return a end
500+ error('x')
501+ end)
502+
503+assert(not coroutine.resume(x))
504+-- overwrite previous position of local `a'
505+assert(not coroutine.resume(x, 1, 1, 1, 1, 1, 1, 1))
506+assert(_G.F() == 11)
507+assert(_G.F() == 12)
508+_G.F = nil
509+
510+
511+if not T then
512+ (Message or print)
513+ ('\n >>> testC not active: skipping coroutine API tests <<<\n')
514+else
515+ print "testing yields inside hooks"
516+
517+ local turn
518+
519+ local function fact (t, x)
520+ assert(turn == t)
521+ if x == 0 then return 1
522+ else return x*fact(t, x-1)
523+ end
524+ end
525+
526+ local A, B = 0, 0
527+
528+ local x = coroutine.create(function ()
529+ T.sethook("yield 0", "", 2)
530+ A = fact("A", 6)
531+ end)
532+
533+ local y = coroutine.create(function ()
534+ T.sethook("yield 0", "", 3)
535+ B = fact("B", 7)
536+ end)
537+
538+ while A==0 or B==0 do -- A ~= 0 when 'x' finishes (similar for 'B','y')
539+ if A==0 then turn = "A"; assert(T.resume(x)) end
540+ if B==0 then turn = "B"; assert(T.resume(y)) end
541+
542+ -- check that traceback works correctly after yields inside hooks
543+ debug.traceback(x)
544+ debug.traceback(y)
545+ end
546+
547+ assert(B // A == 7) -- fact(7) // fact(6)
548+
549+ do -- hooks vs. multiple values
550+ local done
551+ local function test (n)
552+ done = false
553+ return coroutine.wrap(function ()
554+ local a = {}
555+ for i = 1, n do a[i] = i end
556+ -- 'pushint' just to perturb the stack
557+ T.sethook("pushint 10; yield 0", "", 1) -- yield at each op.
558+ local a1 = {table.unpack(a)} -- must keep top between ops.
559+ assert(#a1 == n)
560+ for i = 1, n do assert(a[i] == i) end
561+ done = true
562+ end)
563+ end
564+ -- arguments to the coroutine are just to perturb its stack
565+ local co = test(0); while not done do co(30) end
566+ co = test(1); while not done do co(20, 10) end
567+ co = test(3); while not done do co() end
568+ co = test(100); while not done do co() end
569+ end
570+
571+ local line = debug.getinfo(1, "l").currentline + 2 -- get line number
572+ local function foo ()
573+ local x = 10 --<< this line is 'line'
574+ x = x + 10
575+ _G.XX = x
576+ end
577+
578+ -- testing yields in line hook
579+ local co = coroutine.wrap(function ()
580+ T.sethook("setglobal X; yield 0", "l", 0); foo(); return 10 end)
581+
582+ _G.XX = nil;
583+ _G.X = nil; co(); assert(_G.X == line)
584+ _G.X = nil; co(); assert(_G.X == line + 1)
585+ _G.X = nil; co(); assert(_G.X == line + 2 and _G.XX == nil)
586+ _G.X = nil; co(); assert(_G.X == line + 3 and _G.XX == 20)
587+ assert(co() == 10)
588+ _G.X = nil
589+
590+ -- testing yields in count hook
591+ co = coroutine.wrap(function ()
592+ T.sethook("yield 0", "", 1); foo(); return 10 end)
593+
594+ _G.XX = nil;
595+ local c = 0
596+ repeat c = c + 1; local a = co() until a == 10
597+ assert(_G.XX == 20 and c >= 5)
598+
599+ co = coroutine.wrap(function ()
600+ T.sethook("yield 0", "", 2); foo(); return 10 end)
601+
602+ _G.XX = nil;
603+ local c = 0
604+ repeat c = c + 1; local a = co() until a == 10
605+ assert(_G.XX == 20 and c >= 5)
606+ _G.X = nil; _G.XX = nil
607+
608+ do
609+ -- testing debug library on a coroutine suspended inside a hook
610+ -- (bug in 5.2/5.3)
611+ c = coroutine.create(function (a, ...)
612+ T.sethook("yield 0", "l") -- will yield on next two lines
613+ local b = a
614+ return ...
615+ end)
616+
617+ assert(coroutine.resume(c, 1, 2, 3)) -- start coroutine
618+ local n,v = debug.getlocal(c, 0, 1) -- check its local
619+ assert(n == "a" and v == 1 and debug.getlocal(c, 0, 2) ~= "b")
620+ assert(debug.setlocal(c, 0, 1, 10)) -- test 'setlocal'
621+ local t = debug.getinfo(c, 0) -- test 'getinfo'
622+ assert(t.currentline == t.linedefined + 2)
623+ assert(not debug.getinfo(c, 1)) -- no other level
624+ assert(coroutine.resume(c)) -- run next line
625+ local n,v = debug.getlocal(c, 0, 2) -- check next local
626+ assert(n == "b" and v == 10)
627+ v = {coroutine.resume(c)} -- finish coroutine
628+ assert(v[1] == true and v[2] == 2 and v[3] == 3 and v[4] == undef)
629+ assert(not coroutine.resume(c))
630+ end
631+
632+ do
633+ -- testing debug library on last function in a suspended coroutine
634+ -- (bug in 5.2/5.3)
635+ local c = coroutine.create(function () T.testC("yield 1", 10, 20) end)
636+ local a, b = coroutine.resume(c)
637+ assert(a and b == 20)
638+ assert(debug.getinfo(c, 0).linedefined == -1)
639+ a, b = debug.getlocal(c, 0, 2)
640+ assert(b == 10)
641+ end
642+
643+
644+ print "testing coroutine API"
645+
646+ -- reusing a thread
647+ assert(T.testC([[
648+ newthread # create thread
649+ pushvalue 2 # push body
650+ pushstring 'a a a' # push argument
651+ xmove 0 3 2 # move values to new thread
652+ resume -1, 1 # call it first time
653+ pushstatus
654+ xmove 3 0 0 # move results back to stack
655+ setglobal X # result
656+ setglobal Y # status
657+ pushvalue 2 # push body (to call it again)
658+ pushstring 'b b b'
659+ xmove 0 3 2
660+ resume -1, 1 # call it again
661+ pushstatus
662+ xmove 3 0 0
663+ return 1 # return result
664+ ]], function (...) return ... end) == 'b b b')
665+
666+ assert(X == 'a a a' and Y == 'OK')
667+
668+ X, Y = nil
669+
670+
671+ -- resuming running coroutine
672+ C = coroutine.create(function ()
673+ return T.testC([[
674+ pushnum 10;
675+ pushnum 20;
676+ resume -3 2;
677+ pushstatus
678+ gettop;
679+ return 3]], C)
680+ end)
681+ local a, b, c, d = coroutine.resume(C)
682+ assert(a == true and string.find(b, "non%-suspended") and
683+ c == "ERRRUN" and d == 4)
684+
685+ a, b, c, d = T.testC([[
686+ rawgeti R 1 # get main thread
687+ pushnum 10;
688+ pushnum 20;
689+ resume -3 2;
690+ pushstatus
691+ gettop;
692+ return 4]])
693+ assert(a == coroutine.running() and string.find(b, "non%-suspended") and
694+ c == "ERRRUN" and d == 4)
695+
696+
697+ -- using a main thread as a coroutine (dubious use!)
698+ local state = T.newstate()
699+
700+ -- check that yielddable is working correctly
701+ assert(T.testC(state, "newthread; isyieldable -1; remove 1; return 1"))
702+
703+ -- main thread is not yieldable
704+ assert(not T.testC(state, "rawgeti R 1; isyieldable -1; remove 1; return 1"))
705+
706+ T.testC(state, "settop 0")
707+
708+ T.loadlib(state)
709+
710+ assert(T.doremote(state, [[
711+ coroutine = require'coroutine';
712+ X = function (x) coroutine.yield(x, 'BB'); return 'CC' end;
713+ return 'ok']]))
714+
715+ local t = table.pack(T.testC(state, [[
716+ rawgeti R 1 # get main thread
717+ pushstring 'XX'
718+ getglobal X # get function for body
719+ pushstring AA # arg
720+ resume 1 1 # 'resume' shadows previous stack!
721+ gettop
722+ setglobal T # top
723+ setglobal B # second yielded value
724+ setglobal A # fist yielded value
725+ rawgeti R 1 # get main thread
726+ pushnum 5 # arg (noise)
727+ resume 1 1 # after coroutine ends, previous stack is back
728+ pushstatus
729+ return *
730+ ]]))
731+ assert(t.n == 4 and t[2] == 'XX' and t[3] == 'CC' and t[4] == 'OK')
732+ assert(T.doremote(state, "return T") == '2')
733+ assert(T.doremote(state, "return A") == 'AA')
734+ assert(T.doremote(state, "return B") == 'BB')
735+
736+ T.closestate(state)
737+
738+ print'+'
739+
740+end
741+
742+
743+-- leaving a pending coroutine open
744+_G.TO_SURVIVE = coroutine.wrap(function ()
745+ local a = 10
746+ local x = function () a = a+1 end
747+ coroutine.yield()
748+ end)
749+
750+_G.TO_SURVIVE()
751+
752+
753+if not _soft then
754+ -- bug (stack overflow)
755+ local lim = 1000000 -- stack limit; assume 32-bit machine
756+ local t = {lim - 10, lim - 5, lim - 1, lim, lim + 1, lim + 5}
757+ for i = 1, #t do
758+ local j = t[i]
759+ local co = coroutine.create(function()
760+ return table.unpack({}, 1, j)
761+ end)
762+ local r, msg = coroutine.resume(co)
763+ -- must fail for unpacking larger than stack limit
764+ assert(j < lim or not r)
765+ end
766+end
767+
768+
769+assert(coroutine.running() == main)
770+
771+print"+"
772+
773+
774+print"testing yields inside metamethods"
775+
776+local function val(x)
777+ if type(x) == "table" then return x.x else return x end
778+end
779+
780+local mt = {
781+ __eq = function(a,b) coroutine.yield(nil, "eq"); return val(a) == val(b) end,
782+ __lt = function(a,b) coroutine.yield(nil, "lt"); return val(a) < val(b) end,
783+ __le = function(a,b) coroutine.yield(nil, "le"); return a - b <= 0 end,
784+ __add = function(a,b) coroutine.yield(nil, "add");
785+ return val(a) + val(b) end,
786+ __sub = function(a,b) coroutine.yield(nil, "sub"); return val(a) - val(b) end,
787+ __mul = function(a,b) coroutine.yield(nil, "mul"); return val(a) * val(b) end,
788+ __div = function(a,b) coroutine.yield(nil, "div"); return val(a) / val(b) end,
789+ __idiv = function(a,b) coroutine.yield(nil, "idiv");
790+ return val(a) // val(b) end,
791+ __pow = function(a,b) coroutine.yield(nil, "pow"); return val(a) ^ val(b) end,
792+ __mod = function(a,b) coroutine.yield(nil, "mod"); return val(a) % val(b) end,
793+ __unm = function(a,b) coroutine.yield(nil, "unm"); return -val(a) end,
794+ __bnot = function(a,b) coroutine.yield(nil, "bnot"); return ~val(a) end,
795+ __shl = function(a,b) coroutine.yield(nil, "shl");
796+ return val(a) << val(b) end,
797+ __shr = function(a,b) coroutine.yield(nil, "shr");
798+ return val(a) >> val(b) end,
799+ __band = function(a,b)
800+ coroutine.yield(nil, "band")
801+ return val(a) & val(b)
802+ end,
803+ __bor = function(a,b) coroutine.yield(nil, "bor");
804+ return val(a) | val(b) end,
805+ __bxor = function(a,b) coroutine.yield(nil, "bxor");
806+ return val(a) ~ val(b) end,
807+
808+ __concat = function(a,b)
809+ coroutine.yield(nil, "concat");
810+ return val(a) .. val(b)
811+ end,
812+ __index = function (t,k) coroutine.yield(nil, "idx"); return t.k[k] end,
813+ __newindex = function (t,k,v) coroutine.yield(nil, "nidx"); t.k[k] = v end,
814+}
815+
816+
817+local function new (x)
818+ return setmetatable({x = x, k = {}}, mt)
819+end
820+
821+
822+local a = new(10)
823+local b = new(12)
824+local c = new"hello"
825+
826+local function run (f, t)
827+ local i = 1
828+ local c = coroutine.wrap(f)
829+ while true do
830+ local res, stat = c()
831+ if res then assert(t[i] == undef); return res, t end
832+ assert(stat == t[i])
833+ i = i + 1
834+ end
835+end
836+
837+
838+assert(run(function () if (a>=b) then return '>=' else return '<' end end,
839+ {"le", "sub"}) == "<")
840+assert(run(function () if (a<=b) then return '<=' else return '>' end end,
841+ {"le", "sub"}) == "<=")
842+assert(run(function () if (a==b) then return '==' else return '~=' end end,
843+ {"eq"}) == "~=")
844+
845+assert(run(function () return a & b + a end, {"add", "band"}) == 2)
846+
847+assert(run(function () return 1 + a end, {"add"}) == 11)
848+assert(run(function () return a - 25 end, {"sub"}) == -15)
849+assert(run(function () return 2 * a end, {"mul"}) == 20)
850+assert(run(function () return a ^ 2 end, {"pow"}) == 100)
851+assert(run(function () return a / 2 end, {"div"}) == 5)
852+assert(run(function () return a % 6 end, {"mod"}) == 4)
853+assert(run(function () return a // 3 end, {"idiv"}) == 3)
854+
855+assert(run(function () return a + b end, {"add"}) == 22)
856+assert(run(function () return a - b end, {"sub"}) == -2)
857+assert(run(function () return a * b end, {"mul"}) == 120)
858+assert(run(function () return a ^ b end, {"pow"}) == 10^12)
859+assert(run(function () return a / b end, {"div"}) == 10/12)
860+assert(run(function () return a % b end, {"mod"}) == 10)
861+assert(run(function () return a // b end, {"idiv"}) == 0)
862+
863+-- repeat tests with larger constants (to use 'K' opcodes)
864+local a1000 = new(1000)
865+
866+assert(run(function () return a1000 + 1000 end, {"add"}) == 2000)
867+assert(run(function () return a1000 - 25000 end, {"sub"}) == -24000)
868+assert(run(function () return 2000 * a end, {"mul"}) == 20000)
869+assert(run(function () return a1000 / 1000 end, {"div"}) == 1)
870+assert(run(function () return a1000 % 600 end, {"mod"}) == 400)
871+assert(run(function () return a1000 // 500 end, {"idiv"}) == 2)
872+
873+
874+
875+assert(run(function () return a % b end, {"mod"}) == 10)
876+
877+assert(run(function () return ~a & b end, {"bnot", "band"}) == ~10 & 12)
878+assert(run(function () return a | b end, {"bor"}) == 10 | 12)
879+assert(run(function () return a ~ b end, {"bxor"}) == 10 ~ 12)
880+assert(run(function () return a << b end, {"shl"}) == 10 << 12)
881+assert(run(function () return a >> b end, {"shr"}) == 10 >> 12)
882+
883+assert(run(function () return 10 & b end, {"band"}) == 10 & 12)
884+assert(run(function () return a | 2 end, {"bor"}) == 10 | 2)
885+assert(run(function () return a ~ 2 end, {"bxor"}) == 10 ~ 2)
886+assert(run(function () return a >> 2 end, {"shr"}) == 10 >> 2)
887+assert(run(function () return 1 >> a end, {"shr"}) == 1 >> 10)
888+assert(run(function () return a << 2 end, {"shl"}) == 10 << 2)
889+assert(run(function () return 1 << a end, {"shl"}) == 1 << 10)
890+assert(run(function () return 2 ~ a end, {"bxor"}) == 2 ~ 10)
891+
892+
893+assert(run(function () return a..b end, {"concat"}) == "1012")
894+
895+assert(run(function() return a .. b .. c .. a end,
896+ {"concat", "concat", "concat"}) == "1012hello10")
897+
898+assert(run(function() return "a" .. "b" .. a .. "c" .. c .. b .. "x" end,
899+ {"concat", "concat", "concat"}) == "ab10chello12x")
900+
901+
902+do -- a few more tests for comparison operators
903+ local mt1 = {
904+ __le = function (a,b)
905+ coroutine.yield(10)
906+ return (val(a) <= val(b))
907+ end,
908+ __lt = function (a,b)
909+ coroutine.yield(10)
910+ return val(a) < val(b)
911+ end,
912+ }
913+ local mt2 = { __lt = mt1.__lt, __le = mt1.__le }
914+
915+ local function run (f)
916+ local co = coroutine.wrap(f)
917+ local res
918+ repeat
919+ res = co()
920+ until res ~= 10
921+ return res
922+ end
923+
924+ local function test ()
925+ local a1 = setmetatable({x=1}, mt1)
926+ local a2 = setmetatable({x=2}, mt2)
927+ assert(a1 < a2)
928+ assert(a1 <= a2)
929+ assert(1 < a2)
930+ assert(1 <= a2)
931+ assert(2 > a1)
932+ assert(2 >= a2)
933+ return true
934+ end
935+
936+ run(test)
937+
938+end
939+
940+assert(run(function ()
941+ a.BB = print
942+ return a.BB
943+ end, {"nidx", "idx"}) == print)
944+
945+-- getuptable & setuptable
946+do local _ENV = _ENV
947+ f = function () AAA = BBB + 1; return AAA end
948+end
949+local g = new(10); g.k.BBB = 10;
950+debug.setupvalue(f, 1, g)
951+assert(run(f, {"idx", "nidx", "idx"}) == 11)
952+assert(g.k.AAA == 11)
953+
954+print"+"
955+
956+print"testing yields inside 'for' iterators"
957+
958+local f = function (s, i)
959+ if i%2 == 0 then coroutine.yield(nil, "for") end
960+ if i < s then return i + 1 end
961+ end
962+
963+assert(run(function ()
964+ local s = 0
965+ for i in f, 4, 0 do s = s + i end
966+ return s
967+ end, {"for", "for", "for"}) == 10)
968+
969+
970+
971+-- tests for coroutine API
972+if T==nil then
973+ (Message or print)('\n >>> testC not active: skipping coroutine API tests <<<\n')
974+ print "OK"; return
975+end
976+
977+print('testing coroutine API')
978+
979+local function apico (...)
980+ local x = {...}
981+ return coroutine.wrap(function ()
982+ return T.testC(table.unpack(x))
983+ end)
984+end
985+
986+local a = {apico(
987+[[
988+ pushstring errorcode
989+ pcallk 1 0 2;
990+ invalid command (should not arrive here)
991+]],
992+[[return *]],
993+"stackmark",
994+error
995+)()}
996+assert(#a == 4 and
997+ a[3] == "stackmark" and
998+ a[4] == "errorcode" and
999+ _G.status == "ERRRUN" and
1000+ _G.ctx == 2) -- 'ctx' to pcallk
1001+
1002+local co = apico(
1003+ "pushvalue 2; pushnum 10; pcallk 1 2 3; invalid command;",
1004+ coroutine.yield,
1005+ "getglobal status; getglobal ctx; pushvalue 2; pushstring a; pcallk 1 0 4; invalid command",
1006+ "getglobal status; getglobal ctx; return *")
1007+
1008+assert(co() == 10)
1009+assert(co(20, 30) == 'a')
1010+a = {co()}
1011+assert(#a == 10 and
1012+ a[2] == coroutine.yield and
1013+ a[5] == 20 and a[6] == 30 and
1014+ a[7] == "YIELD" and a[8] == 3 and
1015+ a[9] == "YIELD" and a[10] == 4)
1016+assert(not pcall(co)) -- coroutine is dead now
1017+
1018+
1019+f = T.makeCfunc("pushnum 3; pushnum 5; yield 1;")
1020+co = coroutine.wrap(function ()
1021+ assert(f() == 23); assert(f() == 23); return 10
1022+end)
1023+assert(co(23,16) == 5)
1024+assert(co(23,16) == 5)
1025+assert(co(23,16) == 10)
1026+
1027+
1028+-- testing coroutines with C bodies
1029+f = T.makeCfunc([[
1030+ pushnum 102
1031+ yieldk 1 U2
1032+ cannot be here!
1033+]],
1034+[[ # continuation
1035+ pushvalue U3 # accessing upvalues inside a continuation
1036+ pushvalue U4
1037+ return *
1038+]], 23, "huu")
1039+
1040+x = coroutine.wrap(f)
1041+assert(x() == 102)
1042+eqtab({x()}, {23, "huu"})
1043+
1044+
1045+f = T.makeCfunc[[pushstring 'a'; pushnum 102; yield 2; ]]
1046+
1047+a, b, c, d = T.testC([[newthread; pushvalue 2; xmove 0 3 1; resume 3 0;
1048+ pushstatus; xmove 3 0 0; resume 3 0; pushstatus;
1049+ return 4; ]], f)
1050+
1051+assert(a == 'YIELD' and b == 'a' and c == 102 and d == 'OK')
1052+
1053+
1054+-- testing chain of suspendable C calls
1055+
1056+local count = 3 -- number of levels
1057+
1058+f = T.makeCfunc([[
1059+ remove 1; # remove argument
1060+ pushvalue U3; # get selection function
1061+ call 0 1; # call it (result is 'f' or 'yield')
1062+ pushstring hello # single argument for selected function
1063+ pushupvalueindex 2; # index of continuation program
1064+ callk 1 -1 .; # call selected function
1065+ errorerror # should never arrive here
1066+]],
1067+[[
1068+ # continuation program
1069+ pushnum 34 # return value
1070+ return * # return all results
1071+]],
1072+function () -- selection function
1073+ count = count - 1
1074+ if count == 0 then return coroutine.yield
1075+ else return f
1076+ end
1077+end
1078+)
1079+
1080+co = coroutine.wrap(function () return f(nil) end)
1081+assert(co() == "hello") -- argument to 'yield'
1082+a = {co()}
1083+-- three '34's (one from each pending C call)
1084+assert(#a == 3 and a[1] == a[2] and a[2] == a[3] and a[3] == 34)
1085+
1086+
1087+-- testing yields with continuations
1088+
1089+local y
1090+
1091+co = coroutine.wrap(function (...) return
1092+ T.testC([[ # initial function
1093+ yieldk 1 2
1094+ cannot be here!
1095+ ]],
1096+ [[ # 1st continuation
1097+ yieldk 0 3
1098+ cannot be here!
1099+ ]],
1100+ [[ # 2nd continuation
1101+ yieldk 0 4
1102+ cannot be here!
1103+ ]],
1104+ [[ # 3th continuation
1105+ pushvalue 6 # function which is last arg. to 'testC' here
1106+ pushnum 10; pushnum 20;
1107+ pcall 2 0 0 # call should throw an error and return to next line
1108+ pop 1 # remove error message
1109+ pushvalue 6
1110+ getglobal status; getglobal ctx
1111+ pcallk 2 2 5 # call should throw an error and jump to continuation
1112+ cannot be here!
1113+ ]],
1114+ [[ # 4th (and last) continuation
1115+ return *
1116+ ]],
1117+ -- function called by 3th continuation
1118+ function (a,b) x=a; y=b; error("errmsg") end,
1119+ ...
1120+)
1121+end)
1122+
1123+local a = {co(3,4,6)}
1124+assert(a[1] == 6 and a[2] == undef)
1125+a = {co()}; assert(a[1] == undef and _G.status == "YIELD" and _G.ctx == 2)
1126+a = {co()}; assert(a[1] == undef and _G.status == "YIELD" and _G.ctx == 3)
1127+a = {co(7,8)};
1128+-- original arguments
1129+assert(type(a[1]) == 'string' and type(a[2]) == 'string' and
1130+ type(a[3]) == 'string' and type(a[4]) == 'string' and
1131+ type(a[5]) == 'string' and type(a[6]) == 'function')
1132+-- arguments left from fist resume
1133+assert(a[7] == 3 and a[8] == 4)
1134+-- arguments to last resume
1135+assert(a[9] == 7 and a[10] == 8)
1136+-- error message and nothing more
1137+assert(a[11]:find("errmsg") and #a == 11)
1138+-- check arguments to pcallk
1139+assert(x == "YIELD" and y == 4)
1140+
1141+assert(not pcall(co)) -- coroutine should be dead
1142+
1143+_G.ctx = nil
1144+_G.status = nil
1145+
1146+
1147+-- bug in nCcalls
1148+local co = coroutine.wrap(function ()
1149+ local a = {pcall(pcall,pcall,pcall,pcall,pcall,pcall,pcall,error,"hi")}
1150+ return pcall(assert, table.unpack(a))
1151+end)
1152+
1153+local a = {co()}
1154+assert(a[10] == "hi")
1155+
1156+print'OK'
desk/res/lua/cstack.luanew file+197
@@ -0,0 +1,197 @@
1+-- $Id: testes/cstack.lua $
2+-- See Copyright Notice in file all.lua
3+
4+
5+local tracegc = require"tracegc"
6+
7+print"testing stack overflow detection"
8+
9+-- Segmentation faults in these tests probably result from a C-stack
10+-- overflow. To avoid these errors, you should set a smaller limit for
11+-- the use of C stack by Lua, by changing the constant 'LUAI_MAXCCALLS'.
12+-- Alternatively, you can ensure a larger stack for the program.
13+
14+
15+local function checkerror (msg, f, ...)
16+ local s, err = pcall(f, ...)
17+ assert(not s and string.find(err, msg))
18+end
19+
20+do print("testing stack overflow in message handling")
21+ local count = 0
22+ local function loop (x, y, z)
23+ count = count + 1
24+ return 1 + loop(x, y, z)
25+ end
26+ tracegc.stop() -- __gc should not be called with a full stack
27+ local res, msg = xpcall(loop, loop)
28+ tracegc.start()
29+ assert(msg == "error in error handling")
30+ print("final count: ", count)
31+end
32+
33+
34+-- bug since 2.5 (C-stack overflow in recursion inside pattern matching)
35+do print("testing recursion inside pattern matching")
36+ local function f (size)
37+ local s = string.rep("a", size)
38+ local p = string.rep(".?", size)
39+ return string.match(s, p)
40+ end
41+ local m = f(80)
42+ assert(#m == 80)
43+ checkerror("too complex", f, 2000)
44+end
45+
46+
47+do print("testing stack-overflow in recursive 'gsub'")
48+ local count = 0
49+ local function foo ()
50+ count = count + 1
51+ string.gsub("a", ".", foo)
52+ end
53+ checkerror("stack overflow", foo)
54+ print("final count: ", count)
55+
56+ print("testing stack-overflow in recursive 'gsub' with metatables")
57+ local count = 0
58+ local t = setmetatable({}, {__index = foo})
59+ foo = function ()
60+ count = count + 1
61+ string.gsub("a", ".", t)
62+ end
63+ checkerror("stack overflow", foo)
64+ print("final count: ", count)
65+end
66+
67+
68+do -- bug in 5.4.0
69+ print("testing limits in coroutines inside deep calls")
70+ local count = 0
71+ local lim = 1000
72+ local function stack (n)
73+ if n > 0 then return stack(n - 1) + 1
74+ else coroutine.wrap(function ()
75+ count = count + 1
76+ stack(lim)
77+ end)()
78+ end
79+ end
80+
81+ local st, msg = xpcall(stack, function () return "ok" end, lim)
82+ assert(not st and msg == "ok")
83+ print("final count: ", count)
84+end
85+
86+
87+do -- bug since 5.4.0
88+ local count = 0
89+ print("chain of 'coroutine.close'")
90+ -- create N coroutines forming a list so that each one, when closed,
91+ -- closes the previous one. (With a large enough N, previous Lua
92+ -- versions crash in this test.)
93+ local coro = false
94+ for i = 1, 1000 do
95+ local previous = coro
96+ coro = coroutine.create(function()
97+ local cc <close> = setmetatable({}, {__close=function()
98+ count = count + 1
99+ if previous then
100+ assert(coroutine.close(previous))
101+ end
102+ end})
103+ coroutine.yield() -- leaves 'cc' pending to be closed
104+ end)
105+ assert(coroutine.resume(coro)) -- start it and run until it yields
106+ end
107+ local st, msg = coroutine.close(coro)
108+ assert(not st and string.find(msg, "C stack overflow"))
109+ print("final count: ", count)
110+end
111+
112+
113+do
114+ print("nesting of resuming yielded coroutines")
115+ local count = 0
116+
117+ local function body ()
118+ coroutine.yield()
119+ local f = coroutine.wrap(body)
120+ f(); -- start new coroutine (will stop in previous yield)
121+ count = count + 1
122+ f() -- call it recursively
123+ end
124+
125+ local f = coroutine.wrap(body)
126+ f()
127+ assert(not pcall(f))
128+ print("final count: ", count)
129+end
130+
131+
132+do -- bug in 5.4.2
133+ print("nesting coroutines running after recoverable errors")
134+ local count = 0
135+ local function foo()
136+ count = count + 1
137+ pcall(1) -- create an error
138+ -- running now inside 'precover' ("protected recover")
139+ coroutine.wrap(foo)() -- call another coroutine
140+ end
141+ checkerror("C stack overflow", foo)
142+ print("final count: ", count)
143+end
144+
145+
146+if T then
147+ print("testing stack recovery")
148+ local N = 0 -- trace number of calls
149+ local LIM = -1 -- will store N just before stack overflow
150+
151+ -- trace stack size; after stack overflow, it should be
152+ -- the maximum allowed stack size.
153+ local stack1
154+ local dummy
155+
156+ local function err(msg)
157+ assert(string.find(msg, "stack overflow"))
158+ local _, stacknow = T.stacklevel()
159+ assert(stacknow == stack1 + 200)
160+ end
161+
162+ -- When LIM==-1, the 'if' is not executed, so this function only
163+ -- counts and stores the stack limits up to overflow. Then, LIM
164+ -- becomes N, and then the 'if' code is run when the stack is
165+ -- full. Then, there is a stack overflow inside 'xpcall', after which
166+ -- the stack must have been restored back to its maximum normal size.
167+ local function f()
168+ dummy, stack1 = T.stacklevel()
169+ if N == LIM then
170+ xpcall(f, err)
171+ local _, stacknow = T.stacklevel()
172+ assert(stacknow == stack1)
173+ return
174+ end
175+ N = N + 1
176+ f()
177+ end
178+
179+ local topB, sizeB -- top and size Before overflow
180+ local topA, sizeA -- top and size After overflow
181+ topB, sizeB = T.stacklevel()
182+ tracegc.stop() -- __gc should not be called with a full stack
183+ xpcall(f, err)
184+ tracegc.start()
185+ topA, sizeA = T.stacklevel()
186+ -- sizes should be comparable
187+ assert(topA == topB and sizeA < sizeB * 2)
188+ print(string.format("maximum stack size: %d", stack1))
189+ LIM = N -- will stop recursion at maximum level
190+ N = 0 -- to count again
191+ tracegc.stop() -- __gc should not be called with a full stack
192+ f()
193+ tracegc.start()
194+ print"+"
195+end
196+
197+print'OK'
desk/res/lua/cycled/all.luanew file+203
@@ -0,0 +1,203 @@
1+local version = "\u{4c}\u{75}\u{61}\u{20}\u{35}\u{2e}\u{34}"
2+if (_VERSION ~= version) then
3+io.stderr:write("\u{54}\u{68}\u{69}\u{73}\u{20}\u{74}\u{65}\u{73}\u{74}\u{20}\u{73}\u{75}\u{69}\u{74}\u{65}\u{20}\u{69}\u{73}\u{20}\u{66}\u{6f}\u{72}\u{20}",version,"\u{2c}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{66}\u{6f}\u{72}\u{20}",_VERSION,"\u{a}\u{45}\u{78}\u{69}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{74}\u{65}\u{73}\u{74}\u{73}")
4+return
5+end
6+_G.ARG=arg
7+_soft=(rawget(_G,"\u{5f}\u{73}\u{6f}\u{66}\u{74}") or false)
8+_port=(rawget(_G,"\u{5f}\u{70}\u{6f}\u{72}\u{74}") or false)
9+_nomsg=(rawget(_G,"\u{5f}\u{6e}\u{6f}\u{6d}\u{73}\u{67}") or false)
10+local usertests = rawget(_G,"\u{5f}\u{55}")
11+if usertests then
12+_soft=true
13+_port=true
14+_nomsg=true
15+end
16+debug=nil
17+if usertests then
18+T=nil
19+else
20+T=rawget(_G,"\u{54}")
21+end
22+print("\u{a}\u{9}\u{53}\u{74}\u{61}\u{72}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{54}\u{65}\u{73}\u{74}\u{73}")
23+do
24+local random_x,random_y = math.randomseed()
25+print(string.format("\u{72}\u{61}\u{6e}\u{64}\u{6f}\u{6d}\u{20}\u{73}\u{65}\u{65}\u{64}\u{73}\u{3a}\u{20}\u{25}\u{64}\u{2c}\u{20}\u{25}\u{64}",random_x,random_y))
26+end
27+print(("\u{63}\u{75}\u{72}\u{72}\u{65}\u{6e}\u{74}\u{20}\u{70}\u{61}\u{74}\u{68}\u{3a}\u{a}\u{2a}\u{2a}\u{2a}\u{2a}" .. (package.path .. "\u{2a}\u{2a}\u{2a}\u{2a}\u{a}")))
28+local initclock = os.clock()
29+local lastclock = initclock
30+local walltime = os.time()
31+local collectgarbage = collectgarbage
32+do
33+local msgs = {}
34+function Message(m)
35+if (not _nomsg) then
36+print(m)
37+msgs[(# (msgs + 0x1))]=string.sub(m,0x3,(- 0x3))
38+end
39+end
40+assert(os.setlocale("\u{43}"))
41+local T,print,format,write,assert,type,unpack,floor = T,print,string.format,io.write,assert,type,table.unpack,math.floor
42+local function F
43+(m)
44+local function round
45+(m)
46+m=(m + 0.04999)
47+return format("\u{25}\u{2e}\u{31}\u{66}",m)
48+end
49+if (m < 0x3e8) then
50+return m
51+else
52+m=(m / 0x3e8)
53+if (m < 0x3e8) then
54+return (round(m) .. "\u{4b}")
55+else
56+return (round((m / 0x3e8)) .. "\u{4d}")
57+end
58+end
59+end
60+local Cstacklevel
61+local showmem
62+if (not T) then
63+local max = 0x0
64+showmem=function ()
65+local m = (collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}") * 0x400)
66+max=(((m > max) and m) or max)
67+print(format("\u{20}\u{20}\u{20}\u{20}\u{2d}\u{2d}\u{2d}\u{2d}\u{20}\u{74}\u{6f}\u{74}\u{61}\u{6c}\u{20}\u{6d}\u{65}\u{6d}\u{6f}\u{72}\u{79}\u{3a}\u{20}\u{25}\u{73}\u{2c}\u{20}\u{6d}\u{61}\u{78}\u{20}\u{6d}\u{65}\u{6d}\u{6f}\u{72}\u{79}\u{3a}\u{20}\u{25}\u{73}\u{20}\u{2d}\u{2d}\u{2d}\u{2d}\u{a}",F(m),F(max)))
68+end
69+Cstacklevel=function ()
70+return 0x0
71+end
72+else
73+showmem=function ()
74+T.checkmemory()
75+local total,numblocks,maxmem = T.totalmem()
76+local count = collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}")
77+print(format("\u{a}\u{20}\u{20}\u{20}\u{20}\u{2d}\u{2d}\u{2d}\u{2d}\u{20}\u{74}\u{6f}\u{74}\u{61}\u{6c}\u{20}\u{6d}\u{65}\u{6d}\u{6f}\u{72}\u{79}\u{3a}\u{20}\u{25}\u{73}\u{20}\u{28}\u{25}\u{2e}\u{30}\u{66}\u{4b}\u{29}\u{2c}\u{20}\u{6d}\u{61}\u{78}\u{20}\u{75}\u{73}\u{65}\u{3a}\u{20}\u{25}\u{73}\u{2c}\u{20}\u{20}\u{62}\u{6c}\u{6f}\u{63}\u{6b}\u{73}\u{3a}\u{20}\u{25}\u{64}\u{a}",F(total),count,F(maxmem),numblocks))
78+print(format(("\u{9}\u{28}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{73}\u{3a}\u{20}\u{20}\u{25}\u{64}\u{2c}\u{20}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{73}\u{3a}\u{20}\u{25}\u{64}\u{2c}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{73}\u{3a}\u{20}\u{25}\u{64}\u{2c}\u{20}" .. "\u{a}\u{9}\u{75}\u{64}\u{61}\u{74}\u{61}\u{3a}\u{20}\u{25}\u{64}\u{2c}\u{20}\u{74}\u{68}\u{72}\u{65}\u{61}\u{64}\u{73}\u{3a}\u{20}\u{25}\u{64}\u{29}"),T.totalmem("\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}"),T.totalmem("\u{74}\u{61}\u{62}\u{6c}\u{65}"),T.totalmem("\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}"),T.totalmem("\u{75}\u{73}\u{65}\u{72}\u{64}\u{61}\u{74}\u{61}"),T.totalmem("\u{74}\u{68}\u{72}\u{65}\u{61}\u{64}")))
79+end
80+Cstacklevel=function ()
81+local _,_,ncalls = T.stacklevel()
82+return ncalls
83+end
84+end
85+local Cstack = Cstacklevel()
86+local function report
87+(n)
88+print(("\u{a}\u{2a}\u{2a}\u{2a}\u{2a}\u{2a}\u{20}\u{46}\u{49}\u{4c}\u{45}\u{20}\u{27}" .. (n .. "\u{27}\u{2a}\u{2a}\u{2a}\u{2a}\u{2a}")))
89+end
90+local olddofile = dofile
91+local dofile = function (n,strip)
92+showmem()
93+local c = os.clock()
94+print(string.format("\u{74}\u{69}\u{6d}\u{65}\u{3a}\u{20}\u{25}\u{67}\u{20}\u{28}\u{2b}\u{25}\u{67}\u{29}",(c - initclock),(c - lastclock)))
95+lastclock=c
96+report(n)
97+local f = assert(loadfile(n))
98+local b = string.dump(f,strip)
99+f=assert(load(b))
100+return f()
101+end
102+dofile("\u{6d}\u{61}\u{69}\u{6e}\u{2e}\u{6c}\u{75}\u{61}")
103+require("\u{74}\u{72}\u{61}\u{63}\u{65}\u{67}\u{63}").start()
104+report("\u{67}\u{63}\u{2e}\u{6c}\u{75}\u{61}")
105+local f = assert(loadfile("\u{67}\u{63}\u{2e}\u{6c}\u{75}\u{61}"))
106+f()
107+dofile("\u{64}\u{62}\u{2e}\u{6c}\u{75}\u{61}")
108+assert(((dofile("\u{63}\u{61}\u{6c}\u{6c}\u{73}\u{2e}\u{6c}\u{75}\u{61}") == deep) and deep))
109+_G.deep=nil
110+olddofile("\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{73}\u{2e}\u{6c}\u{75}\u{61}")
111+olddofile("\u{6c}\u{69}\u{74}\u{65}\u{72}\u{61}\u{6c}\u{73}\u{2e}\u{6c}\u{75}\u{61}")
112+dofile("\u{74}\u{70}\u{61}\u{63}\u{6b}\u{2e}\u{6c}\u{75}\u{61}")
113+assert((dofile("\u{61}\u{74}\u{74}\u{72}\u{69}\u{62}\u{2e}\u{6c}\u{75}\u{61}") == 0x1b))
114+dofile("\u{67}\u{65}\u{6e}\u{67}\u{63}\u{2e}\u{6c}\u{75}\u{61}")
115+assert((dofile("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{73}\u{2e}\u{6c}\u{75}\u{61}") == 0x5))
116+dofile("\u{63}\u{6f}\u{6e}\u{73}\u{74}\u{72}\u{75}\u{63}\u{74}\u{73}\u{2e}\u{6c}\u{75}\u{61}")
117+dofile("\u{63}\u{6f}\u{64}\u{65}\u{2e}\u{6c}\u{75}\u{61}",true)
118+if (not _G._soft) then
119+report("\u{62}\u{69}\u{67}\u{2e}\u{6c}\u{75}\u{61}")
120+local f = coroutine.wrap(assert(loadfile("\u{62}\u{69}\u{67}\u{2e}\u{6c}\u{75}\u{61}")))
121+assert((f() == "\u{62}"))
122+assert((f() == "\u{61}"))
123+end
124+dofile("\u{63}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{2e}\u{6c}\u{75}\u{61}")
125+dofile("\u{6e}\u{65}\u{78}\u{74}\u{76}\u{61}\u{72}\u{2e}\u{6c}\u{75}\u{61}")
126+dofile("\u{70}\u{6d}\u{2e}\u{6c}\u{75}\u{61}")
127+dofile("\u{75}\u{74}\u{66}\u{38}\u{2e}\u{6c}\u{75}\u{61}")
128+dofile("\u{61}\u{70}\u{69}\u{2e}\u{6c}\u{75}\u{61}")
129+assert((dofile("\u{65}\u{76}\u{65}\u{6e}\u{74}\u{73}\u{2e}\u{6c}\u{75}\u{61}") == 0xc))
130+dofile("\u{76}\u{61}\u{72}\u{61}\u{72}\u{67}\u{2e}\u{6c}\u{75}\u{61}")
131+dofile("\u{63}\u{6c}\u{6f}\u{73}\u{75}\u{72}\u{65}\u{2e}\u{6c}\u{75}\u{61}")
132+dofile("\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}\u{2e}\u{6c}\u{75}\u{61}")
133+dofile("\u{67}\u{6f}\u{74}\u{6f}\u{2e}\u{6c}\u{75}\u{61}",true)
134+dofile("\u{65}\u{72}\u{72}\u{6f}\u{72}\u{73}\u{2e}\u{6c}\u{75}\u{61}")
135+dofile("\u{6d}\u{61}\u{74}\u{68}\u{2e}\u{6c}\u{75}\u{61}")
136+dofile("\u{73}\u{6f}\u{72}\u{74}\u{2e}\u{6c}\u{75}\u{61}",true)
137+dofile("\u{62}\u{69}\u{74}\u{77}\u{69}\u{73}\u{65}\u{2e}\u{6c}\u{75}\u{61}")
138+assert((dofile("\u{76}\u{65}\u{72}\u{79}\u{62}\u{69}\u{67}\u{2e}\u{6c}\u{75}\u{61}",true) == 0xa))
139+;
140+collectgarbage()
141+dofile("\u{66}\u{69}\u{6c}\u{65}\u{73}\u{2e}\u{6c}\u{75}\u{61}")
142+if (# (msgs > 0x0)) then
143+local m = table.concat(msgs,"\u{a}\u{20}\u{20}")
144+warn("\u{23}\u{74}\u{65}\u{73}\u{74}\u{73}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{70}\u{65}\u{72}\u{66}\u{6f}\u{72}\u{6d}\u{65}\u{64}\u{3a}\u{a}\u{20}\u{20}",m,"\u{a}")
145+end
146+print("\u{28}\u{74}\u{68}\u{65}\u{72}\u{65}\u{20}\u{73}\u{68}\u{6f}\u{75}\u{6c}\u{64}\u{20}\u{62}\u{65}\u{20}\u{74}\u{77}\u{6f}\u{20}\u{77}\u{61}\u{72}\u{6e}\u{69}\u{6e}\u{67}\u{73}\u{20}\u{6e}\u{6f}\u{77}\u{29}")
147+warn("\u{40}\u{6f}\u{6e}")
148+warn("\u{23}\u{54}\u{68}\u{69}\u{73}\u{20}\u{69}\u{73}\u{20}","\u{61}\u{6e}\u{20}\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}","\u{20}\u{77}\u{61}\u{72}\u{6e}\u{69}\u{6e}\u{67}")
149+warn("\u{40}\u{6f}\u{66}\u{66}")
150+warn("\u{2a}\u{2a}\u{2a}\u{2a}\u{2a}\u{2a}\u{2a}\u{2a}\u{20}\u{54}\u{48}\u{49}\u{53}\u{20}\u{57}\u{41}\u{52}\u{4e}\u{49}\u{4e}\u{47}\u{20}\u{53}\u{48}\u{4f}\u{55}\u{4c}\u{44}\u{20}\u{4e}\u{4f}\u{54}\u{20}\u{41}\u{50}\u{50}\u{45}\u{41}\u{52}\u{20}\u{2a}\u{2a}\u{2a}\u{2a}\u{2a}\u{2a}\u{2a}\u{2a}\u{2a}\u{2a}")
151+warn("\u{2a}\u{2a}\u{2a}\u{2a}\u{2a}\u{2a}\u{2a}\u{2a}\u{20}\u{54}\u{48}\u{49}\u{53}\u{20}\u{57}\u{41}\u{52}\u{4e}\u{49}\u{4e}\u{47}\u{20}\u{41}\u{4c}\u{53}\u{4f}\u{20}\u{53}\u{48}\u{4f}\u{55}\u{4c}\u{44}\u{20}\u{4e}\u{4f}\u{54}\u{20}\u{41}\u{50}\u{50}\u{45}\u{41}\u{52}\u{20}\u{2a}\u{2a}\u{2a}\u{2a}\u{2a}\u{2a}\u{2a}\u{2a}\u{2a}\u{2a}")
152+warn("\u{40}\u{6f}\u{6e}")
153+warn("\u{23}\u{54}\u{68}\u{69}\u{73}\u{20}\u{69}\u{73}","\u{20}\u{61}\u{6e}\u{6f}\u{74}\u{68}\u{65}\u{72}\u{20}\u{6f}\u{6e}\u{65}")
154+assert((debug == nil))
155+local debug = require("\u{64}\u{65}\u{62}\u{75}\u{67}")
156+print(string.format("\u{25}\u{64}\u{2d}\u{62}\u{69}\u{74}\u{20}\u{69}\u{6e}\u{74}\u{65}\u{67}\u{65}\u{72}\u{73}\u{2c}\u{20}\u{25}\u{64}\u{2d}\u{62}\u{69}\u{74}\u{20}\u{66}\u{6c}\u{6f}\u{61}\u{74}\u{73}",(string.packsize("\u{6a}") * 0x8),(string.packsize("\u{6e}") * 0x8)))
157+debug.sethook(function (a)
158+assert((type(a) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}"))
159+end,"\u{63}\u{72}")
160+_G.showmem=showmem
161+assert((Cstack == Cstacklevel()),"\u{73}\u{68}\u{6f}\u{75}\u{6c}\u{64}\u{20}\u{62}\u{65}\u{20}\u{61}\u{74}\u{20}\u{74}\u{68}\u{65}\u{20}\u{73}\u{61}\u{6d}\u{65}\u{20}\u{43}\u{2d}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{6c}\u{65}\u{76}\u{65}\u{6c}\u{20}\u{69}\u{74}\u{20}\u{77}\u{61}\u{73}\u{20}\u{77}\u{68}\u{65}\u{6e}\u{20}\u{73}\u{74}\u{61}\u{72}\u{74}\u{65}\u{64}\u{20}\u{74}\u{68}\u{65}\u{20}\u{74}\u{65}\u{73}\u{74}\u{73}")
162+end
163+local _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
164+local fname = ((T and "\u{74}\u{69}\u{6d}\u{65}\u{2d}\u{64}\u{65}\u{62}\u{75}\u{67}\u{2e}\u{74}\u{78}\u{74}") or "\u{74}\u{69}\u{6d}\u{65}\u{2e}\u{74}\u{78}\u{74}")
165+local lasttime
166+if (not usertests) then
167+local f = io.open(fname)
168+if f then
169+lasttime=assert(tonumber(f:read("\u{61}")))
170+f:close()
171+;
172+else
173+lasttime=nil
174+end
175+end
176+print("\u{63}\u{6c}\u{65}\u{61}\u{6e}\u{69}\u{6e}\u{67}\u{20}\u{61}\u{6c}\u{6c}\u{21}\u{21}\u{21}\u{21}")
177+for n in pairs(_G)
178+do
179+if (not ({["\u{5f}\u{5f}\u{5f}\u{47}\u{6c}\u{6f}\u{62}"] = 0x1,["\u{74}\u{6f}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}"] = 0x1})[n]) then
180+_G[n]=undef
181+end
182+end
183+collectgarbage()
184+collectgarbage()
185+collectgarbage()
186+collectgarbage()
187+collectgarbage()
188+collectgarbage()
189+;
190+showmem()
191+local clocktime = (clock() - initclock)
192+walltime=difftime(time(),walltime)
193+print(format("\u{a}\u{a}\u{74}\u{6f}\u{74}\u{61}\u{6c}\u{20}\u{74}\u{69}\u{6d}\u{65}\u{3a}\u{20}\u{25}\u{2e}\u{32}\u{66}\u{73}\u{20}\u{28}\u{77}\u{61}\u{6c}\u{6c}\u{20}\u{74}\u{69}\u{6d}\u{65}\u{3a}\u{20}\u{25}\u{67}\u{73}\u{29}\u{a}",clocktime,walltime))
194+if (not usertests) then
195+lasttime=(lasttime or clocktime)
196+local diff = ((clocktime - lasttime) / lasttime)
197+local tolerance = 0.05
198+if ((diff >= tolerance) or (diff <= (- tolerance))) then
199+warn(format("\u{23}\u{74}\u{69}\u{6d}\u{65}\u{20}\u{64}\u{69}\u{66}\u{66}\u{65}\u{72}\u{65}\u{6e}\u{63}\u{65}\u{20}\u{66}\u{72}\u{6f}\u{6d}\u{20}\u{70}\u{72}\u{65}\u{76}\u{69}\u{6f}\u{75}\u{73}\u{20}\u{74}\u{65}\u{73}\u{74}\u{3a}\u{20}\u{25}\u{2b}\u{2e}\u{31}\u{66}\u{25}\u{25}",(diff * 0x64)))
200+end
201+assert(open(fname,"\u{77}")):write(clocktime):close()
202+end
203+print("\u{66}\u{69}\u{6e}\u{61}\u{6c}\u{20}\u{4f}\u{4b}\u{20}\u{21}\u{21}\u{21}")
desk/res/lua/cycled/api.luanew file+1167
@@ -0,0 +1,1167 @@
1+if (T == nil) then
2+(Message or print)("\u{a}\u{20}\u{3e}\u{3e}\u{3e}\u{20}\u{74}\u{65}\u{73}\u{74}\u{43}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{61}\u{63}\u{74}\u{69}\u{76}\u{65}\u{3a}\u{20}\u{73}\u{6b}\u{69}\u{70}\u{70}\u{69}\u{6e}\u{67}\u{20}\u{41}\u{50}\u{49}\u{20}\u{74}\u{65}\u{73}\u{74}\u{73}\u{20}\u{3c}\u{3c}\u{3c}\u{a}")
3+return
4+end
5+local debug = require("\u{64}\u{65}\u{62}\u{75}\u{67}")
6+local pack = table.pack
7+local MEMERRMSG = "\u{6e}\u{6f}\u{74}\u{20}\u{65}\u{6e}\u{6f}\u{75}\u{67}\u{68}\u{20}\u{6d}\u{65}\u{6d}\u{6f}\u{72}\u{79}"
8+local function tcheck
9+(t1,t2)
10+assert((t1.n == ((t2.n or (# t2)) + 0x1)))
11+for i = 0x2, t1.n
12+do
13+assert((t1[i] == t2[(i - 0x1)]))
14+end
15+end
16+local function checkerr
17+(msg,f, ...)
18+local stat,err = pcall(f,...)
19+assert((not (stat and string.find(err,msg))))
20+end
21+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{43}\u{20}\u{41}\u{50}\u{49}")
22+local a = T.testC("\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{52}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}")
23+assert((a == debug.getregistry()))
24+assert((T.testC("\u{73}\u{65}\u{74}\u{74}\u{6f}\u{70}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{61}\u{62}\u{73}\u{69}\u{6e}\u{64}\u{65}\u{78}\u{20}\u{2d}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}") == 0xa))
25+assert((T.testC("\u{73}\u{65}\u{74}\u{74}\u{6f}\u{70}\u{20}\u{35}\u{3b}\u{20}\u{61}\u{62}\u{73}\u{69}\u{6e}\u{64}\u{65}\u{78}\u{20}\u{2d}\u{35}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}") == 0x1))
26+assert((T.testC("\u{73}\u{65}\u{74}\u{74}\u{6f}\u{70}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{61}\u{62}\u{73}\u{69}\u{6e}\u{64}\u{65}\u{78}\u{20}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}") == 0x1))
27+assert((T.testC("\u{73}\u{65}\u{74}\u{74}\u{6f}\u{70}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{61}\u{62}\u{73}\u{69}\u{6e}\u{64}\u{65}\u{78}\u{20}\u{52}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}") < (- 0xa)))
28+a=T.d2s(12458954321123.0)
29+assert((a == string.pack("\u{64}",12458954321123.0)))
30+assert((T.s2d(a) == 12458954321123.0))
31+local a,b,c = T.testC("\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{32}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{33}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}")
32+assert((((a == 0x2) and (b == 0x3)) and (not c)))
33+local f = T.makeCfunc("\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{32}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{33}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}")
34+a,b,c=f()
35+assert((((a == 0x2) and (b == 0x3)) and (not c)))
36+a,b,c=T.testC("\u{70}\u{75}\u{73}\u{68}\u{62}\u{6f}\u{6f}\u{6c}\u{20}\u{31}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{62}\u{6f}\u{6f}\u{6c}\u{20}\u{32}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{62}\u{6f}\u{6f}\u{6c}\u{20}\u{30}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{33}")
37+assert((((a == b) and (a == true)) and (c == false)))
38+a,b,c=T.testC("\u{70}\u{75}\u{73}\u{68}\u{62}\u{6f}\u{6f}\u{6c}\u{20}\u{30}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{62}\u{6f}\u{6f}\u{6c}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{69}\u{6c}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{74}\u{6f}\u{62}\u{6f}\u{6f}\u{6c}\u{20}\u{2d}\u{33}\u{3b}\u{20}\u{74}\u{6f}\u{62}\u{6f}\u{6f}\u{6c}\u{20}\u{2d}\u{33}\u{3b}\u{20}\u{74}\u{6f}\u{62}\u{6f}\u{6f}\u{6c}\u{20}\u{2d}\u{33}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{33}")
39+assert((((a == false) and (b == true)) and (c == false)))
40+a,b,c=T.testC("\u{67}\u{65}\u{74}\u{74}\u{6f}\u{70}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}",0xa,0x14,0x1e,0x28)
41+assert((((a == 0x28) and (b == 0x5)) and (not c)))
42+local t = pack(T.testC("\u{73}\u{65}\u{74}\u{74}\u{6f}\u{70}\u{20}\u{35}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}",0x2,0x3))
43+tcheck(t,{["\u{6e}"] = 0x4,0x2,0x3})
44+t=pack(T.testC("\u{73}\u{65}\u{74}\u{74}\u{6f}\u{70}\u{20}\u{30}\u{3b}\u{20}\u{73}\u{65}\u{74}\u{74}\u{6f}\u{70}\u{20}\u{31}\u{35}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}\u{30}",0x3,0x1,0x17))
45+assert((((t.n == 0xa) and (t[0x1] == nil)) and (t[0xa] == nil)))
46+t=pack(T.testC("\u{72}\u{65}\u{6d}\u{6f}\u{76}\u{65}\u{20}\u{2d}\u{32}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}",0x2,0x3,0x4))
47+tcheck(t,{["\u{6e}"] = 0x2,0x2,0x4})
48+t=pack(T.testC("\u{69}\u{6e}\u{73}\u{65}\u{72}\u{74}\u{20}\u{2d}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}",0x2,0x3))
49+tcheck(t,{["\u{6e}"] = 0x2,0x2,0x3})
50+t=pack(T.testC("\u{69}\u{6e}\u{73}\u{65}\u{72}\u{74}\u{20}\u{33}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}",0x2,0x3,0x4,0x5))
51+tcheck(t,{["\u{6e}"] = 0x4,0x2,0x5,0x3,0x4})
52+t=pack(T.testC("\u{72}\u{65}\u{70}\u{6c}\u{61}\u{63}\u{65}\u{20}\u{32}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}",0x2,0x3,0x4,0x5))
53+tcheck(t,{["\u{6e}"] = 0x3,0x5,0x3,0x4})
54+t=pack(T.testC("\u{72}\u{65}\u{70}\u{6c}\u{61}\u{63}\u{65}\u{20}\u{2d}\u{32}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}",0x2,0x3,0x4,0x5))
55+tcheck(t,{["\u{6e}"] = 0x3,0x2,0x3,0x5})
56+t=pack(T.testC("\u{72}\u{65}\u{6d}\u{6f}\u{76}\u{65}\u{20}\u{33}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}",0x2,0x3,0x4,0x5))
57+tcheck(t,{["\u{6e}"] = 0x3,0x2,0x4,0x5})
58+t=pack(T.testC("\u{63}\u{6f}\u{70}\u{79}\u{20}\u{33}\u{20}\u{34}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}",0x2,0x3,0x4,0x5))
59+tcheck(t,{["\u{6e}"] = 0x4,0x2,0x3,0x3,0x5})
60+t=pack(T.testC("\u{63}\u{6f}\u{70}\u{79}\u{20}\u{2d}\u{33}\u{20}\u{2d}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}",0x2,0x3,0x4,0x5))
61+tcheck(t,{["\u{6e}"] = 0x4,0x2,0x3,0x4,0x3})
62+do
63+local t = {0xa,0x14,0x1e,0x28,0x32,0x3c}
64+for i = (- 0x6), 0x6
65+do
66+local s = string.format("\u{72}\u{6f}\u{74}\u{61}\u{74}\u{65}\u{20}\u{32}\u{20}\u{25}\u{64}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{37}",i)
67+local t1 = pack(T.testC(s,0xa,0x14,0x1e,0x28,0x32,0x3c))
68+tcheck(t1,t)
69+table.insert(t,0x1,table.remove(t))
70+end
71+t=pack(T.testC("\u{72}\u{6f}\u{74}\u{61}\u{74}\u{65}\u{20}\u{2d}\u{32}\u{20}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}",0xa,0x14,0x1e,0x28))
72+tcheck(t,{0xa,0x14,0x28,0x1e})
73+t=pack(T.testC("\u{72}\u{6f}\u{74}\u{61}\u{74}\u{65}\u{20}\u{2d}\u{32}\u{20}\u{2d}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}",0xa,0x14,0x1e,0x28))
74+tcheck(t,{0xa,0x14,0x28,0x1e})
75+t=pack(T.testC("\u{72}\u{6f}\u{74}\u{61}\u{74}\u{65}\u{20}\u{2d}\u{31}\u{20}\u{30}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}",0xa,0x14,0x1e,0x28))
76+tcheck(t,{0xa,0x14,0x1e,0x28})
77+t=pack(T.testC("\u{72}\u{6f}\u{74}\u{61}\u{74}\u{65}\u{20}\u{2d}\u{31}\u{20}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}",0xa,0x14,0x1e,0x28))
78+tcheck(t,{0xa,0x14,0x1e,0x28})
79+t=pack(T.testC("\u{72}\u{6f}\u{74}\u{61}\u{74}\u{65}\u{20}\u{35}\u{20}\u{2d}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}",0xa,0x14,0x1e,0x28))
80+tcheck(t,{0xa,0x14,0x1e,0x28})
81+end
82+T.testC("\u{20}\u{20}\u{77}\u{61}\u{72}\u{6e}\u{69}\u{6e}\u{67}\u{43}\u{20}\u{22}\u{23}\u{54}\u{68}\u{69}\u{73}\u{20}\u{73}\u{68}\u{6f}\u{6c}\u{64}\u{20}\u{62}\u{65}\u{20}\u{61}\u{22}\u{a}\u{20}\u{20}\u{77}\u{61}\u{72}\u{6e}\u{69}\u{6e}\u{67}\u{43}\u{20}\u{22}\u{20}\u{73}\u{69}\u{6e}\u{67}\u{6c}\u{65}\u{20}\u{22}\u{a}\u{20}\u{20}\u{77}\u{61}\u{72}\u{6e}\u{69}\u{6e}\u{67}\u{20}\u{22}\u{77}\u{61}\u{72}\u{6e}\u{69}\u{6e}\u{67}\u{22}\u{a}\u{20}\u{20}\u{77}\u{61}\u{72}\u{6e}\u{69}\u{6e}\u{67}\u{43}\u{20}\u{22}\u{23}\u{54}\u{68}\u{69}\u{73}\u{20}\u{73}\u{68}\u{6f}\u{75}\u{6c}\u{64}\u{20}\u{62}\u{65}\u{20}\u{22}\u{a}\u{20}\u{20}\u{77}\u{61}\u{72}\u{6e}\u{69}\u{6e}\u{67}\u{20}\u{22}\u{61}\u{6e}\u{6f}\u{74}\u{68}\u{65}\u{72}\u{20}\u{6f}\u{6e}\u{65}\u{22}\u{a}")
83+do
84+local f = T.makeCfunc("\u{20}\u{20}\u{20}\u{20}\u{67}\u{65}\u{74}\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{62}\u{6f}\u{6c}\u{61}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{31}\u{20}\u{31}\u{20}\u{31}\u{20}\u{20}\u{20}\u{23}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{27}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{27}\u{20}\u{77}\u{69}\u{74}\u{68}\u{20}\u{67}\u{69}\u{76}\u{65}\u{6e}\u{20}\u{68}\u{61}\u{6e}\u{64}\u{6c}\u{65}\u{72}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{61}\u{74}\u{75}\u{73}\u{a}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}\u{20}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{20}\u{6d}\u{65}\u{73}\u{73}\u{61}\u{67}\u{65}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{73}\u{74}\u{61}\u{74}\u{75}\u{73}\u{a}\u{20}\u{20}")
85+local msg,st = f(string.upper)
86+assert(((st == "\u{45}\u{52}\u{52}\u{52}\u{55}\u{4e}") and (msg == "\u{42}\u{4f}\u{4c}\u{41}")))
87+local msg,st = f(string.len)
88+assert(((st == "\u{45}\u{52}\u{52}\u{52}\u{55}\u{4e}") and (msg == 0x4)))
89+end
90+t=pack(T.testC("\u{69}\u{6e}\u{73}\u{65}\u{72}\u{74}\u{20}\u{33}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{33}\u{3b}\u{20}\u{72}\u{65}\u{6d}\u{6f}\u{76}\u{65}\u{20}\u{33}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{32}\u{3b}\u{20}\u{72}\u{65}\u{6d}\u{6f}\u{76}\u{65}\u{20}\u{32}\u{3b}\u{20}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{69}\u{6e}\u{73}\u{65}\u{72}\u{74}\u{20}\u{32}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{6d}\u{6f}\u{76}\u{65}\u{20}\u{31}\u{3b}\u{20}\u{69}\u{6e}\u{73}\u{65}\u{72}\u{74}\u{20}\u{31}\u{3b}\u{20}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{69}\u{6e}\u{73}\u{65}\u{72}\u{74}\u{20}\u{2d}\u{32}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{2d}\u{32}\u{3b}\u{20}\u{72}\u{65}\u{6d}\u{6f}\u{76}\u{65}\u{20}\u{2d}\u{33}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}",0x2,0x3,0x4,0x5,0xa,0x28,0x5a))
91+tcheck(t,{["\u{6e}"] = 0x7,0x2,0x3,0x4,0x5,0xa,0x28,0x5a})
92+t=pack(T.testC("\u{63}\u{6f}\u{6e}\u{63}\u{61}\u{74}\u{20}\u{35}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}","\u{61}\u{6c}\u{6f}",0x2,0x3,"\u{6a}\u{6f}\u{61}\u{6f}",0xc))
93+tcheck(t,{["\u{6e}"] = 0x1,"\u{61}\u{6c}\u{6f}\u{32}\u{33}\u{6a}\u{6f}\u{61}\u{6f}\u{31}\u{32}"})
94+t=pack(T.testC("\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{32}\u{2c}\u{2d}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}",function (a,b)
95+return 0x1,0x2,0x3,0x4,a,b
96+end,"\u{61}\u{6c}\u{6f}","\u{6a}\u{6f}\u{61}\u{6f}"))
97+tcheck(t,{["\u{6e}"] = 0x6,0x1,0x2,0x3,0x4,"\u{61}\u{6c}\u{6f}","\u{6a}\u{6f}\u{61}\u{6f}"})
98+do
99+local a = {}
100+for i = 0x1, 0x3e8
101+do
102+a[i]=true
103+end
104+;
105+a[0x3e7]=0xa
106+local b = T.testC("\u{70}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{31}\u{20}\u{2d}\u{31}\u{20}\u{30}\u{3b}\u{20}\u{70}\u{6f}\u{70}\u{20}\u{31}\u{3b}\u{20}\u{74}\u{6f}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{2d}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",table.unpack,a)
107+assert((b == "\u{31}\u{30}"))
108+end
109+_G.AA=0xe
110+;
111+_G.BB="\u{61}\u{33}\u{31}"
112+local a = {T.testC("\u{20}\u{20}\u{67}\u{65}\u{74}\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{41}\u{41}\u{3b}\u{a}\u{20}\u{20}\u{67}\u{65}\u{74}\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{42}\u{42}\u{3b}\u{a}\u{20}\u{20}\u{67}\u{65}\u{74}\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{42}\u{42}\u{3b}\u{a}\u{20}\u{20}\u{73}\u{65}\u{74}\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{41}\u{41}\u{3b}\u{a}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}\u{a}")}
113+assert(((((a[0x2] == 0xe) and (a[0x3] == "\u{61}\u{33}\u{31}")) and (a[0x4] == nil)) and (_G.AA == "\u{61}\u{33}\u{31}")))
114+_G.AA,_G.BB=nil
115+assert((T.testC("\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{32}\u{30}\u{3b}\u{20}\u{61}\u{72}\u{69}\u{74}\u{68}\u{20}\u{2f}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}") == 0.5))
116+assert((T.testC("\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{32}\u{30}\u{3b}\u{20}\u{61}\u{72}\u{69}\u{74}\u{68}\u{20}\u{2d}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}") == (- 0xa)))
117+assert((T.testC("\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{2d}\u{32}\u{30}\u{3b}\u{20}\u{61}\u{72}\u{69}\u{74}\u{68}\u{20}\u{2a}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}") == (- 0xc8)))
118+assert((T.testC("\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{33}\u{3b}\u{20}\u{61}\u{72}\u{69}\u{74}\u{68}\u{20}\u{5e}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}") == 0x3e8))
119+assert((T.testC("\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{32}\u{30}\u{3b}\u{20}\u{61}\u{72}\u{69}\u{74}\u{68}\u{20}\u{2f}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}") == 0.5))
120+assert((T.testC("\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{32}\u{30}\u{3b}\u{20}\u{61}\u{72}\u{69}\u{74}\u{68}\u{20}\u{2d}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}") == (- 0xa)))
121+assert((T.testC("\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{2d}\u{32}\u{30}\u{3b}\u{20}\u{61}\u{72}\u{69}\u{74}\u{68}\u{20}\u{2a}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}") == (- 0xc8)))
122+assert((T.testC("\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{33}\u{3b}\u{20}\u{61}\u{72}\u{69}\u{74}\u{68}\u{20}\u{5e}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}") == 0x3e8))
123+assert((T.testC("\u{61}\u{72}\u{69}\u{74}\u{68}\u{20}\u{2f}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",0x2,0x0) == (10.0 / 0x0)))
124+a=T.testC("\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{69}\u{6e}\u{74}\u{20}\u{33}\u{3b}\u{20}\u{61}\u{72}\u{69}\u{74}\u{68}\u{20}\u{5c}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}")
125+assert(((a == 3.0) and (math.type(a) == "\u{66}\u{6c}\u{6f}\u{61}\u{74}")))
126+a=T.testC("\u{70}\u{75}\u{73}\u{68}\u{69}\u{6e}\u{74}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{69}\u{6e}\u{74}\u{20}\u{33}\u{3b}\u{20}\u{61}\u{72}\u{69}\u{74}\u{68}\u{20}\u{5c}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}")
127+assert(((a == 0x3) and (math.type(a) == "\u{69}\u{6e}\u{74}\u{65}\u{67}\u{65}\u{72}")))
128+a=assert(T.testC("\u{70}\u{75}\u{73}\u{68}\u{69}\u{6e}\u{74}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{69}\u{6e}\u{74}\u{20}\u{33}\u{3b}\u{20}\u{61}\u{72}\u{69}\u{74}\u{68}\u{20}\u{2b}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}"))
129+assert(((a == 0xd) and (math.type(a) == "\u{69}\u{6e}\u{74}\u{65}\u{67}\u{65}\u{72}")))
130+a=assert(T.testC("\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{69}\u{6e}\u{74}\u{20}\u{33}\u{3b}\u{20}\u{61}\u{72}\u{69}\u{74}\u{68}\u{20}\u{2b}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}"))
131+assert(((a == 0xd) and (math.type(a) == "\u{66}\u{6c}\u{6f}\u{61}\u{74}")))
132+a,b,c=T.testC("\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{61}\u{72}\u{69}\u{74}\u{68}\u{20}\u{5f}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{35}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{33}")
133+assert(((a == 0x1) and (b == (- (0xa and (c == "\u{35}"))))))
134+local mt = {["\u{5f}\u{5f}\u{61}\u{64}\u{64}"] = function (a,b)
135+return setmetatable({(a[0x1] + b[0x1])},mt)
136+end,["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}"] = function (a,b)
137+return setmetatable({(a[0x1] % b[0x1])},mt)
138+end,["\u{5f}\u{5f}\u{75}\u{6e}\u{6d}"] = function (a)
139+return setmetatable({(a[0x1] * 0x2)},mt)
140+end}
141+a,b,c=setmetatable({0x4},mt),setmetatable({0x8},mt),setmetatable({(- 0x3)},mt)
142+local x,y,z = T.testC("\u{61}\u{72}\u{69}\u{74}\u{68}\u{20}\u{2b}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}",0xa,a,b)
143+assert((((x == 0xa) and (y[0x1] == 0xc)) and (z == nil)))
144+assert((T.testC("\u{61}\u{72}\u{69}\u{74}\u{68}\u{20}\u{25}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",a,c)[0x1] == (0x4 % (- 0x3))))
145+assert((T.testC("\u{61}\u{72}\u{69}\u{74}\u{68}\u{20}\u{5f}\u{3b}\u{20}\u{61}\u{72}\u{69}\u{74}\u{68}\u{20}\u{2b}\u{3b}\u{20}\u{61}\u{72}\u{69}\u{74}\u{68}\u{20}\u{25}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",b,a,c)[0x1] == (0x8 % (0x4 + ((- 0x3) * 0x2)))))
146+checkerr("\u{64}\u{69}\u{76}\u{69}\u{64}\u{65}\u{20}\u{62}\u{79}\u{20}\u{7a}\u{65}\u{72}\u{6f}",T.testC,"\u{61}\u{72}\u{69}\u{74}\u{68}\u{20}\u{5c}",0xa,0x0)
147+checkerr("\u{25}\u{25}\u{30}",T.testC,"\u{61}\u{72}\u{69}\u{74}\u{68}\u{20}\u{25}",0xa,0x0)
148+assert(T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{4c}\u{54}\u{20}\u{32}\u{20}\u{35}\u{2c}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",0x3,0x2,0x2,0x4,0x2,0x2))
149+assert(T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{4c}\u{45}\u{20}\u{32}\u{20}\u{35}\u{2c}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",0x3,0x2,0x2,0x4,0x2,0x2))
150+assert((not T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{4c}\u{54}\u{20}\u{33}\u{20}\u{34}\u{2c}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",0x3,0x2,0x2,0x4,0x2,0x2)))
151+assert(T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{4c}\u{45}\u{20}\u{33}\u{20}\u{34}\u{2c}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",0x3,0x2,0x2,0x4,0x2,0x2))
152+assert(T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{4c}\u{54}\u{20}\u{35}\u{20}\u{32}\u{2c}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",0x4,0x2,0x2,0x3,0x2,0x2))
153+assert((not T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{4c}\u{54}\u{20}\u{32}\u{20}\u{2d}\u{33}\u{2c}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}","\u{34}","\u{32}","\u{32}","\u{33}","\u{32}","\u{32}")))
154+assert((not T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{4c}\u{54}\u{20}\u{2d}\u{33}\u{20}\u{32}\u{2c}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}","\u{33}","\u{32}","\u{32}","\u{34}","\u{32}","\u{32}")))
155+assert((not T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{4c}\u{54}\u{20}\u{31}\u{20}\u{34}\u{2c}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}")))
156+assert((not T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{4c}\u{45}\u{20}\u{39}\u{20}\u{31}\u{2c}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}")))
157+assert((not T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{45}\u{51}\u{20}\u{39}\u{20}\u{39}\u{2c}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}")))
158+local b = {["\u{5f}\u{5f}\u{6c}\u{74}"] = function (a,b)
159+return (a[0x1] < b[0x1])
160+end}
161+local a1,a3,a4 = setmetatable({0x1},b),setmetatable({0x3},b),setmetatable({0x4},b)
162+assert(T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{4c}\u{54}\u{20}\u{32}\u{20}\u{35}\u{2c}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",a3,0x2,0x2,a4,0x2,0x2))
163+assert(T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{4c}\u{45}\u{20}\u{32}\u{20}\u{35}\u{2c}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",a3,0x2,0x2,a4,0x2,0x2))
164+assert(T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{4c}\u{54}\u{20}\u{35}\u{20}\u{2d}\u{36}\u{2c}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",a4,0x2,0x2,a3,0x2,0x2))
165+a,b=T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{4c}\u{54}\u{20}\u{35}\u{20}\u{2d}\u{36}\u{2c}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}",a1,0x2,0x2,a3,0x2,0x14)
166+assert(((a == 0x14) and (b == false)))
167+a,b=T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{4c}\u{45}\u{20}\u{35}\u{20}\u{2d}\u{36}\u{2c}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}",a1,0x2,0x2,a3,0x2,0x14)
168+assert(((a == 0x14) and (b == false)))
169+a,b=T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{4c}\u{45}\u{20}\u{35}\u{20}\u{2d}\u{36}\u{2c}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}",a1,0x2,0x2,a1,0x2,0x14)
170+assert(((a == 0x14) and (b == true)))
171+do
172+local mt = {["\u{5f}\u{5f}\u{6c}\u{74}"] = function (a,b)
173+return (a[0x1] < b[0x1])
174+end,["\u{5f}\u{5f}\u{6c}\u{65}"] = function (a,b)
175+return (a[0x1] <= b[0x1])
176+end,["\u{5f}\u{5f}\u{65}\u{71}"] = function (a,b)
177+return (a[0x1] == b[0x1])
178+end}
179+local function O
180+(x)
181+return setmetatable({x},mt)
182+end
183+local a,b = T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{4c}\u{54}\u{20}\u{32}\u{20}\u{33}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{69}\u{6e}\u{74}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}",O(0x1),O(0x2))
184+assert(((a == true) and (b == 0xa)))
185+local a,b = T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{4c}\u{45}\u{20}\u{32}\u{20}\u{33}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{69}\u{6e}\u{74}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}",O(0x3),O(0x2))
186+assert(((a == false) and (b == 0xa)))
187+local a,b = T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{45}\u{51}\u{20}\u{32}\u{20}\u{33}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{69}\u{6e}\u{74}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}",O(0x3),O(0x3))
188+assert(((a == true) and (b == 0xa)))
189+end
190+local t = setmetatable({["\u{78}"] = 0x14},{["\u{5f}\u{5f}\u{6c}\u{65}\u{6e}"] = function (t)
191+return t.x
192+end})
193+a,b,c=T.testC("\u{20}\u{20}\u{20}\u{6c}\u{65}\u{6e}\u{20}\u{32}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{4c}\u{6c}\u{65}\u{6e}\u{20}\u{32}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{6f}\u{62}\u{6a}\u{73}\u{69}\u{7a}\u{65}\u{20}\u{32}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{33}\u{a}",t)
194+assert((((a == 0x14) and (b == 0x14)) and (c == 0x0)))
195+t.x="\u{32}\u{33}\u{34}"
196+;
197+t[0x1]=0x14
198+a,b,c=T.testC("\u{20}\u{20}\u{20}\u{6c}\u{65}\u{6e}\u{20}\u{32}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{4c}\u{6c}\u{65}\u{6e}\u{20}\u{32}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{6f}\u{62}\u{6a}\u{73}\u{69}\u{7a}\u{65}\u{20}\u{32}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{33}\u{a}",t)
199+assert((((a == "\u{32}\u{33}\u{34}") and (b == 0xea)) and (c == 0x1)))
200+t.x=print
201+;
202+t[0x1]=0x14
203+a,c=T.testC("\u{20}\u{20}\u{20}\u{6c}\u{65}\u{6e}\u{20}\u{32}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{6f}\u{62}\u{6a}\u{73}\u{69}\u{7a}\u{65}\u{20}\u{32}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}\u{a}",t)
204+assert(((a == print) and (c == 0x1)))
205+a=setmetatable({["\u{78}"] = "\u{75}"},{["\u{5f}\u{5f}\u{63}\u{6f}\u{6e}\u{63}\u{61}\u{74}"] = function (a,b)
206+return (a.x .. ("\u{2e}" .. b.x))
207+end})
208+x,y=T.testC("\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{35}\u{a}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{32}\u{3b}\u{a}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{32}\u{3b}\u{a}\u{20}\u{20}\u{63}\u{6f}\u{6e}\u{63}\u{61}\u{74}\u{20}\u{32}\u{3b}\u{a}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{2d}\u{32}\u{3b}\u{a}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}\u{3b}\u{a}",a,a)
209+assert(((x == (a .. a)) and (y == 0x5)))
210+assert((T.testC("\u{63}\u{6f}\u{6e}\u{63}\u{61}\u{74}\u{20}\u{30}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}") == ""))
211+assert((T.testC("\u{63}\u{6f}\u{6e}\u{63}\u{61}\u{74}\u{20}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}","\u{78}\u{75}\u{78}\u{75}") == "\u{78}\u{75}\u{78}\u{75}"))
212+local function B
213+(x)
214+return ((x and 0x1) or 0x0)
215+end
216+local function count
217+(x,n)
218+n=(n or 0x2)
219+local prog = "\u{20}\u{20}\u{20}\u{20}\u{69}\u{73}\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}\u{20}\u{25}\u{64}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{69}\u{73}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{25}\u{64}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{69}\u{73}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{25}\u{64}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{69}\u{73}\u{63}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{25}\u{64}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{69}\u{73}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{25}\u{64}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{69}\u{73}\u{75}\u{73}\u{65}\u{72}\u{64}\u{61}\u{74}\u{61}\u{20}\u{25}\u{64}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{69}\u{73}\u{6e}\u{69}\u{6c}\u{20}\u{25}\u{64}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{69}\u{73}\u{6e}\u{75}\u{6c}\u{6c}\u{20}\u{25}\u{64}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{38}\u{a}\u{20}\u{20}"
220+prog=string.format(prog,n,n,n,n,n,n,n,n)
221+local a,b,c,d,e,f,g,h = T.testC(prog,x)
222+return (((((((B(a) + B(b)) + B(c)) + B(d)) + B(e)) + B(f)) + B(g)) + (0x64 * B(h)))
223+end
224+assert((count(0x3) == 0x2))
225+assert((count("\u{61}\u{6c}\u{6f}") == 0x1))
226+assert((count("\u{33}\u{32}") == 0x2))
227+assert((count({}) == 0x1))
228+assert((count(print) == 0x2))
229+assert((count(function ()
230+
231+end) == 0x1))
232+assert((count(nil) == 0x1))
233+assert((count(io.stdin) == 0x1))
234+assert((count(nil,0xf) == 0x64))
235+local function to
236+(s,x,n)
237+n=(n or 0x2)
238+return T.testC(string.format("\u{25}\u{73}\u{20}\u{25}\u{64}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",s,n),x)
239+end
240+local null = T.pushuserdata(0x0)
241+local hfunc = string.gmatch("","")
242+assert(debug.getupvalue(hfunc,0x1))
243+assert((to("\u{74}\u{6f}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}",{}) == nil))
244+assert((to("\u{74}\u{6f}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}","\u{61}\u{6c}\u{6f}") == "\u{61}\u{6c}\u{6f}"))
245+assert((to("\u{74}\u{6f}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}",0xc) == "\u{31}\u{32}"))
246+assert((to("\u{74}\u{6f}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}",0xc,0x3) == nil))
247+assert((to("\u{6f}\u{62}\u{6a}\u{73}\u{69}\u{7a}\u{65}",{}) == 0x0))
248+assert((to("\u{6f}\u{62}\u{6a}\u{73}\u{69}\u{7a}\u{65}",{0x1,0x2,0x3}) == 0x3))
249+assert((to("\u{6f}\u{62}\u{6a}\u{73}\u{69}\u{7a}\u{65}","\u{61}\u{6c}\u{6f}\u{0}\u{0}\u{61}") == 0x6))
250+assert((to("\u{6f}\u{62}\u{6a}\u{73}\u{69}\u{7a}\u{65}",T.newuserdata(0x0)) == 0x0))
251+assert((to("\u{6f}\u{62}\u{6a}\u{73}\u{69}\u{7a}\u{65}",T.newuserdata(0x65)) == 0x65))
252+assert((to("\u{6f}\u{62}\u{6a}\u{73}\u{69}\u{7a}\u{65}",0x7c) == 0x0))
253+assert((to("\u{6f}\u{62}\u{6a}\u{73}\u{69}\u{7a}\u{65}",true) == 0x0))
254+assert((to("\u{74}\u{6f}\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}",{}) == 0x0))
255+assert((to("\u{74}\u{6f}\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}","\u{31}\u{32}") == 0xc))
256+assert((to("\u{74}\u{6f}\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}","\u{73}\u{32}") == 0x0))
257+assert((to("\u{74}\u{6f}\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}",0x1,0x14) == 0x0))
258+assert((to("\u{74}\u{6f}\u{70}\u{6f}\u{69}\u{6e}\u{74}\u{65}\u{72}",0xa) == null))
259+assert((to("\u{74}\u{6f}\u{70}\u{6f}\u{69}\u{6e}\u{74}\u{65}\u{72}",true) == null))
260+assert((to("\u{74}\u{6f}\u{70}\u{6f}\u{69}\u{6e}\u{74}\u{65}\u{72}",nil) == null))
261+assert((to("\u{74}\u{6f}\u{70}\u{6f}\u{69}\u{6e}\u{74}\u{65}\u{72}","\u{61}\u{62}\u{63}") ~= null))
262+assert((to("\u{74}\u{6f}\u{70}\u{6f}\u{69}\u{6e}\u{74}\u{65}\u{72}",string.rep("\u{78}",0xa)) == to("\u{74}\u{6f}\u{70}\u{6f}\u{69}\u{6e}\u{74}\u{65}\u{72}",string.rep("\u{78}",0xa))))
263+do
264+local s1 = string.rep("\u{78}",0x12c)
265+local s2 = string.rep("\u{78}",0x12c)
266+assert((to("\u{74}\u{6f}\u{70}\u{6f}\u{69}\u{6e}\u{74}\u{65}\u{72}",s1) ~= to("\u{74}\u{6f}\u{70}\u{6f}\u{69}\u{6e}\u{74}\u{65}\u{72}",s2)))
267+end
268+assert((to("\u{74}\u{6f}\u{70}\u{6f}\u{69}\u{6e}\u{74}\u{65}\u{72}",T.pushuserdata(0x14)) ~= null))
269+assert((to("\u{74}\u{6f}\u{70}\u{6f}\u{69}\u{6e}\u{74}\u{65}\u{72}",io.read) ~= null))
270+assert((to("\u{74}\u{6f}\u{70}\u{6f}\u{69}\u{6e}\u{74}\u{65}\u{72}",hfunc) ~= null))
271+assert((to("\u{74}\u{6f}\u{70}\u{6f}\u{69}\u{6e}\u{74}\u{65}\u{72}",function ()
272+
273+end) ~= null))
274+assert((to("\u{74}\u{6f}\u{70}\u{6f}\u{69}\u{6e}\u{74}\u{65}\u{72}",io.stdin) ~= null))
275+assert((to("\u{66}\u{75}\u{6e}\u{63}\u{32}\u{6e}\u{75}\u{6d}",0x14) == 0x0))
276+assert((to("\u{66}\u{75}\u{6e}\u{63}\u{32}\u{6e}\u{75}\u{6d}",T.pushuserdata(0xa)) == 0x0))
277+assert((to("\u{66}\u{75}\u{6e}\u{63}\u{32}\u{6e}\u{75}\u{6d}",io.read) ~= 0x0))
278+assert((to("\u{66}\u{75}\u{6e}\u{63}\u{32}\u{6e}\u{75}\u{6d}",hfunc) ~= 0x0))
279+a=to("\u{74}\u{6f}\u{63}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}",math.deg)
280+assert(((a(0x3) == math.deg(0x3)) and (a == math.deg)))
281+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{70}\u{61}\u{6e}\u{69}\u{63}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}")
282+do
283+assert((T.checkpanic("\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{68}\u{69}\u{3b}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}") == "\u{68}\u{69}"))
284+assert((T.checkpanic("\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{68}\u{69}\u{3b}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{3b}","\u{63}\u{68}\u{65}\u{63}\u{6b}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{35}\u{20}\u{58}\u{58}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{27}\u{20}\u{61}\u{6c}\u{6f}\u{27}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{27}\u{20}\u{6d}\u{75}\u{6e}\u{64}\u{6f}\u{27}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{63}\u{6f}\u{6e}\u{63}\u{61}\u{74}\u{20}\u{33}") == "\u{68}\u{69}\u{20}\u{61}\u{6c}\u{6f}\u{20}\u{6d}\u{75}\u{6e}\u{64}\u{6f}"))
285+assert((T.checkpanic("\u{6c}\u{6f}\u{61}\u{64}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{34}") == "\u{62}\u{61}\u{64}\u{20}\u{61}\u{72}\u{67}\u{75}\u{6d}\u{65}\u{6e}\u{74}\u{20}\u{23}\u{34}\u{20}\u{28}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}\u{2c}\u{20}\u{67}\u{6f}\u{74}\u{20}\u{6e}\u{6f}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{29}"))
286+T.totalmem((T.totalmem() + 0x2710))
287+assert((T.checkpanic("\u{6e}\u{65}\u{77}\u{75}\u{73}\u{65}\u{72}\u{64}\u{61}\u{74}\u{61}\u{20}\u{32}\u{30}\u{30}\u{30}\u{30}") == MEMERRMSG))
288+T.totalmem(0x0)
289+if (not _soft) then
290+local msg = T.checkpanic("\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{22}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{66}\u{28}\u{29}\u{20}\u{66}\u{28}\u{29}\u{20}\u{65}\u{6e}\u{64}\u{22}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{6c}\u{6f}\u{61}\u{64}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{2d}\u{31}\u{3b}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{30}\u{20}\u{30}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{67}\u{65}\u{74}\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{66}\u{3b}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{30}\u{20}\u{30}\u{a}\u{20}\u{20}\u{20}\u{20}")
291+assert(string.find(msg,"\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}"))
292+end
293+assert((T.checkpanic("\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{22}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{7b}\u{5f}\u{5f}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{20}\u{3d}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{28}\u{29}\u{20}\u{59}\u{20}\u{3d}\u{20}\u{27}\u{68}\u{6f}\u{27}\u{3b}\u{20}\u{65}\u{6e}\u{64}\u{7d}\u{22}\u{a}\u{20}\u{20}\u{20}\u{20}\u{6e}\u{65}\u{77}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{a}\u{20}\u{20}\u{20}\u{20}\u{6c}\u{6f}\u{61}\u{64}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{2d}\u{32}\u{a}\u{20}\u{20}\u{20}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{30}\u{20}\u{31}\u{a}\u{20}\u{20}\u{20}\u{20}\u{73}\u{65}\u{74}\u{6d}\u{65}\u{74}\u{61}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{2d}\u{32}\u{a}\u{20}\u{20}\u{20}\u{20}\u{74}\u{6f}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{20}\u{2d}\u{31}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{22}\u{68}\u{69}\u{22}\u{a}\u{20}\u{20}\u{20}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{a}\u{20}\u{20}","\u{20}\u{20}\u{20}\u{20}\u{67}\u{65}\u{74}\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{59}\u{a}\u{20}\u{20}\u{20}\u{20}\u{63}\u{6f}\u{6e}\u{63}\u{61}\u{74}\u{20}\u{32}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{63}\u{6f}\u{6e}\u{63}\u{61}\u{74}\u{20}\u{6f}\u{72}\u{69}\u{67}\u{69}\u{6e}\u{61}\u{6c}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{20}\u{77}\u{69}\u{74}\u{68}\u{20}\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{59}\u{a}\u{20}\u{20}") == "\u{68}\u{69}\u{68}\u{6f}"))
294+end
295+if (not _soft) then
296+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}")
297+collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
298+checkerr("\u{58}\u{58}\u{58}\u{58}",T.testC,"\u{63}\u{68}\u{65}\u{63}\u{6b}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{31}\u{30}\u{30}\u{30}\u{30}\u{32}\u{33}\u{20}\u{58}\u{58}\u{58}\u{58}")
299+checkerr("\u{5e}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}\u{24}",T.testC,"\u{63}\u{68}\u{65}\u{63}\u{6b}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{31}\u{30}\u{30}\u{30}\u{30}\u{32}\u{33}\u{20}\u{27}\u{27}")
300+local s = string.rep("\u{70}\u{75}\u{73}\u{68}\u{6e}\u{69}\u{6c}\u{3b}\u{63}\u{68}\u{65}\u{63}\u{6b}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{31}\u{20}\u{58}\u{58}\u{3b}",0xf4240)
301+checkerr("\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}",T.testC,s)
302+collectgarbage("\u{72}\u{65}\u{73}\u{74}\u{61}\u{72}\u{74}")
303+print("\u{2b}")
304+end
305+local lim = ((_soft and 0x1f4) or 0x2ee0)
306+local prog = {("\u{63}\u{68}\u{65}\u{63}\u{6b}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}" .. (((lim * 0x2) + 0x64) .. "\u{6d}\u{73}\u{67}")),"\u{6e}\u{65}\u{77}\u{74}\u{61}\u{62}\u{6c}\u{65}"}
307+for i = 0x1, lim
308+do
309+prog[(# (prog + 0x1))]=("\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}" .. i)
310+prog[(# (prog + 0x1))]=("\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}" .. (i * 0xa))
311+end
312+prog[(# (prog + 0x1))]="\u{72}\u{61}\u{77}\u{67}\u{65}\u{74}\u{69}\u{20}\u{52}\u{20}\u{32}"
313+prog[(# (prog + 0x1))]=("\u{69}\u{6e}\u{73}\u{65}\u{72}\u{74}\u{20}" .. (- ((0x2 * lim) + 0x2)))
314+for i = 0x1, lim
315+do
316+prog[(# (prog + 0x1))]=("\u{73}\u{65}\u{74}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}" .. (- ((0x2 * ((lim - i) + 0x1)) + 0x1)))
317+end
318+prog[(# (prog + 0x1))]="\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}"
319+prog=table.concat(prog,"\u{3b}")
320+local g,t = T.testC(prog)
321+assert((g == _G))
322+for i = 0x1, lim
323+do
324+assert((t[i] == (i * 0xa)))
325+;
326+t[i]=undef
327+end
328+assert((next(t) == nil))
329+prog,g,t=nil
330+a=T.testC("\u{20}\u{20}\u{6c}\u{6f}\u{61}\u{64}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{32}\u{3b}\u{20}\u{70}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{30}\u{20}\u{31}\u{20}\u{30}\u{3b}\u{a}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{33}\u{3b}\u{20}\u{69}\u{6e}\u{73}\u{65}\u{72}\u{74}\u{20}\u{2d}\u{32}\u{3b}\u{20}\u{70}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{31}\u{20}\u{31}\u{20}\u{30}\u{3b}\u{a}\u{20}\u{20}\u{70}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{30}\u{20}\u{30}\u{20}\u{30}\u{3b}\u{a}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}\u{a}","\u{58}\u{58}\u{3d}\u{31}\u{35}\u{30}",function (a)
331+assert((a == nil))
332+;
333+return 0x3
334+end)
335+assert(((type(a) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}") and (XX == 0x96)))
336+_G.XX=nil
337+local function check3
338+(p, ...)
339+local arg = {...}
340+assert((# (arg == 0x3)))
341+assert(string.find(arg[0x3],p))
342+end
343+check3("\u{3a}\u{31}\u{3a}",T.testC("\u{6c}\u{6f}\u{61}\u{64}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{32}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}","\u{78}\u{3d}"))
344+check3("\u{25}\u{2e}",T.testC("\u{6c}\u{6f}\u{61}\u{64}\u{66}\u{69}\u{6c}\u{65}\u{20}\u{32}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}","\u{2e}"))
345+check3("\u{78}\u{78}\u{78}\u{78}",T.testC("\u{6c}\u{6f}\u{61}\u{64}\u{66}\u{69}\u{6c}\u{65}\u{20}\u{32}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}","\u{78}\u{78}\u{78}\u{78}"))
346+local function checkerrnopro
347+(code,msg)
348+local th = coroutine.create(function ()
349+
350+end)
351+local stt,err = pcall(T.testC,th,code)
352+assert((not (stt and string.find(err,msg))))
353+end
354+if (not _soft) then
355+collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
356+checkerrnopro("\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{33}\u{3b}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{30}\u{20}\u{30}","\u{61}\u{74}\u{74}\u{65}\u{6d}\u{70}\u{74}\u{20}\u{74}\u{6f}\u{20}\u{63}\u{61}\u{6c}\u{6c}")
357+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}\u{20}\u{69}\u{6e}\u{20}\u{75}\u{6e}\u{70}\u{72}\u{6f}\u{74}\u{65}\u{63}\u{74}\u{65}\u{64}\u{20}\u{74}\u{68}\u{72}\u{65}\u{61}\u{64}")
358+function F()
359+F()
360+end
361+checkerrnopro("\u{67}\u{65}\u{74}\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{27}\u{46}\u{27}\u{3b}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{30}\u{20}\u{30}\u{3b}","\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}")
362+F=nil
363+collectgarbage("\u{72}\u{65}\u{73}\u{74}\u{61}\u{72}\u{74}")
364+end
365+print("\u{2b}")
366+do
367+local a = {}
368+local a1 = T.testC("\u{72}\u{61}\u{77}\u{73}\u{65}\u{74}\u{70}\u{20}\u{32}\u{20}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",a,0x14)
369+assert((a == a1))
370+assert((a[T.pushuserdata(0x1)] == 0x14))
371+local a1,res = T.testC("\u{72}\u{61}\u{77}\u{67}\u{65}\u{74}\u{70}\u{20}\u{2d}\u{31}\u{20}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}",a)
372+assert(((a == a1) and (res == 0x14)))
373+end
374+do
375+local a = {}
376+a[a]=0xa
377+local prog = "\u{67}\u{65}\u{74}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{2d}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}"
378+local res = {T.testC(prog,a)}
379+assert((# (((res == 0x2) and (res[0x1] == prog)) and (res[0x2] == 0xa))))
380+local prog = "\u{73}\u{65}\u{74}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{2d}\u{32}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}"
381+local res = {T.testC(prog,a,0x14)}
382+assert((a[a] == 0x14))
383+assert((# ((res == 0x1) and (res[0x1] == prog))))
384+a[a]=0xa
385+local prog = "\u{72}\u{61}\u{77}\u{67}\u{65}\u{74}\u{20}\u{2d}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}"
386+local res = {T.testC(prog,a)}
387+assert((# (((res == 0x2) and (res[0x1] == prog)) and (res[0x2] == 0xa))))
388+local prog = "\u{72}\u{61}\u{77}\u{73}\u{65}\u{74}\u{20}\u{2d}\u{32}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}"
389+local res = {T.testC(prog,a,0x14)}
390+assert((a[a] == 0x14))
391+assert((# ((res == 0x1) and (res[0x1] == prog))))
392+local prog = "\u{72}\u{61}\u{77}\u{73}\u{65}\u{74}\u{20}\u{2d}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}"
393+local res = {T.testC(prog,0x1e,a)}
394+assert((a[0x1e] == a))
395+assert((# ((res == 0x1) and (res[0x1] == prog))))
396+local prog = "\u{73}\u{65}\u{74}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{2d}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}"
397+local res = {T.testC(prog,0x28,a)}
398+assert((a[0x28] == a))
399+assert((# ((res == 0x1) and (res[0x1] == prog))))
400+local prog = "\u{72}\u{61}\u{77}\u{73}\u{65}\u{74}\u{69}\u{20}\u{2d}\u{31}\u{20}\u{31}\u{30}\u{30}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}"
401+local res = {T.testC(prog,a)}
402+assert((a[0x64] == a))
403+assert((# ((res == 0x1) and (res[0x1] == prog))))
404+local prog = "\u{73}\u{65}\u{74}\u{69}\u{20}\u{2d}\u{31}\u{20}\u{32}\u{30}\u{30}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}"
405+local res = {T.testC(prog,a)}
406+assert((a[0xc8] == a))
407+assert((# ((res == 0x1) and (res[0x1] == prog))))
408+end
409+a={["\u{78}"] = 0x0,["\u{79}"] = 0xc}
410+x,y=T.testC("\u{67}\u{65}\u{74}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{32}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{34}\u{3b}\u{20}\u{67}\u{65}\u{74}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{32}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}",a,0x3,"\u{79}",0x4,"\u{78}")
411+assert(((x == 0x0) and (y == 0xc)))
412+T.testC("\u{73}\u{65}\u{74}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{2d}\u{35}",a,0x3,0x4,"\u{78}",0xf)
413+assert((a.x == 0xf))
414+a[a]=print
415+x=T.testC("\u{67}\u{65}\u{74}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{32}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",a)
416+assert((x == print))
417+T.testC("\u{73}\u{65}\u{74}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{32}",a,"\u{78}")
418+assert((a[a] == "\u{78}"))
419+b=setmetatable({["\u{70}"] = a},{})
420+getmetatable(b).__index=function (t,i)
421+return t.p[i]
422+end
423+local k,x = T.testC("\u{67}\u{65}\u{74}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{33}\u{2c}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}",0x4,b,0x14,0x23,"\u{78}")
424+assert(((x == 0xf) and (k == 0x23)))
425+k=T.testC("\u{67}\u{65}\u{74}\u{66}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{32}\u{20}\u{79}\u{2c}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",b)
426+assert((k == 0xc))
427+getmetatable(b).__index=function (t,i)
428+return a[i]
429+end
430+getmetatable(b).__newindex=function (t,i,v)
431+a[i]=v
432+end
433+y=T.testC("\u{69}\u{6e}\u{73}\u{65}\u{72}\u{74}\u{20}\u{32}\u{3b}\u{20}\u{67}\u{65}\u{74}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{2d}\u{35}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",0x2,0x3,0x4,"\u{79}",b)
434+assert((y == 0xc))
435+k=T.testC("\u{73}\u{65}\u{74}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{2d}\u{35}\u{2c}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",b,0x3,0x4,"\u{78}",0x10)
436+assert(((a.x == 0x10) and (k == 0x4)))
437+a[b]="\u{78}\u{75}\u{78}\u{75}"
438+y=T.testC("\u{67}\u{65}\u{74}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{32}\u{2c}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",b)
439+assert((y == "\u{78}\u{75}\u{78}\u{75}"))
440+T.testC("\u{73}\u{65}\u{74}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{32}",b,0x13)
441+assert((a[b] == 0x13))
442+do
443+local t = {["\u{5f}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}"] = 0x20}
444+local a = T.testC("\u{20}\u{20}\u{20}\u{20}\u{67}\u{65}\u{74}\u{66}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{32}\u{20}\u{5f}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}\u{a}\u{20}\u{20}",t)
445+assert((a == 0x20))
446+local a = T.testC("\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{33}\u{33}\u{a}\u{20}\u{20}\u{20}\u{20}\u{73}\u{65}\u{74}\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{5f}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}\u{20}\u{20}")
447+assert((_012345678901234567890123456789012345678901234567890123456789 == 0x21))
448+_012345678901234567890123456789012345678901234567890123456789=nil
449+end
450+a={}
451+t=pack(T.testC("\u{6e}\u{65}\u{78}\u{74}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}",a,nil))
452+tcheck(t,{["\u{6e}"] = 0x1,a})
453+a={["\u{61}"] = 0x3}
454+t=pack(T.testC("\u{6e}\u{65}\u{78}\u{74}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}",a,nil))
455+tcheck(t,{["\u{6e}"] = 0x3,a,"\u{61}",0x3})
456+t=pack(T.testC("\u{6e}\u{65}\u{78}\u{74}\u{3b}\u{20}\u{70}\u{6f}\u{70}\u{20}\u{31}\u{3b}\u{20}\u{6e}\u{65}\u{78}\u{74}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}",a,nil))
457+tcheck(t,{["\u{6e}"] = 0x1,a})
458+do
459+local A = T.testC("\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{32}\u{30}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{63}\u{63}\u{6c}\u{6f}\u{73}\u{75}\u{72}\u{65}\u{20}\u{32}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}")
460+t,b,c=A("\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{55}\u{30}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{55}\u{31}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{55}\u{32}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{33}")
461+assert((((b == 0xa) and (c == 0x14)) and (type(t) == "\u{74}\u{61}\u{62}\u{6c}\u{65}")))
462+a,b=A("\u{74}\u{6f}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{55}\u{33}\u{3b}\u{20}\u{74}\u{6f}\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}\u{20}\u{55}\u{34}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}")
463+assert(((a == nil) and (b == 0x0)))
464+A("\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{30}\u{30}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{32}\u{30}\u{30}\u{3b}\u{20}\u{72}\u{65}\u{70}\u{6c}\u{61}\u{63}\u{65}\u{20}\u{55}\u{32}\u{3b}\u{20}\u{72}\u{65}\u{70}\u{6c}\u{61}\u{63}\u{65}\u{20}\u{55}\u{31}")
465+b,c=A("\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{55}\u{31}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{55}\u{32}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}")
466+assert(((b == 0x64) and (c == 0xc8)))
467+A("\u{72}\u{65}\u{70}\u{6c}\u{61}\u{63}\u{65}\u{20}\u{55}\u{32}\u{3b}\u{20}\u{72}\u{65}\u{70}\u{6c}\u{61}\u{63}\u{65}\u{20}\u{55}\u{31}",{["\u{78}"] = 0x1},{["\u{78}"] = 0x2})
468+b,c=A("\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{55}\u{31}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{55}\u{32}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}")
469+assert(((b.x == 0x1) and (c.x == 0x2)))
470+T.checkmemory()
471+end
472+assert((T.testC("\u{69}\u{73}\u{6e}\u{75}\u{6c}\u{6c}\u{20}\u{55}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}") == true))
473+assert((T.testC("\u{69}\u{73}\u{6e}\u{75}\u{6c}\u{6c}\u{20}\u{55}\u{31}\u{30}\u{30}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}") == true))
474+assert((T.testC("\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{55}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}") == nil))
475+local f = T.testC("\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{32}\u{30}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{63}\u{63}\u{6c}\u{6f}\u{73}\u{75}\u{72}\u{65}\u{20}\u{32}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}")
476+assert((((T.upvalue(f,0x1) == 0xa) and (T.upvalue(f,0x2) == 0x14)) and (T.upvalue(f,0x3) == nil)))
477+T.upvalue(f,0x2,"\u{78}\u{75}\u{78}\u{75}")
478+assert((T.upvalue(f,0x2) == "\u{78}\u{75}\u{78}\u{75}"))
479+do
480+local A = ("\u{63}\u{68}\u{65}\u{63}\u{6b}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{33}\u{30}\u{30}\u{20}\u{6d}\u{73}\u{67}\u{3b}" .. (string.rep("\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{30}\u{3b}",0xff) .. "\u{70}\u{75}\u{73}\u{68}\u{63}\u{63}\u{6c}\u{6f}\u{73}\u{75}\u{72}\u{65}\u{20}\u{32}\u{35}\u{35}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}"))
481+A=T.testC(A)
482+for i = 0x1, 0xff
483+do
484+assert((A(("\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{55}\u{25}\u{64}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}"):format(i)) == 0xa))
485+end
486+assert(A("\u{69}\u{73}\u{6e}\u{75}\u{6c}\u{6c}\u{20}\u{55}\u{32}\u{35}\u{36}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}"))
487+assert((not A("\u{69}\u{73}\u{6e}\u{69}\u{6c}\u{20}\u{55}\u{32}\u{35}\u{36}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}")))
488+end
489+checkerr("\u{67}\u{6f}\u{74}\u{20}\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}",debug.setuservalue,0x3,{})
490+checkerr("\u{67}\u{6f}\u{74}\u{20}\u{6e}\u{69}\u{6c}",debug.setuservalue,nil,{})
491+checkerr("\u{67}\u{6f}\u{74}\u{20}\u{6c}\u{69}\u{67}\u{68}\u{74}\u{20}\u{75}\u{73}\u{65}\u{72}\u{64}\u{61}\u{74}\u{61}",debug.setuservalue,T.pushuserdata(0x1),{})
492+local b = T.newuserdata(0x0,0xa)
493+for i = 0x1, 0xa
494+do
495+local v,p = debug.getuservalue(b,i)
496+assert(((v == nil) and p))
497+end
498+do
499+local v,p = debug.getuservalue(b,(- 0x2))
500+assert(((v == nil) and (not p)))
501+local v,p = debug.getuservalue(b,0xb)
502+assert(((v == nil) and (not p)))
503+end
504+local t = {true,false,4.56,print,{},b,"\u{58}\u{59}\u{5a}"}
505+for k,v in ipairs(t)
506+do
507+debug.setuservalue(b,v,k)
508+end
509+for k,v in ipairs(t)
510+do
511+local v1,p = debug.getuservalue(b,k)
512+assert(((v1 == v) and p))
513+end
514+assert((not debug.getuservalue(0x4)))
515+debug.setuservalue(b,function ()
516+return 0xa
517+end,0xa)
518+collectgarbage()
519+assert((debug.getuservalue(b,0xa)() == 0xa))
520+debug.setuservalue(b,0x86)
521+collectgarbage()
522+assert((debug.getuservalue(b) == 0x86))
523+do
524+local oldmode = collectgarbage("\u{69}\u{6e}\u{63}\u{72}\u{65}\u{6d}\u{65}\u{6e}\u{74}\u{61}\u{6c}")
525+T.gcstate("\u{61}\u{74}\u{6f}\u{6d}\u{69}\u{63}")
526+assert((T.gccolor(b) == "\u{62}\u{6c}\u{61}\u{63}\u{6b}"))
527+debug.setuservalue(b,{["\u{78}"] = 0x64})
528+T.gcstate("\u{70}\u{61}\u{75}\u{73}\u{65}")
529+assert((debug.getuservalue(b).x == 0x64))
530+collectgarbage(oldmode)
531+end
532+for i = 0x1, 0x3e8
533+do
534+local bb = T.newuserdata(0x0,0x1)
535+debug.setuservalue(bb,b)
536+b=bb
537+end
538+collectgarbage()
539+for i = 0x1, 0x3e8
540+do
541+b=debug.getuservalue(b)
542+end
543+assert((debug.getuservalue(b).x == 0x64))
544+b=nil
545+local i = T.ref({})
546+T.unref(i)
547+assert((T.ref({}) == i))
548+local Arr = {}
549+local Lim = 0x64
550+for i = 0x1, Lim
551+do
552+Arr[i]=T.ref({})
553+end
554+assert((T.ref(nil) == (- (0x1 and (T.getref((- 0x1)) == nil)))))
555+T.unref((- 0x1))
556+;
557+T.unref((- 0x1))
558+for i = 0x1, Lim
559+do
560+T.unref(Arr[i])
561+end
562+local function printlocks
563+()
564+local f = T.makeCfunc("\u{67}\u{65}\u{74}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{52}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}")
565+local n = f("\u{6e}")
566+print("\u{6e}",n)
567+for i = 0x0, n
568+do
569+print(i,f(i))
570+end
571+end
572+for i = 0x1, Lim
573+do
574+Arr[i]=T.ref({})
575+end
576+for i = 0x1, Lim, 0x2
577+do
578+T.unref(Arr[i])
579+end
580+assert((type(T.getref(Arr[0x2])) == "\u{74}\u{61}\u{62}\u{6c}\u{65}"))
581+assert((T.getref((- 0x1)) == nil))
582+a=T.ref({})
583+collectgarbage()
584+assert((type(T.getref(a)) == "\u{74}\u{61}\u{62}\u{6c}\u{65}"))
585+local tt = {}
586+local cl = {["\u{6e}"] = 0x0}
587+A=nil
588+;
589+B=nil
590+local F
591+F=function (x)
592+local udval = T.udataval(x)
593+table.insert(cl,udval)
594+local d = T.newuserdata(0x64)
595+d=nil
596+assert((debug.getmetatable(x).__gc == F))
597+assert(load("\u{74}\u{61}\u{62}\u{6c}\u{65}\u{2e}\u{69}\u{6e}\u{73}\u{65}\u{72}\u{74}\u{28}\u{7b}\u{7d}\u{2c}\u{20}\u{7b}\u{7d}\u{29}"))()
598+assert((not collectgarbage()))
599+local dummy = {}
600+if (A ~= nil) then
601+assert((type(A) == "\u{75}\u{73}\u{65}\u{72}\u{64}\u{61}\u{74}\u{61}"))
602+assert((T.udataval(A) == B))
603+debug.getmetatable(A)
604+end
605+A=x
606+B=udval
607+return 0x1,0x2,0x3
608+end
609+tt.__gc=F
610+do
611+collectgarbage()
612+;
613+collectgarbage()
614+;
615+local x = collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}")
616+;
617+local a = T.newuserdata(0x1389)
618+assert((T.testC("\u{6f}\u{62}\u{6a}\u{73}\u{69}\u{7a}\u{65}\u{20}\u{32}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",a) == 0x1389))
619+assert((collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}") >= (x + 0x4)))
620+a=nil
621+collectgarbage()
622+;
623+assert((collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}") <= (x + 0x1)))
624+x=collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}")
625+collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
626+for i = 0x1, 0x3e8
627+do
628+T.newuserdata(0x0)
629+end
630+assert((collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}") > (x + 0xa)))
631+collectgarbage()
632+assert((collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}") <= (x + 0x1)))
633+collectgarbage()
634+x=collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}")
635+collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
636+a={["\u{5f}\u{5f}\u{67}\u{63}"] = function ()
637+
638+end}
639+for i = 0x1, 0x3e8
640+do
641+debug.setmetatable(T.newuserdata(0x0),a)
642+end
643+assert((collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}") >= (x + 0xa)))
644+collectgarbage()
645+assert((collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}") >= (x + 0xa)))
646+collectgarbage()
647+assert((collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}") <= (x + 0x1)))
648+collectgarbage("\u{72}\u{65}\u{73}\u{74}\u{61}\u{72}\u{74}")
649+end
650+collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
651+a=T.newuserdata(0x0)
652+;
653+debug.setmetatable(a,tt)
654+;
655+local na = T.udataval(a)
656+b=T.newuserdata(0x0)
657+;
658+debug.setmetatable(b,tt)
659+;
660+local nb = T.udataval(b)
661+c=T.newuserdata(0x0)
662+;
663+debug.setmetatable(c,tt)
664+;
665+local nc = T.udataval(c)
666+x=T.newuserdata(0x4)
667+y=T.newuserdata(0x0)
668+checkerr("\u{46}\u{49}\u{4c}\u{45}\u{25}\u{2a}\u{20}\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}\u{2c}\u{20}\u{67}\u{6f}\u{74}\u{20}\u{75}\u{73}\u{65}\u{72}\u{64}\u{61}\u{74}\u{61}",io.input,a)
669+checkerr("\u{46}\u{49}\u{4c}\u{45}\u{25}\u{2a}\u{20}\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}\u{2c}\u{20}\u{67}\u{6f}\u{74}\u{20}\u{75}\u{73}\u{65}\u{72}\u{64}\u{61}\u{74}\u{61}",io.input,x)
670+assert(((debug.getmetatable(x) == nil) and (debug.getmetatable(y) == nil)))
671+local d = T.ref(a)
672+;
673+local e = T.ref(b)
674+;
675+local f = T.ref(c)
676+;
677+t={T.getref(d),T.getref(e),T.getref(f)}
678+assert((((t[0x1] == a) and (t[0x2] == b)) and (t[0x3] == c)))
679+t=nil
680+;
681+a=nil
682+;
683+c=nil
684+;
685+T.unref(e)
686+;
687+T.unref(f)
688+collectgarbage()
689+assert((# ((cl == 0x1) and (cl[0x1] == nc))))
690+x=T.getref(d)
691+assert(((type(x) == "\u{75}\u{73}\u{65}\u{72}\u{64}\u{61}\u{74}\u{61}") and (debug.getmetatable(x) == tt)))
692+x=nil
693+tt.b=b
694+tt=nil
695+A=nil
696+b=nil
697+T.unref(d)
698+;
699+local n5 = T.newuserdata(0x0)
700+debug.setmetatable(n5,{["\u{5f}\u{5f}\u{67}\u{63}"] = F})
701+n5=T.udataval(n5)
702+collectgarbage()
703+assert((# (cl == 0x4)))
704+assert((((cl[0x2] == n5) and (cl[0x3] == nb)) and (cl[0x4] == na)))
705+collectgarbage("\u{72}\u{65}\u{73}\u{74}\u{61}\u{72}\u{74}")
706+a,na={},{}
707+for i = 0x1e, 0x1, (- 0x1)
708+do
709+a[i]=T.newuserdata(0x0)
710+debug.setmetatable(a[i],{["\u{5f}\u{5f}\u{67}\u{63}"] = F})
711+na[i]=T.udataval(a[i])
712+end
713+cl={}
714+a=nil
715+;
716+collectgarbage()
717+assert((# (cl == 0x1e)))
718+for i = 0x1, 0x1e
719+do
720+assert((cl[i] == na[i]))
721+end
722+na=nil
723+for i = 0x2, Lim, 0x2
724+do
725+T.unref(Arr[i])
726+end
727+x=T.newuserdata(0x29)
728+;
729+debug.setmetatable(x,{["\u{5f}\u{5f}\u{67}\u{63}"] = F})
730+assert((T.testC("\u{6f}\u{62}\u{6a}\u{73}\u{69}\u{7a}\u{65}\u{20}\u{32}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",x) == 0x29))
731+cl={}
732+a={[x] = 0x1}
733+x=T.udataval(x)
734+collectgarbage()
735+assert((# (cl == 0x0)))
736+for n in pairs(a)
737+do
738+a[n]=undef
739+end
740+collectgarbage()
741+assert((# ((cl == 0x1) and (cl[0x1] == x))))
742+assert(T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{45}\u{51}\u{20}\u{32}\u{20}\u{34}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",print,0x1,print,0x14))
743+assert(T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{45}\u{51}\u{20}\u{33}\u{20}\u{32}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}","\u{61}\u{6c}\u{6f}","\u{61}\u{6c}\u{6f}"))
744+assert(T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{45}\u{51}\u{20}\u{32}\u{20}\u{33}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",nil,nil))
745+assert((not T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{45}\u{51}\u{20}\u{32}\u{20}\u{33}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",{},{})))
746+assert((not T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{45}\u{51}\u{20}\u{32}\u{20}\u{33}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}")))
747+assert((not T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{45}\u{51}\u{20}\u{32}\u{20}\u{33}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",0x3)))
748+do
749+local map = {}
750+local t = {["\u{5f}\u{5f}\u{65}\u{71}"] = function (a,b)
751+return (map[a] == map[b])
752+end}
753+local function f
754+(x)
755+local u = T.newuserdata(0x0)
756+debug.setmetatable(u,t)
757+map[u]=x
758+return u
759+end
760+assert((f(0xa) == f(0xa)))
761+assert((f(0xa) ~= f(0xb)))
762+assert(T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{45}\u{51}\u{20}\u{32}\u{20}\u{33}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",f(0xa),f(0xa)))
763+assert((not T.testC("\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}\u{20}\u{45}\u{51}\u{20}\u{32}\u{20}\u{33}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",f(0xa),f(0x14))))
764+t.__eq=nil
765+assert((f(0xa) ~= f(0xa)))
766+end
767+print("\u{2b}")
768+_G.TT={}
769+T.sethook("\u{20}\u{20}\u{23}\u{20}\u{73}\u{65}\u{74}\u{20}\u{61}\u{20}\u{6c}\u{69}\u{6e}\u{65}\u{20}\u{68}\u{6f}\u{6f}\u{6b}\u{20}\u{61}\u{66}\u{74}\u{65}\u{72}\u{20}\u{33}\u{20}\u{63}\u{6f}\u{75}\u{6e}\u{74}\u{20}\u{68}\u{6f}\u{6f}\u{6b}\u{73}\u{a}\u{20}\u{20}\u{73}\u{65}\u{74}\u{68}\u{6f}\u{6f}\u{6b}\u{20}\u{34}\u{20}\u{30}\u{20}\u{27}\u{a}\u{20}\u{20}\u{20}\u{20}\u{67}\u{65}\u{74}\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{54}\u{54}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{2d}\u{33}\u{3b}\u{20}\u{61}\u{70}\u{70}\u{65}\u{6e}\u{64}\u{20}\u{2d}\u{32}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{2d}\u{32}\u{3b}\u{20}\u{61}\u{70}\u{70}\u{65}\u{6e}\u{64}\u{20}\u{2d}\u{32}\u{a}\u{20}\u{20}\u{27}","\u{63}",0x3)
770+local a = 0x1
771+a=0x1
772+a=0x1
773+a=0x1
774+a=0x1
775+debug.sethook()
776+local t = _G.TT
777+assert((t[0x1] == "\u{6c}\u{69}\u{6e}\u{65}"))
778+local line = t[0x2]
779+assert(((t[0x3] == "\u{6c}\u{69}\u{6e}\u{65}") and (t[0x4] == (line + 0x1))))
780+assert(((t[0x5] == "\u{6c}\u{69}\u{6e}\u{65}") and (t[0x6] == (line + 0x2))))
781+assert((t[0x7] == nil))
782+_G.TT=nil
783+do
784+warn("\u{40}\u{6f}\u{66}\u{66}")
785+collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
786+local a = {}
787+for i = 0x1, 0x14
788+do
789+a[i]=T.newuserdata(i)
790+end
791+for i = 0x1, 0x14, 0x2
792+do
793+debug.setmetatable(a[i],{["\u{5f}\u{5f}\u{67}\u{63}"] = function (x)
794+error("\u{40}\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{20}\u{69}\u{6e}\u{20}\u{67}\u{63}")
795+end})
796+end
797+for i = 0x2, 0x14, 0x2
798+do
799+debug.setmetatable(a[i],{["\u{5f}\u{5f}\u{67}\u{63}"] = function (x)
800+load("\u{41}\u{3d}\u{41}\u{2b}\u{31}")()
801+end})
802+end
803+a=nil
804+_G.A=0x0
805+collectgarbage()
806+assert((A == 0xa))
807+collectgarbage("\u{72}\u{65}\u{73}\u{74}\u{61}\u{72}\u{74}")
808+warn("\u{40}\u{6f}\u{6e}")
809+end
810+_G.A=nil
811+do
812+local a = {}
813+;
814+local lim = 0x1e
815+for i = 0x0, lim
816+do
817+a[i]=T.pushuserdata(i)
818+end
819+for i = 0x0, lim
820+do
821+assert((T.udataval(a[i]) == i))
822+end
823+for i = 0x0, lim
824+do
825+assert((T.pushuserdata(i) == a[i]))
826+end
827+for i = 0x0, lim
828+do
829+a[a[i]]=i
830+end
831+for i = 0x0, lim
832+do
833+a[T.pushuserdata(i)]=i
834+end
835+assert((type(tostring(a[0x1])) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}"))
836+end
837+T.closestate(T.newstate())
838+;
839+L1=T.newstate()
840+assert(L1)
841+assert((T.doremote(L1,"\u{58}\u{3d}\u{27}\u{61}\u{27}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{27}\u{61}\u{27}") == "\u{61}"))
842+assert((# (pack(T.doremote(L1,"\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{66}\u{20}\u{28}\u{29}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{27}\u{61}\u{6c}\u{6f}\u{27}\u{2c}\u{20}\u{33}\u{20}\u{65}\u{6e}\u{64}\u{3b}\u{20}\u{66}\u{28}\u{29}")) == 0x0)))
843+a,b=T.doremote(L1,"\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{66}\u{28}\u{29}")
844+assert(((a == "\u{61}\u{6c}\u{6f}") and (b == "\u{33}")))
845+T.doremote(L1,"\u{5f}\u{45}\u{52}\u{52}\u{4f}\u{52}\u{4d}\u{45}\u{53}\u{53}\u{41}\u{47}\u{45}\u{20}\u{3d}\u{20}\u{6e}\u{69}\u{6c}")
846+a,b,c=T.doremote(L1,"\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{73}\u{69}\u{6e}\u{28}\u{31}\u{29}")
847+assert(((a == nil) and (c == 0x2)))
848+a,b,c=T.doremote(L1,"\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{61}\u{2b}")
849+assert((((a == nil) and (c == 0x3)) and (type(b) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}")))
850+T.loadlib(L1)
851+a,b,c=T.doremote(L1,"\u{20}\u{20}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{3d}\u{20}\u{72}\u{65}\u{71}\u{75}\u{69}\u{72}\u{65}\u{27}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{27}\u{a}\u{20}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{72}\u{65}\u{71}\u{75}\u{69}\u{72}\u{65}\u{27}\u{5f}\u{47}\u{27}\u{3b}\u{20}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{61}\u{20}\u{3d}\u{3d}\u{20}\u{5f}\u{47}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{72}\u{65}\u{71}\u{75}\u{69}\u{72}\u{65}\u{28}\u{22}\u{5f}\u{47}\u{22}\u{29}\u{20}\u{3d}\u{3d}\u{20}\u{61}\u{29}\u{a}\u{20}\u{20}\u{69}\u{6f}\u{20}\u{3d}\u{20}\u{72}\u{65}\u{71}\u{75}\u{69}\u{72}\u{65}\u{27}\u{69}\u{6f}\u{27}\u{3b}\u{20}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{74}\u{79}\u{70}\u{65}\u{28}\u{69}\u{6f}\u{2e}\u{72}\u{65}\u{61}\u{64}\u{29}\u{20}\u{3d}\u{3d}\u{20}\u{22}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{22}\u{29}\u{a}\u{20}\u{20}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{72}\u{65}\u{71}\u{75}\u{69}\u{72}\u{65}\u{28}\u{22}\u{69}\u{6f}\u{22}\u{29}\u{20}\u{3d}\u{3d}\u{20}\u{69}\u{6f}\u{29}\u{a}\u{20}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{72}\u{65}\u{71}\u{75}\u{69}\u{72}\u{65}\u{27}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{27}\u{3b}\u{20}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{74}\u{79}\u{70}\u{65}\u{28}\u{61}\u{2e}\u{69}\u{6e}\u{73}\u{65}\u{72}\u{74}\u{29}\u{20}\u{3d}\u{3d}\u{20}\u{22}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{22}\u{29}\u{a}\u{20}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{72}\u{65}\u{71}\u{75}\u{69}\u{72}\u{65}\u{27}\u{64}\u{65}\u{62}\u{75}\u{67}\u{27}\u{3b}\u{20}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{74}\u{79}\u{70}\u{65}\u{28}\u{61}\u{2e}\u{67}\u{65}\u{74}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{29}\u{20}\u{3d}\u{3d}\u{20}\u{22}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{22}\u{29}\u{a}\u{20}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{72}\u{65}\u{71}\u{75}\u{69}\u{72}\u{65}\u{27}\u{6d}\u{61}\u{74}\u{68}\u{27}\u{3b}\u{20}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{74}\u{79}\u{70}\u{65}\u{28}\u{61}\u{2e}\u{73}\u{69}\u{6e}\u{29}\u{20}\u{3d}\u{3d}\u{20}\u{22}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{22}\u{29}\u{a}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{2e}\u{73}\u{75}\u{62}\u{28}\u{27}\u{6f}\u{6b}\u{69}\u{6e}\u{61}\u{6d}\u{61}\u{27}\u{2c}\u{20}\u{31}\u{2c}\u{20}\u{32}\u{29}\u{a}")
852+assert((a == "\u{6f}\u{6b}"))
853+T.closestate(L1)
854+;
855+L1=T.newstate()
856+T.loadlib(L1)
857+T.doremote(L1,"\u{61}\u{20}\u{3d}\u{20}\u{7b}\u{7d}")
858+T.testC(L1,"\u{67}\u{65}\u{74}\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{22}\u{61}\u{22}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{22}\u{78}\u{22}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{69}\u{6e}\u{74}\u{20}\u{31}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{73}\u{65}\u{74}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{2d}\u{33}")
859+assert((T.doremote(L1,"\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{61}\u{2e}\u{78}") == "\u{31}"))
860+T.closestate(L1)
861+L1=nil
862+print("\u{2b}")
863+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{74}\u{6f}\u{2d}\u{62}\u{65}\u{2d}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{64}\u{20}\u{76}\u{61}\u{72}\u{69}\u{61}\u{62}\u{6c}\u{65}\u{73}")
864+do
865+local openresource = {}
866+local function newresource
867+()
868+local x = setmetatable({0xa},{["\u{5f}\u{5f}\u{63}\u{6c}\u{6f}\u{73}\u{65}"] = function (y)
869+assert((openresource[(# openresource)] == y))
870+openresource[(# openresource)]=nil
871+y[0x1]=(y[0x1] + 0x1)
872+end})
873+openresource[(# (openresource + 0x1))]=x
874+return x
875+end
876+local a,b = T.testC("\u{20}\u{20}\u{20}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{30}\u{20}\u{31}\u{20}\u{20}\u{20}\u{23}\u{20}\u{63}\u{72}\u{65}\u{61}\u{74}\u{65}\u{20}\u{72}\u{65}\u{73}\u{6f}\u{75}\u{72}\u{63}\u{65}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{69}\u{6c}\u{a}\u{20}\u{20}\u{20}\u{20}\u{74}\u{6f}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{20}\u{2d}\u{32}\u{20}\u{20}\u{23}\u{20}\u{6d}\u{61}\u{72}\u{6b}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{72}\u{65}\u{73}\u{75}\u{6c}\u{74}\u{20}\u{74}\u{6f}\u{20}\u{62}\u{65}\u{20}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{64}\u{a}\u{20}\u{20}\u{20}\u{20}\u{74}\u{6f}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{20}\u{2d}\u{31}\u{20}\u{20}\u{23}\u{20}\u{6d}\u{61}\u{72}\u{6b}\u{20}\u{6e}\u{69}\u{6c}\u{20}\u{74}\u{6f}\u{20}\u{62}\u{65}\u{20}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{64}\u{20}\u{28}\u{77}\u{69}\u{6c}\u{6c}\u{20}\u{62}\u{65}\u{20}\u{69}\u{67}\u{6e}\u{6f}\u{72}\u{65}\u{64}\u{29}\u{a}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}\u{a}\u{20}\u{20}",newresource)
877+assert(((a[0x1] == 0xb) and (b == nil)))
878+assert((# (openresource == 0x0)))
879+local a = {T.testC("\u{20}\u{20}\u{20}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{30}\u{20}\u{31}\u{20}\u{20}\u{20}\u{23}\u{20}\u{63}\u{72}\u{65}\u{61}\u{74}\u{65}\u{20}\u{72}\u{65}\u{73}\u{6f}\u{75}\u{72}\u{63}\u{65}\u{a}\u{20}\u{20}\u{20}\u{20}\u{74}\u{6f}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{20}\u{32}\u{20}\u{23}\u{20}\u{6d}\u{61}\u{72}\u{6b}\u{20}\u{69}\u{74}\u{20}\u{74}\u{6f}\u{20}\u{62}\u{65}\u{20}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{64}\u{a}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}\u{a}\u{20}\u{20}",newresource)}
880+assert(((type(a[0x1]) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}") and (a[0x2][0x1] == 0xb)))
881+assert((# (openresource == 0x0)))
882+local a,b = pcall(T.makeCfunc("\u{20}\u{20}\u{20}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{30}\u{20}\u{31}\u{20}\u{20}\u{20}\u{23}\u{20}\u{63}\u{72}\u{65}\u{61}\u{74}\u{65}\u{20}\u{72}\u{65}\u{73}\u{6f}\u{75}\u{72}\u{63}\u{65}\u{a}\u{20}\u{20}\u{20}\u{20}\u{74}\u{6f}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{20}\u{2d}\u{31}\u{20}\u{23}\u{20}\u{6d}\u{61}\u{72}\u{6b}\u{20}\u{69}\u{74}\u{20}\u{74}\u{6f}\u{20}\u{62}\u{65}\u{20}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{64}\u{a}\u{20}\u{20}\u{20}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{72}\u{65}\u{73}\u{6f}\u{75}\u{72}\u{63}\u{65}\u{20}\u{69}\u{73}\u{20}\u{74}\u{68}\u{65}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{20}\u{6f}\u{62}\u{6a}\u{65}\u{63}\u{74}\u{a}\u{20}\u{20}"),newresource)
883+assert(((a == false) and (b[0x1] == 0xb)))
884+assert((# (openresource == 0x0)))
885+local a,b = pcall(T.makeCfunc("\u{20}\u{20}\u{20}\u{20}\u{6e}\u{65}\u{77}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{20}\u{20}\u{23}\u{20}\u{63}\u{72}\u{65}\u{61}\u{74}\u{65}\u{20}\u{6e}\u{6f}\u{6e}\u{2d}\u{63}\u{6c}\u{6f}\u{73}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{6f}\u{62}\u{6a}\u{65}\u{63}\u{74}\u{a}\u{20}\u{20}\u{20}\u{20}\u{74}\u{6f}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{20}\u{2d}\u{31}\u{20}\u{23}\u{20}\u{6d}\u{61}\u{72}\u{6b}\u{20}\u{69}\u{74}\u{20}\u{74}\u{6f}\u{20}\u{62}\u{65}\u{20}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{64}\u{20}\u{28}\u{73}\u{68}\u{6f}\u{75}\u{6c}\u{64}\u{20}\u{72}\u{61}\u{69}\u{73}\u{65}\u{20}\u{61}\u{6e}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{29}\u{a}\u{20}\u{20}\u{20}\u{20}\u{61}\u{62}\u{6f}\u{72}\u{74}\u{20}\u{20}\u{23}\u{20}\u{77}\u{69}\u{6c}\u{6c}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{62}\u{65}\u{20}\u{65}\u{78}\u{65}\u{63}\u{75}\u{74}\u{65}\u{64}\u{a}\u{20}\u{20}"))
886+assert(((a == false) and string.find(b,"\u{6e}\u{6f}\u{6e}\u{25}\u{2d}\u{63}\u{6c}\u{6f}\u{73}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}")))
887+local function check
888+(n)
889+assert((# (openresource == n)))
890+end
891+_ENV.xxx=true
892+local a = T.testC("\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{32}\u{20}\u{20}\u{23}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{3a}\u{20}\u{53}\u{2c}\u{20}\u{4e}\u{52}\u{2c}\u{20}\u{43}\u{48}\u{2c}\u{20}\u{4e}\u{52}\u{a}\u{20}\u{20}\u{20}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{30}\u{20}\u{31}\u{20}\u{20}\u{20}\u{23}\u{20}\u{63}\u{72}\u{65}\u{61}\u{74}\u{65}\u{20}\u{72}\u{65}\u{73}\u{6f}\u{75}\u{72}\u{63}\u{65}\u{3b}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{3a}\u{20}\u{53}\u{2c}\u{20}\u{4e}\u{52}\u{2c}\u{20}\u{43}\u{48}\u{2c}\u{20}\u{52}\u{a}\u{20}\u{20}\u{20}\u{20}\u{74}\u{6f}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{20}\u{2d}\u{31}\u{20}\u{23}\u{20}\u{6d}\u{61}\u{72}\u{6b}\u{20}\u{69}\u{74}\u{20}\u{74}\u{6f}\u{20}\u{62}\u{65}\u{20}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{64}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{32}\u{20}\u{20}\u{23}\u{20}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{3a}\u{20}\u{53}\u{2c}\u{20}\u{4e}\u{52}\u{2c}\u{20}\u{43}\u{48}\u{2c}\u{20}\u{52}\u{2c}\u{20}\u{4e}\u{52}\u{a}\u{20}\u{20}\u{20}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{30}\u{20}\u{31}\u{20}\u{20}\u{20}\u{23}\u{20}\u{63}\u{72}\u{65}\u{61}\u{74}\u{65}\u{20}\u{61}\u{6e}\u{6f}\u{74}\u{68}\u{65}\u{72}\u{20}\u{72}\u{65}\u{73}\u{6f}\u{75}\u{72}\u{63}\u{65}\u{3b}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{3a}\u{20}\u{53}\u{2c}\u{20}\u{4e}\u{52}\u{2c}\u{20}\u{43}\u{48}\u{2c}\u{20}\u{52}\u{2c}\u{20}\u{52}\u{a}\u{20}\u{20}\u{20}\u{20}\u{74}\u{6f}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{20}\u{2d}\u{31}\u{20}\u{23}\u{20}\u{6d}\u{61}\u{72}\u{6b}\u{20}\u{69}\u{74}\u{20}\u{74}\u{6f}\u{20}\u{62}\u{65}\u{20}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{64}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{33}\u{20}\u{20}\u{23}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{3a}\u{20}\u{53}\u{2c}\u{20}\u{4e}\u{52}\u{2c}\u{20}\u{43}\u{48}\u{2c}\u{20}\u{52}\u{2c}\u{20}\u{52}\u{2c}\u{20}\u{43}\u{48}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{69}\u{6e}\u{74}\u{20}\u{32}\u{20}\u{20}\u{20}\u{23}\u{20}\u{74}\u{68}\u{65}\u{72}\u{65}\u{20}\u{73}\u{68}\u{6f}\u{75}\u{6c}\u{64}\u{20}\u{62}\u{65}\u{20}\u{74}\u{77}\u{6f}\u{20}\u{6f}\u{70}\u{65}\u{6e}\u{20}\u{72}\u{65}\u{73}\u{6f}\u{75}\u{72}\u{63}\u{65}\u{73}\u{a}\u{20}\u{20}\u{20}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{31}\u{20}\u{30}\u{20}\u{20}\u{23}\u{20}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{3a}\u{20}\u{53}\u{2c}\u{20}\u{4e}\u{52}\u{2c}\u{20}\u{43}\u{48}\u{2c}\u{20}\u{52}\u{2c}\u{20}\u{52}\u{a}\u{20}\u{20}\u{20}\u{20}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{73}\u{6c}\u{6f}\u{74}\u{20}\u{2d}\u{31}\u{20}\u{20}\u{20}\u{23}\u{20}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{20}\u{73}\u{65}\u{63}\u{6f}\u{6e}\u{64}\u{20}\u{72}\u{65}\u{73}\u{6f}\u{75}\u{72}\u{63}\u{65}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{33}\u{20}\u{20}\u{23}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{3a}\u{20}\u{53}\u{2c}\u{20}\u{4e}\u{52}\u{2c}\u{20}\u{43}\u{48}\u{2c}\u{20}\u{52}\u{2c}\u{20}\u{52}\u{2c}\u{20}\u{43}\u{48}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{69}\u{6e}\u{74}\u{20}\u{31}\u{20}\u{20}\u{20}\u{23}\u{20}\u{74}\u{68}\u{65}\u{72}\u{65}\u{20}\u{73}\u{68}\u{6f}\u{75}\u{6c}\u{64}\u{20}\u{62}\u{65}\u{20}\u{6f}\u{6e}\u{65}\u{20}\u{6f}\u{70}\u{65}\u{6e}\u{20}\u{72}\u{65}\u{73}\u{6f}\u{75}\u{72}\u{63}\u{65}\u{a}\u{20}\u{20}\u{20}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{31}\u{20}\u{30}\u{20}\u{20}\u{23}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{3a}\u{20}\u{53}\u{2c}\u{20}\u{4e}\u{52}\u{2c}\u{20}\u{43}\u{48}\u{2c}\u{20}\u{52}\u{2c}\u{20}\u{52}\u{a}\u{20}\u{20}\u{20}\u{20}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{73}\u{6c}\u{6f}\u{74}\u{20}\u{34}\u{a}\u{20}\u{20}\u{20}\u{20}\u{73}\u{65}\u{74}\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{22}\u{78}\u{78}\u{78}\u{22}\u{20}\u{20}\u{23}\u{20}\u{70}\u{72}\u{65}\u{76}\u{69}\u{6f}\u{75}\u{73}\u{20}\u{6f}\u{70}\u{2e}\u{20}\u{65}\u{72}\u{61}\u{73}\u{65}\u{64}\u{20}\u{74}\u{68}\u{65}\u{20}\u{73}\u{6c}\u{6f}\u{74}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{6f}\u{70}\u{20}\u{31}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{70}\u{6f}\u{70}\u{20}\u{6f}\u{74}\u{68}\u{65}\u{72}\u{20}\u{72}\u{65}\u{73}\u{6f}\u{75}\u{72}\u{63}\u{65}\u{20}\u{66}\u{72}\u{6f}\u{6d}\u{20}\u{74}\u{68}\u{65}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{69}\u{6e}\u{74}\u{20}\u{2a}\u{a}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{73}\u{69}\u{7a}\u{65}\u{a}\u{20}\u{20}",newresource,check)
893+assert(((a == 0x3) and (_ENV.xxx == nil)))
894+local a = T.testC("\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{32}\u{20}\u{20}\u{23}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{3a}\u{20}\u{53}\u{2c}\u{20}\u{4e}\u{52}\u{2c}\u{20}\u{43}\u{48}\u{2c}\u{20}\u{4e}\u{52}\u{a}\u{20}\u{20}\u{20}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{30}\u{20}\u{31}\u{20}\u{20}\u{20}\u{23}\u{20}\u{63}\u{72}\u{65}\u{61}\u{74}\u{65}\u{20}\u{72}\u{65}\u{73}\u{6f}\u{75}\u{72}\u{63}\u{65}\u{3b}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{3a}\u{20}\u{53}\u{2c}\u{20}\u{4e}\u{52}\u{2c}\u{20}\u{43}\u{48}\u{2c}\u{20}\u{52}\u{a}\u{20}\u{20}\u{20}\u{20}\u{74}\u{6f}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{20}\u{2d}\u{31}\u{20}\u{23}\u{20}\u{6d}\u{61}\u{72}\u{6b}\u{20}\u{69}\u{74}\u{20}\u{74}\u{6f}\u{20}\u{62}\u{65}\u{20}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{64}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{32}\u{20}\u{20}\u{23}\u{20}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{3a}\u{20}\u{53}\u{2c}\u{20}\u{4e}\u{52}\u{2c}\u{20}\u{43}\u{48}\u{2c}\u{20}\u{52}\u{2c}\u{20}\u{4e}\u{52}\u{a}\u{20}\u{20}\u{20}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{30}\u{20}\u{31}\u{20}\u{20}\u{20}\u{23}\u{20}\u{63}\u{72}\u{65}\u{61}\u{74}\u{65}\u{20}\u{61}\u{6e}\u{6f}\u{74}\u{68}\u{65}\u{72}\u{20}\u{72}\u{65}\u{73}\u{6f}\u{75}\u{72}\u{63}\u{65}\u{3b}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{3a}\u{20}\u{53}\u{2c}\u{20}\u{4e}\u{52}\u{2c}\u{20}\u{43}\u{48}\u{2c}\u{20}\u{52}\u{2c}\u{20}\u{52}\u{a}\u{20}\u{20}\u{20}\u{20}\u{74}\u{6f}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{20}\u{2d}\u{31}\u{20}\u{23}\u{20}\u{6d}\u{61}\u{72}\u{6b}\u{20}\u{69}\u{74}\u{20}\u{74}\u{6f}\u{20}\u{62}\u{65}\u{20}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{64}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{33}\u{20}\u{20}\u{23}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{3a}\u{20}\u{53}\u{2c}\u{20}\u{4e}\u{52}\u{2c}\u{20}\u{43}\u{48}\u{2c}\u{20}\u{52}\u{2c}\u{20}\u{52}\u{2c}\u{20}\u{43}\u{48}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{69}\u{6e}\u{74}\u{20}\u{32}\u{20}\u{20}\u{20}\u{23}\u{20}\u{74}\u{68}\u{65}\u{72}\u{65}\u{20}\u{73}\u{68}\u{6f}\u{75}\u{6c}\u{64}\u{20}\u{62}\u{65}\u{20}\u{74}\u{77}\u{6f}\u{20}\u{6f}\u{70}\u{65}\u{6e}\u{20}\u{72}\u{65}\u{73}\u{6f}\u{75}\u{72}\u{63}\u{65}\u{73}\u{a}\u{20}\u{20}\u{20}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{31}\u{20}\u{30}\u{20}\u{20}\u{23}\u{20}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{3a}\u{20}\u{53}\u{2c}\u{20}\u{4e}\u{52}\u{2c}\u{20}\u{43}\u{48}\u{2c}\u{20}\u{52}\u{2c}\u{20}\u{52}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{6f}\u{70}\u{20}\u{31}\u{20}\u{20}\u{20}\u{23}\u{20}\u{70}\u{6f}\u{70}\u{20}\u{73}\u{65}\u{63}\u{6f}\u{6e}\u{64}\u{20}\u{72}\u{65}\u{73}\u{6f}\u{75}\u{72}\u{63}\u{65}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{33}\u{20}\u{20}\u{23}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{3a}\u{20}\u{53}\u{2c}\u{20}\u{4e}\u{52}\u{2c}\u{20}\u{43}\u{48}\u{2c}\u{20}\u{52}\u{2c}\u{20}\u{43}\u{48}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{69}\u{6e}\u{74}\u{20}\u{31}\u{20}\u{20}\u{20}\u{23}\u{20}\u{74}\u{68}\u{65}\u{72}\u{65}\u{20}\u{73}\u{68}\u{6f}\u{75}\u{6c}\u{64}\u{20}\u{62}\u{65}\u{20}\u{6f}\u{6e}\u{65}\u{20}\u{6f}\u{70}\u{65}\u{6e}\u{20}\u{72}\u{65}\u{73}\u{6f}\u{75}\u{72}\u{63}\u{65}\u{a}\u{20}\u{20}\u{20}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{31}\u{20}\u{30}\u{20}\u{20}\u{23}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{3a}\u{20}\u{53}\u{2c}\u{20}\u{4e}\u{52}\u{2c}\u{20}\u{43}\u{48}\u{2c}\u{20}\u{52}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{6f}\u{70}\u{20}\u{31}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{70}\u{6f}\u{70}\u{20}\u{6f}\u{74}\u{68}\u{65}\u{72}\u{20}\u{72}\u{65}\u{73}\u{6f}\u{75}\u{72}\u{63}\u{65}\u{20}\u{66}\u{72}\u{6f}\u{6d}\u{20}\u{74}\u{68}\u{65}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{33}\u{20}\u{20}\u{23}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{3a}\u{20}\u{53}\u{2c}\u{20}\u{4e}\u{52}\u{2c}\u{20}\u{43}\u{48}\u{2c}\u{20}\u{43}\u{48}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{69}\u{6e}\u{74}\u{20}\u{30}\u{20}\u{20}\u{20}\u{23}\u{20}\u{74}\u{68}\u{65}\u{72}\u{65}\u{20}\u{73}\u{68}\u{6f}\u{75}\u{6c}\u{64}\u{20}\u{62}\u{65}\u{20}\u{6e}\u{6f}\u{20}\u{6f}\u{70}\u{65}\u{6e}\u{20}\u{72}\u{65}\u{73}\u{6f}\u{75}\u{72}\u{63}\u{65}\u{73}\u{a}\u{20}\u{20}\u{20}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{31}\u{20}\u{30}\u{20}\u{20}\u{23}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{3a}\u{20}\u{53}\u{2c}\u{20}\u{4e}\u{52}\u{2c}\u{20}\u{43}\u{48}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{69}\u{6e}\u{74}\u{20}\u{2a}\u{a}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{73}\u{69}\u{7a}\u{65}\u{a}\u{20}\u{20}",newresource,check)
895+assert((a == 0x3))
896+local a,b = pcall(T.makeCfunc("\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{69}\u{6e}\u{74}\u{20}\u{33}\u{32}\u{a}\u{20}\u{20}\u{20}\u{20}\u{74}\u{6f}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{20}\u{2d}\u{31}\u{a}\u{20}\u{20}"))
897+assert((not (a and string.find(b,"\u{28}\u{43}\u{20}\u{74}\u{65}\u{6d}\u{70}\u{6f}\u{72}\u{61}\u{72}\u{79}\u{29}"))))
898+end
899+print("\u{6d}\u{65}\u{6d}\u{6f}\u{72}\u{79}\u{2d}\u{61}\u{6c}\u{6c}\u{6f}\u{63}\u{61}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{73}")
900+checkerr("\u{62}\u{6c}\u{6f}\u{63}\u{6b}\u{20}\u{74}\u{6f}\u{6f}\u{20}\u{62}\u{69}\u{67}",T.newuserdata,math.maxinteger)
901+collectgarbage()
902+local f = load("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{3d}\u{7b}\u{7d}\u{3b}\u{20}\u{66}\u{6f}\u{72}\u{20}\u{69}\u{3d}\u{31}\u{2c}\u{31}\u{30}\u{30}\u{30}\u{30}\u{30}\u{20}\u{64}\u{6f}\u{20}\u{61}\u{5b}\u{69}\u{5d}\u{3d}\u{69}\u{20}\u{65}\u{6e}\u{64}")
903+T.alloccount(0xa)
904+checkerr(MEMERRMSG,f)
905+T.alloccount()
906+local function testbytes
907+(s,f)
908+collectgarbage()
909+local M = T.totalmem()
910+local oldM = M
911+local a,b = nil
912+while true do
913+collectgarbage()
914+;
915+collectgarbage()
916+T.totalmem(M)
917+a,b=T.testC("\u{70}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{30}\u{20}\u{31}\u{20}\u{30}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{61}\u{74}\u{75}\u{73}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}",f)
918+T.totalmem(0x0)
919+if (a and (b == "\u{4f}\u{4b}")) then
920+break
921+end
922+if ((b ~= "\u{4f}\u{4b}") and (b ~= MEMERRMSG)) then
923+error(a,0x0)
924+end
925+M=(M + 0x7)
926+end
927+print(string.format("\u{6d}\u{69}\u{6e}\u{69}\u{6d}\u{75}\u{6d}\u{20}\u{6d}\u{65}\u{6d}\u{6f}\u{72}\u{79}\u{20}\u{66}\u{6f}\u{72}\u{20}\u{25}\u{73}\u{3a}\u{20}\u{25}\u{64}\u{20}\u{62}\u{79}\u{74}\u{65}\u{73}",s,(M - oldM)))
928+return a
929+end
930+local function testalloc
931+(s,f)
932+collectgarbage()
933+local M = 0x0
934+local a,b = nil
935+while true do
936+collectgarbage()
937+;
938+collectgarbage()
939+T.alloccount(M)
940+a,b=T.testC("\u{70}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{30}\u{20}\u{31}\u{20}\u{30}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{61}\u{74}\u{75}\u{73}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}",f)
941+T.alloccount()
942+if (a and (b == "\u{4f}\u{4b}")) then
943+break
944+end
945+if ((b ~= "\u{4f}\u{4b}") and (b ~= MEMERRMSG)) then
946+error(a,0x0)
947+end
948+M=(M + 0x1)
949+end
950+print(string.format("\u{6d}\u{69}\u{6e}\u{69}\u{6d}\u{75}\u{6d}\u{20}\u{61}\u{6c}\u{6c}\u{6f}\u{63}\u{61}\u{74}\u{69}\u{6f}\u{6e}\u{73}\u{20}\u{66}\u{6f}\u{72}\u{20}\u{25}\u{73}\u{3a}\u{20}\u{25}\u{64}\u{20}\u{61}\u{6c}\u{6c}\u{6f}\u{63}\u{61}\u{74}\u{69}\u{6f}\u{6e}\u{73}",s,M))
951+return a
952+end
953+local function testamem
954+(s,f)
955+testalloc(s,f)
956+return testbytes(s,f)
957+end
958+b=testamem("\u{64}\u{6f}\u{69}\u{6e}\u{67}\u{20}\u{6e}\u{6f}\u{74}\u{68}\u{69}\u{6e}\u{67}",function ()
959+return 0xa
960+end)
961+assert((b == 0xa))
962+testamem("\u{73}\u{74}\u{61}\u{74}\u{65}\u{20}\u{63}\u{72}\u{65}\u{61}\u{74}\u{69}\u{6f}\u{6e}",function ()
963+local st = T.newstate()
964+if st then
965+T.closestate(st)
966+end
967+return st
968+end)
969+testamem("\u{65}\u{6d}\u{70}\u{74}\u{79}\u{2d}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{63}\u{72}\u{65}\u{61}\u{74}\u{69}\u{6f}\u{6e}",function ()
970+return {}
971+end)
972+testamem("\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{63}\u{72}\u{65}\u{61}\u{74}\u{69}\u{6f}\u{6e}",function ()
973+return ("\u{58}\u{58}\u{58}" .. "\u{59}\u{59}\u{59}")
974+end)
975+testamem("\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}\u{20}\u{63}\u{72}\u{65}\u{61}\u{74}\u{69}\u{6f}\u{6e}",function ()
976+return coroutine.create(print)
977+end)
978+testamem("\u{74}\u{6f}\u{2d}\u{62}\u{65}\u{2d}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{64}\u{20}\u{76}\u{61}\u{72}\u{69}\u{61}\u{62}\u{6c}\u{65}\u{73}",function ()
979+local flag
980+do
981+local x <close> = setmetatable({},{["\u{5f}\u{5f}\u{63}\u{6c}\u{6f}\u{73}\u{65}"] = function ()
982+flag=true
983+end})
984+flag=false
985+local x = {}
986+end
987+return flag
988+end)
989+local mt = T.testC("\u{72}\u{61}\u{77}\u{67}\u{65}\u{74}\u{69}\u{20}\u{52}\u{20}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}")
990+assert(((type(mt) == "\u{74}\u{68}\u{72}\u{65}\u{61}\u{64}") and (coroutine.running() == mt)))
991+local function expand
992+(n,s)
993+if (n == 0x0) then
994+return ""
995+end
996+local e = string.rep("\u{3d}",n)
997+return string.format("\u{54}\u{2e}\u{64}\u{6f}\u{6f}\u{6e}\u{6e}\u{65}\u{77}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{28}\u{5b}\u{25}\u{73}\u{5b}\u{20}\u{25}\u{73}\u{3b}\u{a}\u{20}\u{63}\u{6f}\u{6c}\u{6c}\u{65}\u{63}\u{74}\u{67}\u{61}\u{72}\u{62}\u{61}\u{67}\u{65}\u{28}\u{29}\u{3b}\u{20}\u{25}\u{73}\u{5d}\u{25}\u{73}\u{5d}\u{29}\u{a}",e,s,expand((n - 0x1),s),e)
998+end
999+G=0x0
1000+;
1001+collectgarbage()
1002+;
1003+a=collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}")
1004+load(expand(0x14,"\u{47}\u{3d}\u{47}\u{2b}\u{31}"))()
1005+assert((G == 0x14))
1006+;
1007+collectgarbage()
1008+;
1009+G=nil
1010+testamem("\u{72}\u{75}\u{6e}\u{6e}\u{69}\u{6e}\u{67}\u{20}\u{63}\u{6f}\u{64}\u{65}\u{20}\u{6f}\u{6e}\u{20}\u{6e}\u{65}\u{77}\u{20}\u{74}\u{68}\u{72}\u{65}\u{61}\u{64}",function ()
1011+return (T.doonnewstack("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{78}\u{3d}\u{31}") == 0x0)
1012+end)
1013+testamem("\u{6c}\u{6f}\u{61}\u{64}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}",function ()
1014+return load("\u{78}\u{3d}\u{31}")
1015+end)
1016+local testprog = "\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{66}\u{6f}\u{6f}\u{20}\u{28}\u{29}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{74}\u{20}\u{3d}\u{20}\u{7b}\u{22}\u{78}\u{22}\u{7d}\u{a}\u{41}\u{41}\u{20}\u{3d}\u{20}\u{22}\u{61}\u{61}\u{61}\u{22}\u{a}\u{66}\u{6f}\u{72}\u{20}\u{69}\u{20}\u{3d}\u{20}\u{31}\u{2c}\u{20}\u{23}\u{74}\u{20}\u{64}\u{6f}\u{20}\u{41}\u{41}\u{20}\u{3d}\u{20}\u{41}\u{41}\u{20}\u{2e}\u{2e}\u{20}\u{74}\u{5b}\u{69}\u{5d}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{74}\u{72}\u{75}\u{65}\u{a}"
1017+_G.AA=nil
1018+local t = os.tmpname()
1019+local f = assert(io.open(t,"\u{77}"))
1020+f:write(testprog)
1021+f:close()
1022+testamem("\u{64}\u{6f}\u{66}\u{69}\u{6c}\u{65}",function ()
1023+local a = loadfile(t)
1024+return (a and a())
1025+end)
1026+assert(os.remove(t))
1027+assert((_G.AA == "\u{61}\u{61}\u{61}\u{78}"))
1028+testamem("\u{67}\u{73}\u{75}\u{62}",function ()
1029+local a,b = string.gsub("\u{61}\u{6c}\u{6f}\u{20}\u{61}\u{6c}\u{6f}","\u{28}\u{61}\u{29}",function (x)
1030+return (x .. "\u{62}")
1031+end)
1032+return (a == "\u{61}\u{62}\u{6c}\u{6f}\u{20}\u{61}\u{62}\u{6c}\u{6f}")
1033+end)
1034+testamem("\u{64}\u{75}\u{6d}\u{70}\u{2f}\u{75}\u{6e}\u{64}\u{75}\u{6d}\u{70}",function ()
1035+local a = load(testprog)
1036+local b = (a and string.dump(a))
1037+a=(b and load(b))
1038+return (a and a())
1039+end)
1040+_G.AA=nil
1041+local t = os.tmpname()
1042+testamem("\u{66}\u{69}\u{6c}\u{65}\u{20}\u{63}\u{72}\u{65}\u{61}\u{74}\u{69}\u{6f}\u{6e}",function ()
1043+local f = assert(io.open(t,"\u{77}"))
1044+assert((not io.open("\u{6e}\u{6f}\u{6d}\u{65}\u{6e}\u{61}\u{6f}\u{65}\u{78}\u{69}\u{73}\u{74}\u{65}\u{6e}\u{74}\u{65}")))
1045+io.close(f)
1046+;
1047+return (not loadfile("\u{6e}\u{6f}\u{6d}\u{65}\u{6e}\u{61}\u{6f}\u{65}\u{78}\u{69}\u{73}\u{74}\u{65}\u{6e}\u{74}\u{65}"))
1048+end)
1049+assert(os.remove(t))
1050+testamem("\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{63}\u{72}\u{65}\u{61}\u{74}\u{69}\u{6f}\u{6e}",function ()
1051+local a,lim = {},0xa
1052+for i = 0x1, lim
1053+do
1054+a[i]=i
1055+;
1056+a[(i .. "\u{61}")]={}
1057+end
1058+return ((type(a[(lim .. "\u{61}")]) == "\u{74}\u{61}\u{62}\u{6c}\u{65}") and (a[lim] == lim))
1059+end)
1060+testamem("\u{63}\u{6f}\u{6e}\u{73}\u{74}\u{72}\u{75}\u{63}\u{74}\u{6f}\u{72}\u{73}",function ()
1061+local a = {0xa,0x14,0x1e,0x28,0x32,["\u{61}"] = 0x1,["\u{62}"] = 0x2,["\u{63}"] = 0x3,["\u{64}"] = 0x4,["\u{65}"] = 0x5}
1062+return ((type(a) == "\u{74}\u{61}\u{62}\u{6c}\u{65}") and (a.e == 0x5))
1063+end)
1064+local a = 0x1
1065+local close = nil
1066+testamem("\u{63}\u{6c}\u{6f}\u{73}\u{75}\u{72}\u{65}\u{20}\u{63}\u{72}\u{65}\u{61}\u{74}\u{69}\u{6f}\u{6e}",function ()
1067+function close(b)
1068+return function (x)
1069+return (b + x)
1070+end
1071+end
1072+return (close(0x2)(0x4) == 0x6)
1073+end)
1074+testamem("\u{75}\u{73}\u{69}\u{6e}\u{67}\u{20}\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}\u{73}",function ()
1075+local a = coroutine.wrap(function ()
1076+coroutine.yield(string.rep("\u{61}",0xa))
1077+return {}
1078+end)
1079+assert((string.len(a()) == 0xa))
1080+return a()
1081+end)
1082+do
1083+local lim = 0x64
1084+local a = {}
1085+;
1086+for i = 0x1, lim
1087+do
1088+a[i]="\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}"
1089+end
1090+testamem("\u{61}\u{75}\u{78}\u{69}\u{6c}\u{69}\u{61}\u{72}\u{79}\u{20}\u{62}\u{75}\u{66}\u{66}\u{65}\u{72}",function ()
1091+return (# (table.concat(a,"\u{2c}") == (((0x14 * lim) + lim) - 0x1)))
1092+end)
1093+end
1094+testamem("\u{67}\u{72}\u{6f}\u{77}\u{69}\u{6e}\u{67}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}",function ()
1095+local function foo
1096+(n)
1097+if (n == 0x0) then
1098+return 0x1
1099+else
1100+return (0x1 + foo((n - 0x1)))
1101+end
1102+end
1103+return foo(0x64)
1104+end)
1105+do
1106+local res = T.testC("\u{72}\u{61}\u{77}\u{63}\u{68}\u{65}\u{63}\u{6b}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{35}\u{30}\u{30}\u{30}\u{30}\u{30}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}")
1107+assert((res == false))
1108+local L = T.newstate()
1109+T.alloccount(0x0)
1110+res=T.testC(L,"\u{72}\u{61}\u{77}\u{63}\u{68}\u{65}\u{63}\u{6b}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{35}\u{30}\u{30}\u{30}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}")
1111+T.alloccount()
1112+T.closestate(L)
1113+assert((res == false))
1114+end
1115+do
1116+local L = T.newstate()
1117+T.alloccount(0x0)
1118+T.closestate(L)
1119+T.alloccount()
1120+end
1121+do
1122+local L = T.newstate()
1123+T.loadlib(L)
1124+local res = T.doremote(L,"\u{20}\u{20}\u{20}\u{20}\u{5f}\u{45}\u{4e}\u{56}\u{20}\u{3d}\u{20}\u{72}\u{65}\u{71}\u{75}\u{69}\u{72}\u{65}\u{22}\u{5f}\u{47}\u{22}\u{a}\u{20}\u{20}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{54}\u{20}\u{3d}\u{20}\u{72}\u{65}\u{71}\u{75}\u{69}\u{72}\u{65}\u{22}\u{54}\u{22}\u{a}\u{20}\u{20}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{7b}\u{7d}\u{a}\u{20}\u{20}\u{20}\u{20}\u{66}\u{6f}\u{72}\u{20}\u{69}\u{20}\u{3d}\u{20}\u{31}\u{2c}\u{20}\u{31}\u{30}\u{30}\u{30}\u{20}\u{64}\u{6f}\u{20}\u{61}\u{5b}\u{69}\u{5d}\u{20}\u{3d}\u{20}\u{27}\u{69}\u{27}\u{20}\u{2e}\u{2e}\u{20}\u{69}\u{20}\u{65}\u{6e}\u{64}\u{20}\u{20}\u{20}\u{20}\u{2d}\u{2d}\u{20}\u{67}\u{72}\u{6f}\u{77}\u{20}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{a}\u{20}\u{20}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{73}\u{74}\u{73}\u{69}\u{7a}\u{65}\u{2c}\u{20}\u{73}\u{74}\u{75}\u{73}\u{65}\u{20}\u{3d}\u{20}\u{54}\u{2e}\u{71}\u{75}\u{65}\u{72}\u{79}\u{73}\u{74}\u{72}\u{28}\u{29}\u{a}\u{20}\u{20}\u{20}\u{20}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{73}\u{74}\u{75}\u{73}\u{65}\u{20}\u{3e}\u{20}\u{31}\u{30}\u{30}\u{30}\u{29}\u{a}\u{20}\u{20}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{66}\u{6f}\u{6f}\u{20}\u{28}\u{6e}\u{29}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{69}\u{66}\u{20}\u{6e}\u{20}\u{3e}\u{20}\u{30}\u{20}\u{74}\u{68}\u{65}\u{6e}\u{20}\u{66}\u{6f}\u{6f}\u{28}\u{6e}\u{20}\u{2d}\u{20}\u{31}\u{29}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{20}\u{20}\u{20}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{20}\u{20}\u{20}\u{20}\u{66}\u{6f}\u{6f}\u{28}\u{31}\u{38}\u{30}\u{29}\u{20}\u{20}\u{20}\u{20}\u{2d}\u{2d}\u{20}\u{67}\u{72}\u{6f}\u{77}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{5f}\u{2c}\u{20}\u{73}\u{74}\u{6b}\u{73}\u{69}\u{7a}\u{65}\u{20}\u{3d}\u{20}\u{54}\u{2e}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{6c}\u{65}\u{76}\u{65}\u{6c}\u{28}\u{29}\u{a}\u{20}\u{20}\u{20}\u{20}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{73}\u{74}\u{6b}\u{73}\u{69}\u{7a}\u{65}\u{20}\u{3e}\u{20}\u{31}\u{38}\u{30}\u{29}\u{a}\u{20}\u{20}\u{20}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{6e}\u{69}\u{6c}\u{a}\u{20}\u{20}\u{20}\u{20}\u{54}\u{2e}\u{61}\u{6c}\u{6c}\u{6f}\u{63}\u{63}\u{6f}\u{75}\u{6e}\u{74}\u{28}\u{30}\u{29}\u{a}\u{20}\u{20}\u{20}\u{20}\u{63}\u{6f}\u{6c}\u{6c}\u{65}\u{63}\u{74}\u{67}\u{61}\u{72}\u{62}\u{61}\u{67}\u{65}\u{28}\u{29}\u{a}\u{20}\u{20}\u{20}\u{20}\u{54}\u{2e}\u{61}\u{6c}\u{6c}\u{6f}\u{63}\u{63}\u{6f}\u{75}\u{6e}\u{74}\u{28}\u{29}\u{a}\u{20}\u{20}\u{20}\u{20}\u{2d}\u{2d}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{63}\u{6f}\u{75}\u{6c}\u{64}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{62}\u{65}\u{20}\u{72}\u{65}\u{61}\u{6c}\u{6c}\u{6f}\u{63}\u{61}\u{74}\u{65}\u{64}\u{2c}\u{a}\u{20}\u{20}\u{20}\u{20}\u{2d}\u{2d}\u{20}\u{73}\u{6f}\u{20}\u{74}\u{68}\u{65}\u{79}\u{20}\u{6b}\u{65}\u{70}\u{74}\u{20}\u{74}\u{68}\u{65}\u{69}\u{72}\u{20}\u{73}\u{69}\u{7a}\u{65}\u{73}\u{20}\u{28}\u{77}\u{69}\u{74}\u{68}\u{6f}\u{75}\u{74}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{73}\u{29}\u{a}\u{20}\u{20}\u{20}\u{20}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{73}\u{65}\u{6c}\u{65}\u{63}\u{74}\u{28}\u{32}\u{2c}\u{20}\u{54}\u{2e}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{6c}\u{65}\u{76}\u{65}\u{6c}\u{28}\u{29}\u{29}\u{20}\u{3d}\u{3d}\u{20}\u{73}\u{74}\u{6b}\u{73}\u{69}\u{7a}\u{65}\u{29}\u{a}\u{20}\u{20}\u{20}\u{20}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{54}\u{2e}\u{71}\u{75}\u{65}\u{72}\u{79}\u{73}\u{74}\u{72}\u{28}\u{29}\u{20}\u{3d}\u{3d}\u{20}\u{73}\u{74}\u{73}\u{69}\u{7a}\u{65}\u{29}\u{a}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{27}\u{6f}\u{6b}\u{27}\u{a}\u{20}\u{20}")
1125+assert((res == "\u{6f}\u{6b}"))
1126+T.closestate(L)
1127+end
1128+print("\u{2b}")
1129+local function gsub
1130+(a,b,c)
1131+a,b=T.testC("\u{67}\u{73}\u{75}\u{62}\u{20}\u{32}\u{20}\u{33}\u{20}\u{34}\u{3b}\u{20}\u{67}\u{65}\u{74}\u{74}\u{6f}\u{70}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}",a,b,c)
1132+assert((b == 0x5))
1133+return a
1134+end
1135+assert((gsub("\u{61}\u{6c}\u{6f}\u{2e}\u{61}\u{6c}\u{6f}\u{2e}\u{75}\u{68}\u{75}\u{68}\u{2e}","\u{2e}","\u{2f}\u{2f}") == "\u{61}\u{6c}\u{6f}\u{2f}\u{2f}\u{61}\u{6c}\u{6f}\u{2f}\u{2f}\u{75}\u{68}\u{75}\u{68}\u{2f}\u{2f}"))
1136+assert((gsub("\u{61}\u{6c}\u{6f}\u{2e}\u{61}\u{6c}\u{6f}\u{2e}\u{75}\u{68}\u{75}\u{68}\u{2e}","\u{61}\u{6c}\u{6f}","\u{2f}\u{2f}") == "\u{2f}\u{2f}\u{2e}\u{2f}\u{2f}\u{2e}\u{75}\u{68}\u{75}\u{68}\u{2e}"))
1137+assert((gsub("","\u{61}\u{6c}\u{6f}","\u{2f}\u{2f}") == ""))
1138+assert((gsub("\u{2e}\u{2e}\u{2e}","\u{2e}","\u{2f}\u{2e}") == "\u{2f}\u{2e}\u{2f}\u{2e}\u{2f}\u{2e}"))
1139+assert((gsub("\u{2e}\u{2e}\u{2e}","\u{2e}\u{2e}\u{2e}","") == ""))
1140+local mt_xuxu,res,top = T.testC("\u{6e}\u{65}\u{77}\u{6d}\u{65}\u{74}\u{61}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{78}\u{75}\u{78}\u{75}\u{3b}\u{20}\u{67}\u{65}\u{74}\u{74}\u{6f}\u{70}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{33}")
1141+assert((((type(mt_xuxu) == "\u{74}\u{61}\u{62}\u{6c}\u{65}") and res) and (top == 0x3)))
1142+local d,res,top = T.testC("\u{6e}\u{65}\u{77}\u{6d}\u{65}\u{74}\u{61}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{78}\u{75}\u{78}\u{75}\u{3b}\u{20}\u{67}\u{65}\u{74}\u{74}\u{6f}\u{70}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{33}")
1143+assert(((mt_xuxu == d) and (not (res and (top == 0x3)))))
1144+d,res,top=T.testC("\u{6e}\u{65}\u{77}\u{6d}\u{65}\u{74}\u{61}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{78}\u{75}\u{78}\u{75}\u{31}\u{3b}\u{20}\u{67}\u{65}\u{74}\u{74}\u{6f}\u{70}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{33}")
1145+assert((((mt_xuxu ~= d) and res) and (top == 0x3)))
1146+x=T.newuserdata(0x0)
1147+;
1148+y=T.newuserdata(0x0)
1149+;
1150+T.testC("\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{78}\u{75}\u{78}\u{75}\u{3b}\u{20}\u{67}\u{65}\u{74}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{52}\u{3b}\u{20}\u{73}\u{65}\u{74}\u{6d}\u{65}\u{74}\u{61}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{32}",x)
1151+assert((getmetatable(x) == mt_xuxu))
1152+local res1,res2,top = T.testC("\u{74}\u{65}\u{73}\u{74}\u{75}\u{64}\u{61}\u{74}\u{61}\u{20}\u{2d}\u{31}\u{20}\u{78}\u{75}\u{78}\u{75}\u{a}\u{20}\u{20}\u{20}\u{9}\u{20}\u{9}\u{9}\u{9}\u{20}\u{20}\u{74}\u{65}\u{73}\u{74}\u{75}\u{64}\u{61}\u{74}\u{61}\u{20}\u{32}\u{20}\u{78}\u{75}\u{78}\u{75}\u{a}\u{9}\u{9}\u{9}\u{9}\u{20}\u{20}\u{67}\u{65}\u{74}\u{74}\u{6f}\u{70}\u{a}\u{9}\u{9}\u{9}\u{9}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{33}",x)
1153+assert(((res1 and res2) and (top == 0x4)))
1154+res1,res2,top=T.testC("\u{74}\u{65}\u{73}\u{74}\u{75}\u{64}\u{61}\u{74}\u{61}\u{20}\u{2d}\u{31}\u{20}\u{78}\u{75}\u{78}\u{75}\u{31}\u{a}\u{9}\u{9}\u{9}\u{20}\u{20}\u{20}\u{20}\u{74}\u{65}\u{73}\u{74}\u{75}\u{64}\u{61}\u{74}\u{61}\u{20}\u{32}\u{20}\u{78}\u{75}\u{78}\u{75}\u{31}\u{a}\u{9}\u{9}\u{9}\u{20}\u{20}\u{20}\u{20}\u{67}\u{65}\u{74}\u{74}\u{6f}\u{70}\u{a}\u{9}\u{9}\u{9}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{33}",x)
1155+assert((not (res1 and (not (res2 and (top == 0x4))))))
1156+res1,res2,top=T.testC("\u{74}\u{65}\u{73}\u{74}\u{75}\u{64}\u{61}\u{74}\u{61}\u{20}\u{2d}\u{31}\u{20}\u{78}\u{75}\u{78}\u{75}\u{32}\u{a}\u{9}\u{9}\u{9}\u{20}\u{20}\u{20}\u{20}\u{74}\u{65}\u{73}\u{74}\u{75}\u{64}\u{61}\u{74}\u{61}\u{20}\u{32}\u{20}\u{78}\u{75}\u{78}\u{75}\u{32}\u{a}\u{9}\u{9}\u{9}\u{20}\u{20}\u{20}\u{20}\u{67}\u{65}\u{74}\u{74}\u{6f}\u{70}\u{a}\u{9}\u{9}\u{9}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{33}",x)
1157+assert((not (res1 and (not (res2 and (top == 0x4))))))
1158+res1,res2,top=T.testC("\u{74}\u{65}\u{73}\u{74}\u{75}\u{64}\u{61}\u{74}\u{61}\u{20}\u{2d}\u{31}\u{20}\u{78}\u{75}\u{78}\u{75}\u{a}\u{9}\u{9}\u{9}\u{20}\u{20}\u{20}\u{20}\u{74}\u{65}\u{73}\u{74}\u{75}\u{64}\u{61}\u{74}\u{61}\u{20}\u{32}\u{20}\u{78}\u{75}\u{78}\u{75}\u{a}\u{9}\u{9}\u{9}\u{20}\u{20}\u{20}\u{20}\u{67}\u{65}\u{74}\u{74}\u{6f}\u{70}\u{a}\u{9}\u{9}\u{9}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{33}",y)
1159+assert((not (res1 and (not (res2 and (top == 0x4))))))
1160+do
1161+local r = debug.getregistry()
1162+assert(((r.xuxu == mt_xuxu) and (r.xuxu1 == d)))
1163+r.xuxu=nil
1164+;
1165+r.xuxu1=nil
1166+end
1167+print("\u{4f}\u{4b}")
desk/res/lua/cycled/attrib.luanew file+431
@@ -0,0 +1,431 @@
1+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{72}\u{65}\u{71}\u{75}\u{69}\u{72}\u{65}")
2+assert((require("\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}") == string))
3+assert((require("\u{6d}\u{61}\u{74}\u{68}") == math))
4+assert((require("\u{74}\u{61}\u{62}\u{6c}\u{65}") == table))
5+assert((require("\u{69}\u{6f}") == io))
6+assert((require("\u{6f}\u{73}") == os))
7+assert((require("\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}") == coroutine))
8+assert((type(package.path) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}"))
9+assert((type(package.cpath) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}"))
10+assert((type(package.loaded) == "\u{74}\u{61}\u{62}\u{6c}\u{65}"))
11+assert((type(package.preload) == "\u{74}\u{61}\u{62}\u{6c}\u{65}"))
12+assert((type(package.config) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}"))
13+print(("\u{70}\u{61}\u{63}\u{6b}\u{61}\u{67}\u{65}\u{20}\u{63}\u{6f}\u{6e}\u{66}\u{69}\u{67}\u{3a}\u{20}" .. string.gsub(package.config,"\u{a}","\u{7c}")))
14+do
15+local max = ((_soft and 0x64) or 0x7d0)
16+local t = {}
17+for i = 0x1, max
18+do
19+t[i]=string.rep("\u{3f}",((i % 0xa) + 0x1))
20+end
21+t[(# (t + 0x1))]="\u{3b}"
22+local path = table.concat(t,"\u{3b}")
23+local s,err = package.searchpath("\u{78}\u{75}\u{78}\u{75}",path)
24+assert((not ((s and string.find(err,string.rep("\u{78}\u{75}\u{78}\u{75}",0xa))) and (# (string.gsub(err,"\u{5b}\u{5e}\u{a}\u{5d}","") >= max)))))
25+local path = string.rep("\u{3f}",max)
26+local s,err = package.searchpath("\u{78}\u{75}\u{78}\u{75}",path)
27+assert((not (s and string.find(err,string.rep("\u{78}\u{75}\u{78}\u{75}",max)))))
28+end
29+do
30+local oldpath = package.path
31+package.path={}
32+local s,err = pcall(require,"\u{6e}\u{6f}\u{2d}\u{73}\u{75}\u{63}\u{68}\u{2d}\u{66}\u{69}\u{6c}\u{65}")
33+assert((not (s and string.find(err,"\u{70}\u{61}\u{63}\u{6b}\u{61}\u{67}\u{65}\u{2e}\u{70}\u{61}\u{74}\u{68}"))))
34+package.path=oldpath
35+end
36+do
37+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{27}\u{72}\u{65}\u{71}\u{75}\u{69}\u{72}\u{65}\u{27}\u{20}\u{6d}\u{65}\u{73}\u{73}\u{61}\u{67}\u{65}")
38+local oldpath = package.path
39+local oldcpath = package.cpath
40+package.path="\u{3f}\u{2e}\u{6c}\u{75}\u{61}\u{3b}\u{3f}\u{2f}\u{3f}"
41+package.cpath="\u{3f}\u{2e}\u{73}\u{6f}\u{3b}\u{3f}\u{2f}\u{69}\u{6e}\u{69}\u{74}"
42+local st,msg = pcall(require,"\u{58}\u{58}\u{58}")
43+local expected = "\u{6d}\u{6f}\u{64}\u{75}\u{6c}\u{65}\u{20}\u{27}\u{58}\u{58}\u{58}\u{27}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{66}\u{6f}\u{75}\u{6e}\u{64}\u{3a}\u{a}\u{9}\u{6e}\u{6f}\u{20}\u{66}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{70}\u{61}\u{63}\u{6b}\u{61}\u{67}\u{65}\u{2e}\u{70}\u{72}\u{65}\u{6c}\u{6f}\u{61}\u{64}\u{5b}\u{27}\u{58}\u{58}\u{58}\u{27}\u{5d}\u{a}\u{9}\u{6e}\u{6f}\u{20}\u{66}\u{69}\u{6c}\u{65}\u{20}\u{27}\u{58}\u{58}\u{58}\u{2e}\u{6c}\u{75}\u{61}\u{27}\u{a}\u{9}\u{6e}\u{6f}\u{20}\u{66}\u{69}\u{6c}\u{65}\u{20}\u{27}\u{58}\u{58}\u{58}\u{2f}\u{58}\u{58}\u{58}\u{27}\u{a}\u{9}\u{6e}\u{6f}\u{20}\u{66}\u{69}\u{6c}\u{65}\u{20}\u{27}\u{58}\u{58}\u{58}\u{2e}\u{73}\u{6f}\u{27}\u{a}\u{9}\u{6e}\u{6f}\u{20}\u{66}\u{69}\u{6c}\u{65}\u{20}\u{27}\u{58}\u{58}\u{58}\u{2f}\u{69}\u{6e}\u{69}\u{74}\u{27}"
44+assert((msg == expected))
45+package.path=oldpath
46+package.cpath=oldcpath
47+end
48+print("\u{2b}")
49+if (not _port) then
50+local dirsep = string.match(package.config,"\u{5e}\u{28}\u{5b}\u{5e}\u{a}\u{5d}\u{2b}\u{29}\u{a}")
51+local DIR = ("\u{6c}\u{69}\u{62}\u{73}" .. dirsep)
52+local function D
53+(x)
54+local x = string.gsub(x,"\u{2f}",dirsep)
55+return (DIR .. x)
56+end
57+local function DC
58+(x)
59+local ext = (((dirsep == "\u{5c}") and "\u{2e}\u{64}\u{6c}\u{6c}") or "\u{2e}\u{73}\u{6f}")
60+return D((x .. ext))
61+end
62+local function createfiles
63+(files,preextras,posextras)
64+for n,c in pairs(files)
65+do
66+io.output(D(n))
67+io.write(string.format(preextras,n))
68+io.write(c)
69+io.write(string.format(posextras,n))
70+io.close(io.output())
71+end
72+end
73+local function removefiles
74+(files)
75+for n in pairs(files)
76+do
77+os.remove(D(n))
78+end
79+end
80+local files = {["\u{6e}\u{61}\u{6d}\u{65}\u{73}\u{2e}\u{6c}\u{75}\u{61}"] = "\u{64}\u{6f}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{7b}\u{2e}\u{2e}\u{2e}\u{7d}\u{20}\u{65}\u{6e}\u{64}\u{a}",["\u{65}\u{72}\u{72}\u{2e}\u{6c}\u{75}\u{61}"] = "\u{42}\u{20}\u{3d}\u{20}\u{31}\u{35}\u{3b}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{61}\u{20}\u{2b}\u{20}\u{31}\u{3b}",["\u{73}\u{79}\u{6e}\u{65}\u{72}\u{72}\u{2e}\u{6c}\u{75}\u{61}"] = "\u{42}\u{20}\u{3d}",["\u{41}\u{2e}\u{6c}\u{75}\u{61}"] = "",["\u{42}\u{2e}\u{6c}\u{75}\u{61}"] = "\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{2e}\u{2e}\u{2e}\u{3d}\u{3d}\u{27}\u{42}\u{27}\u{29}\u{3b}\u{72}\u{65}\u{71}\u{75}\u{69}\u{72}\u{65}\u{20}\u{27}\u{41}\u{27}",["\u{41}\u{2e}\u{6c}\u{63}"] = "",["\u{41}"] = "",["\u{4c}"] = "",["\u{58}\u{58}\u{78}\u{58}"] = "",["\u{43}\u{2e}\u{6c}\u{75}\u{61}"] = "\u{70}\u{61}\u{63}\u{6b}\u{61}\u{67}\u{65}\u{2e}\u{6c}\u{6f}\u{61}\u{64}\u{65}\u{64}\u{5b}\u{2e}\u{2e}\u{2e}\u{5d}\u{20}\u{3d}\u{20}\u{32}\u{35}\u{3b}\u{20}\u{72}\u{65}\u{71}\u{75}\u{69}\u{72}\u{65}\u{27}\u{43}\u{27}"}
81+AA=nil
82+local extras = "\u{4e}\u{41}\u{4d}\u{45}\u{20}\u{3d}\u{20}\u{27}\u{25}\u{73}\u{27}\u{a}\u{52}\u{45}\u{51}\u{55}\u{49}\u{52}\u{45}\u{44}\u{20}\u{3d}\u{20}\u{2e}\u{2e}\u{2e}\u{a}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{41}\u{41}"
83+createfiles(files,"",extras)
84+assert((package.searchpath("\u{43}\u{2e}\u{6c}\u{75}\u{61}",D("\u{3f}"),"","") == D("\u{43}\u{2e}\u{6c}\u{75}\u{61}")))
85+assert((package.searchpath("\u{43}\u{2e}\u{6c}\u{75}\u{61}",D("\u{3f}"),"\u{2e}","\u{2e}") == D("\u{43}\u{2e}\u{6c}\u{75}\u{61}")))
86+assert((package.searchpath("\u{2d}\u{2d}\u{78}\u{2d}",D("\u{3f}"),"\u{2d}","\u{58}") == D("\u{58}\u{58}\u{78}\u{58}")))
87+assert((package.searchpath("\u{2d}\u{2d}\u{2d}\u{78}\u{58}",D("\u{3f}"),"\u{2d}\u{2d}\u{2d}","\u{58}\u{58}") == D("\u{58}\u{58}\u{78}\u{58}")))
88+assert((package.searchpath(D("\u{43}\u{2e}\u{6c}\u{75}\u{61}"),"\u{3f}",dirsep) == D("\u{43}\u{2e}\u{6c}\u{75}\u{61}")))
89+assert((package.searchpath("\u{2e}\u{5c}\u{43}\u{2e}\u{6c}\u{75}\u{61}",D("\u{3f}"),"\u{5c}") == D("\u{2e}\u{2f}\u{43}\u{2e}\u{6c}\u{75}\u{61}")))
90+local oldpath = package.path
91+package.path=string.gsub("\u{44}\u{2f}\u{3f}\u{2e}\u{6c}\u{75}\u{61}\u{3b}\u{44}\u{2f}\u{3f}\u{2e}\u{6c}\u{63}\u{3b}\u{44}\u{2f}\u{3f}\u{3b}\u{44}\u{2f}\u{3f}\u{3f}\u{78}\u{3f}\u{3b}\u{44}\u{2f}\u{4c}","\u{44}\u{2f}",DIR)
92+local try = function (p,n,r,ext)
93+NAME=nil
94+local rr,x = require(p)
95+assert((NAME == n))
96+assert((REQUIRED == p))
97+assert((rr == r))
98+assert((ext == x))
99+end
100+local a = require("\u{6e}\u{61}\u{6d}\u{65}\u{73}")
101+assert(((a[0x1] == "\u{6e}\u{61}\u{6d}\u{65}\u{73}") and (a[0x2] == D("\u{6e}\u{61}\u{6d}\u{65}\u{73}\u{2e}\u{6c}\u{75}\u{61}"))))
102+local st,msg = pcall(require,"\u{65}\u{72}\u{72}")
103+assert((not ((st and string.find(msg,"\u{61}\u{72}\u{69}\u{74}\u{68}\u{6d}\u{65}\u{74}\u{69}\u{63}")) and (B == 0xf))))
104+st,msg=pcall(require,"\u{73}\u{79}\u{6e}\u{65}\u{72}\u{72}")
105+assert((not (st and string.find(msg,"\u{65}\u{72}\u{72}\u{6f}\u{72}\u{20}\u{6c}\u{6f}\u{61}\u{64}\u{69}\u{6e}\u{67}\u{20}\u{6d}\u{6f}\u{64}\u{75}\u{6c}\u{65}"))))
106+assert((package.searchpath("\u{43}",package.path) == D("\u{43}\u{2e}\u{6c}\u{75}\u{61}")))
107+assert((require("\u{43}") == 0x19))
108+assert((require("\u{43}") == 0x19))
109+AA=nil
110+try("\u{42}","\u{42}\u{2e}\u{6c}\u{75}\u{61}",true,"\u{6c}\u{69}\u{62}\u{73}\u{2f}\u{42}\u{2e}\u{6c}\u{75}\u{61}")
111+assert(package.loaded.B)
112+assert((require("\u{42}") == true))
113+assert(package.loaded.A)
114+assert((require("\u{43}") == 0x19))
115+package.loaded.A=nil
116+try("\u{42}",nil,true,nil)
117+try("\u{41}","\u{41}\u{2e}\u{6c}\u{75}\u{61}",true,"\u{6c}\u{69}\u{62}\u{73}\u{2f}\u{41}\u{2e}\u{6c}\u{75}\u{61}")
118+package.loaded.A=nil
119+os.remove(D("\u{41}\u{2e}\u{6c}\u{75}\u{61}"))
120+AA={}
121+try("\u{41}","\u{41}\u{2e}\u{6c}\u{63}",AA,"\u{6c}\u{69}\u{62}\u{73}\u{2f}\u{41}\u{2e}\u{6c}\u{63}")
122+assert((package.searchpath("\u{41}",package.path) == D("\u{41}\u{2e}\u{6c}\u{63}")))
123+assert((require("\u{41}") == AA))
124+AA=false
125+try("\u{4b}","\u{4c}",false,"\u{6c}\u{69}\u{62}\u{73}\u{2f}\u{4c}")
126+try("\u{4b}","\u{4c}",false,"\u{6c}\u{69}\u{62}\u{73}\u{2f}\u{4c}")
127+assert((rawget(_G,"\u{5f}\u{52}\u{45}\u{51}\u{55}\u{49}\u{52}\u{45}\u{44}\u{4e}\u{41}\u{4d}\u{45}") == nil))
128+AA="\u{78}"
129+try("\u{58}","\u{58}\u{58}\u{78}\u{58}",AA,"\u{6c}\u{69}\u{62}\u{73}\u{2f}\u{58}\u{58}\u{78}\u{58}")
130+removefiles(files)
131+NAME,REQUIRED,AA,B=nil
132+local _G = _G
133+package.path=string.gsub("\u{44}\u{2f}\u{3f}\u{2e}\u{6c}\u{75}\u{61}\u{3b}\u{44}\u{2f}\u{3f}\u{2f}\u{69}\u{6e}\u{69}\u{74}\u{2e}\u{6c}\u{75}\u{61}","\u{44}\u{2f}",DIR)
134+files={["\u{50}\u{31}\u{2f}\u{69}\u{6e}\u{69}\u{74}\u{2e}\u{6c}\u{75}\u{61}"] = "\u{41}\u{41}\u{20}\u{3d}\u{20}\u{31}\u{30}",["\u{50}\u{31}\u{2f}\u{78}\u{75}\u{78}\u{75}\u{2e}\u{6c}\u{75}\u{61}"] = "\u{41}\u{41}\u{20}\u{3d}\u{20}\u{32}\u{30}"}
135+createfiles(files,"\u{5f}\u{45}\u{4e}\u{56}\u{20}\u{3d}\u{20}\u{7b}\u{7d}\u{a}","\u{a}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{5f}\u{45}\u{4e}\u{56}\u{a}")
136+AA=0x0
137+local m,ext = assert(require("\u{50}\u{31}"))
138+assert((ext == "\u{6c}\u{69}\u{62}\u{73}\u{2f}\u{50}\u{31}\u{2f}\u{69}\u{6e}\u{69}\u{74}\u{2e}\u{6c}\u{75}\u{61}"))
139+assert(((AA == 0x0) and (m.AA == 0xa)))
140+assert((require("\u{50}\u{31}") == m))
141+assert((require("\u{50}\u{31}") == m))
142+assert((package.searchpath("\u{50}\u{31}\u{2e}\u{78}\u{75}\u{78}\u{75}",package.path) == D("\u{50}\u{31}\u{2f}\u{78}\u{75}\u{78}\u{75}\u{2e}\u{6c}\u{75}\u{61}")))
143+m.xuxu,ext=assert(require("\u{50}\u{31}\u{2e}\u{78}\u{75}\u{78}\u{75}"))
144+assert(((AA == 0x0) and (m.xuxu.AA == 0x14)))
145+assert((ext == "\u{6c}\u{69}\u{62}\u{73}\u{2f}\u{50}\u{31}\u{2f}\u{78}\u{75}\u{78}\u{75}\u{2e}\u{6c}\u{75}\u{61}"))
146+assert((require("\u{50}\u{31}\u{2e}\u{78}\u{75}\u{78}\u{75}") == m.xuxu))
147+assert((require("\u{50}\u{31}\u{2e}\u{78}\u{75}\u{78}\u{75}") == m.xuxu))
148+assert(((require("\u{50}\u{31}") == m) and (m.AA == 0xa)))
149+removefiles(files)
150+AA=nil
151+package.path=""
152+assert((not pcall(require,"\u{66}\u{69}\u{6c}\u{65}\u{5f}\u{64}\u{6f}\u{65}\u{73}\u{5f}\u{6e}\u{6f}\u{74}\u{5f}\u{65}\u{78}\u{69}\u{73}\u{74}")))
153+package.path="\u{3f}\u{3f}\u{0}\u{3f}"
154+assert((not pcall(require,"\u{66}\u{69}\u{6c}\u{65}\u{5f}\u{64}\u{6f}\u{65}\u{73}\u{5f}\u{6e}\u{6f}\u{74}\u{5f}\u{65}\u{78}\u{69}\u{73}\u{74}\u{31}")))
155+package.path=oldpath
156+local fname = "\u{66}\u{69}\u{6c}\u{65}\u{5f}\u{64}\u{6f}\u{65}\u{73}\u{5f}\u{6e}\u{6f}\u{74}\u{5f}\u{65}\u{78}\u{69}\u{73}\u{74}\u{32}"
157+local m,err = pcall(require,fname)
158+for t in string.gmatch((package.path .. ("\u{3b}" .. package.cpath)),"\u{5b}\u{5e}\u{3b}\u{5d}\u{2b}")
159+do
160+t=string.gsub(t,"\u{3f}",fname)
161+assert(string.find(err,t,0x1,true))
162+end
163+do
164+local searchers = package.searchers
165+package.searchers=0x3
166+local st,msg = pcall(require,"\u{61}")
167+assert((not (st and string.find(msg,"\u{6d}\u{75}\u{73}\u{74}\u{20}\u{62}\u{65}\u{20}\u{61}\u{20}\u{74}\u{61}\u{62}\u{6c}\u{65}"))))
168+package.searchers=searchers
169+end
170+local function import
171+(...)
172+local f = {...}
173+return function (m)
174+for i = 0x1, (# f)
175+do
176+m[f[i]]=_G[f[i]]
177+end
178+end
179+end
180+assert((not pcall(module,"\u{58}\u{55}\u{58}\u{55}")))
181+local p = ""
182+local st,err,when = package.loadlib(DC("\u{6c}\u{69}\u{62}\u{31}"),"\u{2a}")
183+if (not st) then
184+local f,err,when = package.loadlib("\u{64}\u{6f}\u{6e}\u{6f}\u{74}\u{65}\u{78}\u{69}\u{73}\u{74}",(p .. "\u{78}\u{75}\u{78}\u{75}"))
185+assert((not ((f and (type(err) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}")) and (when == "\u{61}\u{62}\u{73}\u{65}\u{6e}\u{74}"))))
186+;
187+(Message or print)("\u{a}\u{20}\u{3e}\u{3e}\u{3e}\u{20}\u{63}\u{61}\u{6e}\u{6e}\u{6f}\u{74}\u{20}\u{6c}\u{6f}\u{61}\u{64}\u{20}\u{64}\u{79}\u{6e}\u{61}\u{6d}\u{69}\u{63}\u{20}\u{6c}\u{69}\u{62}\u{72}\u{61}\u{72}\u{79}\u{20}\u{3c}\u{3c}\u{3c}\u{a}")
188+print(err,when)
189+else
190+local f = assert(package.loadlib(DC("\u{6c}\u{69}\u{62}\u{31}"),(p .. "\u{6f}\u{6e}\u{65}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}")))
191+local a,b = f(0xf,0x19)
192+assert(((a == 0x19) and (b == 0xf)))
193+f=assert(package.loadlib(DC("\u{6c}\u{69}\u{62}\u{31}"),(p .. "\u{61}\u{6e}\u{6f}\u{74}\u{68}\u{65}\u{72}\u{66}\u{75}\u{6e}\u{63}")))
194+assert((f(0xa,0x14) == "\u{31}\u{30}\u{25}\u{32}\u{30}\u{a}"))
195+local f,err,when = package.loadlib(DC("\u{6c}\u{69}\u{62}\u{31}"),(p .. "\u{78}\u{75}\u{78}\u{75}"))
196+assert((not ((f and (type(err) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}")) and (when == "\u{69}\u{6e}\u{69}\u{74}"))))
197+f,err,when=package.loadlib("\u{64}\u{6f}\u{6e}\u{6f}\u{74}\u{65}\u{78}\u{69}\u{73}\u{74}",(p .. "\u{78}\u{75}\u{78}\u{75}"))
198+assert((not ((f and (type(err) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}")) and (when == "\u{6f}\u{70}\u{65}\u{6e}"))))
199+f=assert(package.loadlib(DC("\u{6c}\u{69}\u{62}\u{31}\u{31}"),(p .. "\u{6c}\u{75}\u{61}\u{6f}\u{70}\u{65}\u{6e}\u{5f}\u{6c}\u{69}\u{62}\u{31}\u{31}")))
200+assert((f() == "\u{65}\u{78}\u{70}\u{6f}\u{72}\u{74}\u{65}\u{64}"))
201+package.cpath=DC("\u{3f}")
202+local lib2,ext = require("\u{6c}\u{69}\u{62}\u{32}\u{2d}\u{76}\u{32}")
203+assert(string.find(ext,"\u{6c}\u{69}\u{62}\u{73}\u{2f}\u{6c}\u{69}\u{62}\u{32}\u{2d}\u{76}\u{32}",0x1,true))
204+assert(((_ENV.x == "\u{6c}\u{69}\u{62}\u{32}\u{2d}\u{76}\u{32}") and (_ENV.y == DC("\u{6c}\u{69}\u{62}\u{32}\u{2d}\u{76}\u{32}"))))
205+assert((lib2.id("\u{78}") == true))
206+local fs,ext = require("\u{6c}\u{69}\u{62}\u{31}\u{2e}\u{73}\u{75}\u{62}")
207+assert(((_ENV.x == "\u{6c}\u{69}\u{62}\u{31}\u{2e}\u{73}\u{75}\u{62}") and (_ENV.y == DC("\u{6c}\u{69}\u{62}\u{31}"))))
208+assert(string.find(ext,"\u{6c}\u{69}\u{62}\u{73}\u{2f}\u{6c}\u{69}\u{62}\u{31}",0x1,true))
209+assert((fs.id(0x2d) == 0x2d))
210+_ENV.x,_ENV.y=nil
211+end
212+_ENV=_G
213+do
214+local p = package
215+package={}
216+p.preload.pl=function (...)
217+local _ENV = {...}
218+function xuxu(x)
219+return (x + 0x14)
220+end
221+return _ENV
222+end
223+local pl,ext = require("\u{70}\u{6c}")
224+assert((require("\u{70}\u{6c}") == pl))
225+assert((pl.xuxu(0xa) == 0x1e))
226+assert((((pl[0x1] == "\u{70}\u{6c}") and (pl[0x2] == "\u{3a}\u{70}\u{72}\u{65}\u{6c}\u{6f}\u{61}\u{64}\u{3a}")) and (ext == "\u{3a}\u{70}\u{72}\u{65}\u{6c}\u{6f}\u{61}\u{64}\u{3a}")))
227+package=p
228+assert((type(package.path) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}"))
229+end
230+print("\u{2b}")
231+end
232+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{61}\u{73}\u{73}\u{69}\u{67}\u{6e}\u{6d}\u{65}\u{6e}\u{74}\u{73}\u{2c}\u{20}\u{6c}\u{6f}\u{67}\u{69}\u{63}\u{61}\u{6c}\u{20}\u{6f}\u{70}\u{65}\u{72}\u{61}\u{74}\u{6f}\u{72}\u{73}\u{2c}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{63}\u{6f}\u{6e}\u{73}\u{74}\u{72}\u{75}\u{63}\u{74}\u{6f}\u{72}\u{73}")
233+local res,res2 = 0x1b
234+local a,b = 0x1,(0x2 + 0x3)
235+assert(((a == 0x1) and (b == 0x5)))
236+a={}
237+local function f
238+()
239+return 0xa,0xb,0xc
240+end
241+a.x,b,a[0x1]=0x1,0x2,f()
242+assert((((a.x == 0x1) and (b == 0x2)) and (a[0x1] == 0xa)))
243+a[f()],b,a[(f() + 0x3)]=f(),a,"\u{78}"
244+assert((((a[0xa] == 0xa) and (b == a)) and (a[0xd] == "\u{78}")))
245+do
246+local f = function (n)
247+local x = {}
248+;
249+for i = 0x1, n
250+do
251+x[i]=i
252+end
253+;
254+return table.unpack(x)
255+end
256+;
257+local a,b,c
258+a,b=0x0,f(0x1)
259+assert(((a == 0x0) and (b == 0x1)))
260+a,b=0x0,f(0x1)
261+assert(((a == 0x0) and (b == 0x1)))
262+a,b,c=0x0,0x5,f(0x4)
263+assert((((a == 0x0) and (b == 0x5)) and (c == 0x1)))
264+a,b,c=0x0,0x5,f(0x0)
265+assert((((a == 0x0) and (b == 0x5)) and (c == nil)))
266+end
267+local a,b,c,d = (0x1 and nil),(0x1 or nil),(0x1 and (nil or 0x1)),0x6
268+assert((not (((a and b) and c) and (d == 0x6))))
269+d=0x14
270+a,b,c,d=f()
271+assert(((((a == 0xa) and (b == 0xb)) and (c == 0xc)) and (d == nil)))
272+a,b=f(),0x1,0x2,0x3,f()
273+assert(((a == 0xa) and (b == 0x1)))
274+assert((((a < b) == false) and ((a > b) == true)))
275+assert(((0xa and 0x2) == 0x2))
276+assert(((0xa or 0x2) == 0xa))
277+assert(((0xa or assert(nil)) == 0xa))
278+assert((not (nil and assert(nil))))
279+assert(((nil or "\u{61}\u{6c}\u{6f}") == "\u{61}\u{6c}\u{6f}"))
280+assert(((nil and 0xa) == nil))
281+assert(((false and 0xa) == false))
282+assert(((true or 0xa) == true))
283+assert(((false or 0xa) == 0xa))
284+assert((false ~= nil))
285+assert((nil ~= false))
286+assert((not (nil == true)))
287+assert((not (not (nil == false))))
288+assert((not (not (0x1 == true))))
289+assert((not (not (a == true))))
290+assert((not (not ((0x6 or nil) == true))))
291+assert((not (not ((nil and 0x38) == false))))
292+assert((not (not ((nil and true) == false))))
293+assert((not (0xa == false)))
294+assert((not ({} == false)))
295+assert((not (0.5 == false)))
296+assert((not ("\u{78}" == false)))
297+assert(({} ~= {}))
298+print("\u{2b}")
299+a={}
300+a[true]=0x14
301+a[false]=0xa
302+assert(((a[(0x1 < 0x2)] == 0x14) and (a[(0x1 > 0x2)] == 0xa)))
303+function f(a)
304+return a
305+end
306+local a = {}
307+for i = 0xbb8, (- 0xbb8), (- 0x1)
308+do
309+a[(i + 0.0)]=i
310+;
311+end
312+a[1e31]="\u{61}\u{6c}\u{6f}"
313+;
314+a[true]=0xa
315+;
316+a[false]=0x14
317+assert((((a[1e31] == "\u{61}\u{6c}\u{6f}") and (a[(not 0x1)] == 0x14)) and (a[(0xa < 0x14)] == 0xa)))
318+for i = 0xbb8, (- 0xbb8), (- 0x1)
319+do
320+assert((a[i] == i))
321+;
322+end
323+a[print]=assert
324+a[f]=print
325+a[a]=a
326+assert((a[a][a][a][a][print] == assert))
327+a[print]((a[a[f]] == a[print]))
328+assert((not pcall(function ()
329+local a = {}
330+;
331+a[nil]=0xa
332+end)))
333+assert((not pcall(function ()
334+local a = {[nil] = 0xa}
335+end)))
336+assert((a[nil] == undef))
337+a=nil
338+local a,b,c
339+a={0xa,0x9,0x8,0x7,0x6,0x5,0x4,0x3,0x2,[(- 0x3)] = "\u{61}",[f] = print,["\u{61}"] = "\u{61}",["\u{62}"] = "\u{61}\u{62}"}
340+a,a.x,a.y=a,a[(- 0x3)]
341+assert((((((a[0x1] == 0xa) and (a[(- 0x3)] == a.a)) and (a[f] == print)) and (a.x == "\u{61}")) and (not a.y)))
342+a[0x1],f(a)[0x2],b,c={["\u{61}\u{6c}\u{6f}"] = assert},0xa,a[0x1],a[f],0x6,0xa,0x17,f(a),0x2
343+a[0x1].alo((((a[0x2] == 0xa) and (b == 0xa)) and (c == print)))
344+a.aVeryLongName012345678901234567890123456789012345678901234567890123456789=0xa
345+local function foo
346+()
347+return a.aVeryLongName012345678901234567890123456789012345678901234567890123456789
348+end
349+assert(((foo() == 0xa) and (a.aVeryLongName012345678901234567890123456789012345678901234567890123456789 == 0xa)))
350+do
351+local function foo
352+()
353+local _ENV <const> = 0xb
354+X="\u{68}\u{69}"
355+end
356+local st,msg = pcall(foo)
357+assert((not (st and string.find(msg,"\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}"))))
358+end
359+local maxint = math.maxinteger
360+while ((maxint ~= (maxint + 0.0)) or ((maxint - 0x1) ~= (maxint - 1.0))) do
361+maxint=(maxint // 0x2)
362+end
363+local maxintF = (maxint + 0.0)
364+assert((((maxintF == maxint) and (math.type(maxintF) == "\u{66}\u{6c}\u{6f}\u{61}\u{74}")) and (maxintF >= (2.0 ^ 0xe))))
365+a[maxintF]=0xa
366+;
367+a[(maxintF - 1.0)]=0xb
368+;
369+a[(- maxintF)]=0xc
370+;
371+a[(- (maxintF + 1.0))]=0xd
372+;
373+assert(((((a[maxint] == 0xa) and (a[(maxint - 0x1)] == 0xb)) and (a[(- maxint)] == 0xc)) and (a[(- (maxint + 0x1))] == 0xd)))
374+a[maxint]=0x14
375+a[(- maxint)]=0x16
376+assert(((((a[maxintF] == 0x14) and (a[(maxintF - 1.0)] == 0xb)) and (a[(- maxintF)] == 0x16)) and (a[(- (maxintF + 1.0))] == 0xd)))
377+a=nil
378+do
379+local a,i,j,b
380+a={"\u{61}","\u{62}"}
381+;
382+i=0x1
383+;
384+j=0x2
385+;
386+b=a
387+i,a[i],a,j,a[j],a[(i + j)]=j,i,i,b,j,i
388+assert(((((((i == 0x2) and (b[0x1] == 0x1)) and (a == 0x1)) and (j == b)) and (b[0x2] == 0x2)) and (b[0x3] == 0x1)))
389+a={}
390+local function foo
391+()
392+b,a.x,a=a,0xa,0x14
393+end
394+foo()
395+assert(((a == 0x14) and (b.x == 0xa)))
396+end
397+do
398+local a,i,j,b
399+a={"\u{61}","\u{62}"}
400+;
401+i=0x1
402+;
403+j=0x2
404+;
405+b=a
406+local function foo
407+()
408+i,a[i],a,j,a[j],a[(i + j)]=j,i,i,b,j,i
409+end
410+foo()
411+assert(((((((i == 0x2) and (b[0x1] == 0x1)) and (a == 0x1)) and (j == b)) and (b[0x2] == 0x2)) and (b[0x3] == 0x1)))
412+local t = {}
413+(function (a)
414+t[a],a=0xa,0x14
415+end)(0x1)
416+;
417+assert((t[0x1] == 0xa))
418+end
419+local function foo
420+()
421+local a
422+return function ()
423+local b
424+a,b=0x3,0xe
425+return a,b
426+end
427+end
428+local a,b = foo()()
429+assert(((a == 0x3) and (b == 0xe)))
430+print("\u{4f}\u{4b}")
431+return res
desk/res/lua/cycled/bar.luanew file+2
@@ -0,0 +1,2 @@
1+assert((0xa .. (0x14 .. (- (0x1e == "\u{31}\u{30}\u{32}\u{30}\u{2d}\u{33}\u{30}")))))
2+x=(- (0x2 ^ (- (0x3 ^ 0x4))))
desk/res/lua/cycled/big.luanew file+67
@@ -0,0 +1,67 @@
1+if _soft then
2+return "\u{61}"
3+end
4+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{6c}\u{61}\u{72}\u{67}\u{65}\u{20}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{73}")
5+local debug = require("\u{64}\u{65}\u{62}\u{75}\u{67}")
6+local lim = ((0x2 ^ 0x12) + 0x3e8)
7+local prog = {"\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{79}\u{20}\u{3d}\u{20}\u{7b}\u{30}"}
8+for i = 0x1, lim
9+do
10+prog[(# (prog + 0x1))]=i
11+end
12+prog[(# (prog + 0x1))]="\u{7d}\u{a}"
13+prog[(# (prog + 0x1))]="\u{58}\u{20}\u{3d}\u{20}\u{79}\u{a}"
14+prog[(# (prog + 0x1))]=("\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{58}\u{5b}\u{25}\u{64}\u{5d}\u{20}\u{3d}\u{3d}\u{20}\u{25}\u{64}\u{29}"):format((lim - 0x1),(lim - 0x2))
15+prog[(# (prog + 0x1))]="\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{30}"
16+prog=table.concat(prog,"\u{3b}")
17+local env = {["\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}"] = string,["\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}"] = assert}
18+local f = assert(load(prog,nil,nil,env))
19+f()
20+assert(((env.X[lim] == (lim - 0x1)) and (env.X[(lim + 0x1)] == lim)))
21+for k in pairs(env)
22+do
23+env[k]=undef
24+end
25+setmetatable(env,{["\u{5f}\u{5f}\u{69}\u{6e}\u{64}\u{65}\u{78}"] = function (t,n)
26+coroutine.yield("\u{67}")
27+;
28+return _G[n]
29+end,["\u{5f}\u{5f}\u{6e}\u{65}\u{77}\u{69}\u{6e}\u{64}\u{65}\u{78}"] = function (t,n,v)
30+coroutine.yield("\u{73}")
31+;
32+_G[n]=v
33+end})
34+X=nil
35+local co = coroutine.wrap(f)
36+assert((co() == "\u{73}"))
37+assert((co() == "\u{67}"))
38+assert((co() == "\u{67}"))
39+assert((co() == 0x0))
40+assert(((X[lim] == (lim - 0x1)) and (X[(lim + 0x1)] == lim)))
41+getmetatable(env).__index=function ()
42+
43+end
44+getmetatable(env).__newindex=function ()
45+
46+end
47+local e,m = pcall(f)
48+assert((not (e and m:find("\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{27}\u{58}\u{27}"))))
49+getmetatable(env).__newindex=function ()
50+error("\u{68}\u{69}")
51+end
52+local e,m = xpcall(f,debug.traceback)
53+assert((not (e and m:find("\u{27}\u{6e}\u{65}\u{77}\u{69}\u{6e}\u{64}\u{65}\u{78}\u{27}"))))
54+f,X=nil
55+coroutine.yield("\u{62}")
56+if ((0x2 ^ 0x20) == 0x0) then
57+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{6c}\u{65}\u{6e}\u{67}\u{74}\u{68}\u{20}\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}")
58+local repstrings = 0xc0
59+local ssize = (math.ceil(((2.0 ^ 0x20) / repstrings)) + 0x1)
60+assert(((repstrings * ssize) > (2.0 ^ 0x20)))
61+local longs = string.rep("\u{0}",ssize)
62+local rep = assert(load(("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{2e}\u{2e}\u{2e}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}" .. string.rep("\u{61}",repstrings,"\u{2e}\u{2e}"))))
63+local a,b = pcall(rep,longs)
64+assert((not (a and string.find(b,"\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}"))))
65+end
66+print("\u{4f}\u{4b}")
67+return "\u{61}"
desk/res/lua/cycled/bitwise.luanew file+309
@@ -0,0 +1,309 @@
1+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{62}\u{69}\u{74}\u{77}\u{69}\u{73}\u{65}\u{20}\u{6f}\u{70}\u{65}\u{72}\u{61}\u{74}\u{69}\u{6f}\u{6e}\u{73}")
2+require("\u{62}\u{77}\u{63}\u{6f}\u{65}\u{72}\u{63}\u{69}\u{6f}\u{6e}")
3+local numbits = (string.packsize("\u{6a}") * 0x8)
4+assert((~ (0x0 == (- 0x1))))
5+assert(((0x1 << (numbits - 0x1)) == math.mininteger))
6+local a,b,c,d
7+a=0xffffffffffffffff
8+assert((a == (- (0x1 and (a & (- ((0x1 == a) and ((a & 0x23) == 0x23))))))))
9+a=0xf0f0f0f0f0f0f0f0
10+assert((a | (- (0x1 == (- 0x1)))))
11+assert(((((a ~ a) == 0x0) and ((a ~ 0x0) == a)) and (a ~ (~ (a == (- 0x1))))))
12+assert(((a >> 0x4) == (~ a)))
13+a=0xf0
14+;
15+b=0xcc
16+;
17+c=0xaa
18+;
19+d=0xfd
20+assert(((a | (b ~ (c & d))) == 0xf4))
21+a=240.0
22+;
23+b=204.0
24+;
25+c="\u{30}\u{78}\u{41}\u{41}\u{2e}\u{30}"
26+;
27+d="\u{30}\u{78}\u{46}\u{44}\u{2e}\u{30}"
28+assert(((a | (b ~ (c & d))) == 0xf4))
29+a=0xf0000000
30+;
31+b=0xcc000000
32+;
33+c=0xaa000000
34+;
35+d=0xfd000000
36+assert(((a | (b ~ (c & d))) == 0xf4000000))
37+assert((~ (~ ((a == a) and (~ (a == (- ((0x1 ~ a) and (- (d == (~ (d + 0x1))))))))))))
38+a=(a << 0x20)
39+b=(b << 0x20)
40+c=(c << 0x20)
41+d=(d << 0x20)
42+assert(((a | (b ~ (c & d))) == (0xf4000000 << 0x20)))
43+assert((~ (~ ((a == a) and (~ (a == (- ((0x1 ~ a) and (- (d == (~ (d + 0x1))))))))))))
44+do
45+local code = string.format("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2d}\u{31}\u{20}\u{3e}\u{3e}\u{20}\u{25}\u{64}",math.maxinteger)
46+assert((load(code)() == 0x0))
47+local code = string.format("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2d}\u{31}\u{20}\u{3e}\u{3e}\u{20}\u{25}\u{64}",math.mininteger)
48+assert((load(code)() == 0x0))
49+local code = string.format("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2d}\u{31}\u{20}\u{3c}\u{3c}\u{20}\u{25}\u{64}",math.maxinteger)
50+assert((load(code)() == 0x0))
51+local code = string.format("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2d}\u{31}\u{20}\u{3c}\u{3c}\u{20}\u{25}\u{64}",math.mininteger)
52+assert((load(code)() == 0x0))
53+end
54+assert((- (((0x1 >> 0x1) == ((0x1 << (numbits - 0x1)) - 0x1)) and ((0x1 << 0x1f) == 0x80000000))))
55+assert((- ((0x1 >> (numbits - 0x1)) == 0x1)))
56+assert((- (((0x1 >> numbits) == 0x0) and (- (0x1 >> (- ((numbits == 0x0) and (- (((0x1 << numbits) == 0x0) and (- (0x1 << (- (numbits == 0x0)))))))))))))
57+assert(((0x1 >> math.mininteger) == 0x0))
58+assert(((0x1 >> math.maxinteger) == 0x0))
59+assert(((0x1 << math.mininteger) == 0x0))
60+assert(((0x1 << math.maxinteger) == 0x0))
61+assert(((((0x2 ^ 0x1e) - 0x1) << (0x2 ^ 0x1e)) == 0x0))
62+assert(((((0x2 ^ 0x1e) - 0x1) >> (0x2 ^ 0x1e)) == 0x0))
63+assert((0x1 >> (- ((0x3 == (0x1 << 0x3)) and ((0x3e8 >> 0x5) == (0x3e8 << (- 0x5)))))))
64+assert((("\u{30}\u{78}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}" | 0x0) == (- 0x1)))
65+assert((("\u{30}\u{78}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{65}" & "\u{2d}\u{31}") == (- 0x2)))
66+assert((("\u{20}\u{9}\u{2d}\u{30}\u{78}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{65}\u{a}\u{9}" & "\u{2d}\u{31}") == 0x2))
67+assert((("\u{20}\u{20}\u{20}\u{a}\u{20}\u{20}\u{2d}\u{34}\u{35}\u{20}\u{20}\u{9}\u{20}" >> "\u{20}\u{20}\u{2d}\u{32}\u{20}\u{20}") == (- (0x2d * 0x4))))
68+assert((("\u{31}\u{32}\u{33}\u{34}\u{2e}\u{30}" << "\u{35}\u{2e}\u{30}") == (0x4d2 * 0x20)))
69+assert((("\u{30}\u{78}\u{66}\u{66}\u{66}\u{66}\u{2e}\u{30}" ~ "\u{30}\u{78}\u{41}\u{41}\u{41}\u{41}") == 0x5555))
70+assert((~ ("\u{30}\u{78}\u{30}\u{2e}\u{30}\u{30}\u{30}\u{70}\u{34}" == (- 0x1))))
71+assert(((("\u{37}" .. 0x3) << 0x1) == 0x92))
72+assert(((0xffffffff >> (0x1 .. "\u{39}")) == 0x1fff))
73+assert(((0xa | (0x1 .. "\u{39}")) == 0x1b))
74+do
75+local st,msg = pcall(function ()
76+return (0x4 & "\u{61}")
77+end)
78+assert(string.find(msg,"\u{27}\u{62}\u{61}\u{6e}\u{64}\u{27}"))
79+local st,msg = pcall(function ()
80+return (~ "\u{61}")
81+end)
82+assert(string.find(msg,"\u{27}\u{62}\u{6e}\u{6f}\u{74}\u{27}"))
83+end
84+assert((not pcall(function ()
85+return ("\u{30}\u{78}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{2e}\u{30}" | 0x0)
86+end)))
87+assert((not pcall(function ()
88+return ("\u{30}\u{78}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{0}" | 0x0)
89+end)))
90+print("\u{2b}")
91+package.preload.bit32=function ()
92+local bit = {}
93+function bit.bnot(a)
94+return (~ (a & 0xffffffff))
95+end
96+function bit.band(x,y,z, ...)
97+if (not z) then
98+return (((x or (- 0x1)) & (y or (- 0x1))) & 0xffffffff)
99+else
100+local arg = {...}
101+local res = ((x & y) & z)
102+for i = 0x1, (# arg)
103+do
104+res=(res & arg[i])
105+end
106+return (res & 0xffffffff)
107+end
108+end
109+function bit.bor(x,y,z, ...)
110+if (not z) then
111+return (((x or 0x0) | (y or 0x0)) & 0xffffffff)
112+else
113+local arg = {...}
114+local res = ((x | y) | z)
115+for i = 0x1, (# arg)
116+do
117+res=(res | arg[i])
118+end
119+return (res & 0xffffffff)
120+end
121+end
122+function bit.bxor(x,y,z, ...)
123+if (not z) then
124+return (((x or 0x0) ~ (y or 0x0)) & 0xffffffff)
125+else
126+local arg = {...}
127+local res = ((x ~ y) ~ z)
128+for i = 0x1, (# arg)
129+do
130+res=(res ~ arg[i])
131+end
132+return (res & 0xffffffff)
133+end
134+end
135+function bit.btest(...)
136+return (bit.band(...) ~= 0x0)
137+end
138+function bit.lshift(a,b)
139+return (((a & 0xffffffff) << b) & 0xffffffff)
140+end
141+function bit.rshift(a,b)
142+return (((a & 0xffffffff) >> b) & 0xffffffff)
143+end
144+function bit.arshift(a,b)
145+a=(a & 0xffffffff)
146+if ((b <= 0x0) or ((a & 0x80000000) == 0x0)) then
147+return ((a >> b) & 0xffffffff)
148+else
149+return (((a >> b) | (~ (0xffffffff >> b))) & 0xffffffff)
150+end
151+end
152+function bit.lrotate(a,b)
153+b=(b & 0x1f)
154+a=(a & 0xffffffff)
155+a=((a << b) | (a >> (0x20 - b)))
156+return (a & 0xffffffff)
157+end
158+function bit.rrotate(a,b)
159+return bit.lrotate(a,(- b))
160+end
161+local function checkfield
162+(f,w)
163+w=(w or 0x1)
164+assert((f >= 0x0),"\u{66}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{63}\u{61}\u{6e}\u{6e}\u{6f}\u{74}\u{20}\u{62}\u{65}\u{20}\u{6e}\u{65}\u{67}\u{61}\u{74}\u{69}\u{76}\u{65}")
165+assert((w > 0x0),"\u{77}\u{69}\u{64}\u{74}\u{68}\u{20}\u{6d}\u{75}\u{73}\u{74}\u{20}\u{62}\u{65}\u{20}\u{70}\u{6f}\u{73}\u{69}\u{74}\u{69}\u{76}\u{65}")
166+assert(((f + w) <= 0x20),"\u{74}\u{72}\u{79}\u{69}\u{6e}\u{67}\u{20}\u{74}\u{6f}\u{20}\u{61}\u{63}\u{63}\u{65}\u{73}\u{73}\u{20}\u{6e}\u{6f}\u{6e}\u{2d}\u{65}\u{78}\u{69}\u{73}\u{74}\u{65}\u{6e}\u{74}\u{20}\u{62}\u{69}\u{74}\u{73}")
167+return f,(~ (- (0x1 << w)))
168+end
169+function bit.extract(a,f,w)
170+local f,mask = checkfield(f,w)
171+return ((a >> f) & mask)
172+end
173+function bit.replace(a,v,f,w)
174+local f,mask = checkfield(f,w)
175+v=(v & mask)
176+a=((a & (~ (mask << f))) | (v << f))
177+return (a & 0xffffffff)
178+end
179+return bit
180+end
181+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{62}\u{69}\u{74}\u{77}\u{69}\u{73}\u{65}\u{20}\u{6c}\u{69}\u{62}\u{72}\u{61}\u{72}\u{79}")
182+local bit32 = require("\u{62}\u{69}\u{74}\u{33}\u{32}")
183+assert((bit32.band() == bit32.bnot(0x0)))
184+assert((bit32.btest() == true))
185+assert((bit32.bor() == 0x0))
186+assert((bit32.bxor() == 0x0))
187+assert((bit32.band() == bit32.band(0xffffffff)))
188+assert((bit32.band(0x1,0x2) == 0x0))
189+assert((bit32.band((- 0x1)) == 0xffffffff))
190+assert((bit32.band(((0x1 << 0x21) - 0x1)) == 0xffffffff))
191+assert((bit32.band((- ((0x1 << 0x21) - 0x1))) == 0xffffffff))
192+assert((bit32.band(((0x1 << 0x21) + 0x1)) == 0x1))
193+assert((bit32.band((- ((0x1 << 0x21) + 0x1))) == 0x1))
194+assert((bit32.band((- (0x1 << 0x28))) == 0x0))
195+assert((bit32.band((0x1 << 0x28)) == 0x0))
196+assert((bit32.band((- ((0x1 << 0x28) - 0x2))) == 0xfffffffe))
197+assert((bit32.band(((0x1 << 0x28) - 0x4)) == 0xfffffffc))
198+assert((bit32.lrotate(0x0,(- 0x1)) == 0x0))
199+assert((bit32.lrotate(0x0,0x7) == 0x0))
200+assert((bit32.lrotate(0x12345678,0x0) == 0x12345678))
201+assert((bit32.lrotate(0x12345678,0x20) == 0x12345678))
202+assert((bit32.lrotate(0x12345678,0x4) == 0x23456781))
203+assert((bit32.rrotate(0x12345678,(- 0x4)) == 0x23456781))
204+assert((bit32.lrotate(0x12345678,(- 0x8)) == 0x78123456))
205+assert((bit32.rrotate(0x12345678,0x8) == 0x78123456))
206+assert((bit32.lrotate(0xaaaaaaaa,0x2) == 0xaaaaaaaa))
207+assert((bit32.lrotate(0xaaaaaaaa,(- 0x2)) == 0xaaaaaaaa))
208+for i = (- 0x32), 0x32
209+do
210+assert((bit32.lrotate(0x89abcdef,i) == bit32.lrotate(0x89abcdef,(i % 0x20))))
211+end
212+assert((bit32.lshift(0x12345678,0x4) == 0x23456780))
213+assert((bit32.lshift(0x12345678,0x8) == 0x34567800))
214+assert((bit32.lshift(0x12345678,(- 0x4)) == 0x1234567))
215+assert((bit32.lshift(0x12345678,(- 0x8)) == 0x123456))
216+assert((bit32.lshift(0x12345678,0x20) == 0x0))
217+assert((bit32.lshift(0x12345678,(- 0x20)) == 0x0))
218+assert((bit32.rshift(0x12345678,0x4) == 0x1234567))
219+assert((bit32.rshift(0x12345678,0x8) == 0x123456))
220+assert((bit32.rshift(0x12345678,0x20) == 0x0))
221+assert((bit32.rshift(0x12345678,(- 0x20)) == 0x0))
222+assert((bit32.arshift(0x12345678,0x0) == 0x12345678))
223+assert((bit32.arshift(0x12345678,0x1) == (0x12345678 // 0x2)))
224+assert((bit32.arshift(0x12345678,(- 0x1)) == (0x12345678 * 0x2)))
225+assert((bit32.arshift((- 0x1),0x1) == 0xffffffff))
226+assert((bit32.arshift((- 0x1),0x18) == 0xffffffff))
227+assert((bit32.arshift((- 0x1),0x20) == 0xffffffff))
228+assert((bit32.arshift((- 0x1),(- 0x1)) == bit32.band((- (0x1 * 0x2)),0xffffffff)))
229+assert(((0x12345678 << 0x4) == 0x123456780))
230+assert(((0x12345678 << 0x8) == 0x1234567800))
231+assert((0x12345678 << (- (0x4 == 0x1234567))))
232+assert((0x12345678 << (- (0x8 == 0x123456))))
233+assert(((0x12345678 << 0x20) == 0x1234567800000000))
234+assert((0x12345678 << (- (0x20 == 0x0))))
235+assert(((0x12345678 >> 0x4) == 0x1234567))
236+assert(((0x12345678 >> 0x8) == 0x123456))
237+assert(((0x12345678 >> 0x20) == 0x0))
238+assert((0x12345678 >> (- (0x20 == 0x1234567800000000))))
239+print("\u{2b}")
240+local c = {0x0,0x1,0x2,0x3,0xa,0x80000000,0xaaaaaaaa,0x55555555,0xffffffff,0x7fffffff}
241+for _,b in pairs(c)
242+do
243+assert((bit32.band(b) == b))
244+assert((bit32.band(b,b) == b))
245+assert((bit32.band(b,b,b,b) == b))
246+assert((bit32.btest(b,b) == (b ~= 0x0)))
247+assert((bit32.band(b,b,b) == b))
248+assert((bit32.band(b,b,b,(~ b)) == 0x0))
249+assert((bit32.btest(b,b,b) == (b ~= 0x0)))
250+assert((bit32.band(b,bit32.bnot(b)) == 0x0))
251+assert((bit32.bor(b,bit32.bnot(b)) == bit32.bnot(0x0)))
252+assert((bit32.bor(b) == b))
253+assert((bit32.bor(b,b) == b))
254+assert((bit32.bor(b,b,b) == b))
255+assert((bit32.bor(b,b,0x0,(~ b)) == 0xffffffff))
256+assert((bit32.bxor(b) == b))
257+assert((bit32.bxor(b,b) == 0x0))
258+assert((bit32.bxor(b,b,b) == b))
259+assert((bit32.bxor(b,b,b,b) == 0x0))
260+assert((bit32.bxor(b,0x0) == b))
261+assert((bit32.bnot(b) ~= b))
262+assert((bit32.bnot(bit32.bnot(b)) == b))
263+assert((bit32.bnot(b) == (((0x1 << 0x20) - 0x1) - b)))
264+assert((bit32.lrotate(b,0x20) == b))
265+assert((bit32.rrotate(b,0x20) == b))
266+assert((bit32.lshift(bit32.lshift(b,(- 0x4)),0x4) == bit32.band(b,bit32.bnot(0xf))))
267+assert((bit32.rshift(bit32.rshift(b,0x4),(- 0x4)) == bit32.band(b,bit32.bnot(0xf))))
268+end
269+c={0x0,0x1,0x2,0x3,0xa,0x800000,0xaaaaaa,0x555555,0xffffff,0x7fffff}
270+for _,b in pairs(c)
271+do
272+for i = (- 0x28), 0x28
273+do
274+local x = bit32.lshift(b,i)
275+local y = math.floor(math.fmod((b * (2.0 ^ i)),(2.0 ^ 0x20)))
276+assert((math.fmod((x - y),(2.0 ^ 0x20)) == 0x0))
277+end
278+end
279+assert((not pcall(bit32.band,{})))
280+assert((not pcall(bit32.bnot,"\u{61}")))
281+assert((not pcall(bit32.lshift,0x2d)))
282+assert((not pcall(bit32.lshift,0x2d,print)))
283+assert((not pcall(bit32.rshift,0x2d,print)))
284+print("\u{2b}")
285+assert((bit32.extract(0x12345678,0x0,0x4) == 0x8))
286+assert((bit32.extract(0x12345678,0x4,0x4) == 0x7))
287+assert((bit32.extract(0xa0001111,0x1c,0x4) == 0xa))
288+assert((bit32.extract(0xa0001111,0x1f,0x1) == 0x1))
289+assert((bit32.extract(0x50000111,0x1f,0x1) == 0x0))
290+assert((bit32.extract(0xf2345679,0x0,0x20) == 0xf2345679))
291+assert((not pcall(bit32.extract,0x0,(- 0x1))))
292+assert((not pcall(bit32.extract,0x0,0x20)))
293+assert((not pcall(bit32.extract,0x0,0x0,0x21)))
294+assert((not pcall(bit32.extract,0x0,0x1f,0x2)))
295+assert((bit32.replace(0x12345678,0x5,0x1c,0x4) == 0x52345678))
296+assert((bit32.replace(0x12345678,0x87654321,0x0,0x20) == 0x87654321))
297+assert((bit32.replace(0x0,0x1,0x2) == (0x2 ^ 0x2)))
298+assert((bit32.replace(0x0,(- 0x1),0x4) == (0x2 ^ 0x4)))
299+assert((bit32.replace((- 0x1),0x0,0x1f) == ((0x1 << 0x1f) - 0x1)))
300+assert((bit32.replace((- 0x1),0x0,0x1,0x2) == ((0x1 << 0x20) - 0x7)))
301+assert((bit32.bor(3.0) == 0x3))
302+assert((bit32.bor((- 4.0)) == 0xfffffffc))
303+if (((2.0 ^ 0x32) < ((2.0 ^ 0x32) + 1.0)) and ((2.0 ^ 0x32) < (- (0x1 >> 0x1)))) then
304+assert((bit32.bor(((2.0 ^ 0x20) - 5.0)) == 0xfffffffb))
305+assert((bit32.bor((- ((2.0 ^ 0x20) - 6.0))) == 0xfffffffa))
306+assert((bit32.bor(((2.0 ^ 0x30) - 5.0)) == 0xfffffffb))
307+assert((bit32.bor((- ((2.0 ^ 0x30) - 6.0))) == 0xfffffffa))
308+end
309+print("\u{4f}\u{4b}")
desk/res/lua/cycled/bwcoercion.luanew file+59
@@ -0,0 +1,59 @@
1+local tonumber,tointeger = tonumber,math.tointeger
2+local type,getmetatable,rawget,error = type,getmetatable,rawget,error
3+local strsub = string.sub
4+local print = print
5+_ENV=nil
6+local function toint
7+(x)
8+x=tonumber(x)
9+if (not x) then
10+return false
11+end
12+return tointeger(x)
13+end
14+local function trymt
15+(x,y,mtname)
16+if (type(y) ~= "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}") then
17+local mt = getmetatable(y)
18+local mm = (mt and rawget(mt,mtname))
19+if mm then
20+return mm(x,y)
21+end
22+end
23+error(("\u{61}\u{74}\u{74}\u{65}\u{6d}\u{70}\u{74}\u{20}\u{74}\u{6f}\u{20}\u{27}" .. (strsub(mtname,0x3) .. ("\u{27}\u{20}\u{61}\u{20}" .. (type(x) .. ("\u{20}\u{77}\u{69}\u{74}\u{68}\u{20}\u{61}\u{20}" .. type(y)))))),0x4)
24+end
25+local function checkargs
26+(x,y,mtname)
27+local xi = toint(x)
28+local yi = toint(y)
29+if (xi and yi) then
30+return xi,yi
31+else
32+return trymt(x,y,mtname),nil
33+end
34+end
35+local smt = getmetatable("")
36+smt.__band=function (x,y)
37+local x,y = checkargs(x,y,"\u{5f}\u{5f}\u{62}\u{61}\u{6e}\u{64}")
38+return ((y and (x & y)) or x)
39+end
40+smt.__bor=function (x,y)
41+local x,y = checkargs(x,y,"\u{5f}\u{5f}\u{62}\u{6f}\u{72}")
42+return ((y and (x | y)) or x)
43+end
44+smt.__bxor=function (x,y)
45+local x,y = checkargs(x,y,"\u{5f}\u{5f}\u{62}\u{78}\u{6f}\u{72}")
46+return ((y and (x ~ y)) or x)
47+end
48+smt.__shl=function (x,y)
49+local x,y = checkargs(x,y,"\u{5f}\u{5f}\u{73}\u{68}\u{6c}")
50+return ((y and (x << y)) or x)
51+end
52+smt.__shr=function (x,y)
53+local x,y = checkargs(x,y,"\u{5f}\u{5f}\u{73}\u{68}\u{72}")
54+return ((y and (x >> y)) or x)
55+end
56+smt.__bnot=function (x)
57+local x,y = checkargs(x,x,"\u{5f}\u{5f}\u{62}\u{6e}\u{6f}\u{74}")
58+return (y and (~ (x or x)))
59+end
desk/res/lua/cycled/calls.luanew file+492
@@ -0,0 +1,492 @@
1+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{73}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{73}")
2+local debug = require("\u{64}\u{65}\u{62}\u{75}\u{67}")
3+assert((type((0x1 < 0x2)) == "\u{62}\u{6f}\u{6f}\u{6c}\u{65}\u{61}\u{6e}"))
4+assert(((type(true) == "\u{62}\u{6f}\u{6f}\u{6c}\u{65}\u{61}\u{6e}") and (type(false) == "\u{62}\u{6f}\u{6f}\u{6c}\u{65}\u{61}\u{6e}")))
5+assert((((((type(nil) == "\u{6e}\u{69}\u{6c}") and (type((- 0x3)) == "\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}")) and (type("\u{78}") == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}")) and (type({}) == "\u{74}\u{61}\u{62}\u{6c}\u{65}")) and (type(type) == "\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}")))
6+assert((type(assert) == type(print)))
7+local function f
8+(x)
9+return a:x(x)
10+end
11+assert((type(f) == "\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}"))
12+assert((not pcall(type)))
13+fact=false
14+do
15+local res = 0x1
16+local function fact
17+(n)
18+if (n == 0x0) then
19+return res
20+else
21+return (n * fact((n - 0x1)))
22+end
23+end
24+assert((fact(0x5) == 0x78))
25+end
26+assert((fact == false))
27+fact=nil
28+local a = {["\u{69}"] = 0xa}
29+local self = 0x14
30+function a:x(x)
31+return (x + self.i)
32+end
33+function a.y(x)
34+return (x + self)
35+end
36+assert(((a:x(0x1) + 0xa) == a.y(0x1)))
37+a.t={["\u{69}"] = (- 0x64)}
38+a["\u{74}"].x=function (self,a,b)
39+return ((self.i + a) + b)
40+end
41+assert((a.t:x(0x2,0x3) == (- 0x5f)))
42+do
43+local a = {["\u{78}"] = 0x0}
44+function a:add(x)
45+self.x,a.y=(self.x + x),0x14
46+;
47+return self
48+end
49+assert(((a:add(0xa):add(0x14):add(0x1e).x == 0x3c) and (a.y == 0x14)))
50+end
51+local a = {["\u{62}"] = {["\u{63}"] = {}}}
52+function a.b.c.f1(x)
53+return (x + 0x1)
54+end
55+function a.b.c:f2(x,y)
56+self[x]=y
57+end
58+assert((a.b.c.f1(0x4) == 0x5))
59+a.b.c:f2("\u{6b}",0xc)
60+;
61+assert((a.b.c.k == 0xc))
62+print("\u{2b}")
63+t=nil
64+function f(a,b,c)
65+local d = "\u{61}"
66+;
67+t={a,b,c,d}
68+end
69+f(0x1,0x2)
70+assert(((((t[0x1] == 0x1) and (t[0x2] == 0x2)) and (t[0x3] == nil)) and (t[0x4] == "\u{61}")))
71+f(0x1,0x2,0x3,0x4)
72+assert(((((t[0x1] == 0x1) and (t[0x2] == 0x2)) and (t[0x3] == 0x3)) and (t[0x4] == "\u{61}")))
73+t=nil
74+function fat(x)
75+if (x <= 0x1) then
76+return 0x1
77+else
78+return (x * load(("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{66}\u{61}\u{74}\u{28}" .. ((x - 0x1) .. "\u{29}")),"")())
79+end
80+end
81+assert(load("\u{6c}\u{6f}\u{61}\u{64}\u{20}\u{27}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{66}\u{61}\u{74}\u{28}\u{36}\u{29}\u{3d}\u{3d}\u{37}\u{32}\u{30}\u{29}\u{27}\u{20}\u{28}\u{29}\u{20}"))()
82+a=load("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{66}\u{61}\u{74}\u{28}\u{35}\u{29}\u{2c}\u{20}\u{33}")
83+local a,b = a()
84+assert(((a == 0x78) and (b == 0x3)))
85+fat=nil
86+print("\u{2b}")
87+local function err_on_n
88+(n)
89+if (n == 0x0) then
90+error()
91+;
92+exit(0x1)
93+;
94+else
95+err_on_n((n - 0x1))
96+;
97+exit(0x1)
98+;
99+end
100+end
101+do
102+local function dummy
103+(n)
104+if (n > 0x0) then
105+assert((not pcall(err_on_n,n)))
106+dummy((n - 0x1))
107+end
108+end
109+dummy(0xa)
110+end
111+_G.deep=nil
112+function deep(n)
113+if (n > 0x0) then
114+deep((n - 0x1))
115+end
116+end
117+deep(0xa)
118+deep(0xb4)
119+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{74}\u{61}\u{69}\u{6c}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{73}")
120+function deep(n)
121+if (n > 0x0) then
122+return deep((n - 0x1))
123+else
124+return 0x65
125+end
126+end
127+assert((deep(0x7530) == 0x65))
128+a={}
129+function a:deep(n)
130+if (n > 0x0) then
131+return self:deep((n - 0x1))
132+else
133+return 0x65
134+end
135+end
136+assert((a:deep(0x7530) == 0x65))
137+do
138+local function foo
139+(x, ...)
140+local a = {...}
141+;
142+return x,a[0x1],a[0x2]
143+end
144+local function foo1
145+(x)
146+return foo(0xa,x,(x + 0x1))
147+end
148+local a,b,c = foo1((- 0x2))
149+assert(((a == 0xa) and (b == (- (0x2 and (c == (- 0x1)))))))
150+local t = setmetatable({},{["\u{5f}\u{5f}\u{63}\u{61}\u{6c}\u{6c}"] = foo})
151+local function foo2
152+(x)
153+return t(0xa,x)
154+end
155+a,b,c=foo2(0x64)
156+assert((((a == t) and (b == 0xa)) and (c == 0x64)))
157+a,b=(function ()
158+return foo()
159+end)()
160+assert(((a == nil) and (b == nil)))
161+local X,Y,A
162+local function foo
163+(x,y, ...)
164+X=x
165+;
166+Y=y
167+;
168+A={...}
169+end
170+local function foo1
171+(...)
172+return foo(...)
173+end
174+local a,b,c = foo1()
175+assert((((X == nil) and (Y == nil)) and (# (A == 0x0))))
176+a,b,c=foo1(0xa)
177+assert((((X == 0xa) and (Y == nil)) and (# (A == 0x0))))
178+a,b,c=foo1(0xa,0x14)
179+assert((((X == 0xa) and (Y == 0x14)) and (# (A == 0x0))))
180+a,b,c=foo1(0xa,0x14,0x1e)
181+assert((((X == 0xa) and (Y == 0x14)) and (# ((A == 0x1) and (A[0x1] == 0x1e)))))
182+end
183+do
184+local function loop
185+()
186+assert(pcall(loop))
187+end
188+local err,msg = xpcall(loop,loop)
189+assert((not (err and string.find(msg,"\u{65}\u{72}\u{72}\u{6f}\u{72}"))))
190+end
191+do
192+local n = 0x2710
193+local function foo
194+()
195+if (n == 0x0) then
196+return 0x3ff
197+else
198+n=(n - 0x1)
199+;
200+return foo()
201+end
202+end
203+for i = 0x1, 0x64
204+do
205+foo=setmetatable({},{["\u{5f}\u{5f}\u{63}\u{61}\u{6c}\u{6c}"] = foo})
206+end
207+assert((coroutine.wrap(function ()
208+return foo()
209+end)() == 0x3ff))
210+end
211+print("\u{2b}")
212+do
213+local N = 0x14
214+local u = table.pack
215+for i = 0x1, N
216+do
217+u=setmetatable({i},{["\u{5f}\u{5f}\u{63}\u{61}\u{6c}\u{6c}"] = u})
218+end
219+local Res = u("\u{61}","\u{62}","\u{63}")
220+assert((Res.n == (N + 0x3)))
221+for i = 0x1, N
222+do
223+assert((Res[i][0x1] == i))
224+end
225+assert((((Res[(N + 0x1)] == "\u{61}") and (Res[(N + 0x2)] == "\u{62}")) and (Res[(N + 0x3)] == "\u{63}")))
226+end
227+a=nil
228+(function (x)
229+a=x
230+end)(0x17)
231+assert(((a == 0x17) and ((function (x)
232+return (x * 0x2)
233+end)(0x14) == 0x28)))
234+local Z = function (le)
235+local function a
236+(f)
237+return le(function (x)
238+return f(f)(x)
239+end)
240+end
241+return a(a)
242+end
243+local F = function (f)
244+return function (n)
245+if (n == 0x0) then
246+return 0x1
247+else
248+return (n * f((n - 0x1)))
249+end
250+end
251+end
252+local fat = Z(F)
253+assert((((fat(0x0) == 0x1) and (fat(0x4) == 0x18)) and (Z(F)(0x5) == (0x5 * Z(F)(0x4)))))
254+local function g
255+(z)
256+local function f
257+(a,b,c,d)
258+return function (x,y)
259+return (((((((a + b) + c) + d) + a) + x) + y) + z)
260+end
261+end
262+return f(z,(z + 0x1),(z + 0x2),(z + 0x3))
263+end
264+local f = g(0xa)
265+assert((f(0x9,0x10) == (((((((0xa + 0xb) + 0xc) + 0xd) + 0xa) + 0x9) + 0x10) + 0xa)))
266+print("\u{2b}")
267+local function unlpack
268+(t,i)
269+i=(i or 0x1)
270+if (i <= (# t)) then
271+return t[i],unlpack(t,(i + 0x1))
272+end
273+end
274+local function equaltab
275+(t1,t2)
276+assert((# (t1 == (# t2))))
277+for i = 0x1, (# t1)
278+do
279+assert((t1[i] == t2[i]))
280+end
281+end
282+local pack = function (...)
283+return table.pack(...)
284+end
285+local function f
286+()
287+return 0x1,0x2,0x1e,0x4
288+end
289+local function ret2
290+(a,b)
291+return a,b
292+end
293+local a,b,c,d = unlpack({0x1,0x2,0x3})
294+assert(((((a == 0x1) and (b == 0x2)) and (c == 0x3)) and (d == nil)))
295+a={0x1,0x2,0x3,0x4,false,0xa,"\u{61}\u{6c}\u{6f}",false,assert}
296+equaltab(pack(unlpack(a)),a)
297+equaltab(pack(unlpack(a),(- 0x1)),{0x1,(- 0x1)})
298+a,b,c,d=ret2(f()),ret2(f())
299+assert(((((a == 0x1) and (b == 0x1)) and (c == 0x2)) and (d == nil)))
300+a,b,c,d=unlpack(pack(ret2(f()),ret2(f())))
301+assert(((((a == 0x1) and (b == 0x1)) and (c == 0x2)) and (d == nil)))
302+a,b,c,d=unlpack(pack(ret2(f()),ret2(f())))
303+assert(((((a == 0x1) and (b == 0x1)) and (c == nil)) and (d == nil)))
304+a=ret2({unlpack({0x1,0x2,0x3}),unlpack({0x3,0x2,0x1}),unlpack({"\u{61}","\u{62}"})})
305+assert(((((a[0x1] == 0x1) and (a[0x2] == 0x3)) and (a[0x3] == "\u{61}")) and (a[0x4] == "\u{62}")))
306+rawget({},"\u{78}",0x1)
307+rawset({},"\u{78}",0x1,0x2)
308+assert((math.sin(0x1,0x2) == math.sin(0x1)))
309+table.sort({0xa,0x9,0x8,0x4,0x13,0x17,0x0,0x0},function (a,b)
310+return (a < b)
311+end,"\u{65}\u{78}\u{74}\u{72}\u{61}\u{20}\u{61}\u{72}\u{67}")
312+local x = "\u{2d}\u{2d}\u{20}\u{61}\u{20}\u{63}\u{6f}\u{6d}\u{6d}\u{65}\u{6e}\u{74}\u{0}\u{0}\u{0}\u{a}\u{20}\u{20}\u{78}\u{20}\u{3d}\u{20}\u{31}\u{30}\u{20}\u{2b}\u{20}\u{a}\u{32}\u{33}\u{3b}\u{20}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{28}\u{29}\u{20}\u{78}\u{20}\u{3d}\u{20}\u{27}\u{68}\u{69}\u{27}\u{20}\u{65}\u{6e}\u{64}\u{3b}\u{20}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{27}\u{0}\u{27}"
313+local function read1
314+(x)
315+local i = 0x0
316+return function ()
317+collectgarbage()
318+i=(i + 0x1)
319+return string.sub(x,i,i)
320+end
321+end
322+local function cannotload
323+(msg,a,b)
324+assert((not (a and string.find(b,msg))))
325+end
326+a=assert(load(read1(x),"\u{6d}\u{6f}\u{64}\u{6e}\u{61}\u{6d}\u{65}","\u{74}",_G))
327+assert(((a() == "\u{0}") and (_G.x == 0x21)))
328+assert((debug.getinfo(a).source == "\u{6d}\u{6f}\u{64}\u{6e}\u{61}\u{6d}\u{65}"))
329+cannotload("\u{61}\u{74}\u{74}\u{65}\u{6d}\u{70}\u{74}\u{20}\u{74}\u{6f}\u{20}\u{6c}\u{6f}\u{61}\u{64}\u{20}\u{61}\u{20}\u{74}\u{65}\u{78}\u{74}\u{20}\u{63}\u{68}\u{75}\u{6e}\u{6b}",load(read1(x),"\u{6d}\u{6f}\u{64}\u{6e}\u{61}\u{6d}\u{65}","\u{62}",{}))
330+cannotload("\u{61}\u{74}\u{74}\u{65}\u{6d}\u{70}\u{74}\u{20}\u{74}\u{6f}\u{20}\u{6c}\u{6f}\u{61}\u{64}\u{20}\u{61}\u{20}\u{74}\u{65}\u{78}\u{74}\u{20}\u{63}\u{68}\u{75}\u{6e}\u{6b}",load(x,"\u{6d}\u{6f}\u{64}\u{6e}\u{61}\u{6d}\u{65}","\u{62}"))
331+a=assert(load(function ()
332+return nil
333+end))
334+a()
335+assert((not load(function ()
336+return true
337+end)))
338+local t = {nil,"\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}","\u{33}"}
339+f,msg=load(function ()
340+return table.remove(t,0x1)
341+end)
342+assert((f() == nil))
343+f=load(string.dump(function ()
344+return 0x1
345+end),nil,"\u{62}",{})
346+assert(((type(f) == "\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}") and (f() == 0x1)))
347+do
348+local f = string.dump(function ()
349+return "\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}"
350+end)
351+f=load(read1(f))
352+assert((f() == "\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}"))
353+end
354+x=string.dump(load("\u{78}\u{20}\u{3d}\u{20}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{78}"))
355+a=assert(load(read1(x),nil,"\u{62}"))
356+assert(((a() == 0x1) and (_G.x == 0x1)))
357+cannotload("\u{61}\u{74}\u{74}\u{65}\u{6d}\u{70}\u{74}\u{20}\u{74}\u{6f}\u{20}\u{6c}\u{6f}\u{61}\u{64}\u{20}\u{61}\u{20}\u{62}\u{69}\u{6e}\u{61}\u{72}\u{79}\u{20}\u{63}\u{68}\u{75}\u{6e}\u{6b}",load(read1(x),nil,"\u{74}"))
358+cannotload("\u{61}\u{74}\u{74}\u{65}\u{6d}\u{70}\u{74}\u{20}\u{74}\u{6f}\u{20}\u{6c}\u{6f}\u{61}\u{64}\u{20}\u{61}\u{20}\u{62}\u{69}\u{6e}\u{61}\u{72}\u{79}\u{20}\u{63}\u{68}\u{75}\u{6e}\u{6b}",load(x,nil,"\u{74}"))
359+_G.x=nil
360+assert((not pcall(string.dump,print)))
361+cannotload("\u{75}\u{6e}\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}\u{20}\u{73}\u{79}\u{6d}\u{62}\u{6f}\u{6c}",load(read1("\u{2a}\u{61}\u{20}\u{3d}\u{20}\u{31}\u{32}\u{33}")))
362+cannotload("\u{75}\u{6e}\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}\u{20}\u{73}\u{79}\u{6d}\u{62}\u{6f}\u{6c}",load("\u{2a}\u{61}\u{20}\u{3d}\u{20}\u{31}\u{32}\u{33}"))
363+cannotload("\u{68}\u{68}\u{69}",load(function ()
364+error("\u{68}\u{68}\u{69}")
365+end))
366+assert((load("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{5f}\u{45}\u{4e}\u{56}",nil,nil,0x7b)() == 0x7b))
367+local x
368+;
369+XX=0x7b
370+local function h
371+()
372+local y = x
373+return XX
374+end
375+local d = string.dump(h)
376+x=load(d,"","\u{62}")
377+assert((debug.getupvalue(x,0x2) == "\u{5f}\u{45}\u{4e}\u{56}"))
378+debug.setupvalue(x,0x2,_G)
379+assert((x() == 0x7b))
380+assert((assert(load("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{58}\u{58}\u{20}\u{2b}\u{20}\u{2e}\u{2e}\u{2e}",nil,nil,{["\u{58}\u{58}"] = 0xd}))(0x4) == 0x11))
381+XX=nil
382+x="\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{28}\u{78}\u{29}\u{a}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{28}\u{79}\u{29}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{28}\u{7a}\u{29}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{78}\u{2b}\u{79}\u{2b}\u{7a}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{20}\u{20}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{20}\u{20}\u{65}\u{6e}\u{64}\u{a}"
383+a=assert(load(read1(x),"\u{72}\u{65}\u{61}\u{64}","\u{74}"))
384+assert((a()(0x2)(0x3)(0xa) == 0xf))
385+x=string.dump(a)
386+a=assert(load(read1(x),"\u{72}\u{65}\u{61}\u{64}","\u{62}"))
387+assert((a()(0x2)(0x3)(0xa) == 0xf))
388+local a,b = 0x14,0x1e
389+x=load(string.dump(function (x)
390+if (x == "\u{73}\u{65}\u{74}") then
391+a=(0xa + b)
392+;
393+b=(b + 0x1)
394+else
395+return a
396+end
397+end),"","\u{62}",nil)
398+assert((x() == nil))
399+assert((debug.setupvalue(x,0x1,"\u{68}\u{69}") == "\u{61}"))
400+assert((x() == "\u{68}\u{69}"))
401+assert((debug.setupvalue(x,0x2,0xd) == "\u{62}"))
402+assert((not debug.setupvalue(x,0x3,0xa)))
403+x("\u{73}\u{65}\u{74}")
404+assert((x() == 0x17))
405+x("\u{73}\u{65}\u{74}")
406+assert((x() == 0x18))
407+do
408+local nup = 0xc8
409+local prog = {"\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{31}"}
410+for i = 0x2, nup
411+do
412+prog[(# (prog + 0x1))]=("\u{2c}\u{20}\u{61}" .. i)
413+end
414+prog[(# (prog + 0x1))]="\u{20}\u{3d}\u{20}\u{31}"
415+for i = 0x2, nup
416+do
417+prog[(# (prog + 0x1))]=("\u{2c}\u{20}" .. i)
418+end
419+local sum = 0x1
420+prog[(# (prog + 0x1))]="\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{28}\u{29}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{61}\u{31}"
421+for i = 0x2, nup
422+do
423+prog[(# (prog + 0x1))]=("\u{20}\u{2b}\u{20}\u{61}" .. i)
424+;
425+sum=(sum + i)
426+end
427+prog[(# (prog + 0x1))]="\u{20}\u{65}\u{6e}\u{64}"
428+prog=table.concat(prog)
429+local f = assert(load(prog))()
430+assert((f() == sum))
431+f=load(string.dump(f))
432+local a = 0xa
433+local h = function ()
434+return a
435+end
436+for i = 0x1, nup
437+do
438+debug.upvaluejoin(f,i,h,0x1)
439+end
440+assert((f() == (0xa * nup)))
441+end
442+do
443+local t = {["\u{78}"] = 0x1}
444+function t:_012345678901234567890123456789012345678901234567890123456789()
445+return self.x
446+end
447+assert((t:_012345678901234567890123456789012345678901234567890123456789() == 0x1))
448+end
449+assert(((function ()
450+return nil
451+end)(0x4) == nil))
452+assert(((function ()
453+local a
454+;
455+return a
456+end)(0x4) == nil))
457+assert(((function (a)
458+return a
459+end)() == nil))
460+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{62}\u{69}\u{6e}\u{61}\u{72}\u{79}\u{20}\u{63}\u{68}\u{75}\u{6e}\u{6b}\u{73}")
461+do
462+local header = string.pack("\u{63}\u{34}\u{42}\u{42}\u{63}\u{36}\u{42}\u{42}\u{42}","\u{1b}\u{4c}\u{75}\u{61}",0x54,0x0,"\u{19}\u{93}\u{d}\u{a}\u{1a}\u{a}",0x4,string.packsize("\u{6a}"),string.packsize("\u{6e}"))
463+local c = string.dump(function ()
464+local a = 0x1
465+;
466+local b = 0x3
467+;
468+local f = function ()
469+return ((a + b) + _ENV.c)
470+end
471+local s1 = "\u{61}\u{20}\u{63}\u{6f}\u{6e}\u{73}\u{74}\u{61}\u{6e}\u{74}"
472+local s2 = "\u{61}\u{6e}\u{6f}\u{74}\u{68}\u{65}\u{72}\u{20}\u{63}\u{6f}\u{6e}\u{73}\u{74}\u{61}\u{6e}\u{74}"
473+return (a + (b * 0x3))
474+end)
475+assert((assert(load(c))() == 0xa))
476+assert((string.sub(c,0x1,(# header)) == header))
477+local ci,cn = string.unpack("\u{6a}\u{6e}",c,(# (header + 0x1)))
478+assert(((ci == 0x5678) and (cn == 370.5)))
479+for i = 0x1, (# header)
480+do
481+local s = (string.sub(c,0x1,(i - 0x1)) .. (string.char((string.byte(string.sub(c,i,i)) + 0x1)) .. string.sub(c,(i + 0x1),(- 0x1))))
482+assert((# (s == (# c))))
483+assert((not load(s)))
484+end
485+for i = 0x1, (# (c - 0x1))
486+do
487+local st,msg = load(string.sub(c,0x1,i))
488+assert((not (st and string.find(msg,"\u{74}\u{72}\u{75}\u{6e}\u{63}\u{61}\u{74}\u{65}\u{64}"))))
489+end
490+end
491+print("\u{4f}\u{4b}")
492+return deep
desk/res/lua/cycled/closure.luanew file+327
@@ -0,0 +1,327 @@
1+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{63}\u{6c}\u{6f}\u{73}\u{75}\u{72}\u{65}\u{73}")
2+local A,B = 0x0,{["\u{67}"] = 0xa}
3+local function f
4+(x)
5+local a = {}
6+for i = 0x1, 0x3e8
7+do
8+local y = 0x0
9+do
10+a[i]=function ()
11+B.g=(B.g + 0x1)
12+;
13+y=(y + x)
14+;
15+return (y + A)
16+end
17+end
18+end
19+local dummy = function ()
20+return a[A]
21+end
22+collectgarbage()
23+A=0x1
24+;
25+assert((dummy() == a[0x1]))
26+;
27+A=0x0
28+;
29+assert((a[0x1]() == x))
30+assert((a[0x3]() == x))
31+collectgarbage()
32+assert((B.g == 0xc))
33+return a
34+end
35+local a = f(0xa)
36+local x = {[0x1] = {}}
37+setmetatable(x,{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{6b}\u{76}"})
38+while x[0x1] do
39+local a = (A .. (A .. (A .. A)))
40+A=(A + 0x1)
41+end
42+assert((a[0x1]() == (0x14 + A)))
43+assert((a[0x1]() == (0x1e + A)))
44+assert((a[0x2]() == (0xa + A)))
45+collectgarbage()
46+assert((a[0x2]() == (0x14 + A)))
47+assert((a[0x2]() == (0x1e + A)))
48+assert((a[0x3]() == (0x14 + A)))
49+assert((a[0x8]() == (0xa + A)))
50+assert((getmetatable(x).__mode == "\u{6b}\u{76}"))
51+assert((B.g == 0x13))
52+a={}
53+for i = 0x1, 0x5
54+do
55+a[i]=function (x)
56+return ((i + a) + _ENV)
57+end
58+end
59+assert(((a[0x3] ~= a[0x4]) and (a[0x4] ~= a[0x5])))
60+do
61+local a = function (x)
62+return math.sin(_ENV[x])
63+end
64+local function f
65+()
66+return a
67+end
68+assert((f() == f()))
69+end
70+a={}
71+for i = 0x1, 0xa
72+do
73+a[i]={["\u{73}\u{65}\u{74}"] = function (x)
74+i=x
75+end,["\u{67}\u{65}\u{74}"] = function ()
76+return i
77+end}
78+if (i == 0x3) then
79+break
80+end
81+end
82+assert((a[0x4] == undef))
83+a[0x1].set(0xa)
84+assert((a[0x2].get() == 0x2))
85+a[0x2].set("\u{61}")
86+assert((a[0x3].get() == 0x3))
87+assert((a[0x2].get() == "\u{61}"))
88+a={}
89+local t = {"\u{61}","\u{62}"}
90+for i = 0x1, (# t)
91+do
92+local k = t[i]
93+a[i]={["\u{73}\u{65}\u{74}"] = function (x,y)
94+i=x
95+;
96+k=y
97+end,["\u{67}\u{65}\u{74}"] = function ()
98+return i,k
99+end}
100+if (i == 0x2) then
101+break
102+end
103+end
104+a[0x1].set(0xa,0x14)
105+local r,s = a[0x2].get()
106+assert(((r == 0x2) and (s == "\u{62}")))
107+r,s=a[0x1].get()
108+assert(((r == 0xa) and (s == 0x14)))
109+a[0x2].set("\u{61}","\u{62}")
110+r,s=a[0x2].get()
111+assert(((r == "\u{61}") and (s == "\u{62}")))
112+local f
113+for i = 0x1, 0x3
114+do
115+f=function ()
116+return i
117+end
118+break
119+end
120+assert((f() == 0x1))
121+for k = 0x1, (# t)
122+do
123+local v = t[k]
124+f=function ()
125+return k,v
126+end
127+break
128+end
129+assert((({f()})[0x1] == 0x1))
130+assert((({f()})[0x2] == "\u{61}"))
131+local b
132+function f(x)
133+local first = 0x1
134+while 0x1 do
135+if ((x == 0x3) and (not first)) then
136+return
137+end
138+local a = "\u{78}\u{75}\u{78}\u{75}"
139+b=function (op,y)
140+if (op == "\u{73}\u{65}\u{74}") then
141+a=(x + y)
142+else
143+return a
144+end
145+end
146+if (x == 0x1) then
147+do
148+break
149+end
150+elseif (x == 0x2) then
151+return
152+else
153+if (x ~= 0x3) then
154+error()
155+end
156+end
157+first=nil
158+end
159+end
160+for i = 0x1, 0x3
161+do
162+f(i)
163+assert((b("\u{67}\u{65}\u{74}") == "\u{78}\u{75}\u{78}\u{75}"))
164+b("\u{73}\u{65}\u{74}",0xa)
165+;
166+assert((b("\u{67}\u{65}\u{74}") == (0xa + i)))
167+b=nil
168+end
169+pcall(f,0x4)
170+;
171+assert((b("\u{67}\u{65}\u{74}") == "\u{78}\u{75}\u{78}\u{75}"))
172+b("\u{73}\u{65}\u{74}",0xa)
173+;
174+assert((b("\u{67}\u{65}\u{74}") == 0xe))
175+local y,w
176+function f(x)
177+return function (y)
178+return function (z)
179+return (((w + x) + y) + z)
180+end
181+end
182+end
183+y=f(0xa)
184+w=1.345
185+assert((y(0x14)(0x1e) == (0x3c + w)))
186+do
187+local X,Y
188+local a = math.sin(0x0)
189+while a do
190+local b = 0xa
191+X=function ()
192+return b
193+end
194+if a then
195+break
196+end
197+end
198+do
199+local b = 0x14
200+Y=function ()
201+return b
202+end
203+end
204+assert(((X() == 0xa) and (Y() == 0x14)))
205+end
206+local a = {}
207+local i = 0x1
208+repeat
209+local x = i
210+a[i]=function ()
211+i=(x + 0x1)
212+;
213+return x
214+end
215+until ((i > 0xa) or (a[i]() ~= x))
216+assert(((((i == 0xb) and (a[0x1]() == 0x1)) and (a[0x3]() == 0x3)) and (i == 0x4)))
217+a={}
218+for i = 0x1, 0xa
219+do
220+if ((i % 0x3) == 0x0) then
221+local y = 0x0
222+a[i]=function (x)
223+local t = y
224+;
225+y=x
226+;
227+return t
228+end
229+elseif ((i % 0x3) == 0x1) then
230+goto L1
231+error("\u{6e}\u{6f}\u{74}\u{20}\u{68}\u{65}\u{72}\u{65}")
232+::L1::
233+local y = 0x1
234+a[i]=function (x)
235+local t = y
236+;
237+y=x
238+;
239+return t
240+end
241+elseif ((i % 0x3) == 0x2) then
242+local t
243+goto l4
244+::l4a::
245+a[i]=t
246+;
247+goto l4b
248+error("\u{73}\u{68}\u{6f}\u{75}\u{6c}\u{64}\u{20}\u{6e}\u{65}\u{76}\u{65}\u{72}\u{20}\u{62}\u{65}\u{20}\u{68}\u{65}\u{72}\u{65}\u{21}")
249+::l4::
250+local y = 0x2
251+t=function (x)
252+local t = y
253+;
254+y=x
255+;
256+return t
257+end
258+goto l4a
259+error("\u{73}\u{68}\u{6f}\u{75}\u{6c}\u{64}\u{20}\u{6e}\u{65}\u{76}\u{65}\u{72}\u{20}\u{62}\u{65}\u{20}\u{68}\u{65}\u{72}\u{65}\u{21}")
260+::l4b::
261+end
262+end
263+for i = 0x1, 0xa
264+do
265+assert(((a[i]((i * 0xa)) == (i % 0x3)) and (a[i]() == (i * 0xa))))
266+end
267+print("\u{2b}")
268+local function t
269+()
270+local function c
271+(a,b)
272+assert(((a == "\u{74}\u{65}\u{73}\u{74}") and (b == "\u{4f}\u{4b}")))
273+end
274+local function v
275+(f, ...)
276+c("\u{74}\u{65}\u{73}\u{74}",(((f() ~= 0x1) and "\u{46}\u{41}\u{49}\u{4c}\u{45}\u{44}") or "\u{4f}\u{4b}"))
277+end
278+local x = 0x1
279+return v(function ()
280+return x
281+end)
282+end
283+t()
284+local debug = require("\u{64}\u{65}\u{62}\u{75}\u{67}")
285+local foo1,foo2,foo3
286+do
287+local a,b,c = 0x3,0x5,0x7
288+foo1=function ()
289+return (a + b)
290+end
291+;
292+foo2=function ()
293+return (b + a)
294+end
295+;
296+do
297+local a = 0xa
298+foo3=function ()
299+return (a + b)
300+end
301+;
302+end
303+end
304+assert(debug.upvalueid(foo1,0x1))
305+assert(debug.upvalueid(foo1,0x2))
306+assert((not debug.upvalueid(foo1,0x3)))
307+assert((debug.upvalueid(foo1,0x1) == debug.upvalueid(foo2,0x2)))
308+assert((debug.upvalueid(foo1,0x2) == debug.upvalueid(foo2,0x1)))
309+assert(debug.upvalueid(foo3,0x1))
310+assert((debug.upvalueid(foo1,0x1) ~= debug.upvalueid(foo3,0x1)))
311+assert((debug.upvalueid(foo1,0x2) == debug.upvalueid(foo3,0x2)))
312+assert((debug.upvalueid(string.gmatch("\u{78}","\u{78}"),0x1) ~= nil))
313+assert(((foo1() == (0x3 + 0x5)) and (foo2() == (0x5 + 0x3))))
314+debug.upvaluejoin(foo1,0x2,foo2,0x2)
315+assert(((foo1() == (0x3 + 0x3)) and (foo2() == (0x5 + 0x3))))
316+assert((foo3() == (0xa + 0x5)))
317+debug.upvaluejoin(foo3,0x2,foo2,0x1)
318+assert((foo3() == (0xa + 0x5)))
319+debug.upvaluejoin(foo3,0x2,foo2,0x2)
320+assert((foo3() == (0xa + 0x3)))
321+assert((not pcall(debug.upvaluejoin,foo1,0x3,foo2,0x1)))
322+assert((not pcall(debug.upvaluejoin,foo1,0x1,foo2,0x3)))
323+assert((not pcall(debug.upvaluejoin,foo1,0x0,foo2,0x1)))
324+assert((not pcall(debug.upvaluejoin,print,0x1,foo2,0x1)))
325+assert((not pcall(debug.upvaluejoin,{},0x1,foo2,0x1)))
326+assert((not pcall(debug.upvaluejoin,foo1,0x1,print,0x1)))
327+print("\u{4f}\u{4b}")
desk/res/lua/cycled/code.luanew file+586
@@ -0,0 +1,586 @@
1+if (T == nil) then
2+(Message or print)("\u{a}\u{20}\u{3e}\u{3e}\u{3e}\u{20}\u{74}\u{65}\u{73}\u{74}\u{43}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{61}\u{63}\u{74}\u{69}\u{76}\u{65}\u{3a}\u{20}\u{73}\u{6b}\u{69}\u{70}\u{70}\u{69}\u{6e}\u{67}\u{20}\u{6f}\u{70}\u{63}\u{6f}\u{64}\u{65}\u{20}\u{74}\u{65}\u{73}\u{74}\u{73}\u{20}\u{3c}\u{3c}\u{3c}\u{a}")
3+return
4+end
5+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{63}\u{6f}\u{64}\u{65}\u{20}\u{67}\u{65}\u{6e}\u{65}\u{72}\u{61}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{6f}\u{70}\u{74}\u{69}\u{6d}\u{69}\u{7a}\u{61}\u{74}\u{69}\u{6f}\u{6e}\u{73}")
6+local k0aux <const> = 0x0
7+local k0 <const> = k0aux
8+local k1 <const> = 0x1
9+local k3 <const> = 0x3
10+local k6 <const> = (k3 + (k3 << k0))
11+local kFF0 <const> = 0xff0
12+local k3_78 <const> = 3.78
13+local x,k3_78_4 <const> = 0xa,(k3_78 / 0x4)
14+assert((x == 0xa))
15+local kx <const> = "\u{78}"
16+local kTrue <const> = true
17+local kFalse <const> = false
18+local kNil <const> = nil
19+do
20+local function f
21+(a)
22+for k,v,w in a
23+do
24+
25+end
26+end
27+end
28+local function checkKlist
29+(func,list)
30+local k = T.listk(func)
31+assert((# (k == (# list))))
32+for i = 0x1, (# k)
33+do
34+assert(((k[i] == list[i]) and (math.type(k[i]) == math.type(list[i]))))
35+end
36+end
37+local function foo
38+()
39+local a
40+a=k3
41+;
42+a=0x0
43+;
44+a=0.0
45+;
46+a=(- (0x7 + 0x7))
47+a=(k3_78 / 0x4)
48+;
49+a=k3_78_4
50+a=(- (k3_78 / 0x4))
51+;
52+a=(k3_78 / 0x4)
53+;
54+a=(- (3.78 / 0x4))
55+a=(- (3.79 / 0x4))
56+;
57+a=0.0
58+;
59+a=(- 0x0)
60+;
61+a=k3
62+;
63+a=3.0
64+;
65+a=0x3
66+;
67+a=3.0
68+end
69+checkKlist(foo,{(3.78 / 0x4),(- (3.78 / 0x4)),(- (3.79 / 0x4))})
70+foo=function (f,a)
71+f((0x64 * 0x3e8))
72+f((100.0 * 0x3e8))
73+f((- (0x64 * 0x3e8)))
74+f((- (0x64 * 1e3)))
75+f(0x186a0)
76+f(1e5)
77+f((- 0x186a0))
78+f((- 1e5))
79+end
80+checkKlist(foo,{0x186a0,1e5,(- 0x186a0),(- 1e5)})
81+foo=function (t,a)
82+t[a]=0x1
83+;
84+t[a]=1.0
85+t[a]=0x1
86+;
87+t[a]=1.0
88+t[a]=0x2
89+;
90+t[a]=2.0
91+t[a]=0x0
92+;
93+t[a]=0.0
94+t[a]=0x1
95+;
96+t[a]=1.0
97+t[a]=0x2
98+;
99+t[a]=2.0
100+t[a]=0x0
101+;
102+t[a]=0.0
103+end
104+checkKlist(foo,{0x1,1.0,0x2,2.0,0x0,0.0})
105+local function check
106+(f, ...)
107+local arg = {...}
108+local c = T.listcode(f)
109+for i = 0x1, (# arg)
110+do
111+local opcode = string.match(c[i],"\u{25}\u{75}\u{25}\u{77}\u{2b}")
112+assert((arg[i] == opcode))
113+end
114+assert((c[(# (arg + 0x2))] == undef))
115+end
116+local function checkR
117+(f,p,r, ...)
118+local r1 = f(p)
119+assert(((r == r1) and (math.type(r) == math.type(r1))))
120+check(f,...)
121+end
122+local function checkequal
123+(a,b)
124+a=T.listcode(a)
125+b=T.listcode(b)
126+assert((# (a == (# b))))
127+for i = 0x1, (# a)
128+do
129+a[i]=string.gsub(a[i],"\u{25}\u{62}\u{28}\u{29}","")
130+b[i]=string.gsub(b[i],"\u{25}\u{62}\u{28}\u{29}","")
131+assert((a[i] == b[i]))
132+end
133+end
134+check(function ()
135+(function ()
136+
137+end)({f()})
138+end,"\u{43}\u{4c}\u{4f}\u{53}\u{55}\u{52}\u{45}","\u{4e}\u{45}\u{57}\u{54}\u{41}\u{42}\u{4c}\u{45}","\u{45}\u{58}\u{54}\u{52}\u{41}\u{41}\u{52}\u{47}","\u{47}\u{45}\u{54}\u{54}\u{41}\u{42}\u{55}\u{50}","\u{43}\u{41}\u{4c}\u{4c}","\u{53}\u{45}\u{54}\u{4c}\u{49}\u{53}\u{54}","\u{43}\u{41}\u{4c}\u{4c}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{30}")
139+check(function (x)
140+(function ()
141+return x
142+end)({f()})
143+end,"\u{43}\u{4c}\u{4f}\u{53}\u{55}\u{52}\u{45}","\u{4e}\u{45}\u{57}\u{54}\u{41}\u{42}\u{4c}\u{45}","\u{45}\u{58}\u{54}\u{52}\u{41}\u{41}\u{52}\u{47}","\u{47}\u{45}\u{54}\u{54}\u{41}\u{42}\u{55}\u{50}","\u{43}\u{41}\u{4c}\u{4c}","\u{53}\u{45}\u{54}\u{4c}\u{49}\u{53}\u{54}","\u{43}\u{41}\u{4c}\u{4c}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}")
144+check(function ()
145+local kNil <const> = nil
146+local a,b,c
147+local d
148+;
149+local e
150+;
151+local f,g,h
152+;
153+d=nil
154+;
155+d=nil
156+;
157+b=nil
158+;
159+a=kNil
160+;
161+c=nil
162+;
163+end,"\u{4c}\u{4f}\u{41}\u{44}\u{4e}\u{49}\u{4c}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{30}")
164+check(function ()
165+local a,b,c,d = 0x1,0x1,0x1,0x1
166+d=nil
167+;
168+c=nil
169+;
170+b=nil
171+;
172+a=nil
173+end,"\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{4c}\u{4f}\u{41}\u{44}\u{4e}\u{49}\u{4c}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{30}")
174+do
175+local a,b,c,d = 0x1,0x1,0x1,0x1
176+d=nil
177+;
178+c=nil
179+;
180+b=nil
181+;
182+a=nil
183+assert(((((a == nil) and (b == nil)) and (c == nil)) and (d == nil)))
184+end
185+check(function (a,b,c)
186+return a
187+end,"\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
188+check(function ()
189+while kTrue do
190+local a = (- 0x1)
191+end
192+end,"\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{4a}\u{4d}\u{50}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{30}")
193+check(function ()
194+while 0x1 do
195+local a = (- 0x1)
196+end
197+end,"\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{4a}\u{4d}\u{50}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{30}")
198+check(function ()
199+repeat
200+local x = 0x1
201+until true
202+end,"\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{30}")
203+check(function (a,b,c,d)
204+return (a .. (b .. (c .. d)))
205+end,"\u{4d}\u{4f}\u{56}\u{45}","\u{4d}\u{4f}\u{56}\u{45}","\u{4d}\u{4f}\u{56}\u{45}","\u{4d}\u{4f}\u{56}\u{45}","\u{43}\u{4f}\u{4e}\u{43}\u{41}\u{54}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
206+check(function ()
207+return (not (not nil))
208+end,"\u{4c}\u{4f}\u{41}\u{44}\u{46}\u{41}\u{4c}\u{53}\u{45}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
209+check(function ()
210+return (not (not kFalse))
211+end,"\u{4c}\u{4f}\u{41}\u{44}\u{46}\u{41}\u{4c}\u{53}\u{45}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
212+check(function ()
213+return (not (not true))
214+end,"\u{4c}\u{4f}\u{41}\u{44}\u{54}\u{52}\u{55}\u{45}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
215+check(function ()
216+return (not (not k3))
217+end,"\u{4c}\u{4f}\u{41}\u{44}\u{54}\u{52}\u{55}\u{45}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
218+check(function ()
219+local a,b,c,d
220+a=(b * a)
221+c.x,a[b]=(- (((a + (d / b)) - a[b]) ^ a.x)),b
222+end,"\u{4c}\u{4f}\u{41}\u{44}\u{4e}\u{49}\u{4c}","\u{4d}\u{55}\u{4c}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}","\u{44}\u{49}\u{56}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}","\u{41}\u{44}\u{44}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}","\u{47}\u{45}\u{54}\u{54}\u{41}\u{42}\u{4c}\u{45}","\u{53}\u{55}\u{42}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}","\u{47}\u{45}\u{54}\u{46}\u{49}\u{45}\u{4c}\u{44}","\u{50}\u{4f}\u{57}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}","\u{55}\u{4e}\u{4d}","\u{53}\u{45}\u{54}\u{54}\u{41}\u{42}\u{4c}\u{45}","\u{53}\u{45}\u{54}\u{46}\u{49}\u{45}\u{4c}\u{44}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{30}")
223+check(function ()
224+local a,b
225+local c = kNil
226+a[kx]=3.2
227+a.x=b
228+a[b]="\u{78}"
229+end,"\u{4c}\u{4f}\u{41}\u{44}\u{4e}\u{49}\u{4c}","\u{53}\u{45}\u{54}\u{46}\u{49}\u{45}\u{4c}\u{44}","\u{53}\u{45}\u{54}\u{46}\u{49}\u{45}\u{4c}\u{44}","\u{53}\u{45}\u{54}\u{54}\u{41}\u{42}\u{4c}\u{45}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{30}")
230+check(function (a)
231+local k255 <const> = 0xff
232+a[0x1]=a[0x64]
233+a[k255]=a[0x100]
234+a[0x100]=0x5
235+end,"\u{47}\u{45}\u{54}\u{49}","\u{53}\u{45}\u{54}\u{49}","\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{47}\u{45}\u{54}\u{54}\u{41}\u{42}\u{4c}\u{45}","\u{53}\u{45}\u{54}\u{49}","\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{53}\u{45}\u{54}\u{54}\u{41}\u{42}\u{4c}\u{45}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{30}")
236+check(function ()
237+local a,b
238+a=(a - a)
239+b=(a / a)
240+b=(0x5 - 0x4)
241+end,"\u{4c}\u{4f}\u{41}\u{44}\u{4e}\u{49}\u{4c}","\u{53}\u{55}\u{42}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}","\u{44}\u{49}\u{56}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}","\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{30}")
242+check(function ()
243+local a,b
244+a[kTrue]=false
245+end,"\u{4c}\u{4f}\u{41}\u{44}\u{4e}\u{49}\u{4c}","\u{4c}\u{4f}\u{41}\u{44}\u{54}\u{52}\u{55}\u{45}","\u{53}\u{45}\u{54}\u{54}\u{41}\u{42}\u{4c}\u{45}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{30}")
246+checkR(function (a)
247+if (a == 0x1) then
248+return 0x2
249+end
250+end,0x1,0x2,"\u{45}\u{51}\u{49}","\u{4a}\u{4d}\u{50}","\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
251+checkR(function (a)
252+if (- (4.0 == a)) then
253+return 0x2
254+end
255+end,(- 0x4),0x2,"\u{45}\u{51}\u{49}","\u{4a}\u{4d}\u{50}","\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
256+checkR(function (a)
257+if (a == "\u{68}\u{69}") then
258+return 0x2
259+end
260+end,0xa,nil,"\u{45}\u{51}\u{4b}","\u{4a}\u{4d}\u{50}","\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
261+checkR(function (a)
262+if (a == 0x2710) then
263+return 0x2
264+end
265+end,0x1,nil,"\u{45}\u{51}\u{4b}","\u{4a}\u{4d}\u{50}","\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
266+checkR(function (a)
267+if (- (0x2710 == a)) then
268+return 0x2
269+end
270+end,(- 0x2710),0x2,"\u{45}\u{51}\u{4b}","\u{4a}\u{4d}\u{50}","\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
271+checkR(function (a)
272+if (- (0xa <= a)) then
273+return 0x2
274+end
275+end,(- 0xa),0x2,"\u{47}\u{45}\u{49}","\u{4a}\u{4d}\u{50}","\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
276+checkR(function (a)
277+if (128.0 > a) then
278+return 0x2
279+end
280+end,0x81,nil,"\u{4c}\u{54}\u{49}","\u{4a}\u{4d}\u{50}","\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
281+checkR(function (a)
282+if (- (127.0 < a)) then
283+return 0x2
284+end
285+end,(- 0x7f),nil,"\u{47}\u{54}\u{49}","\u{4a}\u{4d}\u{50}","\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
286+checkR(function (a)
287+if (0xa < a) then
288+return 0x2
289+end
290+end,0xb,0x2,"\u{47}\u{54}\u{49}","\u{4a}\u{4d}\u{50}","\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
291+checkR(function (a)
292+if (0x81 < a) then
293+return 0x2
294+end
295+end,0x82,0x2,"\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{4c}\u{54}","\u{4a}\u{4d}\u{50}","\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
296+checkR(function (a)
297+if (a >= 23.0) then
298+return 0x2
299+end
300+end,0x19,0x2,"\u{47}\u{45}\u{49}","\u{4a}\u{4d}\u{50}","\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
301+checkR(function (a)
302+if (a >= 23.1) then
303+return 0x2
304+end
305+end,0x0,nil,"\u{4c}\u{4f}\u{41}\u{44}\u{4b}","\u{4c}\u{45}","\u{4a}\u{4d}\u{50}","\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
306+checkR(function (a)
307+if (a > 2300.0) then
308+return 0x2
309+end
310+end,0x0,nil,"\u{4c}\u{4f}\u{41}\u{44}\u{46}","\u{4c}\u{54}","\u{4a}\u{4d}\u{50}","\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
311+local function checkK
312+(func,val)
313+check(func,"\u{4c}\u{4f}\u{41}\u{44}\u{4b}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
314+checkKlist(func,{val})
315+assert((func() == val))
316+end
317+local function checkI
318+(func,val)
319+check(func,"\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
320+checkKlist(func,{})
321+assert((func() == val))
322+end
323+local function checkF
324+(func,val)
325+check(func,"\u{4c}\u{4f}\u{41}\u{44}\u{46}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
326+checkKlist(func,{})
327+assert((func() == val))
328+end
329+checkF(function ()
330+return 0.0
331+end,0.0)
332+checkI(function ()
333+return k0
334+end,0x0)
335+checkI(function ()
336+return (- (k0 // 0x1))
337+end,0x0)
338+checkK(function ()
339+return (0x3 ^ (- 0x1))
340+end,(0x1 / 0x3))
341+checkK(function ()
342+return ((0x1 + 0x1) ^ (0x32 + 0x32))
343+end,(0x2 ^ 0x64))
344+checkK(function ()
345+return ((- 0x2) ^ (0x1f - 0x2))
346+end,(- (0x20000000 + 0.0)))
347+checkF(function ()
348+return ((- ((k3 ^ 0x0) + 0x5)) // 3.0)
349+end,1.0)
350+checkI(function ()
351+return (- (k3 % 0x5))
352+end,0x2)
353+checkF(function ()
354+return (- ((((((2.0 ^ 0x8) + (- (- 0x1))) % 0x8) / 0x2) * 0x4) - 0x3))
355+end,(- 5.0))
356+checkF(function ()
357+return (- ((((((0x2 ^ 0x8) + (- (- 0x1))) % 0x8) // 0x2) * 0x4) - 0x3))
358+end,(- 7.0))
359+checkI(function ()
360+return (240.0 | (204.0 ~ (0xaa & 0xfd)))
361+end,0xf4)
362+checkI(function ()
363+return (~ (~ (kFF0 | kFF0)))
364+end,0x0)
365+checkI(function ()
366+return (~ (~ (- 1024.0)))
367+end,(- 0x400))
368+checkI(function ()
369+return (((0x64 << k6) << (- 0x4)) >> 0x2)
370+end,0x64)
371+local a = 0x11
372+;
373+local sbx = (((0x1 << a) - 0x1) >> 0x1)
374+local border <const> = 0xffff
375+checkI(function ()
376+return border
377+end,sbx)
378+checkI(function ()
379+return (- border)
380+end,(- sbx))
381+checkI(function ()
382+return (border + 0x1)
383+end,(sbx + 0x1))
384+checkK(function ()
385+return (border + 0x2)
386+end,(sbx + 0x2))
387+checkK(function ()
388+return (- (border + 0x1))
389+end,(- (sbx + 0x1)))
390+local border <const> = 65535.0
391+checkF(function ()
392+return border
393+end,(sbx + 0.0))
394+checkF(function ()
395+return (- border)
396+end,(- (sbx + 0.0)))
397+checkF(function ()
398+return (border + 0x1)
399+end,(sbx + 1.0))
400+checkK(function ()
401+return (border + 0x2)
402+end,(sbx + 2.0))
403+checkK(function ()
404+return (- (border + 0x1))
405+end,(- (sbx + 1.0)))
406+checkR(function (x)
407+return (x + k1)
408+end,0xa,0xb,"\u{41}\u{44}\u{44}\u{49}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{49}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
409+checkR(function (x)
410+return (x - 0x7f)
411+end,0xa,(- 0x75),"\u{41}\u{44}\u{44}\u{49}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{49}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
412+checkR(function (x)
413+return (0x80 + x)
414+end,0.0,128.0,"\u{41}\u{44}\u{44}\u{49}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{49}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
415+checkR(function (x)
416+return (x * (- 0x7f))
417+end,(- 1.0),127.0,"\u{4d}\u{55}\u{4c}\u{4b}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{4b}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
418+checkR(function (x)
419+return (0x14 * x)
420+end,0x2,0x28,"\u{4d}\u{55}\u{4c}\u{4b}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{4b}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
421+checkR(function (x)
422+return (x ^ (- 0x2))
423+end,0x2,0.25,"\u{50}\u{4f}\u{57}\u{4b}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{4b}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
424+checkR(function (x)
425+return (x / 0x28)
426+end,0x28,1.0,"\u{44}\u{49}\u{56}\u{4b}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{4b}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
427+checkR(function (x)
428+return (x // 0x1)
429+end,10.0,10.0,"\u{49}\u{44}\u{49}\u{56}\u{4b}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{4b}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
430+checkR(function (x)
431+return (x % (0x64 - 0xa))
432+end,0x5b,0x1,"\u{4d}\u{4f}\u{44}\u{4b}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{4b}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
433+checkR(function (x)
434+return (k1 << x)
435+end,0x3,0x8,"\u{53}\u{48}\u{4c}\u{49}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{49}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
436+checkR(function (x)
437+return (x << 0x7f)
438+end,0xa,0x0,"\u{53}\u{48}\u{52}\u{49}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{49}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
439+checkR(function (x)
440+return (x << (- 0x7f))
441+end,0xa,0x0,"\u{53}\u{48}\u{52}\u{49}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{49}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
442+checkR(function (x)
443+return (x >> 0x80)
444+end,0x8,0x0,"\u{53}\u{48}\u{52}\u{49}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{49}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
445+checkR(function (x)
446+return (x >> (- 0x7f))
447+end,0x8,0x0,"\u{53}\u{48}\u{52}\u{49}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{49}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
448+checkR(function (x)
449+return (x & 0x1)
450+end,0x9,0x1,"\u{42}\u{41}\u{4e}\u{44}\u{4b}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{4b}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
451+checkR(function (x)
452+return (0xa | x)
453+end,0x1,0xb,"\u{42}\u{4f}\u{52}\u{4b}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{4b}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
454+checkR(function (x)
455+return (- (0xa ~ x))
456+end,(- 0x1),0x9,"\u{42}\u{58}\u{4f}\u{52}\u{4b}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{4b}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
457+checkR(function (x)
458+return (x + 0.0)
459+end,0x1,1.0,"\u{41}\u{44}\u{44}\u{4b}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{4b}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
460+checkR(function (x)
461+return (x * (- 0x2710))
462+end,0x2,(- 0x4e20),"\u{4d}\u{55}\u{4c}\u{4b}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{4b}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
463+checkR(function (x)
464+return (x ^ 0.5)
465+end,0x4,2.0,"\u{50}\u{4f}\u{57}\u{4b}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{4b}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
466+checkR(function (x)
467+return (x / 2.0)
468+end,0x4,2.0,"\u{44}\u{49}\u{56}\u{4b}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{4b}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
469+checkR(function (x)
470+return (x // 0x2710)
471+end,0x2710,0x1,"\u{49}\u{44}\u{49}\u{56}\u{4b}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{4b}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
472+checkR(function (x)
473+return (x % (100.0 - 0xa))
474+end,0x5b,1.0,"\u{4d}\u{4f}\u{44}\u{4b}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{4b}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
475+check(function ()
476+return (- 0.0)
477+end,"\u{4c}\u{4f}\u{41}\u{44}\u{46}","\u{55}\u{4e}\u{4d}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
478+check(function ()
479+return (k3 / 0x0)
480+end,"\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{44}\u{49}\u{56}\u{4b}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{4b}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
481+check(function ()
482+return (0x0 % 0x0)
483+end,"\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{4d}\u{4f}\u{44}\u{4b}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{4b}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
484+check(function ()
485+return (- (0x4 // 0x0))
486+end,"\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{49}\u{44}\u{49}\u{56}\u{4b}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{4b}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
487+check(function (x)
488+return (x >> 2.0)
489+end,"\u{4c}\u{4f}\u{41}\u{44}\u{46}","\u{53}\u{48}\u{52}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
490+check(function (x)
491+return (x << 0x80)
492+end,"\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{53}\u{48}\u{4c}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
493+check(function (x)
494+return (x & 2.0)
495+end,"\u{4c}\u{4f}\u{41}\u{44}\u{46}","\u{42}\u{41}\u{4e}\u{44}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
496+check(function ()
497+for i = (- 0xa), 10.5
498+do
499+
500+end
501+end,"\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{4c}\u{4f}\u{41}\u{44}\u{4b}","\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{46}\u{4f}\u{52}\u{50}\u{52}\u{45}\u{50}","\u{46}\u{4f}\u{52}\u{4c}\u{4f}\u{4f}\u{50}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{30}")
502+check(function ()
503+for i = 0xfffffff, 10.0, 0x1
504+do
505+
506+end
507+end,"\u{4c}\u{4f}\u{41}\u{44}\u{4b}","\u{4c}\u{4f}\u{41}\u{44}\u{46}","\u{4c}\u{4f}\u{41}\u{44}\u{49}","\u{46}\u{4f}\u{52}\u{50}\u{52}\u{45}\u{50}","\u{46}\u{4f}\u{52}\u{4c}\u{4f}\u{4f}\u{50}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{30}")
508+check(function ()
509+return (- nil)
510+end,"\u{4c}\u{4f}\u{41}\u{44}\u{4e}\u{49}\u{4c}","\u{55}\u{4e}\u{4d}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
511+check(function ()
512+local a,b,c
513+b[c],a=c,b
514+b[a],a=c,b
515+a,b=c,a
516+a=a
517+end,"\u{4c}\u{4f}\u{41}\u{44}\u{4e}\u{49}\u{4c}","\u{4d}\u{4f}\u{56}\u{45}","\u{4d}\u{4f}\u{56}\u{45}","\u{53}\u{45}\u{54}\u{54}\u{41}\u{42}\u{4c}\u{45}","\u{4d}\u{4f}\u{56}\u{45}","\u{4d}\u{4f}\u{56}\u{45}","\u{4d}\u{4f}\u{56}\u{45}","\u{53}\u{45}\u{54}\u{54}\u{41}\u{42}\u{4c}\u{45}","\u{4d}\u{4f}\u{56}\u{45}","\u{4d}\u{4f}\u{56}\u{45}","\u{4d}\u{4f}\u{56}\u{45}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{30}")
518+do
519+local t
520+check(function ()
521+t[kx]=t.y
522+end,"\u{47}\u{45}\u{54}\u{54}\u{41}\u{42}\u{55}\u{50}","\u{53}\u{45}\u{54}\u{54}\u{41}\u{42}\u{55}\u{50}")
523+check(function (a)
524+t[a()]=t[a()]
525+end,"\u{4d}\u{4f}\u{56}\u{45}","\u{43}\u{41}\u{4c}\u{4c}","\u{47}\u{45}\u{54}\u{55}\u{50}\u{56}\u{41}\u{4c}","\u{4d}\u{4f}\u{56}\u{45}","\u{43}\u{41}\u{4c}\u{4c}","\u{47}\u{45}\u{54}\u{55}\u{50}\u{56}\u{41}\u{4c}","\u{47}\u{45}\u{54}\u{54}\u{41}\u{42}\u{4c}\u{45}","\u{53}\u{45}\u{54}\u{54}\u{41}\u{42}\u{4c}\u{45}")
526+end
527+checkequal(function ()
528+local a
529+;
530+if (not (a or b)) then
531+b=a
532+end
533+end,function ()
534+local a
535+;
536+if (not (a and (not b))) then
537+b=a
538+end
539+end)
540+checkequal(function (l)
541+local a
542+;
543+return ((0x0 <= a) and (a <= l))
544+end,function (l)
545+local a
546+;
547+return (not (not ((a >= 0x0) or (not (a <= l)))))
548+end)
549+check(function (a,b)
550+while a do
551+if b then
552+break
553+else
554+a=(a + 0x1)
555+end
556+end
557+end,"\u{54}\u{45}\u{53}\u{54}","\u{4a}\u{4d}\u{50}","\u{54}\u{45}\u{53}\u{54}","\u{4a}\u{4d}\u{50}","\u{41}\u{44}\u{44}\u{49}","\u{4d}\u{4d}\u{42}\u{49}\u{4e}\u{49}","\u{4a}\u{4d}\u{50}","\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{30}")
558+checkequal(function ()
559+return ((0x6 or true) or nil)
560+end,function ()
561+return ((k6 or kTrue) or kNil)
562+end)
563+checkequal(function ()
564+return ((0x6 and true) or nil)
565+end,function ()
566+return ((k6 and kTrue) or kNil)
567+end)
568+do
569+local k0 <const> = "\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}"
570+local function f1
571+()
572+local k <const> = k0
573+return function ()
574+return function ()
575+return k
576+end
577+end
578+end
579+local f2 = f1()
580+local f3 = f2()
581+assert((f3() == k0))
582+checkK(f3,k0)
583+assert((T.listk(f1)[0x1] == nil))
584+assert((T.listk(f2)[0x1] == nil))
585+end
586+print("\u{4f}\u{4b}")
desk/res/lua/cycled/constructs.luanew file+469
@@ -0,0 +1,469 @@
1+;
2+;
3+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{73}\u{79}\u{6e}\u{74}\u{61}\u{78}")
4+;
5+;
6+local debug = require("\u{64}\u{65}\u{62}\u{75}\u{67}")
7+local function checkload
8+(s,msg)
9+assert(string.find(select(0x2,load(s)),msg))
10+end
11+local a
12+do
13+;
14+;
15+;
16+end
17+;
18+do
19+;
20+a=0x3
21+;
22+assert((a == 0x3))
23+end
24+;
25+;
26+if false then
27+a=(0x3 // 0x0)
28+;
29+a=(0x0 % 0x0)
30+end
31+assert(((0x2 ^ (0x3 ^ 0x2)) == (0x2 ^ (0x3 ^ 0x2))))
32+;
33+assert((((0x2 ^ 0x3) * 0x4) == ((0x2 ^ 0x3) * 0x4)))
34+;
35+assert((2.0 ^ (- ((0x2 == (0x1 / 0x4)) and (- (0x2 ^ (- (- (0x2 == (- (- (- 0x4))))))))))))
36+;
37+assert((not ((nil and 0x2) and (not ((0x2 > 0x3) or (0x3 < 0x2))))))
38+;
39+assert((- (((0x3 - 0x1) - 0x5) == ((0x0 + 0x0) - 0x9))))
40+;
41+assert((- ((0x2 ^ 0x2) == (- ((0x4 and (((- 0x2) ^ 0x2) == 0x4)) and ((((0x2 * 0x2) - 0x3) - 0x1) == 0x0))))))
42+;
43+assert((- (((0x3 % 0x5) == 0x2) and (- ((0x3 + 0x5) == 0x2)))))
44+assert(((((0x2 * 0x1) + (0x3 / 0x3)) == 0x3) and (((0x1 + 0x2) .. (0x3 * 0x1)) == "\u{33}\u{33}")))
45+;
46+assert((not (((0x2 + 0x1) > (0x3 * 0x1)) and (("\u{61}" .. "\u{62}") > "\u{61}"))))
47+;
48+assert(((0xf0 | (0xcc ~ (0xaa & 0xfd))) == 0xf4))
49+assert(((((0xfd & 0xaa) ~ 0xcc) | 0xf0) == 0xf4))
50+assert(((0xf0 & (0xf + 0x1)) == 0x10))
51+assert(((((0x3 ^ 0x4) // (0x2 ^ 0x3)) // 0x5) == 0x2))
52+assert((- (((0x3 + (((0x4 * 0x5) // (0x2 ^ (0x3 ^ 0x2))) // 0x9)) + ((0x4 % 0xa) / 0x3)) == (((- 0x3) + (((0x4 * 0x5) // (0x2 ^ (0x3 ^ 0x2))) // 0x9)) + ((0x4 % 0xa) / 0x3)))))
53+assert((not ((true or false) and nil)))
54+assert((true or (false and nil)))
55+assert(((((0x1 or false) and true) or false) == true))
56+assert(((((nil and true) or false) and true) == false))
57+local a,b = 0x1,nil
58+;
59+assert((- ((0x1 or 0x2) == (- (0x1 and (((0x1 and 0x2) + (- (1.25 or (- 0x4)))) == 0.75))))))
60+;
61+local x = ((((b or a) + 0x1) == 0x2) and (((0xa or a) + 0x1) == 0xb))
62+;
63+assert(x)
64+;
65+x=((((0x2 < 0x3) or 0x1) == true) and (((0x2 < 0x3) and 0x4) == 0x4))
66+;
67+assert(x)
68+;
69+local x,y = 0x1,0x2
70+;
71+assert((((x > y) and x) or (y == 0x2)))
72+;
73+x,y=0x2,0x1
74+;
75+assert((((x > y) and x) or (y == 0x2)))
76+;
77+assert(((0x499602d2 == tonumber("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}")) and ((0x499602d2 + 0x1) == 0x499602d3)))
78+do
79+local operand = {0x3,0x64,5.0,(- 0xa),(- 5.0),0x2710,(- 0x2710)}
80+local operator = {"\u{2b}","\u{2d}","\u{2a}","\u{2f}","\u{2f}\u{2f}","\u{25}","\u{5e}","\u{26}","\u{7c}","\u{5e}","\u{3c}\u{3c}","\u{3e}\u{3e}","\u{3d}\u{3d}","\u{7e}\u{3d}","\u{3c}","\u{3e}","\u{3c}\u{3d}","\u{3e}\u{3d}"}
81+for _,op in ipairs(operator)
82+do
83+local f = assert(load(string.format("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{28}\u{78}\u{2c}\u{79}\u{29}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{78}\u{20}\u{25}\u{73}\u{20}\u{79}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{65}\u{6e}\u{64}",op)))()
84+;
85+for _,o1 in ipairs(operand)
86+do
87+for _,o2 in ipairs(operand)
88+do
89+local gab = f(o1,o2)
90+_ENV.XX=o1
91+local code = string.format("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{58}\u{58}\u{20}\u{25}\u{73}\u{20}\u{25}\u{73}",op,o2)
92+local res = assert(load(code))()
93+assert((res == gab))
94+_ENV.XX=o2
95+code=string.format("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{28}\u{25}\u{73}\u{29}\u{20}\u{25}\u{73}\u{20}\u{58}\u{58}",o1,op)
96+res=assert(load(code))()
97+assert((res == gab))
98+code=string.format("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{28}\u{25}\u{73}\u{29}\u{20}\u{25}\u{73}\u{20}\u{25}\u{73}",o1,op,o2)
99+res=assert(load(code))()
100+assert((res == gab))
101+end
102+end
103+end
104+_ENV.XX=nil
105+end
106+repeat
107+
108+until 0x1
109+;
110+repeat
111+
112+until true
113+;
114+while false do
115+
116+end
117+;
118+while nil do
119+
120+end
121+;
122+do
123+local a
124+;
125+local function f
126+(x)
127+x={["\u{61}"] = 0x1}
128+;
129+x={["\u{78}"] = 0x1}
130+;
131+x={["\u{47}"] = 0x1}
132+end
133+end
134+do
135+local code = {"\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{78}\u{20}\u{3d}\u{20}\u{7b}"}
136+for i = 0x1, 0x101
137+do
138+code[(# (code + 0x1))]=(i .. "\u{2e}\u{31}\u{2c}")
139+end
140+code[(# (code + 0x1))]="\u{7d}\u{3b}"
141+code=table.concat(code)
142+local function check
143+(ret,val)
144+local code = (code .. ret)
145+code=load(code)
146+assert((code() == val))
147+end
148+check("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{28}\u{31}\u{20}\u{7e}\u{20}\u{28}\u{32}\u{20}\u{6f}\u{72}\u{20}\u{33}\u{29}\u{29}",(0x1 ~ 0x2))
149+check("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{28}\u{31}\u{20}\u{7c}\u{20}\u{28}\u{32}\u{20}\u{6f}\u{72}\u{20}\u{33}\u{29}\u{29}",(0x1 | 0x2))
150+check("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{28}\u{31}\u{20}\u{2b}\u{20}\u{28}\u{32}\u{20}\u{6f}\u{72}\u{20}\u{33}\u{29}\u{29}",(0x1 + 0x2))
151+check("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{28}\u{31}\u{20}\u{3c}\u{3c}\u{20}\u{28}\u{32}\u{20}\u{6f}\u{72}\u{20}\u{33}\u{29}\u{29}",(0x1 << 0x2))
152+end
153+local function f
154+(i)
155+if (type(i) ~= "\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}") then
156+return i,"\u{6a}\u{6f}\u{6a}\u{6f}"
157+end
158+;
159+if (i > 0x0) then
160+return i,f((i - 0x1))
161+end
162+;
163+end
164+x={f(0x3),f(0x5),f(0xa)}
165+;
166+assert((((((x[0x1] == 0x3) and (x[0x2] == 0x5)) and (x[0x3] == 0xa)) and (x[0x4] == 0x9)) and (x[0xc] == 0x1)))
167+;
168+assert((x[nil] == nil))
169+x={f("\u{61}\u{6c}\u{6f}"),f("\u{78}\u{69}\u{78}\u{69}"),nil}
170+;
171+assert((((x[0x1] == "\u{61}\u{6c}\u{6f}") and (x[0x2] == "\u{78}\u{69}\u{78}\u{69}")) and (x[0x3] == nil)))
172+;
173+x={(f("\u{61}\u{6c}\u{6f}") .. "\u{78}\u{69}\u{78}\u{69}")}
174+;
175+assert((x[0x1] == "\u{61}\u{6c}\u{6f}\u{78}\u{69}\u{78}\u{69}"))
176+x={f({})}
177+assert(((x[0x2] == "\u{6a}\u{6f}\u{6a}\u{6f}") and (type(x[0x1]) == "\u{74}\u{61}\u{62}\u{6c}\u{65}")))
178+local f = function (i)
179+if (i < 0xa) then
180+return "\u{61}"
181+elseif (i < 0x14) then
182+return "\u{62}"
183+elseif (i < 0x1e) then
184+return "\u{63}"
185+end
186+;
187+end
188+assert(((((f(0x3) == "\u{61}") and (f(0xc) == "\u{62}")) and (f(0x1a) == "\u{63}")) and (f(0x64) == nil)))
189+for i = 0x1, 0x3e8
190+do
191+break
192+;
193+end
194+;
195+local n = 0x64
196+;
197+local i = 0x3
198+;
199+local t = {}
200+;
201+local a = nil
202+while (not a) do
203+a=0x0
204+;
205+for i = 0x1, n
206+do
207+for i = i, 0x1, (- 0x1)
208+do
209+a=(a + 0x1)
210+;
211+t[i]=0x1
212+;
213+end
214+;
215+end
216+;
217+end
218+assert(((a == ((n * (n + 0x1)) / 0x2)) and (i == 0x3)))
219+;
220+assert(((t[0x1] and t[n]) and (not (t[0x0] and (not t[(n + 0x1)])))))
221+function f(b)
222+local x = 0x1
223+;
224+repeat
225+local a
226+;
227+if (b == 0x1) then
228+local b = 0x1
229+;
230+x=0xa
231+;
232+break
233+elseif (b == 0x2) then
234+x=0x14
235+;
236+break
237+;
238+elseif (b == 0x3) then
239+x=0x1e
240+;
241+else
242+local a,b,c,d = math.sin(0x1)
243+;
244+x=(x + 0x1)
245+;
246+end
247+until (x >= 0xc)
248+;
249+return x
250+end
251+;
252+assert(((((f(0x1) == 0xa) and (f(0x2) == 0x14)) and (f(0x3) == 0x1e)) and (f(0x4) == 0xc)))
253+local f = function (i)
254+if (i < 0xa) then
255+return "\u{61}"
256+elseif (i < 0x14) then
257+return "\u{62}"
258+elseif (i < 0x1e) then
259+return "\u{63}"
260+else
261+return 0x8
262+end
263+end
264+assert(((((f(0x3) == "\u{61}") and (f(0xc) == "\u{62}")) and (f(0x1a) == "\u{63}")) and (f(0x64) == 0x8)))
265+local a,b = nil,0x17
266+x={(((f(0x64) * 0x2) + 0x3) or a),(a or (b + 0x2))}
267+assert(((x[0x1] == 0x13) and (x[0x2] == 0x19)))
268+x={["\u{66}"] = ((0x2 + 0x3) or a),["\u{61}"] = (b + 0x2)}
269+assert(((x.f == 0x5) and (x.a == 0x19)))
270+a={["\u{79}"] = 0x1}
271+x={a.y}
272+assert((x[0x1] == 0x1))
273+local function f
274+(i)
275+while 0x1 do
276+if (i > 0x0) then
277+i=(i - 0x1)
278+;
279+else
280+return
281+end
282+;
283+end
284+;
285+end
286+;
287+local function g
288+(i)
289+while 0x1 do
290+if (i > 0x0) then
291+i=(i - 0x1)
292+else
293+return
294+end
295+end
296+end
297+f(0xa)
298+;
299+g(0xa)
300+;
301+do
302+function f()
303+return 0x1,0x2,0x3
304+end
305+local a,b,c = f()
306+;
307+assert((((a == 0x1) and (b == 0x2)) and (c == 0x3)))
308+a,b,c=f()
309+;
310+assert((((a == 0x1) and (b == nil)) and (c == nil)))
311+end
312+local a,b = (0x3 and f())
313+;
314+assert(((a == 0x1) and (b == nil)))
315+function g()
316+f()
317+;
318+return
319+end
320+;
321+assert((g() == nil))
322+function g()
323+return (nil or f())
324+end
325+a,b=g()
326+assert(((a == 0x1) and (b == nil)))
327+print("\u{2b}")
328+;
329+do
330+local prog <const> = "\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{78}\u{20}\u{3c}\u{58}\u{58}\u{58}\u{3e}\u{20}\u{3d}\u{20}\u{31}\u{30}"
331+checkload(prog,"\u{75}\u{6e}\u{6b}\u{6e}\u{6f}\u{77}\u{6e}\u{20}\u{61}\u{74}\u{74}\u{72}\u{69}\u{62}\u{75}\u{74}\u{65}\u{20}\u{27}\u{58}\u{58}\u{58}\u{27}")
332+checkload("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{78}\u{78}\u{78}\u{20}\u{3c}\u{63}\u{6f}\u{6e}\u{73}\u{74}\u{3e}\u{20}\u{3d}\u{20}\u{32}\u{30}\u{3b}\u{20}\u{78}\u{78}\u{78}\u{20}\u{3d}\u{20}\u{31}\u{30}","\u{3a}\u{31}\u{3a}\u{20}\u{61}\u{74}\u{74}\u{65}\u{6d}\u{70}\u{74}\u{20}\u{74}\u{6f}\u{20}\u{61}\u{73}\u{73}\u{69}\u{67}\u{6e}\u{20}\u{74}\u{6f}\u{20}\u{63}\u{6f}\u{6e}\u{73}\u{74}\u{20}\u{76}\u{61}\u{72}\u{69}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{27}\u{78}\u{78}\u{78}\u{27}")
333+checkload("\u{20}\u{20}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{78}\u{78}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{78}\u{78}\u{78}\u{20}\u{3c}\u{63}\u{6f}\u{6e}\u{73}\u{74}\u{3e}\u{20}\u{3d}\u{20}\u{32}\u{30}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{79}\u{79}\u{79}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{66}\u{6f}\u{6f}\u{20}\u{28}\u{29}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{62}\u{63}\u{20}\u{3d}\u{20}\u{78}\u{78}\u{20}\u{2b}\u{20}\u{79}\u{79}\u{79}\u{20}\u{2b}\u{20}\u{78}\u{78}\u{78}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{28}\u{29}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{28}\u{29}\u{20}\u{78}\u{78}\u{78}\u{20}\u{3d}\u{20}\u{79}\u{79}\u{79}\u{20}\u{65}\u{6e}\u{64}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{20}\u{20}\u{20}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{20}\u{20}","\u{3a}\u{36}\u{3a}\u{20}\u{61}\u{74}\u{74}\u{65}\u{6d}\u{70}\u{74}\u{20}\u{74}\u{6f}\u{20}\u{61}\u{73}\u{73}\u{69}\u{67}\u{6e}\u{20}\u{74}\u{6f}\u{20}\u{63}\u{6f}\u{6e}\u{73}\u{74}\u{20}\u{76}\u{61}\u{72}\u{69}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{27}\u{78}\u{78}\u{78}\u{27}")
334+checkload("\u{20}\u{20}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{78}\u{20}\u{3c}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{3e}\u{20}\u{3d}\u{20}\u{6e}\u{69}\u{6c}\u{a}\u{20}\u{20}\u{20}\u{20}\u{78}\u{20}\u{3d}\u{20}\u{69}\u{6f}\u{2e}\u{6f}\u{70}\u{65}\u{6e}\u{28}\u{29}\u{a}\u{20}\u{20}","\u{3a}\u{32}\u{3a}\u{20}\u{61}\u{74}\u{74}\u{65}\u{6d}\u{70}\u{74}\u{20}\u{74}\u{6f}\u{20}\u{61}\u{73}\u{73}\u{69}\u{67}\u{6e}\u{20}\u{74}\u{6f}\u{20}\u{63}\u{6f}\u{6e}\u{73}\u{74}\u{20}\u{76}\u{61}\u{72}\u{69}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{27}\u{78}\u{27}")
335+end
336+f="\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{28}\u{20}\u{61}\u{20}\u{2c}\u{20}\u{62}\u{20}\u{2c}\u{20}\u{63}\u{20}\u{2c}\u{20}\u{64}\u{20}\u{2c}\u{20}\u{65}\u{20}\u{29}\u{a}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{78}\u{20}\u{3d}\u{20}\u{61}\u{20}\u{3e}\u{3d}\u{20}\u{62}\u{20}\u{6f}\u{72}\u{20}\u{63}\u{20}\u{6f}\u{72}\u{20}\u{28}\u{20}\u{64}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{65}\u{20}\u{29}\u{20}\u{6f}\u{72}\u{20}\u{6e}\u{69}\u{6c}\u{a}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{78}\u{a}\u{65}\u{6e}\u{64}\u{20}\u{2c}\u{20}\u{7b}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{31}\u{20}\u{2c}\u{20}\u{62}\u{20}\u{3d}\u{20}\u{32}\u{20}\u{3e}\u{3d}\u{20}\u{31}\u{20}\u{2c}\u{20}\u{7d}\u{20}\u{6f}\u{72}\u{20}\u{7b}\u{20}\u{31}\u{20}\u{7d}\u{3b}\u{a}"
337+f=string.gsub(f,"\u{25}\u{73}\u{2b}","\u{a}")
338+;
339+f,a=load(f)()
340+;
341+assert(((a.a == 0x1) and a.b))
342+function g(a,b,c,d,e)
343+if (not ((((a >= b) or c) or (d and e)) or nil)) then
344+return 0x0
345+else
346+return 0x1
347+end
348+;
349+end
350+local function h
351+(a,b,c,d,e)
352+while ((((a >= b) or c) or (d and e)) or nil) do
353+return 0x1
354+end
355+;
356+return 0x0
357+end
358+;
359+assert((((f(0x2,0x1) == true) and (g(0x2,0x1) == 0x1)) and (h(0x2,0x1) == 0x1)))
360+assert((((f(0x1,0x2,"\u{61}") == "\u{61}") and (g(0x1,0x2,"\u{61}") == 0x1)) and (h(0x1,0x2,"\u{61}") == 0x1)))
361+assert((f(0x1,0x2,"\u{61}") ~= nil),"")
362+assert((((f(0x1,0x2,"\u{61}") == "\u{61}") and (g(0x1,0x2,"\u{61}") == 0x1)) and (h(0x1,0x2,"\u{61}") == 0x1)))
363+assert((((f(0x1,0x2,nil,0x1,"\u{78}") == "\u{78}") and (g(0x1,0x2,nil,0x1,"\u{78}") == 0x1)) and (h(0x1,0x2,nil,0x1,"\u{78}") == 0x1)))
364+assert((((f(0x1,0x2,nil,nil,"\u{78}") == nil) and (g(0x1,0x2,nil,nil,"\u{78}") == 0x0)) and (h(0x1,0x2,nil,nil,"\u{78}") == 0x0)))
365+assert((((f(0x1,0x2,nil,0x1,nil) == nil) and (g(0x1,0x2,nil,0x1,nil) == 0x0)) and (h(0x1,0x2,nil,0x1,nil) == 0x0)))
366+assert((((0x1 and ((0x2 < 0x3) == true)) and (0x2 < 0x3)) and (("\u{61}" < "\u{62}") == true)))
367+x=((0x2 < 0x3) and (not 0x3))
368+;
369+assert((x == false))
370+x=((0x2 < 0x1) or ((0x2 > 0x1) and "\u{61}"))
371+;
372+assert((x == "\u{61}"))
373+do
374+local a
375+;
376+if nil then
377+a=0x1
378+;
379+else
380+a=0x2
381+;
382+end
383+;
384+assert((a == 0x2))
385+end
386+local function F
387+(a)
388+assert((debug.getinfo(0x1,"\u{6e}").name == "\u{46}"))
389+return a,0x2,0x3
390+end
391+a,b=(F(0x1) ~= nil)
392+;
393+assert(((a == true) and (b == nil)))
394+;
395+a,b=(F(nil) == nil)
396+;
397+assert(((a == true) and (b == nil)))
398+_ENV.GLOB1=math.random(0x0,0x1)
399+local basiccases = {{"\u{6e}\u{69}\u{6c}",nil},{"\u{66}\u{61}\u{6c}\u{73}\u{65}",false},{"\u{74}\u{72}\u{75}\u{65}",true},{"\u{31}\u{30}",0xa},{"\u{28}\u{30}\u{3d}\u{3d}\u{5f}\u{45}\u{4e}\u{56}\u{2e}\u{47}\u{4c}\u{4f}\u{42}\u{31}\u{29}",(0x0 == _ENV.GLOB1)}}
400+local prog
401+if (_ENV.GLOB1 == 0x0) then
402+basiccases[0x2][0x1]="\u{46}"
403+prog="\u{20}\u{20}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{46}\u{20}\u{3c}\u{63}\u{6f}\u{6e}\u{73}\u{74}\u{3e}\u{20}\u{3d}\u{20}\u{66}\u{61}\u{6c}\u{73}\u{65}\u{a}\u{20}\u{20}\u{20}\u{20}\u{69}\u{66}\u{20}\u{25}\u{73}\u{20}\u{74}\u{68}\u{65}\u{6e}\u{20}\u{49}\u{58}\u{20}\u{3d}\u{20}\u{74}\u{72}\u{75}\u{65}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{25}\u{73}\u{a}"
404+else
405+basiccases[0x4][0x1]="\u{6b}\u{31}\u{30}"
406+prog="\u{20}\u{20}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{6b}\u{31}\u{30}\u{20}\u{3c}\u{63}\u{6f}\u{6e}\u{73}\u{74}\u{3e}\u{20}\u{3d}\u{20}\u{31}\u{30}\u{a}\u{20}\u{20}\u{20}\u{20}\u{69}\u{66}\u{20}\u{25}\u{73}\u{20}\u{74}\u{68}\u{65}\u{6e}\u{20}\u{49}\u{58}\u{20}\u{3d}\u{20}\u{74}\u{72}\u{75}\u{65}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{25}\u{73}\u{a}\u{20}\u{20}"
407+end
408+print(("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{73}\u{68}\u{6f}\u{72}\u{74}\u{2d}\u{63}\u{69}\u{72}\u{63}\u{75}\u{69}\u{74}\u{20}\u{6f}\u{70}\u{74}\u{69}\u{6d}\u{69}\u{7a}\u{61}\u{74}\u{69}\u{6f}\u{6e}\u{73}\u{20}\u{28}" .. (_ENV.GLOB1 .. "\u{29}")))
409+local binops <const> = {{"\u{20}\u{61}\u{6e}\u{64}\u{20}",function (a,b)
410+if (not a) then
411+return a
412+else
413+return b
414+end
415+end},{"\u{20}\u{6f}\u{72}\u{20}",function (a,b)
416+if a then
417+return a
418+else
419+return b
420+end
421+end}}
422+local cases <const> = {}
423+local function createcases
424+(n)
425+local res = {}
426+for i = 0x1, (n - 0x1)
427+do
428+for _,v1 in ipairs(cases[i])
429+do
430+for _,v2 in ipairs(cases[(n - i)])
431+do
432+for _,op in ipairs(binops)
433+do
434+local t = {("\u{28}" .. (v1[0x1] .. (op[0x1] .. (v2[0x1] .. "\u{29}")))),op[0x2](v1[0x2],v2[0x2])}
435+res[(# (res + 0x1))]=t
436+res[(# (res + 0x1))]={("\u{6e}\u{6f}\u{74}" .. t[0x1]),(not t[0x2])}
437+end
438+end
439+end
440+end
441+return res
442+end
443+local level = ((_soft and 0x3) or 0x4)
444+cases[0x1]=basiccases
445+for i = 0x2, level
446+do
447+cases[i]=createcases(i)
448+end
449+print("\u{2b}")
450+local i = 0x0
451+for n = 0x1, level
452+do
453+for _,v in pairs(cases[n])
454+do
455+local s = v[0x1]
456+local p = load(string.format(prog,s,s),"")
457+IX=false
458+assert(((p() == v[0x2]) and (IX == (not (not v[0x2])))))
459+i=(i + 0x1)
460+if ((i % 0xea60) == 0x0) then
461+print("\u{2b}")
462+end
463+end
464+end
465+IX=nil
466+_G.GLOB1=nil
467+checkload("\u{66}\u{6f}\u{72}\u{20}\u{78}\u{20}\u{64}\u{6f}","\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}")
468+checkload("\u{78}\u{3a}\u{63}\u{61}\u{6c}\u{6c}","\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}")
469+print("\u{4f}\u{4b}")
desk/res/lua/cycled/coroutine.luanew file+1119
@@ -0,0 +1,1119 @@
1+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}\u{73}")
2+local debug = require("\u{64}\u{65}\u{62}\u{75}\u{67}")
3+local f
4+local main,ismain = coroutine.running()
5+assert(((type(main) == "\u{74}\u{68}\u{72}\u{65}\u{61}\u{64}") and ismain))
6+assert((not coroutine.resume(main)))
7+assert((not (coroutine.isyieldable(main) and (not coroutine.isyieldable()))))
8+assert((not pcall(coroutine.yield)))
9+assert((not pcall(coroutine.resume,0x0)))
10+assert((not pcall(coroutine.status,0x0)))
11+local function eqtab
12+(t1,t2)
13+assert((# (t1 == (# t2))))
14+for i = 0x1, (# t1)
15+do
16+local v = t1[i]
17+assert((t2[i] == v))
18+end
19+end
20+_G.x=nil
21+_G.f=nil
22+local function foo
23+(a, ...)
24+local x,y = coroutine.running()
25+assert(((x == f) and (y == false)))
26+assert((coroutine.resume(f) == false))
27+assert((coroutine.status(f) == "\u{72}\u{75}\u{6e}\u{6e}\u{69}\u{6e}\u{67}"))
28+local arg = {...}
29+assert(coroutine.isyieldable(x))
30+for i = 0x1, (# arg)
31+do
32+_G.x={coroutine.yield(table.unpack(arg[i]))}
33+end
34+return table.unpack(a)
35+end
36+f=coroutine.create(foo)
37+assert(coroutine.isyieldable(f))
38+assert(((type(f) == "\u{74}\u{68}\u{72}\u{65}\u{61}\u{64}") and (coroutine.status(f) == "\u{73}\u{75}\u{73}\u{70}\u{65}\u{6e}\u{64}\u{65}\u{64}")))
39+assert(string.find(tostring(f),"\u{74}\u{68}\u{72}\u{65}\u{61}\u{64}"))
40+local s,a,b,c,d
41+s,a,b,c,d=coroutine.resume(f,{0x1,0x2,0x3},{},{0x1},{"\u{61}","\u{62}","\u{63}"})
42+assert(coroutine.isyieldable(f))
43+assert(((s and (a == nil)) and (coroutine.status(f) == "\u{73}\u{75}\u{73}\u{70}\u{65}\u{6e}\u{64}\u{65}\u{64}")))
44+s,a,b,c,d=coroutine.resume(f)
45+eqtab(_G.x,{})
46+assert(((s and (a == 0x1)) and (b == nil)))
47+assert(coroutine.isyieldable(f))
48+s,a,b,c,d=coroutine.resume(f,0x1,0x2,0x3)
49+eqtab(_G.x,{0x1,0x2,0x3})
50+assert(((((s and (a == "\u{61}")) and (b == "\u{62}")) and (c == "\u{63}")) and (d == nil)))
51+s,a,b,c,d=coroutine.resume(f,"\u{78}\u{75}\u{78}\u{75}")
52+eqtab(_G.x,{"\u{78}\u{75}\u{78}\u{75}"})
53+assert(((((s and (a == 0x1)) and (b == 0x2)) and (c == 0x3)) and (d == nil)))
54+assert((coroutine.status(f) == "\u{64}\u{65}\u{61}\u{64}"))
55+s,a=coroutine.resume(f,"\u{78}\u{75}\u{78}\u{75}")
56+assert((not ((s and string.find(a,"\u{64}\u{65}\u{61}\u{64}")) and (coroutine.status(f) == "\u{64}\u{65}\u{61}\u{64}"))))
57+_G.f=nil
58+local function foo
59+(i)
60+return coroutine.yield(i)
61+end
62+local f = coroutine.wrap(function ()
63+for i = 0x1, 0xa
64+do
65+assert((foo(i) == _G.x))
66+end
67+return "\u{61}"
68+end)
69+for i = 0x1, 0xa
70+do
71+_G.x=i
72+;
73+assert((f(i) == i))
74+end
75+_G.x="\u{78}\u{75}\u{78}\u{75}"
76+;
77+assert((f("\u{78}\u{75}\u{78}\u{75}") == "\u{61}"))
78+_G.x=nil
79+local function pf
80+(n,i)
81+coroutine.yield(n)
82+pf((n * i),(i + 0x1))
83+end
84+f=coroutine.wrap(pf)
85+local s = 0x1
86+for i = 0x1, 0xa
87+do
88+assert((f(0x1,0x1) == s))
89+s=(s * i)
90+end
91+local function gen
92+(n)
93+return coroutine.wrap(function ()
94+for i = 0x2, n
95+do
96+coroutine.yield(i)
97+end
98+end)
99+end
100+local function filter
101+(p,g)
102+return coroutine.wrap(function ()
103+while 0x1 do
104+local n = g()
105+if (n == nil) then
106+return
107+end
108+if (math.fmod(n,p) ~= 0x0) then
109+coroutine.yield(n)
110+end
111+end
112+end)
113+end
114+local x = gen(0x50)
115+local a = {}
116+while 0x1 do
117+local n = x()
118+if (n == nil) then
119+break
120+end
121+table.insert(a,n)
122+x=filter(n,x)
123+end
124+assert((# ((a == 0x16) and (a[(# a)] == 0x4f))))
125+x,a=nil
126+print("\u{74}\u{6f}\u{2d}\u{62}\u{65}\u{2d}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{64}\u{20}\u{76}\u{61}\u{72}\u{69}\u{61}\u{62}\u{6c}\u{65}\u{73}\u{20}\u{69}\u{6e}\u{20}\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}\u{73}")
127+local function func2close
128+(f)
129+return setmetatable({},{["\u{5f}\u{5f}\u{63}\u{6c}\u{6f}\u{73}\u{65}"] = f})
130+end
131+do
132+local co = coroutine.create(print)
133+assert(coroutine.resume(co,"\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{27}\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}\u{2e}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{27}"))
134+assert((coroutine.status(co) == "\u{64}\u{65}\u{61}\u{64}"))
135+local st,msg = coroutine.close(co)
136+assert((st and (msg == nil)))
137+st,msg=coroutine.close(co)
138+assert((st and (msg == nil)))
139+local st,msg = pcall(coroutine.close,coroutine.running())
140+assert((not (st and string.find(msg,"\u{72}\u{75}\u{6e}\u{6e}\u{69}\u{6e}\u{67}"))))
141+local main = coroutine.running()
142+;
143+(coroutine.wrap(function ()
144+local st,msg = pcall(coroutine.close,main)
145+assert((not (st and string.find(msg,"\u{6e}\u{6f}\u{72}\u{6d}\u{61}\u{6c}"))))
146+end))()
147+do
148+local co
149+co=coroutine.create(function ()
150+local x <close> = func2close(function ()
151+coroutine.close(co)
152+end)
153+coroutine.yield(0x14)
154+end)
155+local st,msg = coroutine.resume(co)
156+assert((st and (msg == 0x14)))
157+st,msg=coroutine.close(co)
158+assert((not (st and string.find(msg,"\u{72}\u{75}\u{6e}\u{6e}\u{69}\u{6e}\u{67}\u{20}\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}"))))
159+end
160+local X
161+local co = coroutine.create(error)
162+local st,msg = coroutine.resume(co,0x64)
163+assert((not (st and (msg == 0x64))))
164+st,msg=coroutine.close(co)
165+assert((not (st and (msg == 0x64))))
166+st,msg=coroutine.close(co)
167+assert((st and (msg == nil)))
168+co=coroutine.create(function ()
169+local x <close> = func2close(function (self,err)
170+assert((err == nil))
171+;
172+X=false
173+end)
174+X=true
175+coroutine.yield()
176+end)
177+coroutine.resume(co)
178+assert(X)
179+assert(coroutine.close(co))
180+assert((not (X and (coroutine.status(co) == "\u{64}\u{65}\u{61}\u{64}"))))
181+local x = 0x0
182+co=coroutine.create(function ()
183+local y <close> = func2close(function (self,err)
184+assert((err == 0x6f))
185+x=0xc8
186+error(0xc8)
187+end)
188+local x <close> = func2close(function (self,err)
189+assert((err == nil))
190+;
191+error(0x6f)
192+end)
193+coroutine.yield()
194+end)
195+coroutine.resume(co)
196+assert((x == 0x0))
197+local st,msg = coroutine.close(co)
198+assert((((st == false) and (coroutine.status(co) == "\u{64}\u{65}\u{61}\u{64}")) and (msg == 0xc8)))
199+assert((x == 0xc8))
200+st,msg=coroutine.close(co)
201+assert((st and (msg == nil)))
202+end
203+do
204+local X = false
205+local Y = false
206+local function foo
207+()
208+local x <close> = func2close(function (self,err)
209+Y=debug.getinfo(0x2)
210+X=err
211+end)
212+error(0x2b)
213+end
214+local co = coroutine.create(function ()
215+return pcall(foo)
216+end)
217+local st1,st2,err = coroutine.resume(co)
218+assert((st1 and (not (st2 and (err == 0x2b)))))
219+assert(((X == 0x2b) and (Y.what == "\u{43}")))
220+local track = {}
221+local function h
222+(o)
223+local hv <close> = o
224+return 0x1
225+end
226+local function foo
227+()
228+local x <close> = func2close(function (_,msg)
229+track[(# (track + 0x1))]=(msg or false)
230+error(0x14)
231+end)
232+local y <close> = func2close(function (_,msg)
233+track[(# (track + 0x1))]=(msg or false)
234+return 0x3e8
235+end)
236+local z <close> = func2close(function (_,msg)
237+track[(# (track + 0x1))]=(msg or false)
238+error(0xa)
239+end)
240+coroutine.yield(0x1)
241+h(func2close(function (_,msg)
242+track[(# (track + 0x1))]=(msg or false)
243+error(0x2)
244+end))
245+end
246+local co = coroutine.create(pcall)
247+local st,res = coroutine.resume(co,foo)
248+assert((st and (res == 0x1)))
249+local st,res1,res2 = coroutine.resume(co)
250+assert((coroutine.status(co) == "\u{64}\u{65}\u{61}\u{64}"))
251+assert((st and (not (res1 and (res2 == 0x14)))))
252+assert(((((track[0x1] == false) and (track[0x2] == 0x2)) and (track[0x3] == 0xa)) and (track[0x4] == 0xa)))
253+end
254+local co = coroutine.wrap(function ()
255+assert((not pcall(table.sort,{0x1,0x2,0x3},coroutine.yield)))
256+assert(coroutine.isyieldable())
257+coroutine.yield(0x14)
258+return 0x1e
259+end)
260+assert((co() == 0x14))
261+assert((co() == 0x1e))
262+local f = function (s,i)
263+return coroutine.yield(i)
264+end
265+local f1 = coroutine.wrap(function ()
266+return xpcall(pcall,function (...)
267+return ...
268+end,function ()
269+local s = 0x0
270+for i in f,nil,0x1
271+do
272+pcall(function ()
273+s=(s + i)
274+end)
275+end
276+error({s})
277+end)
278+end)
279+f1()
280+for i = 0x1, 0xa
281+do
282+assert((f1(i) == i))
283+end
284+local r1,r2,v = f1(nil)
285+assert((r1 and (not (r2 and (v[0x1] == (((0xa + 0x1) * 0xa) / 0x2))))))
286+local function f
287+(a,b)
288+a=coroutine.yield(a)
289+;
290+error({(a + b)})
291+end
292+local function g
293+(x)
294+return (x[0x1] * 0x2)
295+end
296+co=coroutine.wrap(function ()
297+coroutine.yield(xpcall(f,g,0xa,0x14))
298+end)
299+assert((co() == 0xa))
300+local r,msg = co(0x64)
301+assert((not (r and (msg == 0xf0))))
302+do
303+local function f
304+(c)
305+assert((not coroutine.isyieldable()))
306+return (c .. c)
307+end
308+local co = coroutine.wrap(function (c)
309+assert(coroutine.isyieldable())
310+local s = string.gsub("\u{61}","\u{2e}",f)
311+return s
312+end)
313+assert((co() == "\u{61}\u{61}"))
314+end
315+do
316+local X
317+local co = coroutine.create(function ()
318+coroutine.yield(0xa)
319+return 0x14
320+end)
321+local trace = {}
322+local function dotrace
323+(event)
324+trace[(# (trace + 0x1))]=event
325+end
326+debug.sethook(co,dotrace,"\u{63}\u{6c}\u{72}")
327+repeat
328+
329+until (not coroutine.resume(co))
330+local correcttrace = {"\u{63}\u{61}\u{6c}\u{6c}","\u{6c}\u{69}\u{6e}\u{65}","\u{63}\u{61}\u{6c}\u{6c}","\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}","\u{6c}\u{69}\u{6e}\u{65}","\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}"}
331+assert((# (trace == (# correcttrace))))
332+for k,v in pairs(trace)
333+do
334+assert((v == correcttrace[k]))
335+end
336+end
337+function foo()
338+assert((debug.getinfo(0x1).currentline == (debug.getinfo(foo).linedefined + 0x1)))
339+assert((debug.getinfo(0x2).currentline == debug.getinfo(goo).linedefined))
340+coroutine.yield(0x3)
341+error(foo)
342+end
343+function goo()
344+foo()
345+end
346+x=coroutine.wrap(goo)
347+assert((x() == 0x3))
348+local a,b = pcall(x)
349+assert((not (a and (b == foo))))
350+x=coroutine.create(goo)
351+a,b=coroutine.resume(x)
352+assert((a and (b == 0x3)))
353+a,b=coroutine.resume(x)
354+assert((not ((a and (b == foo)) and (coroutine.status(x) == "\u{64}\u{65}\u{61}\u{64}"))))
355+a,b=coroutine.resume(x)
356+assert((not ((a and string.find(b,"\u{64}\u{65}\u{61}\u{64}")) and (coroutine.status(x) == "\u{64}\u{65}\u{61}\u{64}"))))
357+goo=nil
358+local function all
359+(a,n,k)
360+if (k == 0x0) then
361+coroutine.yield(a)
362+else
363+for i = 0x1, n
364+do
365+a[k]=i
366+all(a,n,(k - 0x1))
367+end
368+end
369+end
370+local a = 0x0
371+for t in coroutine.wrap(function ()
372+all({},0x5,0x4)
373+end)
374+do
375+a=(a + 0x1)
376+end
377+assert((a == (0x5 ^ 0x4)))
378+local C = {}
379+;
380+setmetatable(C,{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{6b}\u{76}"})
381+local x = coroutine.wrap(function ()
382+local a = 0xa
383+local function f
384+()
385+a=(a + 0xa)
386+;
387+return a
388+end
389+while true do
390+a=(a + 0x1)
391+coroutine.yield(f)
392+end
393+end)
394+C[0x1]=x
395+;
396+local f = x()
397+assert((((f() == 0x15) and (x()() == 0x20)) and (x() == f)))
398+x=nil
399+collectgarbage()
400+assert((C[0x1] == undef))
401+assert(((f() == 0x2b) and (f() == 0x35)))
402+local function co_func
403+(current_co)
404+assert((coroutine.running() == current_co))
405+assert((coroutine.resume(current_co) == false))
406+coroutine.yield(0xa,0x14)
407+assert((coroutine.resume(current_co) == false))
408+coroutine.yield(0x17)
409+return 0xa
410+end
411+local co = coroutine.create(co_func)
412+local a,b,c = coroutine.resume(co,co)
413+assert((((a == true) and (b == 0xa)) and (c == 0x14)))
414+a,b=coroutine.resume(co,co)
415+assert(((a == true) and (b == 0x17)))
416+a,b=coroutine.resume(co,co)
417+assert(((a == true) and (b == 0xa)))
418+assert((coroutine.resume(co,co) == false))
419+assert((coroutine.resume(co,co) == false))
420+do
421+local A = coroutine.running()
422+local B = coroutine.create(function ()
423+return coroutine.resume(A)
424+end)
425+local st,res = coroutine.resume(B)
426+assert(((st == true) and (res == false)))
427+local X = false
428+A=coroutine.wrap(function ()
429+local _ <close> = func2close(function ()
430+X=true
431+end)
432+return pcall(A,0x1)
433+end)
434+st,res=A()
435+assert((not ((st and string.find(res,"\u{6e}\u{6f}\u{6e}\u{25}\u{2d}\u{73}\u{75}\u{73}\u{70}\u{65}\u{6e}\u{64}\u{65}\u{64}")) and (X == true))))
436+end
437+do
438+local co
439+co=coroutine.wrap(function ()
440+local x <close> = func2close(function ()
441+return pcall(co)
442+end)
443+error(0x6f)
444+end)
445+local st,errobj = pcall(co)
446+assert((not (st and (errobj == 0x6f))))
447+st,errobj=pcall(co)
448+assert((not (st and string.find(errobj,"\u{64}\u{65}\u{61}\u{64}\u{20}\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}"))))
449+end
450+local co1,co2
451+co1=coroutine.create(function ()
452+return co2()
453+end)
454+co2=coroutine.wrap(function ()
455+assert((coroutine.status(co1) == "\u{6e}\u{6f}\u{72}\u{6d}\u{61}\u{6c}"))
456+assert((not coroutine.resume(co1)))
457+coroutine.yield(0x3)
458+end)
459+a,b=coroutine.resume(co1)
460+assert((a and (b == 0x3)))
461+assert((coroutine.status(co1) == "\u{64}\u{65}\u{61}\u{64}"))
462+a=function (a)
463+coroutine.wrap(a)(a)
464+end
465+assert((not pcall(a,a)))
466+a=nil
467+local x = coroutine.create(function ()
468+local a = 0xa
469+_G.F=function ()
470+a=(a + 0x1)
471+;
472+return a
473+end
474+error("\u{78}")
475+end)
476+assert((not coroutine.resume(x)))
477+assert((not coroutine.resume(x,0x1,0x1,0x1,0x1,0x1,0x1,0x1)))
478+assert((_G.F() == 0xb))
479+assert((_G.F() == 0xc))
480+_G.F=nil
481+if (not T) then
482+(Message or print)("\u{a}\u{20}\u{3e}\u{3e}\u{3e}\u{20}\u{74}\u{65}\u{73}\u{74}\u{43}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{61}\u{63}\u{74}\u{69}\u{76}\u{65}\u{3a}\u{20}\u{73}\u{6b}\u{69}\u{70}\u{70}\u{69}\u{6e}\u{67}\u{20}\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}\u{20}\u{41}\u{50}\u{49}\u{20}\u{74}\u{65}\u{73}\u{74}\u{73}\u{20}\u{3c}\u{3c}\u{3c}\u{a}")
483+else
484+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{79}\u{69}\u{65}\u{6c}\u{64}\u{73}\u{20}\u{69}\u{6e}\u{73}\u{69}\u{64}\u{65}\u{20}\u{68}\u{6f}\u{6f}\u{6b}\u{73}")
485+local turn
486+local function fact
487+(t,x)
488+assert((turn == t))
489+if (x == 0x0) then
490+return 0x1
491+else
492+return (x * fact(t,(x - 0x1)))
493+end
494+end
495+local A,B = 0x0,0x0
496+local x = coroutine.create(function ()
497+T.sethook("\u{79}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{30}","",0x2)
498+A=fact("\u{41}",0x6)
499+end)
500+local y = coroutine.create(function ()
501+T.sethook("\u{79}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{30}","",0x3)
502+B=fact("\u{42}",0x7)
503+end)
504+while ((A == 0x0) or (B == 0x0)) do
505+if (A == 0x0) then
506+turn="\u{41}"
507+;
508+assert(T.resume(x))
509+end
510+if (B == 0x0) then
511+turn="\u{42}"
512+;
513+assert(T.resume(y))
514+end
515+debug.traceback(x)
516+debug.traceback(y)
517+end
518+assert(((B // A) == 0x7))
519+do
520+local done
521+local function test
522+(n)
523+done=false
524+return coroutine.wrap(function ()
525+local a = {}
526+for i = 0x1, n
527+do
528+a[i]=i
529+end
530+T.sethook("\u{70}\u{75}\u{73}\u{68}\u{69}\u{6e}\u{74}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{79}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{30}","",0x1)
531+local a1 = {table.unpack(a)}
532+assert((# (a1 == n)))
533+for i = 0x1, n
534+do
535+assert((a[i] == i))
536+end
537+done=true
538+end)
539+end
540+local co = test(0x0)
541+;
542+while (not done) do
543+co(0x1e)
544+end
545+co=test(0x1)
546+;
547+while (not done) do
548+co(0x14,0xa)
549+end
550+co=test(0x3)
551+;
552+while (not done) do
553+co()
554+end
555+co=test(0x64)
556+;
557+while (not done) do
558+co()
559+end
560+end
561+local line = (debug.getinfo(0x1,"\u{6c}").currentline + 0x2)
562+local function foo
563+()
564+local x = 0xa
565+x=(x + 0xa)
566+_G.XX=x
567+end
568+local co = coroutine.wrap(function ()
569+T.sethook("\u{73}\u{65}\u{74}\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{58}\u{3b}\u{20}\u{79}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{30}","\u{6c}",0x0)
570+;
571+foo()
572+;
573+return 0xa
574+end)
575+_G.XX=nil
576+;
577+_G.X=nil
578+;
579+co()
580+;
581+assert((_G.X == line))
582+_G.X=nil
583+;
584+co()
585+;
586+assert((_G.X == (line + 0x1)))
587+_G.X=nil
588+;
589+co()
590+;
591+assert(((_G.X == (line + 0x2)) and (_G.XX == nil)))
592+_G.X=nil
593+;
594+co()
595+;
596+assert(((_G.X == (line + 0x3)) and (_G.XX == 0x14)))
597+assert((co() == 0xa))
598+_G.X=nil
599+co=coroutine.wrap(function ()
600+T.sethook("\u{79}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{30}","",0x1)
601+;
602+foo()
603+;
604+return 0xa
605+end)
606+_G.XX=nil
607+;
608+local c = 0x0
609+repeat
610+c=(c + 0x1)
611+;
612+local a = co()
613+until (a == 0xa)
614+assert(((_G.XX == 0x14) and (c >= 0x5)))
615+co=coroutine.wrap(function ()
616+T.sethook("\u{79}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{30}","",0x2)
617+;
618+foo()
619+;
620+return 0xa
621+end)
622+_G.XX=nil
623+;
624+local c = 0x0
625+repeat
626+c=(c + 0x1)
627+;
628+local a = co()
629+until (a == 0xa)
630+assert(((_G.XX == 0x14) and (c >= 0x5)))
631+_G.X=nil
632+;
633+_G.XX=nil
634+do
635+c=coroutine.create(function (a, ...)
636+T.sethook("\u{79}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{30}","\u{6c}")
637+local b = a
638+return ...
639+end)
640+assert(coroutine.resume(c,0x1,0x2,0x3))
641+local n,v = debug.getlocal(c,0x0,0x1)
642+assert((((n == "\u{61}") and (v == 0x1)) and (debug.getlocal(c,0x0,0x2) ~= "\u{62}")))
643+assert(debug.setlocal(c,0x0,0x1,0xa))
644+local t = debug.getinfo(c,0x0)
645+assert((t.currentline == (t.linedefined + 0x2)))
646+assert((not debug.getinfo(c,0x1)))
647+assert(coroutine.resume(c))
648+local n,v = debug.getlocal(c,0x0,0x2)
649+assert(((n == "\u{62}") and (v == 0xa)))
650+v={coroutine.resume(c)}
651+assert(((((v[0x1] == true) and (v[0x2] == 0x2)) and (v[0x3] == 0x3)) and (v[0x4] == undef)))
652+assert((not coroutine.resume(c)))
653+end
654+do
655+local c = coroutine.create(function ()
656+T.testC("\u{79}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{31}",0xa,0x14)
657+end)
658+local a,b = coroutine.resume(c)
659+assert((a and (b == 0x14)))
660+assert((debug.getinfo(c,0x0).linedefined == (- 0x1)))
661+a,b=debug.getlocal(c,0x0,0x2)
662+assert((b == 0xa))
663+end
664+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}\u{20}\u{41}\u{50}\u{49}")
665+assert((T.testC("\u{20}\u{20}\u{20}\u{20}\u{6e}\u{65}\u{77}\u{74}\u{68}\u{72}\u{65}\u{61}\u{64}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{63}\u{72}\u{65}\u{61}\u{74}\u{65}\u{20}\u{74}\u{68}\u{72}\u{65}\u{61}\u{64}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{32}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{70}\u{75}\u{73}\u{68}\u{20}\u{62}\u{6f}\u{64}\u{79}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{27}\u{61}\u{20}\u{61}\u{20}\u{61}\u{27}\u{20}\u{20}\u{23}\u{20}\u{70}\u{75}\u{73}\u{68}\u{20}\u{61}\u{72}\u{67}\u{75}\u{6d}\u{65}\u{6e}\u{74}\u{a}\u{20}\u{20}\u{20}\u{20}\u{78}\u{6d}\u{6f}\u{76}\u{65}\u{20}\u{30}\u{20}\u{33}\u{20}\u{32}\u{20}\u{20}\u{20}\u{23}\u{20}\u{6d}\u{6f}\u{76}\u{65}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{73}\u{20}\u{74}\u{6f}\u{20}\u{6e}\u{65}\u{77}\u{20}\u{74}\u{68}\u{72}\u{65}\u{61}\u{64}\u{a}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{73}\u{75}\u{6d}\u{65}\u{20}\u{2d}\u{31}\u{2c}\u{20}\u{31}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{69}\u{74}\u{20}\u{66}\u{69}\u{72}\u{73}\u{74}\u{20}\u{74}\u{69}\u{6d}\u{65}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{61}\u{74}\u{75}\u{73}\u{a}\u{20}\u{20}\u{20}\u{20}\u{78}\u{6d}\u{6f}\u{76}\u{65}\u{20}\u{33}\u{20}\u{30}\u{20}\u{30}\u{20}\u{20}\u{20}\u{23}\u{20}\u{6d}\u{6f}\u{76}\u{65}\u{20}\u{72}\u{65}\u{73}\u{75}\u{6c}\u{74}\u{73}\u{20}\u{62}\u{61}\u{63}\u{6b}\u{20}\u{74}\u{6f}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{73}\u{65}\u{74}\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{58}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{72}\u{65}\u{73}\u{75}\u{6c}\u{74}\u{a}\u{20}\u{20}\u{20}\u{20}\u{73}\u{65}\u{74}\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{59}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{73}\u{74}\u{61}\u{74}\u{75}\u{73}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{32}\u{20}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{70}\u{75}\u{73}\u{68}\u{20}\u{62}\u{6f}\u{64}\u{79}\u{20}\u{28}\u{74}\u{6f}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{69}\u{74}\u{20}\u{61}\u{67}\u{61}\u{69}\u{6e}\u{29}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{27}\u{62}\u{20}\u{62}\u{20}\u{62}\u{27}\u{a}\u{20}\u{20}\u{20}\u{20}\u{78}\u{6d}\u{6f}\u{76}\u{65}\u{20}\u{30}\u{20}\u{33}\u{20}\u{32}\u{a}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{73}\u{75}\u{6d}\u{65}\u{20}\u{2d}\u{31}\u{2c}\u{20}\u{31}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{69}\u{74}\u{20}\u{61}\u{67}\u{61}\u{69}\u{6e}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{61}\u{74}\u{75}\u{73}\u{a}\u{20}\u{20}\u{20}\u{20}\u{78}\u{6d}\u{6f}\u{76}\u{65}\u{20}\u{33}\u{20}\u{30}\u{20}\u{30}\u{a}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{72}\u{65}\u{73}\u{75}\u{6c}\u{74}\u{a}\u{20}\u{20}",function (...)
666+return ...
667+end) == "\u{62}\u{20}\u{62}\u{20}\u{62}"))
668+assert(((X == "\u{61}\u{20}\u{61}\u{20}\u{61}") and (Y == "\u{4f}\u{4b}")))
669+X,Y=nil
670+C=coroutine.create(function ()
671+return T.testC("\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{30}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{32}\u{30}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{73}\u{75}\u{6d}\u{65}\u{20}\u{2d}\u{33}\u{20}\u{32}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{61}\u{74}\u{75}\u{73}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{67}\u{65}\u{74}\u{74}\u{6f}\u{70}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{33}",C)
672+end)
673+local a,b,c,d = coroutine.resume(C)
674+assert(((((a == true) and string.find(b,"\u{6e}\u{6f}\u{6e}\u{25}\u{2d}\u{73}\u{75}\u{73}\u{70}\u{65}\u{6e}\u{64}\u{65}\u{64}")) and (c == "\u{45}\u{52}\u{52}\u{52}\u{55}\u{4e}")) and (d == 0x4)))
675+a,b,c,d=T.testC("\u{20}\u{20}\u{20}\u{20}\u{72}\u{61}\u{77}\u{67}\u{65}\u{74}\u{69}\u{20}\u{52}\u{20}\u{31}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{67}\u{65}\u{74}\u{20}\u{6d}\u{61}\u{69}\u{6e}\u{20}\u{74}\u{68}\u{72}\u{65}\u{61}\u{64}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{30}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{32}\u{30}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{73}\u{75}\u{6d}\u{65}\u{20}\u{2d}\u{33}\u{20}\u{32}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{61}\u{74}\u{75}\u{73}\u{a}\u{20}\u{20}\u{20}\u{20}\u{67}\u{65}\u{74}\u{74}\u{6f}\u{70}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{34}")
676+assert(((((a == coroutine.running()) and string.find(b,"\u{6e}\u{6f}\u{6e}\u{25}\u{2d}\u{73}\u{75}\u{73}\u{70}\u{65}\u{6e}\u{64}\u{65}\u{64}")) and (c == "\u{45}\u{52}\u{52}\u{52}\u{55}\u{4e}")) and (d == 0x4)))
677+local state = T.newstate()
678+assert(T.testC(state,"\u{6e}\u{65}\u{77}\u{74}\u{68}\u{72}\u{65}\u{61}\u{64}\u{3b}\u{20}\u{69}\u{73}\u{79}\u{69}\u{65}\u{6c}\u{64}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{2d}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{6d}\u{6f}\u{76}\u{65}\u{20}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}"))
679+assert((not T.testC(state,"\u{72}\u{61}\u{77}\u{67}\u{65}\u{74}\u{69}\u{20}\u{52}\u{20}\u{31}\u{3b}\u{20}\u{69}\u{73}\u{79}\u{69}\u{65}\u{6c}\u{64}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{2d}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{6d}\u{6f}\u{76}\u{65}\u{20}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}")))
680+T.testC(state,"\u{73}\u{65}\u{74}\u{74}\u{6f}\u{70}\u{20}\u{30}")
681+T.loadlib(state)
682+assert(T.doremote(state,"\u{20}\u{20}\u{20}\u{20}\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}\u{20}\u{3d}\u{20}\u{72}\u{65}\u{71}\u{75}\u{69}\u{72}\u{65}\u{27}\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}\u{27}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{58}\u{20}\u{3d}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{28}\u{78}\u{29}\u{20}\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}\u{2e}\u{79}\u{69}\u{65}\u{6c}\u{64}\u{28}\u{78}\u{2c}\u{20}\u{27}\u{42}\u{42}\u{27}\u{29}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{27}\u{43}\u{43}\u{27}\u{20}\u{65}\u{6e}\u{64}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{27}\u{6f}\u{6b}\u{27}"))
683+local t = table.pack(T.testC(state,"\u{20}\u{20}\u{20}\u{20}\u{72}\u{61}\u{77}\u{67}\u{65}\u{74}\u{69}\u{20}\u{52}\u{20}\u{31}\u{20}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{67}\u{65}\u{74}\u{20}\u{6d}\u{61}\u{69}\u{6e}\u{20}\u{74}\u{68}\u{72}\u{65}\u{61}\u{64}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{27}\u{58}\u{58}\u{27}\u{a}\u{20}\u{20}\u{20}\u{20}\u{67}\u{65}\u{74}\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{58}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{67}\u{65}\u{74}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{66}\u{6f}\u{72}\u{20}\u{62}\u{6f}\u{64}\u{79}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{41}\u{41}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{61}\u{72}\u{67}\u{a}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{73}\u{75}\u{6d}\u{65}\u{20}\u{31}\u{20}\u{31}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{27}\u{72}\u{65}\u{73}\u{75}\u{6d}\u{65}\u{27}\u{20}\u{73}\u{68}\u{61}\u{64}\u{6f}\u{77}\u{73}\u{20}\u{70}\u{72}\u{65}\u{76}\u{69}\u{6f}\u{75}\u{73}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{21}\u{a}\u{20}\u{20}\u{20}\u{20}\u{67}\u{65}\u{74}\u{74}\u{6f}\u{70}\u{a}\u{20}\u{20}\u{20}\u{20}\u{73}\u{65}\u{74}\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{54}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{74}\u{6f}\u{70}\u{a}\u{20}\u{20}\u{20}\u{20}\u{73}\u{65}\u{74}\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{42}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{73}\u{65}\u{63}\u{6f}\u{6e}\u{64}\u{20}\u{79}\u{69}\u{65}\u{6c}\u{64}\u{65}\u{64}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{a}\u{20}\u{20}\u{20}\u{20}\u{73}\u{65}\u{74}\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{41}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{66}\u{69}\u{73}\u{74}\u{20}\u{79}\u{69}\u{65}\u{6c}\u{64}\u{65}\u{64}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{a}\u{20}\u{20}\u{20}\u{20}\u{72}\u{61}\u{77}\u{67}\u{65}\u{74}\u{69}\u{20}\u{52}\u{20}\u{31}\u{20}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{67}\u{65}\u{74}\u{20}\u{6d}\u{61}\u{69}\u{6e}\u{20}\u{74}\u{68}\u{72}\u{65}\u{61}\u{64}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{35}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{61}\u{72}\u{67}\u{20}\u{28}\u{6e}\u{6f}\u{69}\u{73}\u{65}\u{29}\u{a}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{73}\u{75}\u{6d}\u{65}\u{20}\u{31}\u{20}\u{31}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{61}\u{66}\u{74}\u{65}\u{72}\u{20}\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}\u{20}\u{65}\u{6e}\u{64}\u{73}\u{2c}\u{20}\u{70}\u{72}\u{65}\u{76}\u{69}\u{6f}\u{75}\u{73}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{69}\u{73}\u{20}\u{62}\u{61}\u{63}\u{6b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{61}\u{74}\u{75}\u{73}\u{a}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}\u{a}\u{20}\u{20}"))
684+assert(((((t.n == 0x4) and (t[0x2] == "\u{58}\u{58}")) and (t[0x3] == "\u{43}\u{43}")) and (t[0x4] == "\u{4f}\u{4b}")))
685+assert((T.doremote(state,"\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{54}") == "\u{32}"))
686+assert((T.doremote(state,"\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{41}") == "\u{41}\u{41}"))
687+assert((T.doremote(state,"\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{42}") == "\u{42}\u{42}"))
688+T.closestate(state)
689+print("\u{2b}")
690+end
691+_G.TO_SURVIVE=coroutine.wrap(function ()
692+local a = 0xa
693+local x = function ()
694+a=(a + 0x1)
695+end
696+coroutine.yield()
697+end)
698+_G.TO_SURVIVE()
699+if (not _soft) then
700+local lim = 0xf4240
701+local t = {(lim - 0xa),(lim - 0x5),(lim - 0x1),lim,(lim + 0x1),(lim + 0x5)}
702+for i = 0x1, (# t)
703+do
704+local j = t[i]
705+local co = coroutine.create(function ()
706+return table.unpack({},0x1,j)
707+end)
708+local r,msg = coroutine.resume(co)
709+assert(((j < lim) or (not r)))
710+end
711+end
712+assert((coroutine.running() == main))
713+print("\u{2b}")
714+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{79}\u{69}\u{65}\u{6c}\u{64}\u{73}\u{20}\u{69}\u{6e}\u{73}\u{69}\u{64}\u{65}\u{20}\u{6d}\u{65}\u{74}\u{61}\u{6d}\u{65}\u{74}\u{68}\u{6f}\u{64}\u{73}")
715+local function val
716+(x)
717+if (type(x) == "\u{74}\u{61}\u{62}\u{6c}\u{65}") then
718+return x.x
719+else
720+return x
721+end
722+end
723+local mt = {["\u{5f}\u{5f}\u{65}\u{71}"] = function (a,b)
724+coroutine.yield(nil,"\u{65}\u{71}")
725+;
726+return (val(a) == val(b))
727+end,["\u{5f}\u{5f}\u{6c}\u{74}"] = function (a,b)
728+coroutine.yield(nil,"\u{6c}\u{74}")
729+;
730+return (val(a) < val(b))
731+end,["\u{5f}\u{5f}\u{6c}\u{65}"] = function (a,b)
732+coroutine.yield(nil,"\u{6c}\u{65}")
733+;
734+return ((a - b) <= 0x0)
735+end,["\u{5f}\u{5f}\u{61}\u{64}\u{64}"] = function (a,b)
736+coroutine.yield(nil,"\u{61}\u{64}\u{64}")
737+;
738+return (val(a) + val(b))
739+end,["\u{5f}\u{5f}\u{73}\u{75}\u{62}"] = function (a,b)
740+coroutine.yield(nil,"\u{73}\u{75}\u{62}")
741+;
742+return (val(a) - val(b))
743+end,["\u{5f}\u{5f}\u{6d}\u{75}\u{6c}"] = function (a,b)
744+coroutine.yield(nil,"\u{6d}\u{75}\u{6c}")
745+;
746+return (val(a) * val(b))
747+end,["\u{5f}\u{5f}\u{64}\u{69}\u{76}"] = function (a,b)
748+coroutine.yield(nil,"\u{64}\u{69}\u{76}")
749+;
750+return (val(a) / val(b))
751+end,["\u{5f}\u{5f}\u{69}\u{64}\u{69}\u{76}"] = function (a,b)
752+coroutine.yield(nil,"\u{69}\u{64}\u{69}\u{76}")
753+;
754+return (val(a) // val(b))
755+end,["\u{5f}\u{5f}\u{70}\u{6f}\u{77}"] = function (a,b)
756+coroutine.yield(nil,"\u{70}\u{6f}\u{77}")
757+;
758+return (val(a) ^ val(b))
759+end,["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}"] = function (a,b)
760+coroutine.yield(nil,"\u{6d}\u{6f}\u{64}")
761+;
762+return (val(a) % val(b))
763+end,["\u{5f}\u{5f}\u{75}\u{6e}\u{6d}"] = function (a,b)
764+coroutine.yield(nil,"\u{75}\u{6e}\u{6d}")
765+;
766+return (- val(a))
767+end,["\u{5f}\u{5f}\u{62}\u{6e}\u{6f}\u{74}"] = function (a,b)
768+coroutine.yield(nil,"\u{62}\u{6e}\u{6f}\u{74}")
769+;
770+return (~ val(a))
771+end,["\u{5f}\u{5f}\u{73}\u{68}\u{6c}"] = function (a,b)
772+coroutine.yield(nil,"\u{73}\u{68}\u{6c}")
773+;
774+return (val(a) << val(b))
775+end,["\u{5f}\u{5f}\u{73}\u{68}\u{72}"] = function (a,b)
776+coroutine.yield(nil,"\u{73}\u{68}\u{72}")
777+;
778+return (val(a) >> val(b))
779+end,["\u{5f}\u{5f}\u{62}\u{61}\u{6e}\u{64}"] = function (a,b)
780+coroutine.yield(nil,"\u{62}\u{61}\u{6e}\u{64}")
781+return (val(a) & val(b))
782+end,["\u{5f}\u{5f}\u{62}\u{6f}\u{72}"] = function (a,b)
783+coroutine.yield(nil,"\u{62}\u{6f}\u{72}")
784+;
785+return (val(a) | val(b))
786+end,["\u{5f}\u{5f}\u{62}\u{78}\u{6f}\u{72}"] = function (a,b)
787+coroutine.yield(nil,"\u{62}\u{78}\u{6f}\u{72}")
788+;
789+return (val(a) ~ val(b))
790+end,["\u{5f}\u{5f}\u{63}\u{6f}\u{6e}\u{63}\u{61}\u{74}"] = function (a,b)
791+coroutine.yield(nil,"\u{63}\u{6f}\u{6e}\u{63}\u{61}\u{74}")
792+;
793+return (val(a) .. val(b))
794+end,["\u{5f}\u{5f}\u{69}\u{6e}\u{64}\u{65}\u{78}"] = function (t,k)
795+coroutine.yield(nil,"\u{69}\u{64}\u{78}")
796+;
797+return t.k[k]
798+end,["\u{5f}\u{5f}\u{6e}\u{65}\u{77}\u{69}\u{6e}\u{64}\u{65}\u{78}"] = function (t,k,v)
799+coroutine.yield(nil,"\u{6e}\u{69}\u{64}\u{78}")
800+;
801+t.k[k]=v
802+end}
803+local function new
804+(x)
805+return setmetatable({["\u{78}"] = x,["\u{6b}"] = {}},mt)
806+end
807+local a = new(0xa)
808+local b = new(0xc)
809+local c = new("\u{68}\u{65}\u{6c}\u{6c}\u{6f}")
810+local function run
811+(f,t)
812+local i = 0x1
813+local c = coroutine.wrap(f)
814+while true do
815+local res,stat = c()
816+if res then
817+assert((t[i] == undef))
818+;
819+return res,t
820+end
821+assert((stat == t[i]))
822+i=(i + 0x1)
823+end
824+end
825+assert((run(function ()
826+if (a >= b) then
827+return "\u{3e}\u{3d}"
828+else
829+return "\u{3c}"
830+end
831+end,{"\u{6c}\u{65}","\u{73}\u{75}\u{62}"}) == "\u{3c}"))
832+assert((run(function ()
833+if (a <= b) then
834+return "\u{3c}\u{3d}"
835+else
836+return "\u{3e}"
837+end
838+end,{"\u{6c}\u{65}","\u{73}\u{75}\u{62}"}) == "\u{3c}\u{3d}"))
839+assert((run(function ()
840+if (a == b) then
841+return "\u{3d}\u{3d}"
842+else
843+return "\u{7e}\u{3d}"
844+end
845+end,{"\u{65}\u{71}"}) == "\u{7e}\u{3d}"))
846+assert((run(function ()
847+return (a & (b + a))
848+end,{"\u{61}\u{64}\u{64}","\u{62}\u{61}\u{6e}\u{64}"}) == 0x2))
849+assert((run(function ()
850+return (0x1 + a)
851+end,{"\u{61}\u{64}\u{64}"}) == 0xb))
852+assert((run(function ()
853+return (a - 0x19)
854+end,{"\u{73}\u{75}\u{62}"}) == (- 0xf)))
855+assert((run(function ()
856+return (0x2 * a)
857+end,{"\u{6d}\u{75}\u{6c}"}) == 0x14))
858+assert((run(function ()
859+return (a ^ 0x2)
860+end,{"\u{70}\u{6f}\u{77}"}) == 0x64))
861+assert((run(function ()
862+return (a / 0x2)
863+end,{"\u{64}\u{69}\u{76}"}) == 0x5))
864+assert((run(function ()
865+return (a % 0x6)
866+end,{"\u{6d}\u{6f}\u{64}"}) == 0x4))
867+assert((run(function ()
868+return (a // 0x3)
869+end,{"\u{69}\u{64}\u{69}\u{76}"}) == 0x3))
870+assert((run(function ()
871+return (a + b)
872+end,{"\u{61}\u{64}\u{64}"}) == 0x16))
873+assert((run(function ()
874+return (a - b)
875+end,{"\u{73}\u{75}\u{62}"}) == (- 0x2)))
876+assert((run(function ()
877+return (a * b)
878+end,{"\u{6d}\u{75}\u{6c}"}) == 0x78))
879+assert((run(function ()
880+return (a ^ b)
881+end,{"\u{70}\u{6f}\u{77}"}) == (0xa ^ 0xc)))
882+assert((run(function ()
883+return (a / b)
884+end,{"\u{64}\u{69}\u{76}"}) == (0xa / 0xc)))
885+assert((run(function ()
886+return (a % b)
887+end,{"\u{6d}\u{6f}\u{64}"}) == 0xa))
888+assert((run(function ()
889+return (a // b)
890+end,{"\u{69}\u{64}\u{69}\u{76}"}) == 0x0))
891+local a1000 = new(0x3e8)
892+assert((run(function ()
893+return (a1000 + 0x3e8)
894+end,{"\u{61}\u{64}\u{64}"}) == 0x7d0))
895+assert((run(function ()
896+return (a1000 - 0x61a8)
897+end,{"\u{73}\u{75}\u{62}"}) == (- 0x5dc0)))
898+assert((run(function ()
899+return (0x7d0 * a)
900+end,{"\u{6d}\u{75}\u{6c}"}) == 0x4e20))
901+assert((run(function ()
902+return (a1000 / 0x3e8)
903+end,{"\u{64}\u{69}\u{76}"}) == 0x1))
904+assert((run(function ()
905+return (a1000 % 0x258)
906+end,{"\u{6d}\u{6f}\u{64}"}) == 0x190))
907+assert((run(function ()
908+return (a1000 // 0x1f4)
909+end,{"\u{69}\u{64}\u{69}\u{76}"}) == 0x2))
910+assert((run(function ()
911+return (a % b)
912+end,{"\u{6d}\u{6f}\u{64}"}) == 0xa))
913+assert((run(function ()
914+return (~ (a & b))
915+end,{"\u{62}\u{6e}\u{6f}\u{74}","\u{62}\u{61}\u{6e}\u{64}"}) == (~ (0xa & 0xc))))
916+assert((run(function ()
917+return (a | b)
918+end,{"\u{62}\u{6f}\u{72}"}) == (0xa | 0xc)))
919+assert((run(function ()
920+return (a ~ b)
921+end,{"\u{62}\u{78}\u{6f}\u{72}"}) == (0xa ~ 0xc)))
922+assert((run(function ()
923+return (a << b)
924+end,{"\u{73}\u{68}\u{6c}"}) == (0xa << 0xc)))
925+assert((run(function ()
926+return (a >> b)
927+end,{"\u{73}\u{68}\u{72}"}) == (0xa >> 0xc)))
928+assert((run(function ()
929+return (0xa & b)
930+end,{"\u{62}\u{61}\u{6e}\u{64}"}) == (0xa & 0xc)))
931+assert((run(function ()
932+return (a | 0x2)
933+end,{"\u{62}\u{6f}\u{72}"}) == (0xa | 0x2)))
934+assert((run(function ()
935+return (a ~ 0x2)
936+end,{"\u{62}\u{78}\u{6f}\u{72}"}) == (0xa ~ 0x2)))
937+assert((run(function ()
938+return (a >> 0x2)
939+end,{"\u{73}\u{68}\u{72}"}) == (0xa >> 0x2)))
940+assert((run(function ()
941+return (0x1 >> a)
942+end,{"\u{73}\u{68}\u{72}"}) == (0x1 >> 0xa)))
943+assert((run(function ()
944+return (a << 0x2)
945+end,{"\u{73}\u{68}\u{6c}"}) == (0xa << 0x2)))
946+assert((run(function ()
947+return (0x1 << a)
948+end,{"\u{73}\u{68}\u{6c}"}) == (0x1 << 0xa)))
949+assert((run(function ()
950+return (0x2 ~ a)
951+end,{"\u{62}\u{78}\u{6f}\u{72}"}) == (0x2 ~ 0xa)))
952+assert((run(function ()
953+return (a .. b)
954+end,{"\u{63}\u{6f}\u{6e}\u{63}\u{61}\u{74}"}) == "\u{31}\u{30}\u{31}\u{32}"))
955+assert((run(function ()
956+return (a .. (b .. (c .. a)))
957+end,{"\u{63}\u{6f}\u{6e}\u{63}\u{61}\u{74}","\u{63}\u{6f}\u{6e}\u{63}\u{61}\u{74}","\u{63}\u{6f}\u{6e}\u{63}\u{61}\u{74}"}) == "\u{31}\u{30}\u{31}\u{32}\u{68}\u{65}\u{6c}\u{6c}\u{6f}\u{31}\u{30}"))
958+assert((run(function ()
959+return ("\u{61}" .. ("\u{62}" .. (a .. ("\u{63}" .. (c .. (b .. "\u{78}"))))))
960+end,{"\u{63}\u{6f}\u{6e}\u{63}\u{61}\u{74}","\u{63}\u{6f}\u{6e}\u{63}\u{61}\u{74}","\u{63}\u{6f}\u{6e}\u{63}\u{61}\u{74}"}) == "\u{61}\u{62}\u{31}\u{30}\u{63}\u{68}\u{65}\u{6c}\u{6c}\u{6f}\u{31}\u{32}\u{78}"))
961+do
962+local mt1 = {["\u{5f}\u{5f}\u{6c}\u{65}"] = function (a,b)
963+coroutine.yield(0xa)
964+return (val(a) <= val(b))
965+end,["\u{5f}\u{5f}\u{6c}\u{74}"] = function (a,b)
966+coroutine.yield(0xa)
967+return (val(a) < val(b))
968+end}
969+local mt2 = {["\u{5f}\u{5f}\u{6c}\u{74}"] = mt1.__lt,["\u{5f}\u{5f}\u{6c}\u{65}"] = mt1.__le}
970+local function run
971+(f)
972+local co = coroutine.wrap(f)
973+local res
974+repeat
975+res=co()
976+until (res ~= 0xa)
977+return res
978+end
979+local function test
980+()
981+local a1 = setmetatable({["\u{78}"] = 0x1},mt1)
982+local a2 = setmetatable({["\u{78}"] = 0x2},mt2)
983+assert((a1 < a2))
984+assert((a1 <= a2))
985+assert((0x1 < a2))
986+assert((0x1 <= a2))
987+assert((0x2 > a1))
988+assert((0x2 >= a2))
989+return true
990+end
991+run(test)
992+end
993+assert((run(function ()
994+a.BB=print
995+return a.BB
996+end,{"\u{6e}\u{69}\u{64}\u{78}","\u{69}\u{64}\u{78}"}) == print))
997+do
998+local _ENV = _ENV
999+f=function ()
1000+AAA=(BBB + 0x1)
1001+;
1002+return AAA
1003+end
1004+end
1005+local g = new(0xa)
1006+;
1007+g.k.BBB=0xa
1008+;
1009+debug.setupvalue(f,0x1,g)
1010+assert((run(f,{"\u{69}\u{64}\u{78}","\u{6e}\u{69}\u{64}\u{78}","\u{69}\u{64}\u{78}"}) == 0xb))
1011+assert((g.k.AAA == 0xb))
1012+print("\u{2b}")
1013+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{79}\u{69}\u{65}\u{6c}\u{64}\u{73}\u{20}\u{69}\u{6e}\u{73}\u{69}\u{64}\u{65}\u{20}\u{27}\u{66}\u{6f}\u{72}\u{27}\u{20}\u{69}\u{74}\u{65}\u{72}\u{61}\u{74}\u{6f}\u{72}\u{73}")
1014+local f = function (s,i)
1015+if ((i % 0x2) == 0x0) then
1016+coroutine.yield(nil,"\u{66}\u{6f}\u{72}")
1017+end
1018+if (i < s) then
1019+return (i + 0x1)
1020+end
1021+end
1022+assert((run(function ()
1023+local s = 0x0
1024+for i in f,0x4,0x0
1025+do
1026+s=(s + i)
1027+end
1028+return s
1029+end,{"\u{66}\u{6f}\u{72}","\u{66}\u{6f}\u{72}","\u{66}\u{6f}\u{72}"}) == 0xa))
1030+if (T == nil) then
1031+(Message or print)("\u{a}\u{20}\u{3e}\u{3e}\u{3e}\u{20}\u{74}\u{65}\u{73}\u{74}\u{43}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{61}\u{63}\u{74}\u{69}\u{76}\u{65}\u{3a}\u{20}\u{73}\u{6b}\u{69}\u{70}\u{70}\u{69}\u{6e}\u{67}\u{20}\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}\u{20}\u{41}\u{50}\u{49}\u{20}\u{74}\u{65}\u{73}\u{74}\u{73}\u{20}\u{3c}\u{3c}\u{3c}\u{a}")
1032+print("\u{4f}\u{4b}")
1033+;
1034+return
1035+end
1036+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}\u{20}\u{41}\u{50}\u{49}")
1037+local function apico
1038+(...)
1039+local x = {...}
1040+return coroutine.wrap(function ()
1041+return T.testC(table.unpack(x))
1042+end)
1043+end
1044+local a = {apico("\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{63}\u{6f}\u{64}\u{65}\u{a}\u{20}\u{20}\u{70}\u{63}\u{61}\u{6c}\u{6c}\u{6b}\u{20}\u{31}\u{20}\u{30}\u{20}\u{32}\u{3b}\u{a}\u{20}\u{20}\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{63}\u{6f}\u{6d}\u{6d}\u{61}\u{6e}\u{64}\u{20}\u{28}\u{73}\u{68}\u{6f}\u{75}\u{6c}\u{64}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{61}\u{72}\u{72}\u{69}\u{76}\u{65}\u{20}\u{68}\u{65}\u{72}\u{65}\u{29}\u{a}","\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}","\u{73}\u{74}\u{61}\u{63}\u{6b}\u{6d}\u{61}\u{72}\u{6b}",error)()}
1045+assert((# (((((a == 0x4) and (a[0x3] == "\u{73}\u{74}\u{61}\u{63}\u{6b}\u{6d}\u{61}\u{72}\u{6b}")) and (a[0x4] == "\u{65}\u{72}\u{72}\u{6f}\u{72}\u{63}\u{6f}\u{64}\u{65}")) and (_G.status == "\u{45}\u{52}\u{52}\u{52}\u{55}\u{4e}")) and (_G.ctx == 0x2))))
1046+local co = apico("\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{32}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{70}\u{63}\u{61}\u{6c}\u{6c}\u{6b}\u{20}\u{31}\u{20}\u{32}\u{20}\u{33}\u{3b}\u{20}\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{63}\u{6f}\u{6d}\u{6d}\u{61}\u{6e}\u{64}\u{3b}",coroutine.yield,"\u{67}\u{65}\u{74}\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{73}\u{74}\u{61}\u{74}\u{75}\u{73}\u{3b}\u{20}\u{67}\u{65}\u{74}\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{63}\u{74}\u{78}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{32}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{61}\u{3b}\u{20}\u{70}\u{63}\u{61}\u{6c}\u{6c}\u{6b}\u{20}\u{31}\u{20}\u{30}\u{20}\u{34}\u{3b}\u{20}\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{63}\u{6f}\u{6d}\u{6d}\u{61}\u{6e}\u{64}","\u{67}\u{65}\u{74}\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{73}\u{74}\u{61}\u{74}\u{75}\u{73}\u{3b}\u{20}\u{67}\u{65}\u{74}\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{63}\u{74}\u{78}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}")
1047+assert((co() == 0xa))
1048+assert((co(0x14,0x1e) == "\u{61}"))
1049+a={co()}
1050+assert((# ((((((((a == 0xa) and (a[0x2] == coroutine.yield)) and (a[0x5] == 0x14)) and (a[0x6] == 0x1e)) and (a[0x7] == "\u{59}\u{49}\u{45}\u{4c}\u{44}")) and (a[0x8] == 0x3)) and (a[0x9] == "\u{59}\u{49}\u{45}\u{4c}\u{44}")) and (a[0xa] == 0x4))))
1051+assert((not pcall(co)))
1052+f=T.makeCfunc("\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{33}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{35}\u{3b}\u{20}\u{79}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{31}\u{3b}")
1053+co=coroutine.wrap(function ()
1054+assert((f() == 0x17))
1055+;
1056+assert((f() == 0x17))
1057+;
1058+return 0xa
1059+end)
1060+assert((co(0x17,0x10) == 0x5))
1061+assert((co(0x17,0x10) == 0x5))
1062+assert((co(0x17,0x10) == 0xa))
1063+f=T.makeCfunc("\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{30}\u{32}\u{a}\u{9}\u{79}\u{69}\u{65}\u{6c}\u{64}\u{6b}\u{9}\u{31}\u{20}\u{55}\u{32}\u{a}\u{9}\u{63}\u{61}\u{6e}\u{6e}\u{6f}\u{74}\u{20}\u{62}\u{65}\u{20}\u{68}\u{65}\u{72}\u{65}\u{21}\u{a}","\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{63}\u{6f}\u{6e}\u{74}\u{69}\u{6e}\u{75}\u{61}\u{74}\u{69}\u{6f}\u{6e}\u{a}\u{9}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{55}\u{33}\u{20}\u{20}\u{20}\u{23}\u{20}\u{61}\u{63}\u{63}\u{65}\u{73}\u{73}\u{69}\u{6e}\u{67}\u{20}\u{75}\u{70}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{73}\u{20}\u{69}\u{6e}\u{73}\u{69}\u{64}\u{65}\u{20}\u{61}\u{20}\u{63}\u{6f}\u{6e}\u{74}\u{69}\u{6e}\u{75}\u{61}\u{74}\u{69}\u{6f}\u{6e}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{55}\u{34}\u{a}\u{9}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}\u{a}",0x17,"\u{68}\u{75}\u{75}")
1064+x=coroutine.wrap(f)
1065+assert((x() == 0x66))
1066+eqtab({x()},{0x17,"\u{68}\u{75}\u{75}"})
1067+f=T.makeCfunc("\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{27}\u{61}\u{27}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{30}\u{32}\u{3b}\u{20}\u{79}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{32}\u{3b}\u{20}")
1068+a,b,c,d=T.testC("\u{6e}\u{65}\u{77}\u{74}\u{68}\u{72}\u{65}\u{61}\u{64}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{32}\u{3b}\u{20}\u{78}\u{6d}\u{6f}\u{76}\u{65}\u{20}\u{30}\u{20}\u{33}\u{20}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{73}\u{75}\u{6d}\u{65}\u{20}\u{33}\u{20}\u{30}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{61}\u{74}\u{75}\u{73}\u{3b}\u{20}\u{78}\u{6d}\u{6f}\u{76}\u{65}\u{20}\u{33}\u{20}\u{30}\u{20}\u{30}\u{3b}\u{20}\u{20}\u{72}\u{65}\u{73}\u{75}\u{6d}\u{65}\u{20}\u{33}\u{20}\u{30}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{61}\u{74}\u{75}\u{73}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{34}\u{3b}\u{20}",f)
1069+assert(((((a == "\u{59}\u{49}\u{45}\u{4c}\u{44}") and (b == "\u{61}")) and (c == 0x66)) and (d == "\u{4f}\u{4b}")))
1070+local count = 0x3
1071+f=T.makeCfunc("\u{20}\u{20}\u{72}\u{65}\u{6d}\u{6f}\u{76}\u{65}\u{20}\u{31}\u{3b}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{72}\u{65}\u{6d}\u{6f}\u{76}\u{65}\u{20}\u{61}\u{72}\u{67}\u{75}\u{6d}\u{65}\u{6e}\u{74}\u{a}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{55}\u{33}\u{3b}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{67}\u{65}\u{74}\u{20}\u{73}\u{65}\u{6c}\u{65}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{a}\u{20}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{30}\u{20}\u{31}\u{3b}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{69}\u{74}\u{20}\u{20}\u{28}\u{72}\u{65}\u{73}\u{75}\u{6c}\u{74}\u{20}\u{69}\u{73}\u{20}\u{27}\u{66}\u{27}\u{20}\u{6f}\u{72}\u{20}\u{27}\u{79}\u{69}\u{65}\u{6c}\u{64}\u{27}\u{29}\u{a}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{68}\u{65}\u{6c}\u{6c}\u{6f}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{73}\u{69}\u{6e}\u{67}\u{6c}\u{65}\u{20}\u{61}\u{72}\u{67}\u{75}\u{6d}\u{65}\u{6e}\u{74}\u{20}\u{66}\u{6f}\u{72}\u{20}\u{73}\u{65}\u{6c}\u{65}\u{63}\u{74}\u{65}\u{64}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{a}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{75}\u{70}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{69}\u{6e}\u{64}\u{65}\u{78}\u{20}\u{32}\u{3b}\u{20}\u{20}\u{20}\u{23}\u{20}\u{69}\u{6e}\u{64}\u{65}\u{78}\u{20}\u{6f}\u{66}\u{20}\u{63}\u{6f}\u{6e}\u{74}\u{69}\u{6e}\u{75}\u{61}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{70}\u{72}\u{6f}\u{67}\u{72}\u{61}\u{6d}\u{a}\u{20}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{6b}\u{20}\u{31}\u{20}\u{2d}\u{31}\u{20}\u{2e}\u{3b}\u{9}\u{9}\u{23}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{73}\u{65}\u{6c}\u{65}\u{63}\u{74}\u{65}\u{64}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{a}\u{20}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{9}\u{9}\u{23}\u{20}\u{73}\u{68}\u{6f}\u{75}\u{6c}\u{64}\u{20}\u{6e}\u{65}\u{76}\u{65}\u{72}\u{20}\u{61}\u{72}\u{72}\u{69}\u{76}\u{65}\u{20}\u{68}\u{65}\u{72}\u{65}\u{a}","\u{20}\u{20}\u{23}\u{20}\u{63}\u{6f}\u{6e}\u{74}\u{69}\u{6e}\u{75}\u{61}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{70}\u{72}\u{6f}\u{67}\u{72}\u{61}\u{6d}\u{a}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{33}\u{34}\u{9}\u{23}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{a}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{61}\u{6c}\u{6c}\u{20}\u{72}\u{65}\u{73}\u{75}\u{6c}\u{74}\u{73}\u{a}",function ()
1072+count=(count - 0x1)
1073+if (count == 0x0) then
1074+return coroutine.yield
1075+else
1076+return f
1077+end
1078+end)
1079+co=coroutine.wrap(function ()
1080+return f(nil)
1081+end)
1082+assert((co() == "\u{68}\u{65}\u{6c}\u{6c}\u{6f}"))
1083+a={co()}
1084+assert((# ((((a == 0x3) and (a[0x1] == a[0x2])) and (a[0x2] == a[0x3])) and (a[0x3] == 0x22))))
1085+local y
1086+co=coroutine.wrap(function (...)
1087+return T.testC("\u{20}\u{23}\u{20}\u{69}\u{6e}\u{69}\u{74}\u{69}\u{61}\u{6c}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{79}\u{69}\u{65}\u{6c}\u{64}\u{6b}\u{20}\u{31}\u{20}\u{32}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{63}\u{61}\u{6e}\u{6e}\u{6f}\u{74}\u{20}\u{62}\u{65}\u{20}\u{68}\u{65}\u{72}\u{65}\u{21}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}","\u{20}\u{20}\u{23}\u{20}\u{31}\u{73}\u{74}\u{20}\u{63}\u{6f}\u{6e}\u{74}\u{69}\u{6e}\u{75}\u{61}\u{74}\u{69}\u{6f}\u{6e}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{79}\u{69}\u{65}\u{6c}\u{64}\u{6b}\u{20}\u{30}\u{20}\u{33}\u{20}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{63}\u{61}\u{6e}\u{6e}\u{6f}\u{74}\u{20}\u{62}\u{65}\u{20}\u{68}\u{65}\u{72}\u{65}\u{21}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}","\u{20}\u{20}\u{23}\u{20}\u{32}\u{6e}\u{64}\u{20}\u{63}\u{6f}\u{6e}\u{74}\u{69}\u{6e}\u{75}\u{61}\u{74}\u{69}\u{6f}\u{6e}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{79}\u{69}\u{65}\u{6c}\u{64}\u{6b}\u{20}\u{30}\u{20}\u{34}\u{20}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{63}\u{61}\u{6e}\u{6e}\u{6f}\u{74}\u{20}\u{62}\u{65}\u{20}\u{68}\u{65}\u{72}\u{65}\u{21}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}","\u{20}\u{20}\u{23}\u{20}\u{33}\u{74}\u{68}\u{20}\u{63}\u{6f}\u{6e}\u{74}\u{69}\u{6e}\u{75}\u{61}\u{74}\u{69}\u{6f}\u{6e}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{36}\u{20}\u{20}\u{20}\u{23}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{77}\u{68}\u{69}\u{63}\u{68}\u{20}\u{69}\u{73}\u{20}\u{6c}\u{61}\u{73}\u{74}\u{20}\u{61}\u{72}\u{67}\u{2e}\u{20}\u{74}\u{6f}\u{20}\u{27}\u{74}\u{65}\u{73}\u{74}\u{43}\u{27}\u{20}\u{68}\u{65}\u{72}\u{65}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{32}\u{30}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{70}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{32}\u{20}\u{30}\u{20}\u{30}\u{20}\u{20}\u{20}\u{23}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{73}\u{68}\u{6f}\u{75}\u{6c}\u{64}\u{20}\u{74}\u{68}\u{72}\u{6f}\u{77}\u{20}\u{61}\u{6e}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{74}\u{6f}\u{20}\u{6e}\u{65}\u{78}\u{74}\u{20}\u{6c}\u{69}\u{6e}\u{65}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{70}\u{6f}\u{70}\u{20}\u{31}\u{9}\u{9}\u{23}\u{20}\u{72}\u{65}\u{6d}\u{6f}\u{76}\u{65}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{20}\u{6d}\u{65}\u{73}\u{73}\u{61}\u{67}\u{65}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{36}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{67}\u{65}\u{74}\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{73}\u{74}\u{61}\u{74}\u{75}\u{73}\u{3b}\u{20}\u{67}\u{65}\u{74}\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{63}\u{74}\u{78}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{70}\u{63}\u{61}\u{6c}\u{6c}\u{6b}\u{20}\u{32}\u{20}\u{32}\u{20}\u{35}\u{20}\u{20}\u{23}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{73}\u{68}\u{6f}\u{75}\u{6c}\u{64}\u{20}\u{74}\u{68}\u{72}\u{6f}\u{77}\u{20}\u{61}\u{6e}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{6a}\u{75}\u{6d}\u{70}\u{20}\u{74}\u{6f}\u{20}\u{63}\u{6f}\u{6e}\u{74}\u{69}\u{6e}\u{75}\u{61}\u{74}\u{69}\u{6f}\u{6e}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{63}\u{61}\u{6e}\u{6e}\u{6f}\u{74}\u{20}\u{62}\u{65}\u{20}\u{68}\u{65}\u{72}\u{65}\u{21}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}","\u{20}\u{20}\u{23}\u{20}\u{34}\u{74}\u{68}\u{20}\u{28}\u{61}\u{6e}\u{64}\u{20}\u{6c}\u{61}\u{73}\u{74}\u{29}\u{20}\u{63}\u{6f}\u{6e}\u{74}\u{69}\u{6e}\u{75}\u{61}\u{74}\u{69}\u{6f}\u{6e}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}",function (a,b)
1088+x=a
1089+;
1090+y=b
1091+;
1092+error("\u{65}\u{72}\u{72}\u{6d}\u{73}\u{67}")
1093+end,...)
1094+end)
1095+local a = {co(0x3,0x4,0x6)}
1096+assert(((a[0x1] == 0x6) and (a[0x2] == undef)))
1097+a={co()}
1098+;
1099+assert((((a[0x1] == undef) and (_G.status == "\u{59}\u{49}\u{45}\u{4c}\u{44}")) and (_G.ctx == 0x2)))
1100+a={co()}
1101+;
1102+assert((((a[0x1] == undef) and (_G.status == "\u{59}\u{49}\u{45}\u{4c}\u{44}")) and (_G.ctx == 0x3)))
1103+a={co(0x7,0x8)}
1104+;
1105+assert(((((((type(a[0x1]) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}") and (type(a[0x2]) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}")) and (type(a[0x3]) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}")) and (type(a[0x4]) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}")) and (type(a[0x5]) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}")) and (type(a[0x6]) == "\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}")))
1106+assert(((a[0x7] == 0x3) and (a[0x8] == 0x4)))
1107+assert(((a[0x9] == 0x7) and (a[0xa] == 0x8)))
1108+assert((a[0xb]:find("\u{65}\u{72}\u{72}\u{6d}\u{73}\u{67}") and (# (a == 0xb))))
1109+assert(((x == "\u{59}\u{49}\u{45}\u{4c}\u{44}") and (y == 0x4)))
1110+assert((not pcall(co)))
1111+_G.ctx=nil
1112+_G.status=nil
1113+local co = coroutine.wrap(function ()
1114+local a = {pcall(pcall,pcall,pcall,pcall,pcall,pcall,pcall,error,"\u{68}\u{69}")}
1115+return pcall(assert,table.unpack(a))
1116+end)
1117+local a = {co()}
1118+assert((a[0xa] == "\u{68}\u{69}"))
1119+print("\u{4f}\u{4b}")
desk/res/lua/cycled/cstack.luanew file+166
@@ -0,0 +1,166 @@
1+local tracegc = require("\u{74}\u{72}\u{61}\u{63}\u{65}\u{67}\u{63}")
2+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}\u{20}\u{64}\u{65}\u{74}\u{65}\u{63}\u{74}\u{69}\u{6f}\u{6e}")
3+local function checkerror
4+(msg,f, ...)
5+local s,err = pcall(f,...)
6+assert((not (s and string.find(err,msg))))
7+end
8+do
9+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}\u{20}\u{69}\u{6e}\u{20}\u{6d}\u{65}\u{73}\u{73}\u{61}\u{67}\u{65}\u{20}\u{68}\u{61}\u{6e}\u{64}\u{6c}\u{69}\u{6e}\u{67}")
10+local count = 0x0
11+local function loop
12+(x,y,z)
13+count=(count + 0x1)
14+return (0x1 + loop(x,y,z))
15+end
16+tracegc.stop()
17+local res,msg = xpcall(loop,loop)
18+tracegc.start()
19+assert((msg == "\u{65}\u{72}\u{72}\u{6f}\u{72}\u{20}\u{69}\u{6e}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{20}\u{68}\u{61}\u{6e}\u{64}\u{6c}\u{69}\u{6e}\u{67}"))
20+print("\u{66}\u{69}\u{6e}\u{61}\u{6c}\u{20}\u{63}\u{6f}\u{75}\u{6e}\u{74}\u{3a}\u{20}",count)
21+end
22+do
23+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{72}\u{65}\u{63}\u{75}\u{72}\u{73}\u{69}\u{6f}\u{6e}\u{20}\u{69}\u{6e}\u{73}\u{69}\u{64}\u{65}\u{20}\u{70}\u{61}\u{74}\u{74}\u{65}\u{72}\u{6e}\u{20}\u{6d}\u{61}\u{74}\u{63}\u{68}\u{69}\u{6e}\u{67}")
24+local function f
25+(size)
26+local s = string.rep("\u{61}",size)
27+local p = string.rep("\u{2e}\u{3f}",size)
28+return string.match(s,p)
29+end
30+local m = f(0x50)
31+assert((# (m == 0x50)))
32+checkerror("\u{74}\u{6f}\u{6f}\u{20}\u{63}\u{6f}\u{6d}\u{70}\u{6c}\u{65}\u{78}",f,0x7d0)
33+end
34+do
35+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{2d}\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}\u{20}\u{69}\u{6e}\u{20}\u{72}\u{65}\u{63}\u{75}\u{72}\u{73}\u{69}\u{76}\u{65}\u{20}\u{27}\u{67}\u{73}\u{75}\u{62}\u{27}")
36+local count = 0x0
37+local function foo
38+()
39+count=(count + 0x1)
40+string.gsub("\u{61}","\u{2e}",foo)
41+end
42+checkerror("\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}",foo)
43+print("\u{66}\u{69}\u{6e}\u{61}\u{6c}\u{20}\u{63}\u{6f}\u{75}\u{6e}\u{74}\u{3a}\u{20}",count)
44+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{2d}\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}\u{20}\u{69}\u{6e}\u{20}\u{72}\u{65}\u{63}\u{75}\u{72}\u{73}\u{69}\u{76}\u{65}\u{20}\u{27}\u{67}\u{73}\u{75}\u{62}\u{27}\u{20}\u{77}\u{69}\u{74}\u{68}\u{20}\u{6d}\u{65}\u{74}\u{61}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{73}")
45+local count = 0x0
46+local t = setmetatable({},{["\u{5f}\u{5f}\u{69}\u{6e}\u{64}\u{65}\u{78}"] = foo})
47+foo=function ()
48+count=(count + 0x1)
49+string.gsub("\u{61}","\u{2e}",t)
50+end
51+checkerror("\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}",foo)
52+print("\u{66}\u{69}\u{6e}\u{61}\u{6c}\u{20}\u{63}\u{6f}\u{75}\u{6e}\u{74}\u{3a}\u{20}",count)
53+end
54+do
55+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{6c}\u{69}\u{6d}\u{69}\u{74}\u{73}\u{20}\u{69}\u{6e}\u{20}\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}\u{73}\u{20}\u{69}\u{6e}\u{73}\u{69}\u{64}\u{65}\u{20}\u{64}\u{65}\u{65}\u{70}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{73}")
56+local count = 0x0
57+local lim = 0x3e8
58+local function stack
59+(n)
60+if (n > 0x0) then
61+return (stack((n - 0x1)) + 0x1)
62+else
63+coroutine.wrap(function ()
64+count=(count + 0x1)
65+stack(lim)
66+end)()
67+end
68+end
69+local st,msg = xpcall(stack,function ()
70+return "\u{6f}\u{6b}"
71+end,lim)
72+assert((not (st and (msg == "\u{6f}\u{6b}"))))
73+print("\u{66}\u{69}\u{6e}\u{61}\u{6c}\u{20}\u{63}\u{6f}\u{75}\u{6e}\u{74}\u{3a}\u{20}",count)
74+end
75+do
76+local count = 0x0
77+print("\u{63}\u{68}\u{61}\u{69}\u{6e}\u{20}\u{6f}\u{66}\u{20}\u{27}\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}\u{2e}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{27}")
78+local coro = false
79+for i = 0x1, 0x3e8
80+do
81+local previous = coro
82+coro=coroutine.create(function ()
83+local cc <close> = setmetatable({},{["\u{5f}\u{5f}\u{63}\u{6c}\u{6f}\u{73}\u{65}"] = function ()
84+count=(count + 0x1)
85+if previous then
86+assert(coroutine.close(previous))
87+end
88+end})
89+coroutine.yield()
90+end)
91+assert(coroutine.resume(coro))
92+end
93+local st,msg = coroutine.close(coro)
94+assert((not (st and string.find(msg,"\u{43}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}"))))
95+print("\u{66}\u{69}\u{6e}\u{61}\u{6c}\u{20}\u{63}\u{6f}\u{75}\u{6e}\u{74}\u{3a}\u{20}",count)
96+end
97+do
98+print("\u{6e}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{6f}\u{66}\u{20}\u{72}\u{65}\u{73}\u{75}\u{6d}\u{69}\u{6e}\u{67}\u{20}\u{79}\u{69}\u{65}\u{6c}\u{64}\u{65}\u{64}\u{20}\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}\u{73}")
99+local count = 0x0
100+local function body
101+()
102+coroutine.yield()
103+local f = coroutine.wrap(body)
104+f()
105+;
106+count=(count + 0x1)
107+f()
108+end
109+local f = coroutine.wrap(body)
110+f()
111+assert((not pcall(f)))
112+print("\u{66}\u{69}\u{6e}\u{61}\u{6c}\u{20}\u{63}\u{6f}\u{75}\u{6e}\u{74}\u{3a}\u{20}",count)
113+end
114+do
115+print("\u{6e}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}\u{73}\u{20}\u{72}\u{75}\u{6e}\u{6e}\u{69}\u{6e}\u{67}\u{20}\u{61}\u{66}\u{74}\u{65}\u{72}\u{20}\u{72}\u{65}\u{63}\u{6f}\u{76}\u{65}\u{72}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{73}")
116+local count = 0x0
117+local function foo
118+()
119+count=(count + 0x1)
120+pcall(0x1)
121+coroutine.wrap(foo)()
122+end
123+checkerror("\u{43}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}",foo)
124+print("\u{66}\u{69}\u{6e}\u{61}\u{6c}\u{20}\u{63}\u{6f}\u{75}\u{6e}\u{74}\u{3a}\u{20}",count)
125+end
126+if T then
127+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{72}\u{65}\u{63}\u{6f}\u{76}\u{65}\u{72}\u{79}")
128+local N = 0x0
129+local LIM = (- 0x1)
130+local stack1
131+local dummy
132+local function err
133+(msg)
134+assert(string.find(msg,"\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}"))
135+local _,stacknow = T.stacklevel()
136+assert((stacknow == (stack1 + 0xc8)))
137+end
138+local function f
139+()
140+dummy,stack1=T.stacklevel()
141+if (N == LIM) then
142+xpcall(f,err)
143+local _,stacknow = T.stacklevel()
144+assert((stacknow == stack1))
145+return
146+end
147+N=(N + 0x1)
148+f()
149+end
150+local topB,sizeB
151+local topA,sizeA
152+topB,sizeB=T.stacklevel()
153+tracegc.stop()
154+xpcall(f,err)
155+tracegc.start()
156+topA,sizeA=T.stacklevel()
157+assert(((topA == topB) and (sizeA < (sizeB * 0x2))))
158+print(string.format("\u{6d}\u{61}\u{78}\u{69}\u{6d}\u{75}\u{6d}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{73}\u{69}\u{7a}\u{65}\u{3a}\u{20}\u{25}\u{64}",stack1))
159+LIM=N
160+N=0x0
161+tracegc.stop()
162+f()
163+tracegc.start()
164+print("\u{2b}")
165+end
166+print("\u{4f}\u{4b}")
desk/res/lua/cycled/db.luanew file+947
@@ -0,0 +1,947 @@
1+local debug = require("\u{64}\u{65}\u{62}\u{75}\u{67}")
2+local function dostring
3+(s)
4+return assert(load(s))()
5+end
6+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{64}\u{65}\u{62}\u{75}\u{67}\u{20}\u{6c}\u{69}\u{62}\u{72}\u{61}\u{72}\u{79}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{64}\u{65}\u{62}\u{75}\u{67}\u{20}\u{69}\u{6e}\u{66}\u{6f}\u{72}\u{6d}\u{61}\u{74}\u{69}\u{6f}\u{6e}")
7+do
8+local a = 0x1
9+end
10+assert((not debug.gethook()))
11+local testline = 0x13
12+local function test
13+(s,l,p)
14+collectgarbage()
15+local function f
16+(event,line)
17+assert((event == "\u{6c}\u{69}\u{6e}\u{65}"))
18+local l = table.remove(l,0x1)
19+if p then
20+print(l,line)
21+end
22+assert((l == line),"\u{77}\u{72}\u{6f}\u{6e}\u{67}\u{20}\u{74}\u{72}\u{61}\u{63}\u{65}\u{21}\u{21}")
23+end
24+debug.sethook(f,"\u{6c}")
25+;
26+load(s)()
27+;
28+debug.sethook()
29+assert((# (l == 0x0)))
30+end
31+do
32+assert((not pcall(debug.getinfo,print,"\u{58}")))
33+assert((not pcall(debug.getinfo,0x0,"\u{3e}")))
34+assert((not debug.getinfo(0x3e8)))
35+assert((not debug.getinfo((- 0x1))))
36+local a = debug.getinfo(print)
37+assert(((a.what == "\u{43}") and (a.short_src == "\u{5b}\u{43}\u{5d}")))
38+a=debug.getinfo(print,"\u{4c}")
39+assert((a.activelines == nil))
40+local b = debug.getinfo(test,"\u{53}\u{66}\u{4c}")
41+assert(((((((b.name == nil) and (b.what == "\u{4c}\u{75}\u{61}")) and (b.linedefined == testline)) and (b.lastlinedefined == (b.linedefined + 0xa))) and (b.func == test)) and (not string.find(b.short_src,"\u{25}\u{5b}"))))
42+assert((b.activelines[(b.linedefined + 0x1)] and b.activelines[b.lastlinedefined]))
43+assert((not (b.activelines[b.linedefined] and (not b.activelines[(b.lastlinedefined + 0x1)]))))
44+end
45+do
46+local func = load(string.dump(load("\u{70}\u{72}\u{69}\u{6e}\u{74}\u{28}\u{31}\u{30}\u{29}"),true))
47+local actl = debug.getinfo(func,"\u{4c}").activelines
48+assert((# (actl == 0x0)))
49+end
50+local a = "\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{66}\u{20}\u{28}\u{29}\u{20}\u{65}\u{6e}\u{64}"
51+local function dostring
52+(s,x)
53+return load(s,x)()
54+end
55+dostring(a)
56+assert((debug.getinfo(f).short_src == string.format("\u{5b}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{22}\u{25}\u{73}\u{22}\u{5d}",a)))
57+dostring((a .. string.format("\u{3b}\u{20}\u{25}\u{73}\u{a}\u{3d}\u{31}",string.rep("\u{70}",0x190))))
58+assert(string.find(debug.getinfo(f).short_src,"\u{5e}\u{25}\u{5b}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{5b}\u{5e}\u{a}\u{5d}\u{2a}\u{25}\u{2e}\u{25}\u{2e}\u{25}\u{2e}\u{22}\u{25}\u{5d}\u{24}"))
59+dostring((a .. string.format("\u{3b}\u{20}\u{25}\u{73}\u{3d}\u{31}",string.rep("\u{70}",0x190))))
60+assert(string.find(debug.getinfo(f).short_src,"\u{5e}\u{25}\u{5b}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{5b}\u{5e}\u{a}\u{5d}\u{2a}\u{25}\u{2e}\u{25}\u{2e}\u{25}\u{2e}\u{22}\u{25}\u{5d}\u{24}"))
61+dostring(("\u{a}" .. a))
62+assert((debug.getinfo(f).short_src == "\u{5b}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{22}\u{2e}\u{2e}\u{2e}\u{22}\u{5d}"))
63+dostring(a,"")
64+assert((debug.getinfo(f).short_src == "\u{5b}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{22}\u{22}\u{5d}"))
65+dostring(a,"\u{40}\u{78}\u{75}\u{78}\u{75}")
66+assert((debug.getinfo(f).short_src == "\u{78}\u{75}\u{78}\u{75}"))
67+dostring(a,("\u{40}" .. (string.rep("\u{70}",0x3e8) .. "\u{74}")))
68+assert(string.find(debug.getinfo(f).short_src,"\u{5e}\u{25}\u{2e}\u{25}\u{2e}\u{25}\u{2e}\u{70}\u{2a}\u{74}\u{24}"))
69+dostring(a,"\u{3d}\u{78}\u{75}\u{78}\u{75}")
70+assert((debug.getinfo(f).short_src == "\u{78}\u{75}\u{78}\u{75}"))
71+dostring(a,string.format("\u{3d}\u{25}\u{73}",string.rep("\u{78}",0x1f4)))
72+assert(string.find(debug.getinfo(f).short_src,"\u{5e}\u{78}\u{2a}\u{24}"))
73+dostring(a,"\u{3d}")
74+assert((debug.getinfo(f).short_src == ""))
75+_G.a=nil
76+;
77+_G.f=nil
78+;
79+_G[string.rep("\u{70}",0x190)]=nil
80+repeat
81+local g = {["\u{78}"] = function ()
82+local a = debug.getinfo(0x2)
83+assert(((a.name == "\u{66}") and (a.namewhat == "\u{6c}\u{6f}\u{63}\u{61}\u{6c}")))
84+a=debug.getinfo(0x1)
85+assert(((a.name == "\u{78}") and (a.namewhat == "\u{66}\u{69}\u{65}\u{6c}\u{64}")))
86+return "\u{78}\u{69}\u{78}\u{69}"
87+end}
88+local f = function ()
89+return ((0x1 + 0x1) and (not (0x1 or g.x())))
90+end
91+assert((f() == "\u{78}\u{69}\u{78}\u{69}"))
92+g=debug.getinfo(f)
93+assert(((((g.what == "\u{4c}\u{75}\u{61}") and (g.func == f)) and (g.namewhat == "")) and (not g.name)))
94+function f(x,name)
95+name=(name or "\u{66}")
96+local a = debug.getinfo(0x1)
97+assert(((a.name == name) and (a.namewhat == "\u{6c}\u{6f}\u{63}\u{61}\u{6c}")))
98+return x
99+end
100+if (0x3 > 0x4) then
101+break
102+end
103+;
104+f()
105+if (0x3 < 0x4) then
106+a=0x1
107+else
108+break
109+end
110+;
111+f()
112+while 0x1 do
113+local x = 0xa
114+;
115+break
116+end
117+;
118+f()
119+local b = 0x1
120+if (0x3 > 0x4) then
121+return math.sin(0x1)
122+end
123+;
124+f()
125+a=(0x3 < 0x4)
126+;
127+f()
128+a=((0x3 < 0x4) or 0x1)
129+;
130+f()
131+repeat
132+local x = 0x14
133+;
134+if (0x4 > 0x3) then
135+f()
136+else
137+break
138+end
139+;
140+f()
141+until 0x1
142+g={}
143+f(g).x=(f(0x2) and (f(0xa) + f(0x9)))
144+assert((g.x == f(0x13)))
145+function g(x)
146+if (not x) then
147+return 0x3
148+end
149+return x("\u{61}","\u{78}")
150+end
151+assert((g(f) == "\u{61}"))
152+until 0x1
153+test("\u{69}\u{66}\u{a}\u{6d}\u{61}\u{74}\u{68}\u{2e}\u{73}\u{69}\u{6e}\u{28}\u{31}\u{29}\u{a}\u{74}\u{68}\u{65}\u{6e}\u{a}\u{20}\u{20}\u{61}\u{3d}\u{31}\u{a}\u{65}\u{6c}\u{73}\u{65}\u{a}\u{20}\u{20}\u{61}\u{3d}\u{32}\u{a}\u{65}\u{6e}\u{64}\u{a}",{0x2,0x3,0x4,0x7})
154+test("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{66}\u{6f}\u{6f}\u{28}\u{29}\u{a}\u{65}\u{6e}\u{64}\u{a}\u{66}\u{6f}\u{6f}\u{28}\u{29}\u{a}\u{41}\u{20}\u{3d}\u{20}\u{31}\u{a}\u{41}\u{20}\u{3d}\u{20}\u{32}\u{a}\u{41}\u{20}\u{3d}\u{20}\u{33}\u{a}",{0x2,0x3,0x2,0x4,0x5,0x6})
155+_G.A=nil
156+test("\u{2d}\u{2d}\u{a}\u{69}\u{66}\u{20}\u{6e}\u{69}\u{6c}\u{20}\u{74}\u{68}\u{65}\u{6e}\u{a}\u{20}\u{20}\u{61}\u{3d}\u{31}\u{a}\u{65}\u{6c}\u{73}\u{65}\u{a}\u{20}\u{20}\u{61}\u{3d}\u{32}\u{a}\u{65}\u{6e}\u{64}\u{a}",{0x2,0x5,0x6})
157+test("\u{61}\u{3d}\u{31}\u{a}\u{72}\u{65}\u{70}\u{65}\u{61}\u{74}\u{a}\u{20}\u{20}\u{61}\u{3d}\u{61}\u{2b}\u{31}\u{a}\u{75}\u{6e}\u{74}\u{69}\u{6c}\u{20}\u{61}\u{3d}\u{3d}\u{33}\u{a}",{0x1,0x3,0x4,0x3,0x4})
158+test("\u{20}\u{64}\u{6f}\u{a}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{a}\u{65}\u{6e}\u{64}\u{a}",{0x2})
159+test("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{a}\u{61}\u{3d}\u{31}\u{a}\u{77}\u{68}\u{69}\u{6c}\u{65}\u{20}\u{61}\u{3c}\u{3d}\u{33}\u{20}\u{64}\u{6f}\u{a}\u{20}\u{20}\u{61}\u{3d}\u{61}\u{2b}\u{31}\u{a}\u{65}\u{6e}\u{64}\u{a}",{0x1,0x2,0x3,0x4,0x3,0x4,0x3,0x4,0x3,0x5})
160+test("\u{77}\u{68}\u{69}\u{6c}\u{65}\u{20}\u{6d}\u{61}\u{74}\u{68}\u{2e}\u{73}\u{69}\u{6e}\u{28}\u{31}\u{29}\u{20}\u{64}\u{6f}\u{a}\u{20}\u{20}\u{69}\u{66}\u{20}\u{6d}\u{61}\u{74}\u{68}\u{2e}\u{73}\u{69}\u{6e}\u{28}\u{31}\u{29}\u{a}\u{20}\u{20}\u{74}\u{68}\u{65}\u{6e}\u{20}\u{62}\u{72}\u{65}\u{61}\u{6b}\u{a}\u{20}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{65}\u{6e}\u{64}\u{a}\u{61}\u{3d}\u{31}",{0x1,0x2,0x3,0x6})
161+test("\u{66}\u{6f}\u{72}\u{20}\u{69}\u{3d}\u{31}\u{2c}\u{33}\u{20}\u{64}\u{6f}\u{a}\u{20}\u{20}\u{61}\u{3d}\u{69}\u{a}\u{65}\u{6e}\u{64}\u{a}",{0x1,0x2,0x1,0x2,0x1,0x2,0x1,0x3})
162+test("\u{66}\u{6f}\u{72}\u{20}\u{69}\u{2c}\u{76}\u{20}\u{69}\u{6e}\u{20}\u{70}\u{61}\u{69}\u{72}\u{73}\u{7b}\u{27}\u{61}\u{27}\u{2c}\u{27}\u{62}\u{27}\u{7d}\u{20}\u{64}\u{6f}\u{a}\u{20}\u{20}\u{61}\u{3d}\u{74}\u{6f}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{28}\u{69}\u{29}\u{20}\u{2e}\u{2e}\u{20}\u{76}\u{a}\u{65}\u{6e}\u{64}\u{a}",{0x1,0x2,0x1,0x2,0x1,0x3})
163+test("\u{66}\u{6f}\u{72}\u{20}\u{69}\u{3d}\u{31}\u{2c}\u{34}\u{20}\u{64}\u{6f}\u{20}\u{61}\u{3d}\u{31}\u{20}\u{65}\u{6e}\u{64}",{0x1,0x1,0x1,0x1})
164+_G.a=nil
165+do
166+local a = {0x1,0x2,0x3,0xa,0x7c,0x7d,0x7e,0x7f,0x80,0x81,0x82,0xff,0x100,0x101,0x1f4,0x3e8}
167+local s = "\u{20}\u{20}\u{20}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{62}\u{20}\u{3d}\u{20}\u{7b}\u{31}\u{30}\u{7d}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{62}\u{5b}\u{31}\u{5d}\u{20}\u{58}\u{20}\u{2b}\u{20}\u{59}\u{20}\u{62}\u{5b}\u{31}\u{5d}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{62}\u{20}\u{3d}\u{20}\u{34}\u{a}\u{20}\u{20}"
168+for _,i in ipairs(a)
169+do
170+local subs = {["\u{58}"] = string.rep("\u{a}",i)}
171+for _,j in ipairs(a)
172+do
173+subs.Y=string.rep("\u{a}",j)
174+local s = string.gsub(s,"\u{5b}\u{58}\u{59}\u{5d}",subs)
175+test(s,{0x1,(0x2 + i),((0x2 + i) + j),(0x2 + i),((0x2 + i) + j),((0x3 + i) + j)})
176+end
177+end
178+end
179+_G.a=nil
180+do
181+local function checkactivelines
182+(f,lines)
183+local t = debug.getinfo(f,"\u{53}\u{4c}")
184+for _,l in pairs(lines)
185+do
186+l=(l + t.linedefined)
187+assert(t.activelines[l])
188+t.activelines[l]=undef
189+end
190+assert((next(t.activelines) == nil))
191+end
192+checkactivelines(function (...)
193+local a = 0x14
194+local b = 0x1e
195+end,{0x4,0x6,0x8})
196+checkactivelines(function (a)
197+local a = 0x14
198+local b = 0x1e
199+end,{0x3,0x4,0x6})
200+checkactivelines(function (a,b, ...)
201+
202+end,{0x0})
203+checkactivelines(function (a,b)
204+
205+end,{0x1})
206+for _,n in pairs({0x0,0x1,0x2,0xa,0x32,0x64,0x3e8,0x2710})
207+do
208+checkactivelines(load(string.format("\u{25}\u{73}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",string.rep("\u{a}",n))),{(n + 0x1)})
209+end
210+end
211+print("\u{2b}")
212+assert((not pcall(debug.getlocal,0x14,0x1)))
213+assert((not pcall(debug.setlocal,(- 0x1),0x1,0xa)))
214+local function foo
215+(a,b, ...)
216+local d,e
217+end
218+local co = coroutine.create(foo)
219+assert((debug.getlocal(foo,0x1) == "\u{61}"))
220+assert((debug.getlocal(foo,0x2) == "\u{62}"))
221+assert((not debug.getlocal(foo,0x3)))
222+assert((debug.getlocal(co,foo,0x1) == "\u{61}"))
223+assert((debug.getlocal(co,foo,0x2) == "\u{62}"))
224+assert((not debug.getlocal(co,foo,0x3)))
225+assert((not debug.getlocal(print,0x1)))
226+local function foo
227+()
228+return debug.getlocal(0x1,(- 0x1))
229+end
230+assert((not foo(0xa)))
231+local function foo
232+(a, ...)
233+local t = table.pack(...)
234+for i = 0x1, t.n
235+do
236+local n,v = debug.getlocal(0x1,(- i))
237+assert(((n == "\u{28}\u{76}\u{61}\u{72}\u{61}\u{72}\u{67}\u{29}") and (v == t[i])))
238+end
239+assert((not debug.getlocal(0x1,(- (t.n + 0x1)))))
240+assert((not debug.setlocal(0x1,(- (t.n + 0x1)),0x1e)))
241+if (t.n > 0x0) then
242+(function (x)
243+assert((debug.setlocal(0x2,(- 0x1),x) == "\u{28}\u{76}\u{61}\u{72}\u{61}\u{72}\u{67}\u{29}"))
244+assert((debug.setlocal(0x2,(- t.n),x) == "\u{28}\u{76}\u{61}\u{72}\u{61}\u{72}\u{67}\u{29}"))
245+end)(0x1ae)
246+assert((... == 0x1ae))
247+end
248+end
249+foo()
250+foo(print)
251+foo(0xc8,0x3,0x4)
252+local a = {}
253+for i = 0x1, ((_soft and 0x64) or 0x3e8)
254+do
255+a[i]=i
256+end
257+foo(table.unpack(a))
258+do
259+assert((not debug.gethook()))
260+local count = 0x0
261+local function f
262+()
263+assert((debug.getinfo(0x1).namewhat == "\u{68}\u{6f}\u{6f}\u{6b}"))
264+local sndline = string.match(debug.traceback(),"\u{a}\u{28}\u{2e}\u{2d}\u{29}\u{a}")
265+assert(string.find(sndline,"\u{68}\u{6f}\u{6f}\u{6b}"))
266+count=(count + 0x1)
267+end
268+debug.sethook(f,"\u{6c}")
269+local a = 0x0
270+_ENV.a=a
271+a=0x1
272+debug.sethook()
273+assert((count == 0x4))
274+end
275+_ENV.a=nil
276+assert((getmetatable(debug.getregistry()._HOOKKEY).__mode == "\u{6b}"))
277+a={}
278+;
279+local L = nil
280+local glob = 0x1
281+local oldglob = glob
282+debug.sethook(function (e,l)
283+collectgarbage()
284+local f,m,c = debug.gethook()
285+assert(((m == "\u{63}\u{72}\u{6c}") and (c == 0x0)))
286+if (e == "\u{6c}\u{69}\u{6e}\u{65}") then
287+if (glob ~= oldglob) then
288+L=(l - 0x1)
289+oldglob=glob
290+end
291+elseif (e == "\u{63}\u{61}\u{6c}\u{6c}") then
292+local f = debug.getinfo(0x2,"\u{66}").func
293+a[f]=0x1
294+else
295+assert((e == "\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}"))
296+end
297+end,"\u{63}\u{72}\u{6c}")
298+function f(a,b)
299+collectgarbage()
300+local _,x = debug.getlocal(0x1,0x1)
301+local _,y = debug.getlocal(0x1,0x2)
302+assert(((x == a) and (y == b)))
303+assert((debug.setlocal(0x2,0x3,"\u{70}\u{65}\u{72}\u{61}") == ("\u{41}\u{41}" .. "\u{41}\u{41}")))
304+assert((debug.setlocal(0x2,0x4,"\u{6d}\u{61}\u{6e}\u{67}\u{61}") == "\u{42}"))
305+x=debug.getinfo(0x2)
306+assert((((((x.func == g) and (x.what == "\u{4c}\u{75}\u{61}")) and (x.name == "\u{67}")) and (x.nups == 0x2)) and string.find(x.source,"\u{5e}\u{40}\u{2e}\u{2a}\u{64}\u{62}\u{25}\u{2e}\u{6c}\u{75}\u{61}\u{24}")))
307+glob=(glob + 0x1)
308+assert((debug.getinfo(0x1,"\u{6c}").currentline == (L + 0x1)))
309+assert((debug.getinfo(0x1,"\u{6c}").currentline == (L + 0x2)))
310+end
311+function foo()
312+glob=(glob + 0x1)
313+assert((debug.getinfo(0x1,"\u{6c}").currentline == (L + 0x1)))
314+end
315+;
316+foo()
317+local _ = ("\u{61}\u{6c}\u{6f}\u{a}\u{61}\u{6c}\u{6f}" .. "\u{a}")
318+assert((debug.getinfo(0x1,"\u{6c}").currentline == (L + 0xb)))
319+function g(...)
320+local arg = {...}
321+do
322+local a,b,c
323+;
324+a=math.sin(0x28)
325+;
326+end
327+local feijao
328+local AAAA,B = "\u{78}\u{75}\u{78}\u{75}","\u{61}\u{62}\u{61}\u{63}\u{61}\u{74}\u{65}"
329+f(AAAA,B)
330+assert(((AAAA == "\u{70}\u{65}\u{72}\u{61}") and (B == "\u{6d}\u{61}\u{6e}\u{67}\u{61}")))
331+do
332+local B = 0xd
333+local x,y = debug.getlocal(0x1,0x5)
334+assert(((x == "\u{42}") and (y == 0xd)))
335+end
336+end
337+g()
338+assert(((((a[f] and a[g]) and a[assert]) and a[debug.getlocal]) and (not a[print])))
339+local n,v = debug.getlocal(0x0,0x1)
340+assert(((v == 0x0) and (n == "\u{28}\u{43}\u{20}\u{74}\u{65}\u{6d}\u{70}\u{6f}\u{72}\u{61}\u{72}\u{79}\u{29}")))
341+local n,v = debug.getlocal(0x0,0x2)
342+assert(((v == 0x2) and (n == "\u{28}\u{43}\u{20}\u{74}\u{65}\u{6d}\u{70}\u{6f}\u{72}\u{61}\u{72}\u{79}\u{29}")))
343+assert((not debug.getlocal(0x0,0x3)))
344+assert((not debug.getlocal(0x0,0x0)))
345+function f()
346+assert((select(0x2,debug.getlocal(0x2,0x3)) == 0x1))
347+assert((not debug.getlocal(0x2,0x4)))
348+debug.setlocal(0x2,0x3,0xa)
349+return 0x14
350+end
351+function g(a,b)
352+return ((a + 0x1) + f())
353+end
354+assert((g(0x0,0x0) == 0x1e))
355+_G.f,_G.g=nil
356+debug.sethook(nil)
357+;
358+assert((not debug.gethook()))
359+do
360+assert((not debug.setuservalue(io.stdin,0xa)))
361+local a,b = debug.getuservalue(io.stdin,0xa)
362+assert(((a == nil) and (not b)))
363+end
364+do
365+local function f
366+(...)
367+return 0x3,...
368+end
369+local count = 0x0
370+local a = {}
371+for i = 0x1, 0x64
372+do
373+a[i]=i
374+end
375+debug.sethook(function ()
376+count=(count + 0x1)
377+end,"",0x1)
378+local t = {table.unpack(a)}
379+assert((# (t == 0x64)))
380+t={table.unpack(a,0x1,0x3)}
381+assert((# (t == 0x3)))
382+t={f(table.unpack(a,0x1,0x1e))}
383+assert((# (t == 0x1f)))
384+end
385+local function collectlocals
386+(level)
387+local tab = {}
388+for i = 0x1, math.huge
389+do
390+local n,v = debug.getlocal((level + 0x1),i)
391+if (not (n and string.find(n,"\u{5e}\u{5b}\u{61}\u{2d}\u{7a}\u{41}\u{2d}\u{5a}\u{30}\u{2d}\u{39}\u{5f}\u{5d}\u{2b}\u{24}"))) then
392+break
393+end
394+tab[n]=v
395+end
396+return tab
397+end
398+local X = nil
399+a={}
400+function a:f(a,b, ...)
401+local arg = {...}
402+;
403+local c = 0xd
404+end
405+debug.sethook(function (e)
406+assert((e == "\u{63}\u{61}\u{6c}\u{6c}"))
407+dostring("\u{58}\u{58}\u{20}\u{3d}\u{20}\u{31}\u{32}")
408+assert((not pcall(load("\u{61}\u{3d}\u{27}\u{6a}\u{6f}\u{61}\u{6f}\u{27}\u{2b}\u{31}"))))
409+debug.sethook(function (e,l)
410+assert((debug.getinfo(0x2,"\u{6c}").currentline == l))
411+local f,m,c = debug.gethook()
412+assert((e == "\u{6c}\u{69}\u{6e}\u{65}"))
413+assert(((m == "\u{6c}") and (c == 0x0)))
414+debug.sethook(nil)
415+assert((not X))
416+X=collectlocals(0x2)
417+end,"\u{6c}")
418+end,"\u{63}")
419+a:f(0x1,0x2,0x3,0x4,0x5)
420+assert(((((X.self == a) and (X.a == 0x1)) and (X.b == 0x2)) and (X.c == nil)))
421+assert((XX == 0xc))
422+assert((not debug.gethook()))
423+_G.XX=nil
424+do
425+local X = false
426+local function foo
427+(a,b, ...)
428+do
429+local x,y,z
430+end
431+local c,d = 0xa,0x14
432+return
433+end
434+local function aux
435+()
436+if (debug.getinfo(0x2).name == "\u{66}\u{6f}\u{6f}") then
437+X=true
438+local tab = {["\u{61}"] = 0x64,["\u{62}"] = 0xc8,["\u{63}"] = 0xa,["\u{64}"] = 0x14}
439+for n,v in pairs(collectlocals(0x2))
440+do
441+assert((tab[n] == v))
442+tab[n]=undef
443+end
444+assert((next(tab) == nil))
445+end
446+end
447+debug.sethook(aux,"\u{72}")
448+;
449+foo(0x64,0xc8)
450+;
451+debug.sethook()
452+assert(X)
453+end
454+local function eqseq
455+(t1,t2)
456+assert((# (t1 == (# t2))))
457+for i = 0x1, (# t1)
458+do
459+assert((t1[i] == t2[i]))
460+end
461+end
462+do
463+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{69}\u{6e}\u{73}\u{70}\u{65}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{6f}\u{66}\u{20}\u{70}\u{61}\u{72}\u{61}\u{6d}\u{65}\u{74}\u{65}\u{72}\u{73}\u{2f}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{65}\u{64}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{73}")
464+local on = false
465+local inp,out
466+local function hook
467+(event)
468+if (not on) then
469+return
470+end
471+local ar = debug.getinfo(0x2,"\u{72}\u{75}\u{53}")
472+local t = {}
473+for i = ar.ftransfer, ((ar.ftransfer + ar.ntransfer) - 0x1)
474+do
475+local _,v = debug.getlocal(0x2,i)
476+t[(# (t + 0x1))]=v
477+end
478+if (event == "\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}") then
479+out=t
480+else
481+inp=t
482+end
483+end
484+debug.sethook(hook,"\u{63}\u{72}")
485+on=true
486+;
487+math.sin(0x3)
488+;
489+on=false
490+eqseq(inp,{0x3})
491+;
492+eqseq(out,{math.sin(0x3)})
493+on=true
494+;
495+select(0x2,0xa,0x14,0x1e,0x28)
496+;
497+on=false
498+eqseq(inp,{0x2,0xa,0x14,0x1e,0x28})
499+;
500+eqseq(out,{0x14,0x1e,0x28})
501+local function foo
502+(a, ...)
503+return ...
504+end
505+local function foo1
506+()
507+on=(not on)
508+;
509+return foo(0x14,0xa,0x0)
510+end
511+foo1()
512+;
513+on=false
514+eqseq(inp,{0x14})
515+;
516+eqseq(out,{0xa,0x0})
517+debug.sethook()
518+end
519+local function getupvalues
520+(f)
521+local t = {}
522+local i = 0x1
523+while true do
524+local name,value = debug.getupvalue(f,i)
525+if (not name) then
526+break
527+end
528+assert((not t[name]))
529+t[name]=value
530+i=(i + 0x1)
531+end
532+return t
533+end
534+local a,b,c = 0x1,0x2,0x3
535+local function foo1
536+(a)
537+b=a
538+;
539+return c
540+end
541+local function foo2
542+(x)
543+a=x
544+;
545+return (c + b)
546+end
547+assert((not debug.getupvalue(foo1,0x3)))
548+assert((not debug.getupvalue(foo1,0x0)))
549+assert((not debug.setupvalue(foo1,0x3,"\u{78}\u{75}\u{78}\u{75}")))
550+local t = getupvalues(foo1)
551+assert((((t.a == nil) and (t.b == 0x2)) and (t.c == 0x3)))
552+t=getupvalues(foo2)
553+assert((((t.a == 0x1) and (t.b == 0x2)) and (t.c == 0x3)))
554+assert((debug.setupvalue(foo1,0x1,"\u{78}\u{75}\u{78}\u{75}") == "\u{62}"))
555+assert((({debug.getupvalue(foo2,0x3)})[0x2] == "\u{78}\u{75}\u{78}\u{75}"))
556+assert((debug.getupvalue(string.gmatch("\u{78}","\u{78}"),0x1) == ""))
557+local a = 0x0
558+debug.sethook(function (e)
559+a=(a + 0x1)
560+end,"",0x1)
561+a=0x0
562+;
563+for i = 0x1, 0x3e8
564+do
565+
566+end
567+;
568+assert(((0x3e8 < a) and (a < 0x3f4)))
569+debug.sethook(function (e)
570+a=(a + 0x1)
571+end,"",0x4)
572+a=0x0
573+;
574+for i = 0x1, 0x3e8
575+do
576+
577+end
578+;
579+assert(((0xfa < a) and (a < 0xff)))
580+local f,m,c = debug.gethook()
581+assert(((m == "") and (c == 0x4)))
582+debug.sethook(function (e)
583+a=(a + 0x1)
584+end,"",0xfa0)
585+a=0x0
586+;
587+for i = 0x1, 0x3e8
588+do
589+
590+end
591+;
592+assert((a == 0x0))
593+do
594+debug.sethook(print,"",((0x2 ^ 0x18) - 0x1))
595+local f,m,c = debug.gethook()
596+assert((({debug.gethook()})[0x3] == ((0x2 ^ 0x18) - 0x1)))
597+end
598+debug.sethook()
599+local g,g1
600+local function f
601+(x)
602+if x then
603+assert((debug.getinfo(0x1,"\u{53}").what == "\u{4c}\u{75}\u{61}"))
604+assert((debug.getinfo(0x1,"\u{74}").istailcall == true))
605+local tail = debug.getinfo(0x2)
606+assert(((tail.func == g1) and (tail.istailcall == true)))
607+assert((debug.getinfo(0x3,"\u{53}").what == "\u{6d}\u{61}\u{69}\u{6e}"))
608+print("\u{2b}")
609+end
610+end
611+function g(x)
612+return f(x)
613+end
614+function g1(x)
615+g(x)
616+end
617+local function h
618+(x)
619+local f = g1
620+;
621+return f(x)
622+end
623+h(true)
624+local b = {}
625+debug.sethook(function (e)
626+table.insert(b,e)
627+end,"\u{63}\u{72}")
628+h(false)
629+debug.sethook()
630+local res = {"\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}","\u{63}\u{61}\u{6c}\u{6c}","\u{74}\u{61}\u{69}\u{6c}\u{20}\u{63}\u{61}\u{6c}\u{6c}","\u{63}\u{61}\u{6c}\u{6c}","\u{74}\u{61}\u{69}\u{6c}\u{20}\u{63}\u{61}\u{6c}\u{6c}","\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}","\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}","\u{63}\u{61}\u{6c}\u{6c}"}
631+for i = 0x1, (# res)
632+do
633+assert((res[i] == table.remove(b,0x1)))
634+end
635+b=0x0
636+debug.sethook(function (e)
637+if (e == "\u{74}\u{61}\u{69}\u{6c}\u{20}\u{63}\u{61}\u{6c}\u{6c}") then
638+b=(b + 0x1)
639+assert((debug.getinfo(0x2,"\u{74}").istailcall == true))
640+else
641+assert((debug.getinfo(0x2,"\u{74}").istailcall == false))
642+end
643+end,"\u{63}")
644+h(false)
645+debug.sethook()
646+assert((b == 0x2))
647+local lim = ((_soft and 0xbb8) or 0x7530)
648+local function foo
649+(x)
650+if (x == 0x0) then
651+assert((debug.getinfo(0x2).what == "\u{6d}\u{61}\u{69}\u{6e}"))
652+local info = debug.getinfo(0x1)
653+assert(((info.istailcall == true) and (info.func == foo)))
654+else
655+return foo((x - 0x1))
656+end
657+end
658+foo(lim)
659+print("\u{2b}")
660+co=load("\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{41}\u{20}\u{3d}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{28}\u{29}\u{a}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{78}\u{a}\u{20}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{a}")
661+local a = 0x0
662+debug.sethook(function (e,l)
663+if (l == 0x3) then
664+a=(a + 0x1)
665+;
666+assert((debug.getlocal(0x2,0x1) == "\u{28}\u{74}\u{65}\u{6d}\u{70}\u{6f}\u{72}\u{61}\u{72}\u{79}\u{29}"))
667+elseif (l == 0x4) then
668+a=(a + 0x1)
669+;
670+assert((debug.getlocal(0x2,0x1) == "\u{41}"))
671+end
672+end,"\u{6c}")
673+co()
674+debug.sethook()
675+assert((a == 0x2))
676+assert((debug.traceback(print) == print))
677+assert((debug.traceback(print,0x4) == print))
678+assert(string.find(debug.traceback("\u{68}\u{69}",0x4),"\u{5e}\u{68}\u{69}\u{a}"))
679+assert(string.find(debug.traceback("\u{68}\u{69}"),"\u{5e}\u{68}\u{69}\u{a}"))
680+assert((not string.find(debug.traceback("\u{68}\u{69}"),"\u{27}\u{64}\u{65}\u{62}\u{75}\u{67}\u{2e}\u{74}\u{72}\u{61}\u{63}\u{65}\u{62}\u{61}\u{63}\u{6b}\u{27}")))
681+assert(string.find(debug.traceback("\u{68}\u{69}",0x0),"\u{27}\u{64}\u{65}\u{62}\u{75}\u{67}\u{2e}\u{74}\u{72}\u{61}\u{63}\u{65}\u{62}\u{61}\u{63}\u{6b}\u{27}"))
682+assert(string.find(debug.traceback(),"\u{5e}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{74}\u{72}\u{61}\u{63}\u{65}\u{62}\u{61}\u{63}\u{6b}\u{3a}\u{a}"))
683+do
684+local st,msg = (function ()
685+return pcall
686+end)()(debug.traceback)
687+assert(((st == true) and string.find(msg,"\u{70}\u{63}\u{61}\u{6c}\u{6c}")))
688+end
689+local t = debug.getinfo(print,"\u{75}")
690+assert((((t.isvararg == true) and (t.nparams == 0x0)) and (t.nups == 0x0)))
691+t=debug.getinfo(function (a,b,c)
692+
693+end,"\u{75}")
694+assert((((t.isvararg == false) and (t.nparams == 0x3)) and (t.nups == 0x0)))
695+t=debug.getinfo(function (a,b, ...)
696+return t[a]
697+end,"\u{75}")
698+assert((((t.isvararg == true) and (t.nparams == 0x2)) and (t.nups == 0x1)))
699+t=debug.getinfo(0x1)
700+assert(((((t.isvararg == true) and (t.nparams == 0x0)) and (t.nups == 0x1)) and (debug.getupvalue(t.func,0x1) == "\u{5f}\u{45}\u{4e}\u{56}")))
701+t=debug.getinfo(math.sin)
702+assert((((t.isvararg == true) and (t.nparams == 0x0)) and (t.nups == 0x0)))
703+t=debug.getinfo(string.gmatch("\u{61}\u{62}\u{63}","\u{61}"))
704+assert((((t.isvararg == true) and (t.nparams == 0x0)) and (t.nups > 0x0)))
705+local function checktraceback
706+(co,p,level)
707+local tb = debug.traceback(co,nil,level)
708+local i = 0x0
709+for l in string.gmatch(tb,"\u{5b}\u{5e}\u{a}\u{5d}\u{2b}\u{a}\u{3f}")
710+do
711+assert(((i == 0x0) or string.find(l,p[i])))
712+i=(i + 0x1)
713+end
714+assert((p[i] == undef))
715+end
716+local function f
717+(n)
718+if (n > 0x0) then
719+f((n - 0x1))
720+else
721+coroutine.yield()
722+end
723+end
724+local co = coroutine.create(f)
725+coroutine.resume(co,0x3)
726+checktraceback(co,{"\u{79}\u{69}\u{65}\u{6c}\u{64}","\u{64}\u{62}\u{2e}\u{6c}\u{75}\u{61}","\u{64}\u{62}\u{2e}\u{6c}\u{75}\u{61}","\u{64}\u{62}\u{2e}\u{6c}\u{75}\u{61}","\u{64}\u{62}\u{2e}\u{6c}\u{75}\u{61}"})
727+checktraceback(co,{"\u{64}\u{62}\u{2e}\u{6c}\u{75}\u{61}","\u{64}\u{62}\u{2e}\u{6c}\u{75}\u{61}","\u{64}\u{62}\u{2e}\u{6c}\u{75}\u{61}","\u{64}\u{62}\u{2e}\u{6c}\u{75}\u{61}"},0x1)
728+checktraceback(co,{"\u{64}\u{62}\u{2e}\u{6c}\u{75}\u{61}","\u{64}\u{62}\u{2e}\u{6c}\u{75}\u{61}","\u{64}\u{62}\u{2e}\u{6c}\u{75}\u{61}"},0x2)
729+checktraceback(co,{"\u{64}\u{62}\u{2e}\u{6c}\u{75}\u{61}"},0x4)
730+checktraceback(co,{},0x28)
731+co=coroutine.create(function (x)
732+local a = 0x1
733+coroutine.yield(debug.getinfo(0x1,"\u{6c}"))
734+coroutine.yield(debug.getinfo(0x1,"\u{6c}").currentline)
735+return a
736+end)
737+local tr = {}
738+local foo = function (e,l)
739+if l then
740+table.insert(tr,l)
741+end
742+end
743+debug.sethook(co,foo,"\u{6c}\u{63}\u{72}")
744+local _,l = coroutine.resume(co,0xa)
745+local x = debug.getinfo(co,0x1,"\u{6c}\u{66}\u{4c}\u{53}")
746+assert(((x.currentline == l.currentline) and x.activelines[x.currentline]))
747+assert((type(x.func) == "\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}"))
748+for i = (x.linedefined + 0x1), x.lastlinedefined
749+do
750+assert(x.activelines[i])
751+x.activelines[i]=undef
752+end
753+assert((next(x.activelines) == nil))
754+assert((not debug.getinfo(co,0x2)))
755+local a,b = debug.getlocal(co,0x1,0x1)
756+assert(((a == "\u{78}") and (b == 0xa)))
757+a,b=debug.getlocal(co,0x1,0x2)
758+assert(((a == "\u{61}") and (b == 0x1)))
759+debug.setlocal(co,0x1,0x2,"\u{68}\u{69}")
760+assert((debug.gethook(co) == foo))
761+assert((# (((tr == 0x2) and (tr[0x1] == (l.currentline - 0x1))) and (tr[0x2] == l.currentline))))
762+a,b,c=pcall(coroutine.resume,co)
763+assert(((a and b) and (c == (l.currentline + 0x1))))
764+checktraceback(co,{"\u{79}\u{69}\u{65}\u{6c}\u{64}","\u{69}\u{6e}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{3c}"})
765+a,b=coroutine.resume(co)
766+assert((a and (b == "\u{68}\u{69}")))
767+assert((# ((tr == 0x4) and (tr[0x4] == (l.currentline + 0x2)))))
768+assert((debug.gethook(co) == foo))
769+assert((not debug.gethook()))
770+checktraceback(co,{})
771+co=coroutine.create(function (x)
772+local a,b = coroutine.yield(x)
773+assert(((a == 0x64) and (b == nil)))
774+return x
775+end)
776+a,b=coroutine.resume(co,0xa)
777+assert((a and (b == 0xa)))
778+a,b=debug.getlocal(co,0x1,0x1)
779+assert(((a == "\u{78}") and (b == 0xa)))
780+assert((not debug.getlocal(co,0x1,0x5)))
781+assert((debug.setlocal(co,0x1,0x1,0x1e) == "\u{78}"))
782+assert((not debug.setlocal(co,0x1,0x5,0x28)))
783+a,b=coroutine.resume(co,0x64)
784+assert((a and (b == 0x1e)))
785+function f(i)
786+if (i == 0x0) then
787+error(i)
788+else
789+coroutine.yield()
790+;
791+f((i - 0x1))
792+end
793+end
794+co=coroutine.create(function (x)
795+f(x)
796+end)
797+a,b=coroutine.resume(co,0x3)
798+t={"\u{27}\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}\u{2e}\u{79}\u{69}\u{65}\u{6c}\u{64}\u{27}","\u{27}\u{66}\u{27}","\u{69}\u{6e}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{3c}"}
799+while (coroutine.status(co) == "\u{73}\u{75}\u{73}\u{70}\u{65}\u{6e}\u{64}\u{65}\u{64}") do
800+checktraceback(co,t)
801+a,b=coroutine.resume(co)
802+table.insert(t,0x2,"\u{27}\u{66}\u{27}")
803+end
804+t[0x1]="\u{27}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{27}"
805+checktraceback(co,t)
806+local function g
807+(x)
808+coroutine.yield(x)
809+end
810+local function f
811+(i)
812+debug.sethook(function ()
813+
814+end,"\u{6c}")
815+for j = 0x1, 0x3e8
816+do
817+g((i + j))
818+end
819+end
820+local co = coroutine.wrap(f)
821+co(0xa)
822+pcall(co)
823+pcall(co)
824+assert((type(debug.getregistry()) == "\u{74}\u{61}\u{62}\u{6c}\u{65}"))
825+local a = {}
826+local function f
827+(t)
828+local info = debug.getinfo(0x1)
829+;
830+assert((info.namewhat == "\u{6d}\u{65}\u{74}\u{61}\u{6d}\u{65}\u{74}\u{68}\u{6f}\u{64}"))
831+a.op=info.name
832+return info.name
833+end
834+setmetatable(a,{["\u{5f}\u{5f}\u{69}\u{6e}\u{64}\u{65}\u{78}"] = f,["\u{5f}\u{5f}\u{61}\u{64}\u{64}"] = f,["\u{5f}\u{5f}\u{64}\u{69}\u{76}"] = f,["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}"] = f,["\u{5f}\u{5f}\u{63}\u{6f}\u{6e}\u{63}\u{61}\u{74}"] = f,["\u{5f}\u{5f}\u{70}\u{6f}\u{77}"] = f,["\u{5f}\u{5f}\u{6d}\u{75}\u{6c}"] = f,["\u{5f}\u{5f}\u{69}\u{64}\u{69}\u{76}"] = f,["\u{5f}\u{5f}\u{75}\u{6e}\u{6d}"] = f,["\u{5f}\u{5f}\u{6c}\u{65}\u{6e}"] = f,["\u{5f}\u{5f}\u{73}\u{75}\u{62}"] = f,["\u{5f}\u{5f}\u{73}\u{68}\u{6c}"] = f,["\u{5f}\u{5f}\u{73}\u{68}\u{72}"] = f,["\u{5f}\u{5f}\u{62}\u{6f}\u{72}"] = f,["\u{5f}\u{5f}\u{62}\u{78}\u{6f}\u{72}"] = f,["\u{5f}\u{5f}\u{65}\u{71}"] = f,["\u{5f}\u{5f}\u{6c}\u{65}"] = f,["\u{5f}\u{5f}\u{6c}\u{74}"] = f,["\u{5f}\u{5f}\u{75}\u{6e}\u{6d}"] = f,["\u{5f}\u{5f}\u{6c}\u{65}\u{6e}"] = f,["\u{5f}\u{5f}\u{62}\u{61}\u{6e}\u{64}"] = f,["\u{5f}\u{5f}\u{62}\u{6e}\u{6f}\u{74}"] = f})
835+local b = setmetatable({},getmetatable(a))
836+assert((((a[0x3] == "\u{69}\u{6e}\u{64}\u{65}\u{78}") and ((a ^ 0x3) == "\u{70}\u{6f}\u{77}")) and ((a .. a) == "\u{63}\u{6f}\u{6e}\u{63}\u{61}\u{74}")))
837+assert((((a / 0x3) == "\u{64}\u{69}\u{76}") and ((0x3 % a) == "\u{6d}\u{6f}\u{64}")))
838+assert((((((a + 0x3) == "\u{61}\u{64}\u{64}") and ((0x3 - a) == "\u{73}\u{75}\u{62}")) and ((a * 0x3) == "\u{6d}\u{75}\u{6c}")) and (- ((a == "\u{75}\u{6e}\u{6d}") and (# ((a == "\u{6c}\u{65}\u{6e}") and ((a & 0x3) == "\u{62}\u{61}\u{6e}\u{64}")))))))
839+assert((((((a + 0x7530) == "\u{61}\u{64}\u{64}") and ((a - 3.0) == "\u{73}\u{75}\u{62}")) and ((a * 3.0) == "\u{6d}\u{75}\u{6c}")) and (- ((a == "\u{75}\u{6e}\u{6d}") and (# ((a == "\u{6c}\u{65}\u{6e}") and ((a & 0x3) == "\u{62}\u{61}\u{6e}\u{64}")))))))
840+assert((((((a | 0x3) == "\u{62}\u{6f}\u{72}") and ((0x3 ~ a) == "\u{62}\u{78}\u{6f}\u{72}")) and ((a << 0x3) == "\u{73}\u{68}\u{6c}")) and ((a >> 0x1) == "\u{73}\u{68}\u{72}")))
841+assert(((a == b) and (a.op == "\u{65}\u{71}")))
842+assert(((a >= b) and (a.op == "\u{6c}\u{65}")))
843+assert((("\u{78}" >= a) and (a.op == "\u{6c}\u{65}")))
844+assert(((a > b) and (a.op == "\u{6c}\u{74}")))
845+assert(((a > 0xa) and (a.op == "\u{6c}\u{74}")))
846+assert((~ (a == "\u{62}\u{6e}\u{6f}\u{74}")))
847+do
848+local function f
849+()
850+assert((debug.getinfo(0x1).name == "\u{66}\u{6f}\u{72}\u{20}\u{69}\u{74}\u{65}\u{72}\u{61}\u{74}\u{6f}\u{72}"))
851+end
852+for i in f
853+do
854+
855+end
856+end
857+do
858+local name = nil
859+setmetatable({},{["\u{5f}\u{5f}\u{67}\u{63}"] = function ()
860+local t = debug.getinfo(0x1)
861+assert((t.namewhat == "\u{6d}\u{65}\u{74}\u{61}\u{6d}\u{65}\u{74}\u{68}\u{6f}\u{64}"))
862+name=t.name
863+end})
864+repeat
865+local a = {}
866+until name
867+assert((name == "\u{5f}\u{5f}\u{67}\u{63}"))
868+end
869+do
870+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{74}\u{72}\u{61}\u{63}\u{65}\u{62}\u{61}\u{63}\u{6b}\u{20}\u{73}\u{69}\u{7a}\u{65}\u{73}")
871+local function countlines
872+(s)
873+return select(0x2,string.gsub(s,"\u{a}",""))
874+end
875+local function deep
876+(lvl,n)
877+if (lvl == 0x0) then
878+return debug.traceback("\u{6d}\u{65}\u{73}\u{73}\u{61}\u{67}\u{65}",n)
879+else
880+return deep((lvl - 0x1),n)
881+end
882+end
883+local function checkdeep
884+(total,start)
885+local s = deep(total,start)
886+local rest = string.match(s,"\u{5e}\u{6d}\u{65}\u{73}\u{73}\u{61}\u{67}\u{65}\u{a}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{74}\u{72}\u{61}\u{63}\u{65}\u{62}\u{61}\u{63}\u{6b}\u{3a}\u{a}\u{28}\u{2e}\u{2a}\u{29}\u{24}")
887+local cl = countlines(rest)
888+assert((cl <= ((0xa + 0xb) + 0x1)))
889+local brk = string.find(rest,"\u{25}\u{2e}\u{25}\u{2e}\u{25}\u{2e}\u{9}\u{25}\u{28}\u{73}\u{6b}\u{69}\u{70}")
890+if brk then
891+local rest1 = string.sub(rest,0x1,brk)
892+local rest2 = string.sub(rest,brk,(# rest))
893+assert(((countlines(rest1) == 0xa) and (countlines(rest2) == 0xb)))
894+else
895+assert((cl == ((total - start) + 0x2)))
896+end
897+end
898+for d = 0x1, 0x33, 0xa
899+do
900+for l = 0x1, d
901+do
902+coroutine.wrap(checkdeep)(d,l)
903+end
904+end
905+end
906+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{64}\u{65}\u{62}\u{75}\u{67}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{73}\u{20}\u{6f}\u{6e}\u{20}\u{63}\u{68}\u{75}\u{6e}\u{6b}\u{20}\u{77}\u{69}\u{74}\u{68}\u{6f}\u{75}\u{74}\u{20}\u{64}\u{65}\u{62}\u{75}\u{67}\u{20}\u{69}\u{6e}\u{66}\u{6f}")
907+local prog = "\u{2d}\u{2d}\u{20}\u{70}\u{72}\u{6f}\u{67}\u{72}\u{61}\u{6d}\u{20}\u{74}\u{6f}\u{20}\u{62}\u{65}\u{20}\u{6c}\u{6f}\u{61}\u{64}\u{65}\u{64}\u{20}\u{77}\u{69}\u{74}\u{68}\u{6f}\u{75}\u{74}\u{20}\u{64}\u{65}\u{62}\u{75}\u{67}\u{20}\u{69}\u{6e}\u{66}\u{6f}\u{72}\u{6d}\u{61}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{28}\u{73}\u{74}\u{72}\u{69}\u{70}\u{29}\u{a}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{64}\u{65}\u{62}\u{75}\u{67}\u{20}\u{3d}\u{20}\u{72}\u{65}\u{71}\u{75}\u{69}\u{72}\u{65}\u{27}\u{64}\u{65}\u{62}\u{75}\u{67}\u{27}\u{a}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{31}\u{32}\u{20}\u{20}\u{2d}\u{2d}\u{20}\u{61}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{76}\u{61}\u{72}\u{69}\u{61}\u{62}\u{6c}\u{65}\u{a}\u{a}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{6e}\u{2c}\u{20}\u{76}\u{20}\u{3d}\u{20}\u{64}\u{65}\u{62}\u{75}\u{67}\u{2e}\u{67}\u{65}\u{74}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{28}\u{31}\u{2c}\u{20}\u{31}\u{29}\u{a}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{6e}\u{20}\u{3d}\u{3d}\u{20}\u{22}\u{28}\u{74}\u{65}\u{6d}\u{70}\u{6f}\u{72}\u{61}\u{72}\u{79}\u{29}\u{22}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{76}\u{20}\u{3d}\u{3d}\u{20}\u{64}\u{65}\u{62}\u{75}\u{67}\u{29}\u{20}\u{20}\u{20}\u{2d}\u{2d}\u{20}\u{75}\u{6e}\u{6b}\u{6f}\u{77}\u{6e}\u{20}\u{6e}\u{61}\u{6d}\u{65}\u{20}\u{62}\u{75}\u{74}\u{20}\u{6b}\u{6e}\u{6f}\u{77}\u{6e}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{a}\u{6e}\u{2c}\u{20}\u{76}\u{20}\u{3d}\u{20}\u{64}\u{65}\u{62}\u{75}\u{67}\u{2e}\u{67}\u{65}\u{74}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{28}\u{31}\u{2c}\u{20}\u{32}\u{29}\u{a}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{6e}\u{20}\u{3d}\u{3d}\u{20}\u{22}\u{28}\u{74}\u{65}\u{6d}\u{70}\u{6f}\u{72}\u{61}\u{72}\u{79}\u{29}\u{22}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{76}\u{20}\u{3d}\u{3d}\u{20}\u{31}\u{32}\u{29}\u{20}\u{20}\u{20}\u{2d}\u{2d}\u{20}\u{75}\u{6e}\u{6b}\u{6f}\u{77}\u{6e}\u{20}\u{6e}\u{61}\u{6d}\u{65}\u{20}\u{62}\u{75}\u{74}\u{20}\u{6b}\u{6e}\u{6f}\u{77}\u{6e}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{a}\u{a}\u{2d}\u{2d}\u{20}\u{61}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{77}\u{69}\u{74}\u{68}\u{20}\u{61}\u{6e}\u{20}\u{75}\u{70}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{a}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{66}\u{20}\u{3d}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{28}\u{29}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{78}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{61}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{6e}\u{2c}\u{20}\u{76}\u{20}\u{3d}\u{20}\u{64}\u{65}\u{62}\u{75}\u{67}\u{2e}\u{67}\u{65}\u{74}\u{75}\u{70}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{28}\u{66}\u{2c}\u{20}\u{31}\u{29}\u{a}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{6e}\u{20}\u{3d}\u{3d}\u{20}\u{22}\u{28}\u{6e}\u{6f}\u{20}\u{6e}\u{61}\u{6d}\u{65}\u{29}\u{22}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{76}\u{20}\u{3d}\u{3d}\u{20}\u{31}\u{32}\u{29}\u{a}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{64}\u{65}\u{62}\u{75}\u{67}\u{2e}\u{73}\u{65}\u{74}\u{75}\u{70}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{28}\u{66}\u{2c}\u{20}\u{31}\u{2c}\u{20}\u{31}\u{33}\u{29}\u{20}\u{3d}\u{3d}\u{20}\u{22}\u{28}\u{6e}\u{6f}\u{20}\u{6e}\u{61}\u{6d}\u{65}\u{29}\u{22}\u{29}\u{a}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{61}\u{20}\u{3d}\u{3d}\u{20}\u{31}\u{33}\u{29}\u{a}\u{a}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{74}\u{20}\u{3d}\u{20}\u{64}\u{65}\u{62}\u{75}\u{67}\u{2e}\u{67}\u{65}\u{74}\u{69}\u{6e}\u{66}\u{6f}\u{28}\u{66}\u{29}\u{a}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{74}\u{2e}\u{6e}\u{61}\u{6d}\u{65}\u{20}\u{3d}\u{3d}\u{20}\u{6e}\u{69}\u{6c}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{74}\u{2e}\u{6c}\u{69}\u{6e}\u{65}\u{64}\u{65}\u{66}\u{69}\u{6e}\u{65}\u{64}\u{20}\u{3e}\u{20}\u{30}\u{20}\u{61}\u{6e}\u{64}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{74}\u{2e}\u{6c}\u{61}\u{73}\u{74}\u{6c}\u{69}\u{6e}\u{65}\u{64}\u{65}\u{66}\u{69}\u{6e}\u{65}\u{64}\u{20}\u{3d}\u{3d}\u{20}\u{74}\u{2e}\u{6c}\u{69}\u{6e}\u{65}\u{64}\u{65}\u{66}\u{69}\u{6e}\u{65}\u{64}\u{20}\u{61}\u{6e}\u{64}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{74}\u{2e}\u{73}\u{68}\u{6f}\u{72}\u{74}\u{5f}\u{73}\u{72}\u{63}\u{20}\u{3d}\u{3d}\u{20}\u{22}\u{3f}\u{22}\u{29}\u{a}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{64}\u{65}\u{62}\u{75}\u{67}\u{2e}\u{67}\u{65}\u{74}\u{69}\u{6e}\u{66}\u{6f}\u{28}\u{31}\u{29}\u{2e}\u{63}\u{75}\u{72}\u{72}\u{65}\u{6e}\u{74}\u{6c}\u{69}\u{6e}\u{65}\u{20}\u{3d}\u{3d}\u{20}\u{2d}\u{31}\u{29}\u{a}\u{a}\u{74}\u{20}\u{3d}\u{20}\u{64}\u{65}\u{62}\u{75}\u{67}\u{2e}\u{67}\u{65}\u{74}\u{69}\u{6e}\u{66}\u{6f}\u{28}\u{66}\u{2c}\u{20}\u{22}\u{4c}\u{22}\u{29}\u{2e}\u{61}\u{63}\u{74}\u{69}\u{76}\u{65}\u{6c}\u{69}\u{6e}\u{65}\u{73}\u{a}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{6e}\u{65}\u{78}\u{74}\u{28}\u{74}\u{29}\u{20}\u{3d}\u{3d}\u{20}\u{6e}\u{69}\u{6c}\u{29}\u{20}\u{20}\u{20}\u{20}\u{2d}\u{2d}\u{20}\u{61}\u{63}\u{74}\u{69}\u{76}\u{65}\u{20}\u{6c}\u{69}\u{6e}\u{65}\u{73}\u{20}\u{61}\u{72}\u{65}\u{20}\u{65}\u{6d}\u{70}\u{74}\u{79}\u{a}\u{a}\u{2d}\u{2d}\u{20}\u{64}\u{75}\u{6d}\u{70}\u{2f}\u{6c}\u{6f}\u{61}\u{64}\u{20}\u{61}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{77}\u{69}\u{74}\u{68}\u{6f}\u{75}\u{74}\u{20}\u{64}\u{65}\u{62}\u{75}\u{67}\u{20}\u{69}\u{6e}\u{66}\u{6f}\u{a}\u{66}\u{20}\u{3d}\u{20}\u{6c}\u{6f}\u{61}\u{64}\u{28}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{2e}\u{64}\u{75}\u{6d}\u{70}\u{28}\u{66}\u{29}\u{29}\u{a}\u{a}\u{74}\u{20}\u{3d}\u{20}\u{64}\u{65}\u{62}\u{75}\u{67}\u{2e}\u{67}\u{65}\u{74}\u{69}\u{6e}\u{66}\u{6f}\u{28}\u{66}\u{29}\u{a}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{74}\u{2e}\u{6e}\u{61}\u{6d}\u{65}\u{20}\u{3d}\u{3d}\u{20}\u{6e}\u{69}\u{6c}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{74}\u{2e}\u{6c}\u{69}\u{6e}\u{65}\u{64}\u{65}\u{66}\u{69}\u{6e}\u{65}\u{64}\u{20}\u{3e}\u{20}\u{30}\u{20}\u{61}\u{6e}\u{64}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{74}\u{2e}\u{6c}\u{61}\u{73}\u{74}\u{6c}\u{69}\u{6e}\u{65}\u{64}\u{65}\u{66}\u{69}\u{6e}\u{65}\u{64}\u{20}\u{3d}\u{3d}\u{20}\u{74}\u{2e}\u{6c}\u{69}\u{6e}\u{65}\u{64}\u{65}\u{66}\u{69}\u{6e}\u{65}\u{64}\u{20}\u{61}\u{6e}\u{64}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{74}\u{2e}\u{73}\u{68}\u{6f}\u{72}\u{74}\u{5f}\u{73}\u{72}\u{63}\u{20}\u{3d}\u{3d}\u{20}\u{22}\u{3f}\u{22}\u{29}\u{a}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{64}\u{65}\u{62}\u{75}\u{67}\u{2e}\u{67}\u{65}\u{74}\u{69}\u{6e}\u{66}\u{6f}\u{28}\u{31}\u{29}\u{2e}\u{63}\u{75}\u{72}\u{72}\u{65}\u{6e}\u{74}\u{6c}\u{69}\u{6e}\u{65}\u{20}\u{3d}\u{3d}\u{20}\u{2d}\u{31}\u{29}\u{a}\u{a}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{61}\u{a}"
908+local f = assert(load(string.dump(load(prog),true)))
909+assert((f() == 0xd))
910+do
911+local function foo
912+()
913+local a = 0x1
914+local b = 0x2
915+return b
916+end
917+local s = load(string.dump(foo,true))
918+local line = true
919+debug.sethook(function (e,l)
920+assert((e == "\u{6c}\u{69}\u{6e}\u{65}"))
921+line=l
922+end,"\u{6c}")
923+assert((s() == 0x2))
924+;
925+debug.sethook(nil)
926+assert((line == nil))
927+end
928+do
929+local prog = "\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{28}\u{78}\u{29}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{28}\u{79}\u{29}\u{20}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{78}\u{20}\u{2b}\u{20}\u{79}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{20}\u{20}\u{20}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{20}\u{20}"
930+local name = string.rep("\u{78}",0x3e8)
931+local p = assert(load(prog,name))
932+local c = string.dump(p)
933+assert((# ((c > 0x3e8) and (# (c < 0x7d0)))))
934+local f = assert(load(c))
935+local g = f()
936+local h = g(0x3)
937+assert((h(0x5) == 0x8))
938+assert((((debug.getinfo(f).source == name) and (debug.getinfo(g).source == name)) and (debug.getinfo(h).source == name)))
939+local c = string.dump(p,true)
940+assert((# (c < 0x1f4)))
941+local f = assert(load(c))
942+local g = f()
943+local h = g(0x1e)
944+assert((h(0x32) == 0x50))
945+assert((((debug.getinfo(f).source == "\u{3d}\u{3f}") and (debug.getinfo(g).source == "\u{3d}\u{3f}")) and (debug.getinfo(h).source == "\u{3d}\u{3f}")))
946+end
947+print("\u{4f}\u{4b}")
desk/res/lua/cycled/errors.luanew file+493
@@ -0,0 +1,493 @@
1+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{73}")
2+local debug = require("\u{64}\u{65}\u{62}\u{75}\u{67}")
3+local mt = (getmetatable(_G) or {})
4+local oldmm = mt.__index
5+mt.__index=nil
6+local function checkerr
7+(msg,f, ...)
8+local st,err = pcall(f,...)
9+assert((not (st and string.find(err,msg))))
10+end
11+local function doit
12+(s)
13+local f,msg = load(s)
14+if (not f) then
15+return msg
16+end
17+local cond,msg = pcall(f)
18+return ((not cond) and msg)
19+end
20+local function checkmessage
21+(prog,msg,debug)
22+local m = doit(prog)
23+if debug then
24+print(m,msg)
25+end
26+assert(string.find(m,msg,0x1,true))
27+end
28+local function checksyntax
29+(prog,extra,token,line)
30+local msg = doit(prog)
31+if (not (string.find(token,"\u{5e}\u{3c}\u{25}\u{61}") and (not string.find(token,"\u{5e}\u{63}\u{68}\u{61}\u{72}\u{25}\u{28}")))) then
32+token=("\u{27}" .. (token .. "\u{27}"))
33+end
34+token=string.gsub(token,"\u{28}\u{25}\u{70}\u{29}","\u{25}\u{25}\u{25}\u{31}")
35+local pt = string.format("\u{5e}\u{25}\u{25}\u{5b}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{22}\u{2e}\u{2a}\u{22}\u{25}\u{25}\u{5d}\u{3a}\u{25}\u{64}\u{3a}\u{20}\u{2e}\u{2d}\u{20}\u{6e}\u{65}\u{61}\u{72}\u{20}\u{25}\u{73}\u{24}",line,token)
36+assert(string.find(msg,pt))
37+assert(string.find(msg,msg,0x1,true))
38+end
39+assert((doit("\u{65}\u{72}\u{72}\u{6f}\u{72}\u{28}\u{27}\u{68}\u{69}\u{27}\u{2c}\u{20}\u{30}\u{29}") == "\u{68}\u{69}"))
40+assert((doit("\u{65}\u{72}\u{72}\u{6f}\u{72}\u{28}\u{29}") == nil))
41+assert(doit("\u{74}\u{61}\u{62}\u{6c}\u{65}\u{2e}\u{75}\u{6e}\u{70}\u{61}\u{63}\u{6b}\u{28}\u{7b}\u{7d}\u{2c}\u{20}\u{31}\u{2c}\u{20}\u{6e}\u{3d}\u{32}\u{5e}\u{33}\u{30}\u{29}"))
42+assert(doit("\u{61}\u{3d}\u{6d}\u{61}\u{74}\u{68}\u{2e}\u{73}\u{69}\u{6e}\u{28}\u{29}"))
43+assert((not (doit("\u{74}\u{6f}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{28}\u{31}\u{29}") and doit("\u{74}\u{6f}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{28}\u{29}"))))
44+assert(doit("\u{74}\u{6f}\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}\u{28}\u{29}"))
45+assert(doit("\u{72}\u{65}\u{70}\u{65}\u{61}\u{74}\u{20}\u{75}\u{6e}\u{74}\u{69}\u{6c}\u{20}\u{31}\u{3b}\u{20}\u{61}"))
46+assert(doit("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{3b}\u{3b}"))
47+assert(doit("\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{66}\u{61}\u{6c}\u{73}\u{65}\u{29}"))
48+assert(doit("\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{6e}\u{69}\u{6c}\u{29}"))
49+assert(doit("\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{61}\u{20}\u{28}\u{2e}\u{2e}\u{2e}\u{20}\u{2c}\u{20}\u{2e}\u{2e}\u{2e}\u{29}\u{20}\u{65}\u{6e}\u{64}"))
50+assert(doit("\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{61}\u{20}\u{28}\u{2c}\u{20}\u{2e}\u{2e}\u{2e}\u{29}\u{20}\u{65}\u{6e}\u{64}"))
51+assert(doit("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{74}\u{3d}\u{7b}\u{7d}\u{3b}\u{20}\u{74}\u{20}\u{3d}\u{20}\u{74}\u{5b}\u{23}\u{74}\u{5d}\u{20}\u{2b}\u{20}\u{31}"))
52+checksyntax("\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{7b}\u{34}\u{a}\u{a}","\u{27}\u{7d}\u{27}\u{20}\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}\u{20}\u{28}\u{74}\u{6f}\u{20}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{20}\u{27}\u{7b}\u{27}\u{20}\u{61}\u{74}\u{20}\u{6c}\u{69}\u{6e}\u{65}\u{20}\u{31}\u{29}","\u{3c}\u{65}\u{6f}\u{66}\u{3e}",0x3)
53+do
54+local function checksyntax
55+(prog,msg,line)
56+local st,err = load(prog)
57+assert(string.find(err,("\u{6c}\u{69}\u{6e}\u{65}\u{20}" .. line)))
58+assert(string.find(err,msg,0x1,true))
59+end
60+checksyntax("\u{20}\u{20}\u{20}\u{20}\u{3a}\u{3a}\u{41}\u{3a}\u{3a}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{31}\u{a}\u{20}\u{20}\u{20}\u{20}\u{3a}\u{3a}\u{41}\u{3a}\u{3a}\u{a}\u{20}\u{20}","\u{6c}\u{61}\u{62}\u{65}\u{6c}\u{20}\u{27}\u{41}\u{27}\u{20}\u{61}\u{6c}\u{72}\u{65}\u{61}\u{64}\u{79}\u{20}\u{64}\u{65}\u{66}\u{69}\u{6e}\u{65}\u{64}",0x1)
61+checksyntax("\u{20}\u{20}\u{20}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{31}\u{a}\u{20}\u{20}\u{20}\u{20}\u{67}\u{6f}\u{74}\u{6f}\u{20}\u{41}\u{a}\u{20}\u{20}\u{20}\u{20}\u{64}\u{6f}\u{20}\u{3a}\u{3a}\u{41}\u{3a}\u{3a}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{20}\u{20}","\u{6e}\u{6f}\u{20}\u{76}\u{69}\u{73}\u{69}\u{62}\u{6c}\u{65}\u{20}\u{6c}\u{61}\u{62}\u{65}\u{6c}\u{20}\u{27}\u{41}\u{27}",0x2)
62+end
63+if (not T) then
64+(Message or print)("\u{a}\u{20}\u{3e}\u{3e}\u{3e}\u{20}\u{74}\u{65}\u{73}\u{74}\u{43}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{61}\u{63}\u{74}\u{69}\u{76}\u{65}\u{3a}\u{20}\u{73}\u{6b}\u{69}\u{70}\u{70}\u{69}\u{6e}\u{67}\u{20}\u{74}\u{65}\u{73}\u{74}\u{73}\u{20}\u{66}\u{6f}\u{72}\u{20}\u{6d}\u{65}\u{73}\u{73}\u{61}\u{67}\u{65}\u{73}\u{20}\u{69}\u{6e}\u{20}\u{43}\u{20}\u{3c}\u{3c}\u{3c}\u{a}")
65+else
66+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{6d}\u{65}\u{6d}\u{6f}\u{72}\u{79}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{20}\u{6d}\u{65}\u{73}\u{73}\u{61}\u{67}\u{65}")
67+local a = {}
68+for i = 0x1, 0x2710
69+do
70+a[i]=true
71+end
72+collectgarbage()
73+T.totalmem((T.totalmem() + 0x2710))
74+local st,msg = pcall(function ()
75+for i = 0x1, 0x186a0
76+do
77+a[i]=tostring(i)
78+end
79+end)
80+T.totalmem(0x0)
81+assert((not (st and (msg == ("\u{6e}\u{6f}\u{74}\u{20}\u{65}\u{6e}\u{6f}\u{75}\u{67}\u{68}" .. "\u{20}\u{6d}\u{65}\u{6d}\u{6f}\u{72}\u{79}")))))
82+local res = T.testC("\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{70}\u{75}\u{73}\u{68}\u{20}\u{31}\u{36}\u{20}\u{65}\u{6c}\u{65}\u{6d}\u{65}\u{6e}\u{74}\u{73}\u{20}\u{6f}\u{6e}\u{20}\u{74}\u{68}\u{65}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{3b}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{74}\u{72}\u{61}\u{63}\u{65}\u{62}\u{61}\u{63}\u{6b}\u{20}\u{73}\u{68}\u{6f}\u{75}\u{6c}\u{64}\u{20}\u{77}\u{6f}\u{72}\u{6b}\u{20}\u{77}\u{69}\u{74}\u{68}\u{20}\u{34}\u{20}\u{72}\u{65}\u{6d}\u{61}\u{69}\u{6e}\u{69}\u{6e}\u{67}\u{20}\u{73}\u{6c}\u{6f}\u{74}\u{73}\u{a}\u{20}\u{20}\u{20}\u{20}\u{74}\u{72}\u{61}\u{63}\u{65}\u{62}\u{61}\u{63}\u{6b}\u{20}\u{78}\u{75}\u{78}\u{75}\u{20}\u{31}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}\u{a}\u{20}\u{20}")
83+assert(string.find(res,"\u{78}\u{75}\u{78}\u{75}\u{2e}\u{2d}\u{6d}\u{61}\u{69}\u{6e}\u{20}\u{63}\u{68}\u{75}\u{6e}\u{6b}"))
84+end
85+checkmessage("\u{61}\u{20}\u{3d}\u{20}\u{7b}\u{7d}\u{20}\u{2b}\u{20}\u{31}","\u{61}\u{72}\u{69}\u{74}\u{68}\u{6d}\u{65}\u{74}\u{69}\u{63}")
86+checkmessage("\u{61}\u{20}\u{3d}\u{20}\u{7b}\u{7d}\u{20}\u{7c}\u{20}\u{31}","\u{62}\u{69}\u{74}\u{77}\u{69}\u{73}\u{65}\u{20}\u{6f}\u{70}\u{65}\u{72}\u{61}\u{74}\u{69}\u{6f}\u{6e}")
87+checkmessage("\u{61}\u{20}\u{3d}\u{20}\u{7b}\u{7d}\u{20}\u{3c}\u{20}\u{31}","\u{61}\u{74}\u{74}\u{65}\u{6d}\u{70}\u{74}\u{20}\u{74}\u{6f}\u{20}\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}")
88+checkmessage("\u{61}\u{20}\u{3d}\u{20}\u{7b}\u{7d}\u{20}\u{3c}\u{3d}\u{20}\u{31}","\u{61}\u{74}\u{74}\u{65}\u{6d}\u{70}\u{74}\u{20}\u{74}\u{6f}\u{20}\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{65}")
89+checkmessage("\u{61}\u{61}\u{61}\u{3d}\u{31}\u{3b}\u{20}\u{62}\u{62}\u{62}\u{62}\u{3d}\u{32}\u{3b}\u{20}\u{61}\u{61}\u{61}\u{3d}\u{6d}\u{61}\u{74}\u{68}\u{2e}\u{73}\u{69}\u{6e}\u{28}\u{33}\u{29}\u{2b}\u{62}\u{62}\u{62}\u{62}\u{28}\u{33}\u{29}","\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{27}\u{62}\u{62}\u{62}\u{62}\u{27}")
90+checkmessage("\u{61}\u{61}\u{61}\u{3d}\u{7b}\u{7d}\u{3b}\u{20}\u{64}\u{6f}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{61}\u{61}\u{3d}\u{31}\u{20}\u{65}\u{6e}\u{64}\u{20}\u{61}\u{61}\u{61}\u{3a}\u{62}\u{62}\u{62}\u{62}\u{28}\u{33}\u{29}","\u{6d}\u{65}\u{74}\u{68}\u{6f}\u{64}\u{20}\u{27}\u{62}\u{62}\u{62}\u{62}\u{27}")
91+checkmessage("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{3d}\u{7b}\u{7d}\u{3b}\u{20}\u{61}\u{2e}\u{62}\u{62}\u{62}\u{62}\u{28}\u{33}\u{29}","\u{66}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{27}\u{62}\u{62}\u{62}\u{62}\u{27}")
92+assert((not string.find(doit("\u{61}\u{61}\u{61}\u{3d}\u{7b}\u{31}\u{33}\u{7d}\u{3b}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{62}\u{62}\u{62}\u{62}\u{3d}\u{31}\u{3b}\u{20}\u{61}\u{61}\u{61}\u{5b}\u{62}\u{62}\u{62}\u{62}\u{5d}\u{28}\u{33}\u{29}"),"\u{27}\u{62}\u{62}\u{62}\u{62}\u{27}")))
93+checkmessage("\u{61}\u{61}\u{61}\u{3d}\u{7b}\u{31}\u{33}\u{7d}\u{3b}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{62}\u{62}\u{62}\u{62}\u{3d}\u{31}\u{3b}\u{20}\u{61}\u{61}\u{61}\u{5b}\u{62}\u{62}\u{62}\u{62}\u{5d}\u{28}\u{33}\u{29}","\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}")
94+checkmessage("\u{61}\u{61}\u{61}\u{3d}\u{28}\u{31}\u{29}\u{2e}\u{2e}\u{7b}\u{7d}","\u{61}\u{20}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}")
95+checkmessage("\u{61}\u{20}\u{3d}\u{20}\u{7b}\u{5f}\u{45}\u{4e}\u{56}\u{20}\u{3d}\u{20}\u{7b}\u{7d}\u{7d}\u{3b}\u{20}\u{70}\u{72}\u{69}\u{6e}\u{74}\u{28}\u{61}\u{2e}\u{5f}\u{45}\u{4e}\u{56}\u{2e}\u{78}\u{20}\u{2b}\u{20}\u{31}\u{29}","\u{66}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{27}\u{78}\u{27}")
96+_G.aaa,_G.bbbb=nil
97+checkmessage("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{3b}\u{20}\u{61}\u{28}\u{31}\u{33}\u{29}","\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{27}\u{61}\u{27}")
98+checkmessage("\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{73}\u{65}\u{74}\u{6d}\u{65}\u{74}\u{61}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{28}\u{7b}\u{7d}\u{2c}\u{20}\u{7b}\u{5f}\u{5f}\u{61}\u{64}\u{64}\u{20}\u{3d}\u{20}\u{33}\u{34}\u{7d}\u{29}\u{a}\u{20}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{61}\u{20}\u{2b}\u{20}\u{31}\u{a}","\u{6d}\u{65}\u{74}\u{61}\u{6d}\u{65}\u{74}\u{68}\u{6f}\u{64}\u{20}\u{27}\u{61}\u{64}\u{64}\u{27}")
99+checkmessage("\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{73}\u{65}\u{74}\u{6d}\u{65}\u{74}\u{61}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{28}\u{7b}\u{7d}\u{2c}\u{20}\u{7b}\u{5f}\u{5f}\u{6c}\u{74}\u{20}\u{3d}\u{20}\u{7b}\u{7d}\u{7d}\u{29}\u{a}\u{20}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{61}\u{20}\u{3e}\u{20}\u{61}\u{a}","\u{6d}\u{65}\u{74}\u{61}\u{6d}\u{65}\u{74}\u{68}\u{6f}\u{64}\u{20}\u{27}\u{6c}\u{74}\u{27}")
100+checkmessage("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{3d}\u{7b}\u{7d}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{61}\u{2e}\u{62}\u{62}\u{62}\u{62}\u{28}\u{33}\u{29}","\u{66}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{27}\u{62}\u{62}\u{62}\u{62}\u{27}")
101+checkmessage("\u{61}\u{61}\u{61}\u{3d}\u{7b}\u{7d}\u{3b}\u{20}\u{64}\u{6f}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{61}\u{61}\u{3d}\u{31}\u{20}\u{65}\u{6e}\u{64}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{61}\u{61}\u{61}\u{3a}\u{62}\u{62}\u{62}\u{62}\u{28}\u{33}\u{29}","\u{6d}\u{65}\u{74}\u{68}\u{6f}\u{64}\u{20}\u{27}\u{62}\u{62}\u{62}\u{62}\u{27}")
102+checkmessage("\u{61}\u{61}\u{61}\u{20}\u{3d}\u{20}\u{23}\u{70}\u{72}\u{69}\u{6e}\u{74}","\u{6c}\u{65}\u{6e}\u{67}\u{74}\u{68}\u{20}\u{6f}\u{66}\u{20}\u{61}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}")
103+checkmessage("\u{61}\u{61}\u{61}\u{20}\u{3d}\u{20}\u{23}\u{33}","\u{6c}\u{65}\u{6e}\u{67}\u{74}\u{68}\u{20}\u{6f}\u{66}\u{20}\u{61}\u{20}\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}")
104+_G.aaa=nil
105+checkmessage("\u{61}\u{61}\u{61}\u{2e}\u{62}\u{62}\u{62}\u{3a}\u{64}\u{64}\u{64}\u{28}\u{39}\u{29}","\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{27}\u{61}\u{61}\u{61}\u{27}")
106+checkmessage("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{61}\u{61}\u{3d}\u{7b}\u{62}\u{62}\u{62}\u{3d}\u{31}\u{7d}\u{3b}\u{20}\u{61}\u{61}\u{61}\u{2e}\u{62}\u{62}\u{62}\u{3a}\u{64}\u{64}\u{64}\u{28}\u{39}\u{29}","\u{66}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{27}\u{62}\u{62}\u{62}\u{27}")
107+checkmessage("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{61}\u{61}\u{3d}\u{7b}\u{62}\u{62}\u{62}\u{3d}\u{7b}\u{7d}\u{7d}\u{3b}\u{20}\u{61}\u{61}\u{61}\u{2e}\u{62}\u{62}\u{62}\u{3a}\u{64}\u{64}\u{64}\u{28}\u{39}\u{29}","\u{6d}\u{65}\u{74}\u{68}\u{6f}\u{64}\u{20}\u{27}\u{64}\u{64}\u{64}\u{27}")
108+checkmessage("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{2c}\u{62}\u{2c}\u{63}\u{3b}\u{20}\u{28}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{28}\u{29}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{62}\u{2b}\u{31}\u{2e}\u{31}\u{20}\u{65}\u{6e}\u{64}\u{29}\u{28}\u{29}","\u{75}\u{70}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{27}\u{62}\u{27}")
109+assert((not doit("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{61}\u{61}\u{3d}\u{7b}\u{62}\u{62}\u{62}\u{3d}\u{7b}\u{64}\u{64}\u{64}\u{3d}\u{6e}\u{65}\u{78}\u{74}\u{7d}\u{7d}\u{3b}\u{20}\u{61}\u{61}\u{61}\u{2e}\u{62}\u{62}\u{62}\u{3a}\u{64}\u{64}\u{64}\u{28}\u{6e}\u{69}\u{6c}\u{29}")))
110+checkmessage("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{2c}\u{62}\u{2c}\u{63}\u{63}\u{3b}\u{20}\u{28}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{28}\u{29}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{63}\u{63}\u{5b}\u{31}\u{5d}\u{20}\u{65}\u{6e}\u{64}\u{29}\u{28}\u{29}","\u{75}\u{70}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{27}\u{63}\u{63}\u{27}")
111+checkmessage("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{2c}\u{62}\u{2c}\u{63}\u{63}\u{3b}\u{20}\u{28}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{28}\u{29}\u{20}\u{61}\u{2e}\u{78}\u{20}\u{3d}\u{20}\u{31}\u{20}\u{65}\u{6e}\u{64}\u{29}\u{28}\u{29}","\u{75}\u{70}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{27}\u{61}\u{27}")
112+checkmessage("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{5f}\u{45}\u{4e}\u{56}\u{20}\u{3d}\u{20}\u{7b}\u{78}\u{3d}\u{7b}\u{7d}\u{7d}\u{3b}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{61}\u{20}\u{2b}\u{20}\u{31}","\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{27}\u{61}\u{27}")
113+checkmessage("\u{42}\u{42}\u{3d}\u{31}\u{3b}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{61}\u{61}\u{3d}\u{7b}\u{7d}\u{3b}\u{20}\u{78}\u{3d}\u{61}\u{61}\u{61}\u{2b}\u{42}\u{42}","\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{27}\u{61}\u{61}\u{61}\u{27}")
114+checkmessage("\u{61}\u{61}\u{61}\u{3d}\u{7b}\u{7d}\u{3b}\u{20}\u{78}\u{3d}\u{33}\u{2e}\u{33}\u{2f}\u{61}\u{61}\u{61}","\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{27}\u{61}\u{61}\u{61}\u{27}")
115+checkmessage("\u{61}\u{61}\u{61}\u{3d}\u{32}\u{3b}\u{20}\u{42}\u{42}\u{3d}\u{6e}\u{69}\u{6c}\u{3b}\u{78}\u{3d}\u{61}\u{61}\u{61}\u{2a}\u{42}\u{42}","\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{27}\u{42}\u{42}\u{27}")
116+checkmessage("\u{61}\u{61}\u{61}\u{3d}\u{7b}\u{7d}\u{3b}\u{20}\u{78}\u{3d}\u{2d}\u{61}\u{61}\u{61}","\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{27}\u{61}\u{61}\u{61}\u{27}")
117+checkmessage("\u{61}\u{61}\u{61}\u{3d}\u{31}\u{3b}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{61}\u{61}\u{2c}\u{62}\u{62}\u{62}\u{62}\u{3d}\u{32}\u{2c}\u{33}\u{3b}\u{20}\u{61}\u{61}\u{61}\u{20}\u{3d}\u{20}\u{6d}\u{61}\u{74}\u{68}\u{2e}\u{73}\u{69}\u{6e}\u{28}\u{31}\u{29}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{62}\u{62}\u{62}\u{62}\u{28}\u{33}\u{29}","\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{27}\u{62}\u{62}\u{62}\u{62}\u{27}")
118+checkmessage("\u{61}\u{61}\u{61}\u{3d}\u{31}\u{3b}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{61}\u{61}\u{2c}\u{62}\u{62}\u{62}\u{62}\u{3d}\u{32}\u{2c}\u{33}\u{3b}\u{20}\u{61}\u{61}\u{61}\u{20}\u{3d}\u{20}\u{62}\u{62}\u{62}\u{62}\u{28}\u{31}\u{29}\u{20}\u{6f}\u{72}\u{20}\u{61}\u{61}\u{61}\u{28}\u{33}\u{29}","\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{27}\u{62}\u{62}\u{62}\u{62}\u{27}")
119+checkmessage("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{2c}\u{62}\u{2c}\u{63}\u{2c}\u{66}\u{20}\u{3d}\u{20}\u{31}\u{2c}\u{31}\u{2c}\u{31}\u{3b}\u{20}\u{66}\u{28}\u{28}\u{61}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{62}\u{29}\u{20}\u{6f}\u{72}\u{20}\u{63}\u{29}","\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{27}\u{66}\u{27}")
120+checkmessage("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{2c}\u{62}\u{2c}\u{63}\u{20}\u{3d}\u{20}\u{31}\u{2c}\u{31}\u{2c}\u{31}\u{3b}\u{20}\u{28}\u{28}\u{61}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{62}\u{29}\u{20}\u{6f}\u{72}\u{20}\u{63}\u{29}\u{28}\u{29}","\u{63}\u{61}\u{6c}\u{6c}\u{20}\u{61}\u{20}\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}")
121+assert((not string.find(doit("\u{61}\u{61}\u{61}\u{3d}\u{7b}\u{7d}\u{3b}\u{20}\u{78}\u{3d}\u{28}\u{61}\u{61}\u{61}\u{20}\u{6f}\u{72}\u{20}\u{61}\u{61}\u{61}\u{29}\u{2b}\u{28}\u{61}\u{61}\u{61}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{61}\u{61}\u{61}\u{29}"),"\u{27}\u{61}\u{61}\u{61}\u{27}")))
122+assert((not string.find(doit("\u{61}\u{61}\u{61}\u{3d}\u{7b}\u{7d}\u{3b}\u{20}\u{28}\u{61}\u{61}\u{61}\u{20}\u{6f}\u{72}\u{20}\u{61}\u{61}\u{61}\u{29}\u{28}\u{29}"),"\u{27}\u{61}\u{61}\u{61}\u{27}")))
123+checkmessage("\u{70}\u{72}\u{69}\u{6e}\u{74}\u{28}\u{70}\u{72}\u{69}\u{6e}\u{74}\u{20}\u{3c}\u{20}\u{31}\u{30}\u{29}","\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{77}\u{69}\u{74}\u{68}\u{20}\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}")
124+checkmessage("\u{70}\u{72}\u{69}\u{6e}\u{74}\u{28}\u{70}\u{72}\u{69}\u{6e}\u{74}\u{20}\u{3c}\u{20}\u{70}\u{72}\u{69}\u{6e}\u{74}\u{29}","\u{74}\u{77}\u{6f}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{73}")
125+checkmessage("\u{70}\u{72}\u{69}\u{6e}\u{74}\u{28}\u{27}\u{31}\u{30}\u{27}\u{20}\u{3c}\u{20}\u{31}\u{30}\u{29}","\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{77}\u{69}\u{74}\u{68}\u{20}\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}")
126+checkmessage("\u{70}\u{72}\u{69}\u{6e}\u{74}\u{28}\u{31}\u{30}\u{20}\u{3c}\u{20}\u{27}\u{32}\u{33}\u{27}\u{29}","\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}\u{20}\u{77}\u{69}\u{74}\u{68}\u{20}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}")
127+checkmessage("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{32}\u{2e}\u{30}\u{5e}\u{31}\u{30}\u{30}\u{3b}\u{20}\u{78}\u{20}\u{3d}\u{20}\u{61}\u{20}\u{3c}\u{3c}\u{20}\u{32}","\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}")
128+checkmessage("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{31}\u{20}\u{3e}\u{3e}\u{20}\u{32}\u{2e}\u{30}\u{5e}\u{31}\u{30}\u{30}","\u{68}\u{61}\u{73}\u{20}\u{6e}\u{6f}\u{20}\u{69}\u{6e}\u{74}\u{65}\u{67}\u{65}\u{72}\u{20}\u{72}\u{65}\u{70}\u{72}\u{65}\u{73}\u{65}\u{6e}\u{74}\u{61}\u{74}\u{69}\u{6f}\u{6e}")
129+checkmessage("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{31}\u{30}\u{2e}\u{31}\u{20}\u{3c}\u{3c}\u{20}\u{32}\u{2e}\u{30}\u{5e}\u{31}\u{30}\u{30}","\u{68}\u{61}\u{73}\u{20}\u{6e}\u{6f}\u{20}\u{69}\u{6e}\u{74}\u{65}\u{67}\u{65}\u{72}\u{20}\u{72}\u{65}\u{70}\u{72}\u{65}\u{73}\u{65}\u{6e}\u{74}\u{61}\u{74}\u{69}\u{6f}\u{6e}")
130+checkmessage("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{32}\u{2e}\u{30}\u{5e}\u{31}\u{30}\u{30}\u{20}\u{26}\u{20}\u{31}","\u{68}\u{61}\u{73}\u{20}\u{6e}\u{6f}\u{20}\u{69}\u{6e}\u{74}\u{65}\u{67}\u{65}\u{72}\u{20}\u{72}\u{65}\u{70}\u{72}\u{65}\u{73}\u{65}\u{6e}\u{74}\u{61}\u{74}\u{69}\u{6f}\u{6e}")
131+checkmessage("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{32}\u{2e}\u{30}\u{5e}\u{31}\u{30}\u{30}\u{20}\u{26}\u{20}\u{31}\u{65}\u{31}\u{30}\u{30}","\u{68}\u{61}\u{73}\u{20}\u{6e}\u{6f}\u{20}\u{69}\u{6e}\u{74}\u{65}\u{67}\u{65}\u{72}\u{20}\u{72}\u{65}\u{70}\u{72}\u{65}\u{73}\u{65}\u{6e}\u{74}\u{61}\u{74}\u{69}\u{6f}\u{6e}")
132+checkmessage("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{32}\u{2e}\u{30}\u{20}\u{7c}\u{20}\u{31}\u{65}\u{34}\u{30}","\u{68}\u{61}\u{73}\u{20}\u{6e}\u{6f}\u{20}\u{69}\u{6e}\u{74}\u{65}\u{67}\u{65}\u{72}\u{20}\u{72}\u{65}\u{70}\u{72}\u{65}\u{73}\u{65}\u{6e}\u{74}\u{61}\u{74}\u{69}\u{6f}\u{6e}")
133+checkmessage("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{32}\u{65}\u{31}\u{30}\u{30}\u{20}\u{7e}\u{20}\u{31}","\u{68}\u{61}\u{73}\u{20}\u{6e}\u{6f}\u{20}\u{69}\u{6e}\u{74}\u{65}\u{67}\u{65}\u{72}\u{20}\u{72}\u{65}\u{70}\u{72}\u{65}\u{73}\u{65}\u{6e}\u{74}\u{61}\u{74}\u{69}\u{6f}\u{6e}")
134+checkmessage("\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{2e}\u{73}\u{75}\u{62}\u{28}\u{27}\u{61}\u{27}\u{2c}\u{20}\u{32}\u{2e}\u{30}\u{5e}\u{31}\u{30}\u{30}\u{29}","\u{68}\u{61}\u{73}\u{20}\u{6e}\u{6f}\u{20}\u{69}\u{6e}\u{74}\u{65}\u{67}\u{65}\u{72}\u{20}\u{72}\u{65}\u{70}\u{72}\u{65}\u{73}\u{65}\u{6e}\u{74}\u{61}\u{74}\u{69}\u{6f}\u{6e}")
135+checkmessage("\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{2e}\u{72}\u{65}\u{70}\u{28}\u{27}\u{61}\u{27}\u{2c}\u{20}\u{33}\u{2e}\u{33}\u{29}","\u{68}\u{61}\u{73}\u{20}\u{6e}\u{6f}\u{20}\u{69}\u{6e}\u{74}\u{65}\u{67}\u{65}\u{72}\u{20}\u{72}\u{65}\u{70}\u{72}\u{65}\u{73}\u{65}\u{6e}\u{74}\u{61}\u{74}\u{69}\u{6f}\u{6e}")
136+checkmessage("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{36}\u{65}\u{34}\u{30}\u{20}\u{26}\u{20}\u{37}","\u{68}\u{61}\u{73}\u{20}\u{6e}\u{6f}\u{20}\u{69}\u{6e}\u{74}\u{65}\u{67}\u{65}\u{72}\u{20}\u{72}\u{65}\u{70}\u{72}\u{65}\u{73}\u{65}\u{6e}\u{74}\u{61}\u{74}\u{69}\u{6f}\u{6e}")
137+checkmessage("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{33}\u{34}\u{20}\u{3c}\u{3c}\u{20}\u{37}\u{65}\u{33}\u{30}","\u{68}\u{61}\u{73}\u{20}\u{6e}\u{6f}\u{20}\u{69}\u{6e}\u{74}\u{65}\u{67}\u{65}\u{72}\u{20}\u{72}\u{65}\u{70}\u{72}\u{65}\u{73}\u{65}\u{6e}\u{74}\u{61}\u{74}\u{69}\u{6f}\u{6e}")
138+checkmessage("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{7e}\u{2d}\u{33}\u{65}\u{34}\u{30}","\u{68}\u{61}\u{73}\u{20}\u{6e}\u{6f}\u{20}\u{69}\u{6e}\u{74}\u{65}\u{67}\u{65}\u{72}\u{20}\u{72}\u{65}\u{70}\u{72}\u{65}\u{73}\u{65}\u{6e}\u{74}\u{61}\u{74}\u{69}\u{6f}\u{6e}")
139+checkmessage("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{7e}\u{2d}\u{33}\u{2e}\u{30}\u{30}\u{39}","\u{68}\u{61}\u{73}\u{20}\u{6e}\u{6f}\u{20}\u{69}\u{6e}\u{74}\u{65}\u{67}\u{65}\u{72}\u{20}\u{72}\u{65}\u{70}\u{72}\u{65}\u{73}\u{65}\u{6e}\u{74}\u{61}\u{74}\u{69}\u{6f}\u{6e}")
140+checkmessage("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{33}\u{2e}\u{30}\u{30}\u{39}\u{20}\u{26}\u{20}\u{31}","\u{68}\u{61}\u{73}\u{20}\u{6e}\u{6f}\u{20}\u{69}\u{6e}\u{74}\u{65}\u{67}\u{65}\u{72}\u{20}\u{72}\u{65}\u{70}\u{72}\u{65}\u{73}\u{65}\u{6e}\u{74}\u{61}\u{74}\u{69}\u{6f}\u{6e}")
141+checkmessage("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{33}\u{34}\u{20}\u{3e}\u{3e}\u{20}\u{7b}\u{7d}","\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}")
142+checkmessage("\u{61}\u{61}\u{61}\u{20}\u{3d}\u{20}\u{32}\u{34}\u{20}\u{2f}\u{2f}\u{20}\u{30}","\u{64}\u{69}\u{76}\u{69}\u{64}\u{65}\u{20}\u{62}\u{79}\u{20}\u{7a}\u{65}\u{72}\u{6f}")
143+checkmessage("\u{61}\u{61}\u{61}\u{20}\u{3d}\u{20}\u{31}\u{20}\u{25}\u{20}\u{30}","\u{27}\u{6e}\u{25}\u{30}\u{27}")
144+checkmessage("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{73}\u{65}\u{74}\u{6d}\u{65}\u{74}\u{61}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{28}\u{7b}\u{7d}\u{2c}\u{20}\u{7b}\u{5f}\u{5f}\u{69}\u{6e}\u{64}\u{65}\u{78}\u{20}\u{3d}\u{20}\u{31}\u{30}\u{7d}\u{29}\u{2e}\u{78}","\u{61}\u{74}\u{74}\u{65}\u{6d}\u{70}\u{74}\u{20}\u{74}\u{6f}\u{20}\u{69}\u{6e}\u{64}\u{65}\u{78}\u{20}\u{61}\u{20}\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}")
145+checkmessage("\u{66}\u{6f}\u{72}\u{20}\u{69}\u{20}\u{3d}\u{20}\u{7b}\u{7d}\u{2c}\u{20}\u{31}\u{30}\u{20}\u{64}\u{6f}\u{20}\u{65}\u{6e}\u{64}","\u{74}\u{61}\u{62}\u{6c}\u{65}")
146+checkmessage("\u{66}\u{6f}\u{72}\u{20}\u{69}\u{20}\u{3d}\u{20}\u{69}\u{6f}\u{2e}\u{73}\u{74}\u{64}\u{69}\u{6e}\u{2c}\u{20}\u{31}\u{30}\u{20}\u{64}\u{6f}\u{20}\u{65}\u{6e}\u{64}","\u{46}\u{49}\u{4c}\u{45}")
147+checkmessage("\u{66}\u{6f}\u{72}\u{20}\u{69}\u{20}\u{3d}\u{20}\u{7b}\u{7d}\u{2c}\u{20}\u{31}\u{30}\u{20}\u{64}\u{6f}\u{20}\u{65}\u{6e}\u{64}","\u{69}\u{6e}\u{69}\u{74}\u{69}\u{61}\u{6c}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}")
148+checkmessage("\u{66}\u{6f}\u{72}\u{20}\u{69}\u{20}\u{3d}\u{20}\u{31}\u{2c}\u{20}\u{27}\u{78}\u{27}\u{2c}\u{20}\u{31}\u{30}\u{20}\u{64}\u{6f}\u{20}\u{65}\u{6e}\u{64}","\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}")
149+checkmessage("\u{66}\u{6f}\u{72}\u{20}\u{69}\u{20}\u{3d}\u{20}\u{31}\u{2c}\u{20}\u{7b}\u{7d}\u{2c}\u{20}\u{31}\u{30}\u{20}\u{64}\u{6f}\u{20}\u{65}\u{6e}\u{64}","\u{6c}\u{69}\u{6d}\u{69}\u{74}")
150+checkmessage("\u{66}\u{6f}\u{72}\u{20}\u{69}\u{20}\u{3d}\u{20}\u{31}\u{2c}\u{20}\u{7b}\u{7d}\u{20}\u{64}\u{6f}\u{20}\u{65}\u{6e}\u{64}","\u{6c}\u{69}\u{6d}\u{69}\u{74}")
151+checkmessage("\u{66}\u{6f}\u{72}\u{20}\u{69}\u{20}\u{3d}\u{20}\u{31}\u{2c}\u{20}\u{31}\u{30}\u{2c}\u{20}\u{70}\u{72}\u{69}\u{6e}\u{74}\u{20}\u{64}\u{6f}\u{20}\u{65}\u{6e}\u{64}","\u{73}\u{74}\u{65}\u{70}")
152+checkmessage("\u{66}\u{6f}\u{72}\u{20}\u{69}\u{20}\u{3d}\u{20}\u{31}\u{2c}\u{20}\u{31}\u{30}\u{2c}\u{20}\u{70}\u{72}\u{69}\u{6e}\u{74}\u{20}\u{64}\u{6f}\u{20}\u{65}\u{6e}\u{64}","\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}")
153+_G.D=debug
154+checkmessage("\u{20}\u{20}\u{2d}\u{2d}\u{20}\u{63}\u{72}\u{65}\u{61}\u{74}\u{65}\u{20}\u{6c}\u{69}\u{67}\u{68}\u{74}\u{20}\u{75}\u{64}\u{61}\u{74}\u{61}\u{a}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{78}\u{20}\u{3d}\u{20}\u{44}\u{2e}\u{75}\u{70}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{69}\u{64}\u{28}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{28}\u{29}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{64}\u{65}\u{62}\u{75}\u{67}\u{20}\u{65}\u{6e}\u{64}\u{2c}\u{20}\u{31}\u{29}\u{a}\u{20}\u{20}\u{44}\u{2e}\u{73}\u{65}\u{74}\u{75}\u{73}\u{65}\u{72}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{28}\u{78}\u{2c}\u{20}\u{7b}\u{7d}\u{29}\u{a}","\u{6c}\u{69}\u{67}\u{68}\u{74}\u{20}\u{75}\u{73}\u{65}\u{72}\u{64}\u{61}\u{74}\u{61}")
155+_G.D=nil
156+do
157+checkmessage("\u{6d}\u{61}\u{74}\u{68}\u{2e}\u{73}\u{69}\u{6e}\u{28}\u{69}\u{6f}\u{2e}\u{69}\u{6e}\u{70}\u{75}\u{74}\u{28}\u{29}\u{29}","\u{28}\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}\u{20}\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}\u{2c}\u{20}\u{67}\u{6f}\u{74}\u{20}\u{46}\u{49}\u{4c}\u{45}\u{2a}\u{29}")
158+_G.XX=setmetatable({},{["\u{5f}\u{5f}\u{6e}\u{61}\u{6d}\u{65}"] = "\u{4d}\u{79}\u{20}\u{54}\u{79}\u{70}\u{65}"})
159+assert(string.find(tostring(XX),"\u{5e}\u{4d}\u{79}\u{20}\u{54}\u{79}\u{70}\u{65}"))
160+checkmessage("\u{69}\u{6f}\u{2e}\u{69}\u{6e}\u{70}\u{75}\u{74}\u{28}\u{58}\u{58}\u{29}","\u{28}\u{46}\u{49}\u{4c}\u{45}\u{2a}\u{20}\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}\u{2c}\u{20}\u{67}\u{6f}\u{74}\u{20}\u{4d}\u{79}\u{20}\u{54}\u{79}\u{70}\u{65}\u{29}")
161+checkmessage("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{58}\u{58}\u{20}\u{2b}\u{20}\u{31}","\u{6f}\u{6e}\u{20}\u{61}\u{20}\u{4d}\u{79}\u{20}\u{54}\u{79}\u{70}\u{65}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}")
162+checkmessage("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{7e}\u{69}\u{6f}\u{2e}\u{73}\u{74}\u{64}\u{69}\u{6e}","\u{6f}\u{6e}\u{20}\u{61}\u{20}\u{46}\u{49}\u{4c}\u{45}\u{2a}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}")
163+checkmessage("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{58}\u{58}\u{20}\u{3c}\u{20}\u{58}\u{58}","\u{74}\u{77}\u{6f}\u{20}\u{4d}\u{79}\u{20}\u{54}\u{79}\u{70}\u{65}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{73}")
164+checkmessage("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{7b}\u{7d}\u{20}\u{3c}\u{20}\u{58}\u{58}","\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{77}\u{69}\u{74}\u{68}\u{20}\u{4d}\u{79}\u{20}\u{54}\u{79}\u{70}\u{65}")
165+checkmessage("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{58}\u{58}\u{20}\u{3c}\u{20}\u{69}\u{6f}\u{2e}\u{73}\u{74}\u{64}\u{69}\u{6e}","\u{4d}\u{79}\u{20}\u{54}\u{79}\u{70}\u{65}\u{20}\u{77}\u{69}\u{74}\u{68}\u{20}\u{46}\u{49}\u{4c}\u{45}\u{2a}")
166+_G.XX=nil
167+if T then
168+local x = setmetatable({},{["\u{5f}\u{5f}\u{6e}\u{61}\u{6d}\u{65}"] = "\u{54}\u{41}\u{42}\u{4c}\u{45}"})
169+assert((T.testC("\u{4c}\u{74}\u{6f}\u{6c}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{2d}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}",x) == tostring(x)))
170+local a,b = T.testC("\u{70}\u{75}\u{73}\u{68}\u{69}\u{6e}\u{74}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{4c}\u{74}\u{6f}\u{6c}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{2d}\u{32}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}",x)
171+assert(((a == 0xa) and (b == tostring(x))))
172+setmetatable(x,{["\u{5f}\u{5f}\u{74}\u{6f}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}"] = function (o)
173+assert((o == x))
174+return "\u{41}\u{42}\u{43}"
175+end})
176+local a,b,c = T.testC("\u{70}\u{75}\u{73}\u{68}\u{69}\u{6e}\u{74}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{4c}\u{74}\u{6f}\u{6c}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{2d}\u{32}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{33}",x)
177+assert((((a == x) and (b == 0xa)) and (c == "\u{41}\u{42}\u{43}")))
178+end
179+end
180+checkmessage("\u{28}\u{69}\u{6f}\u{2e}\u{77}\u{72}\u{69}\u{74}\u{65}\u{20}\u{6f}\u{72}\u{20}\u{70}\u{72}\u{69}\u{6e}\u{74}\u{29}\u{7b}\u{7d}","\u{69}\u{6f}\u{2e}\u{77}\u{72}\u{69}\u{74}\u{65}")
181+checkmessage("\u{28}\u{63}\u{6f}\u{6c}\u{6c}\u{65}\u{63}\u{74}\u{67}\u{61}\u{72}\u{62}\u{61}\u{67}\u{65}\u{20}\u{6f}\u{72}\u{20}\u{70}\u{72}\u{69}\u{6e}\u{74}\u{29}\u{7b}\u{7d}","\u{63}\u{6f}\u{6c}\u{6c}\u{65}\u{63}\u{74}\u{67}\u{61}\u{72}\u{62}\u{61}\u{67}\u{65}")
182+do
183+local f = function (a)
184+return (a + 0x1)
185+end
186+f=assert(load(string.dump(f,true)))
187+assert((f(0x3) == 0x4))
188+checkerr("\u{5e}\u{25}\u{3f}\u{3a}\u{25}\u{2d}\u{31}\u{3a}",f,{})
189+f=function ()
190+local a
191+;
192+a={}
193+;
194+return (a + 0x2)
195+end
196+f=assert(load(string.dump(f,true)))
197+checkerr("\u{5e}\u{25}\u{3f}\u{3a}\u{25}\u{2d}\u{31}\u{3a}\u{2e}\u{2a}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}",f)
198+end
199+local t = {}
200+for i = 0x1, 0x3e8
201+do
202+t[i]=("\u{61}\u{61}\u{61}\u{20}\u{3d}\u{20}\u{78}" .. i)
203+end
204+local s = table.concat(t,"\u{3b}\u{20}")
205+t=nil
206+checkmessage((s .. "\u{3b}\u{20}\u{61}\u{61}\u{61}\u{20}\u{3d}\u{20}\u{62}\u{62}\u{62}\u{20}\u{2b}\u{20}\u{31}"),"\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{27}\u{62}\u{62}\u{62}\u{27}")
207+checkmessage(("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{5f}\u{45}\u{4e}\u{56}\u{3d}\u{5f}\u{45}\u{4e}\u{56}\u{3b}" .. (s .. "\u{3b}\u{20}\u{61}\u{61}\u{61}\u{20}\u{3d}\u{20}\u{62}\u{62}\u{62}\u{20}\u{2b}\u{20}\u{31}")),"\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{27}\u{62}\u{62}\u{62}\u{27}")
208+checkmessage((s .. "\u{3b}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{74}\u{20}\u{3d}\u{20}\u{7b}\u{7d}\u{3b}\u{20}\u{61}\u{61}\u{61}\u{20}\u{3d}\u{20}\u{74}\u{2e}\u{62}\u{62}\u{62}\u{20}\u{2b}\u{20}\u{31}"),"\u{66}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{27}\u{62}\u{62}\u{62}\u{27}")
209+checkmessage((s .. "\u{3b}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{74}\u{20}\u{3d}\u{20}\u{7b}\u{7d}\u{3b}\u{20}\u{74}\u{3a}\u{62}\u{62}\u{62}\u{28}\u{29}"),"\u{6d}\u{65}\u{74}\u{68}\u{6f}\u{64}\u{20}\u{27}\u{62}\u{62}\u{62}\u{27}")
210+checkmessage("\u{61}\u{61}\u{61}\u{3d}\u{39}\u{a}\u{72}\u{65}\u{70}\u{65}\u{61}\u{74}\u{20}\u{75}\u{6e}\u{74}\u{69}\u{6c}\u{20}\u{33}\u{3d}\u{3d}\u{33}\u{a}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{78}\u{3d}\u{6d}\u{61}\u{74}\u{68}\u{2e}\u{73}\u{69}\u{6e}\u{28}\u{6d}\u{61}\u{74}\u{68}\u{2e}\u{63}\u{6f}\u{73}\u{28}\u{33}\u{29}\u{29}\u{a}\u{69}\u{66}\u{20}\u{6d}\u{61}\u{74}\u{68}\u{2e}\u{73}\u{69}\u{6e}\u{28}\u{31}\u{29}\u{20}\u{3d}\u{3d}\u{20}\u{78}\u{20}\u{74}\u{68}\u{65}\u{6e}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{6d}\u{61}\u{74}\u{68}\u{2e}\u{73}\u{69}\u{6e}\u{28}\u{31}\u{29}\u{20}\u{65}\u{6e}\u{64}\u{20}\u{20}\u{20}\u{2d}\u{2d}\u{20}\u{74}\u{61}\u{69}\u{6c}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{a}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{2c}\u{62}\u{20}\u{3d}\u{20}\u{31}\u{2c}\u{20}\u{7b}\u{a}\u{20}\u{20}\u{7b}\u{78}\u{3d}\u{27}\u{61}\u{27}\u{2e}\u{2e}\u{27}\u{62}\u{27}\u{2e}\u{2e}\u{27}\u{63}\u{27}\u{2c}\u{20}\u{79}\u{3d}\u{27}\u{62}\u{27}\u{2c}\u{20}\u{7a}\u{3d}\u{78}\u{7d}\u{2c}\u{a}\u{20}\u{20}\u{7b}\u{31}\u{2c}\u{32}\u{2c}\u{33}\u{2c}\u{34}\u{2c}\u{35}\u{7d}\u{20}\u{6f}\u{72}\u{20}\u{33}\u{2b}\u{33}\u{3c}\u{3d}\u{33}\u{2b}\u{33}\u{2c}\u{a}\u{20}\u{20}\u{33}\u{2b}\u{31}\u{3e}\u{33}\u{2b}\u{31}\u{2c}\u{a}\u{20}\u{20}\u{7b}\u{64}\u{20}\u{3d}\u{20}\u{78}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{61}\u{61}\u{61}\u{5b}\u{78}\u{20}\u{6f}\u{72}\u{20}\u{79}\u{5d}\u{7d}\u{7d}\u{a}","\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{27}\u{61}\u{61}\u{61}\u{27}")
211+checkmessage("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{78}\u{2c}\u{79}\u{20}\u{3d}\u{20}\u{7b}\u{7d}\u{2c}\u{31}\u{a}\u{69}\u{66}\u{20}\u{6d}\u{61}\u{74}\u{68}\u{2e}\u{73}\u{69}\u{6e}\u{28}\u{31}\u{29}\u{20}\u{3d}\u{3d}\u{20}\u{30}\u{20}\u{74}\u{68}\u{65}\u{6e}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{33}\u{20}\u{65}\u{6e}\u{64}\u{20}\u{20}\u{20}\u{20}\u{2d}\u{2d}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{a}\u{78}\u{2e}\u{61}\u{28}\u{29}","\u{66}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{27}\u{61}\u{27}")
212+checkmessage("\u{70}\u{72}\u{65}\u{66}\u{69}\u{78}\u{20}\u{3d}\u{20}\u{6e}\u{69}\u{6c}\u{a}\u{69}\u{6e}\u{73}\u{65}\u{72}\u{74}\u{20}\u{3d}\u{20}\u{6e}\u{69}\u{6c}\u{a}\u{77}\u{68}\u{69}\u{6c}\u{65}\u{20}\u{31}\u{20}\u{64}\u{6f}\u{a}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{a}\u{20}\u{20}\u{69}\u{66}\u{20}\u{6e}\u{69}\u{6c}\u{20}\u{74}\u{68}\u{65}\u{6e}\u{20}\u{62}\u{72}\u{65}\u{61}\u{6b}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{20}\u{20}\u{69}\u{6e}\u{73}\u{65}\u{72}\u{74}\u{28}\u{70}\u{72}\u{65}\u{66}\u{69}\u{78}\u{2c}\u{20}\u{61}\u{29}\u{a}\u{65}\u{6e}\u{64}","\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{27}\u{69}\u{6e}\u{73}\u{65}\u{72}\u{74}\u{27}")
213+checkmessage("\u{20}\u{20}\u{2d}\u{2d}\u{20}\u{74}\u{61}\u{69}\u{6c}\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{a}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{6d}\u{61}\u{74}\u{68}\u{2e}\u{73}\u{69}\u{6e}\u{28}\u{22}\u{61}\u{22}\u{29}\u{a}","\u{73}\u{69}\u{6e}")
214+checkmessage("\u{63}\u{6f}\u{6c}\u{6c}\u{65}\u{63}\u{74}\u{67}\u{61}\u{72}\u{62}\u{61}\u{67}\u{65}\u{28}\u{22}\u{6e}\u{6f}\u{6f}\u{70}\u{74}\u{69}\u{6f}\u{6e}\u{22}\u{29}","\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{6f}\u{70}\u{74}\u{69}\u{6f}\u{6e}")
215+checkmessage("\u{78}\u{20}\u{3d}\u{20}\u{70}\u{72}\u{69}\u{6e}\u{74}\u{20}\u{2e}\u{2e}\u{20}\u{22}\u{61}\u{22}","\u{63}\u{6f}\u{6e}\u{63}\u{61}\u{74}\u{65}\u{6e}\u{61}\u{74}\u{65}")
216+checkmessage("\u{78}\u{20}\u{3d}\u{20}\u{22}\u{61}\u{22}\u{20}\u{2e}\u{2e}\u{20}\u{66}\u{61}\u{6c}\u{73}\u{65}","\u{63}\u{6f}\u{6e}\u{63}\u{61}\u{74}\u{65}\u{6e}\u{61}\u{74}\u{65}")
217+checkmessage("\u{78}\u{20}\u{3d}\u{20}\u{7b}\u{7d}\u{20}\u{2e}\u{2e}\u{20}\u{32}","\u{63}\u{6f}\u{6e}\u{63}\u{61}\u{74}\u{65}\u{6e}\u{61}\u{74}\u{65}")
218+checkmessage("\u{67}\u{65}\u{74}\u{6d}\u{65}\u{74}\u{61}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{28}\u{69}\u{6f}\u{2e}\u{73}\u{74}\u{64}\u{69}\u{6e}\u{29}\u{2e}\u{5f}\u{5f}\u{67}\u{63}\u{28}\u{29}","\u{6e}\u{6f}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}")
219+checkmessage("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{56}\u{61}\u{72}\u{a}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{6d}\u{61}\u{69}\u{6e}\u{28}\u{29}\u{a}\u{20}\u{20}\u{4e}\u{6f}\u{53}\u{75}\u{63}\u{68}\u{4e}\u{61}\u{6d}\u{65}\u{20}\u{28}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{28}\u{29}\u{20}\u{56}\u{61}\u{72}\u{3d}\u{30}\u{20}\u{65}\u{6e}\u{64}\u{29}\u{a}\u{65}\u{6e}\u{64}\u{a}\u{6d}\u{61}\u{69}\u{6e}\u{28}\u{29}\u{a}","\u{67}\u{6c}\u{6f}\u{62}\u{61}\u{6c}\u{20}\u{27}\u{4e}\u{6f}\u{53}\u{75}\u{63}\u{68}\u{4e}\u{61}\u{6d}\u{65}\u{27}")
220+print("\u{2b}")
221+aaa={}
222+;
223+setmetatable(aaa,{["\u{5f}\u{5f}\u{69}\u{6e}\u{64}\u{65}\u{78}"] = string})
224+checkmessage("\u{61}\u{61}\u{61}\u{3a}\u{73}\u{75}\u{62}\u{28}\u{29}","\u{62}\u{61}\u{64}\u{20}\u{73}\u{65}\u{6c}\u{66}")
225+checkmessage("\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{2e}\u{73}\u{75}\u{62}\u{28}\u{27}\u{61}\u{27}\u{2c}\u{20}\u{7b}\u{7d}\u{29}","\u{23}\u{32}")
226+checkmessage("\u{28}\u{27}\u{61}\u{27}\u{29}\u{3a}\u{73}\u{75}\u{62}\u{7b}\u{7d}","\u{23}\u{31}")
227+checkmessage("\u{74}\u{61}\u{62}\u{6c}\u{65}\u{2e}\u{73}\u{6f}\u{72}\u{74}\u{28}\u{7b}\u{31}\u{2c}\u{32}\u{2c}\u{33}\u{7d}\u{2c}\u{20}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{2e}\u{73}\u{6f}\u{72}\u{74}\u{29}","\u{27}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{2e}\u{73}\u{6f}\u{72}\u{74}\u{27}")
228+checkmessage("\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{2e}\u{67}\u{73}\u{75}\u{62}\u{28}\u{27}\u{73}\u{27}\u{2c}\u{20}\u{27}\u{73}\u{27}\u{2c}\u{20}\u{73}\u{65}\u{74}\u{6d}\u{65}\u{74}\u{61}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{29}","\u{27}\u{73}\u{65}\u{74}\u{6d}\u{65}\u{74}\u{61}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{27}")
229+_G.aaa=nil
230+local function f
231+(n)
232+local c = coroutine.create(f)
233+local a,b = coroutine.resume(c)
234+return b
235+end
236+assert(string.find(f(),"\u{43}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}"))
237+checkmessage("\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}\u{2e}\u{79}\u{69}\u{65}\u{6c}\u{64}\u{28}\u{29}","\u{6f}\u{75}\u{74}\u{73}\u{69}\u{64}\u{65}\u{20}\u{61}\u{20}\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}")
238+f=coroutine.wrap(function ()
239+table.sort({0x1,0x2,0x3},coroutine.yield)
240+end)
241+checkerr("\u{79}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{61}\u{63}\u{72}\u{6f}\u{73}\u{73}",f)
242+local idsize = (0x3c - 0x1)
243+local function checksize
244+(source)
245+local _,msg = load("\u{78}",source)
246+msg=string.match(msg,"\u{5e}\u{28}\u{5b}\u{5e}\u{3a}\u{5d}\u{2a}\u{29}\u{3a}")
247+assert((msg:len() <= idsize))
248+end
249+for i = (0x3c - 0xa), (0x3c + 0xa)
250+do
251+checksize(("\u{40}" .. string.rep("\u{78}",i)))
252+checksize(string.rep("\u{78}",(i - 0xa)))
253+checksize(("\u{3d}" .. string.rep("\u{78}",i)))
254+end
255+local function lineerror
256+(s,l)
257+local err,msg = pcall(load(s))
258+local line = tonumber(string.match(msg,"\u{3a}\u{28}\u{25}\u{64}\u{2b}\u{29}\u{3a}"))
259+assert(((line == l) or (not (line and (not l)))))
260+end
261+lineerror("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{a}\u{20}\u{66}\u{6f}\u{72}\u{20}\u{69}\u{3d}\u{31}\u{2c}\u{27}\u{61}\u{27}\u{20}\u{64}\u{6f}\u{20}\u{a}\u{20}\u{70}\u{72}\u{69}\u{6e}\u{74}\u{28}\u{69}\u{29}\u{20}\u{a}\u{20}\u{65}\u{6e}\u{64}",0x2)
262+lineerror("\u{a}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{20}\u{a}\u{20}\u{66}\u{6f}\u{72}\u{20}\u{6b}\u{2c}\u{76}\u{20}\u{69}\u{6e}\u{20}\u{33}\u{20}\u{a}\u{20}\u{64}\u{6f}\u{20}\u{a}\u{20}\u{70}\u{72}\u{69}\u{6e}\u{74}\u{28}\u{6b}\u{29}\u{20}\u{a}\u{20}\u{65}\u{6e}\u{64}",0x3)
263+lineerror("\u{a}\u{a}\u{20}\u{66}\u{6f}\u{72}\u{20}\u{6b}\u{2c}\u{76}\u{20}\u{69}\u{6e}\u{20}\u{a}\u{20}\u{33}\u{20}\u{a}\u{20}\u{64}\u{6f}\u{20}\u{a}\u{20}\u{70}\u{72}\u{69}\u{6e}\u{74}\u{28}\u{6b}\u{29}\u{20}\u{a}\u{20}\u{65}\u{6e}\u{64}",0x4)
264+lineerror("\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{61}\u{2e}\u{78}\u{2e}\u{79}\u{20}\u{28}\u{29}\u{a}\u{61}\u{3d}\u{61}\u{2b}\u{31}\u{a}\u{65}\u{6e}\u{64}",0x1)
265+lineerror("\u{61}\u{20}\u{3d}\u{20}\u{a}\u{61}\u{a}\u{2b}\u{a}\u{7b}\u{7d}",0x3)
266+lineerror("\u{61}\u{20}\u{3d}\u{20}\u{a}\u{33}\u{a}\u{2b}\u{a}\u{28}\u{a}\u{34}\u{a}\u{2f}\u{a}\u{70}\u{72}\u{69}\u{6e}\u{74}\u{29}",0x6)
267+lineerror("\u{61}\u{20}\u{3d}\u{20}\u{a}\u{70}\u{72}\u{69}\u{6e}\u{74}\u{a}\u{2b}\u{a}\u{28}\u{a}\u{34}\u{a}\u{2f}\u{a}\u{37}\u{29}",0x3)
268+lineerror("\u{61}\u{a}\u{3d}\u{a}\u{2d}\u{a}\u{a}\u{70}\u{72}\u{69}\u{6e}\u{74}\u{a}\u{3b}",0x3)
269+lineerror("\u{61}\u{a}\u{28}\u{20}\u{20}\u{20}\u{20}\u{20}\u{2d}\u{2d}\u{20}\u{3c}\u{3c}\u{a}\u{32}\u{33}\u{29}\u{a}",0x2)
270+lineerror("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{7b}\u{78}\u{20}\u{3d}\u{20}\u{31}\u{33}\u{7d}\u{a}\u{61}\u{a}\u{2e}\u{a}\u{78}\u{a}\u{28}\u{20}\u{20}\u{20}\u{20}\u{20}\u{2d}\u{2d}\u{20}\u{3c}\u{3c}\u{a}\u{32}\u{33}\u{a}\u{29}\u{a}",0x5)
271+lineerror("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{7b}\u{78}\u{20}\u{3d}\u{20}\u{31}\u{33}\u{7d}\u{a}\u{61}\u{a}\u{2e}\u{a}\u{78}\u{a}\u{28}\u{a}\u{32}\u{33}\u{20}\u{2b}\u{20}\u{61}\u{a}\u{29}\u{a}",0x6)
272+local p = "\u{20}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{67}\u{28}\u{29}\u{20}\u{66}\u{28}\u{29}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{20}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{66}\u{28}\u{78}\u{29}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{28}\u{27}\u{61}\u{27}\u{2c}\u{20}\u{58}\u{58}\u{29}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{67}\u{28}\u{29}\u{a}"
273+XX=0x3
274+;
275+lineerror(p,0x3)
276+XX=0x0
277+;
278+lineerror(p,false)
279+XX=0x1
280+;
281+lineerror(p,0x2)
282+XX=0x2
283+;
284+lineerror(p,0x1)
285+_G.XX,_G.g,_G.f=nil
286+lineerror("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{62}\u{20}\u{3d}\u{20}\u{66}\u{61}\u{6c}\u{73}\u{65}\u{a}\u{69}\u{66}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{62}\u{20}\u{74}\u{68}\u{65}\u{6e}\u{a}\u{20}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{20}\u{27}\u{74}\u{65}\u{73}\u{74}\u{27}\u{a}\u{65}\u{6e}\u{64}",0x3)
287+lineerror("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{62}\u{20}\u{3d}\u{20}\u{66}\u{61}\u{6c}\u{73}\u{65}\u{a}\u{69}\u{66}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{62}\u{20}\u{74}\u{68}\u{65}\u{6e}\u{a}\u{20}\u{20}\u{69}\u{66}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{62}\u{20}\u{74}\u{68}\u{65}\u{6e}\u{a}\u{20}\u{20}\u{20}\u{20}\u{69}\u{66}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{62}\u{20}\u{74}\u{68}\u{65}\u{6e}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{20}\u{27}\u{74}\u{65}\u{73}\u{74}\u{27}\u{a}\u{20}\u{20}\u{20}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{20}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{65}\u{6e}\u{64}",0x5)
288+lineerror("\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{30}\u{a}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{62}\u{20}\u{3d}\u{20}\u{31}\u{a}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{63}\u{20}\u{3d}\u{20}\u{62}\u{20}\u{25}\u{20}\u{61}\u{a}",0x3)
289+do
290+local s = string.format("\u{25}\u{73}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{5f}\u{5f}\u{41}\u{2e}\u{78}",string.rep("\u{a}",0x12c))
291+lineerror(s,0x12d)
292+end
293+if (not _soft) then
294+collectgarbage()
295+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}")
296+local C = 0x0
297+local l = (debug.getinfo(0x1,"\u{6c}").currentline + 0x1)
298+local function auxy
299+()
300+C=(C + 0x1)
301+;
302+auxy()
303+end
304+function YY()
305+collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
306+auxy()
307+collectgarbage("\u{72}\u{65}\u{73}\u{74}\u{61}\u{72}\u{74}")
308+end
309+local function checkstackmessage
310+(m)
311+print(("\u{28}\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}\u{20}\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}\u{20}\u{61}\u{66}\u{74}\u{65}\u{72}\u{20}" .. (C .. "\u{20}\u{63}\u{61}\u{6c}\u{6c}\u{73}\u{29}")))
312+C=0x0
313+return string.find(m,"\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}")
314+end
315+assert(checkstackmessage(doit("\u{59}\u{59}\u{28}\u{29}")))
316+assert(checkstackmessage(doit("\u{59}\u{59}\u{28}\u{29}")))
317+assert(checkstackmessage(doit("\u{59}\u{59}\u{28}\u{29}")))
318+_G.YY=nil
319+local l1
320+local function g
321+(x)
322+l1=(debug.getinfo(x,"\u{6c}").currentline + 0x2)
323+collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
324+auxy()
325+collectgarbage("\u{72}\u{65}\u{73}\u{74}\u{61}\u{72}\u{74}")
326+end
327+local _,stackmsg = xpcall(g,debug.traceback,0x1)
328+print("\u{2b}")
329+local stack = {}
330+for line in string.gmatch(stackmsg,"\u{5b}\u{5e}\u{a}\u{5d}\u{2a}")
331+do
332+local curr = string.match(line,"\u{3a}\u{28}\u{25}\u{64}\u{2b}\u{29}\u{3a}")
333+if curr then
334+table.insert(stack,tonumber(curr))
335+end
336+end
337+local i = 0x1
338+while (stack[i] ~= l1) do
339+assert((stack[i] == l))
340+i=(i + 0x1)
341+end
342+assert((i > 0xf))
343+local res,msg = xpcall(error,error)
344+assert((not (res and (type(msg) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}"))))
345+print("\u{2b}")
346+local function f
347+(x)
348+if (x == 0x0) then
349+error("\u{61}\u{a}")
350+else
351+local aux = function ()
352+return f((x - 0x1))
353+end
354+local a,b = xpcall(aux,aux)
355+return a,b
356+end
357+end
358+f(0x3)
359+local function loop
360+(x,y,z)
361+return (0x1 + loop(x,y,z))
362+end
363+local res,msg = xpcall(loop,function (m)
364+assert(string.find(m,"\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}"))
365+checkerr("\u{65}\u{72}\u{72}\u{6f}\u{72}\u{20}\u{68}\u{61}\u{6e}\u{64}\u{6c}\u{69}\u{6e}\u{67}",loop)
366+assert((math.sin(0x0) == 0x0))
367+return 0xf
368+end)
369+assert((msg == 0xf))
370+local f = function ()
371+for i = 0xf41dc, 0xf4240, 0x1
372+do
373+table.unpack({},0x1,i)
374+end
375+end
376+checkerr("\u{74}\u{6f}\u{6f}\u{20}\u{6d}\u{61}\u{6e}\u{79}\u{20}\u{72}\u{65}\u{73}\u{75}\u{6c}\u{74}\u{73}",f)
377+end
378+do
379+local t = {}
380+local res,msg = pcall(function ()
381+error(t)
382+end)
383+assert((not (res and (msg == t))))
384+res,msg=pcall(function ()
385+error(nil)
386+end)
387+assert((not (res and (msg == nil))))
388+local function f
389+()
390+error({["\u{6d}\u{73}\u{67}"] = "\u{78}"})
391+end
392+res,msg=xpcall(f,function (r)
393+return {["\u{6d}\u{73}\u{67}"] = (r.msg .. "\u{79}")}
394+end)
395+assert((msg.msg == "\u{78}\u{79}"))
396+res,msg=pcall(assert,false,"\u{58}",t)
397+assert((not (res and (msg == "\u{58}"))))
398+res,msg=pcall(function ()
399+assert(false)
400+end)
401+local line = string.match(msg,"\u{25}\u{77}\u{2b}\u{25}\u{2e}\u{6c}\u{75}\u{61}\u{3a}\u{28}\u{25}\u{64}\u{2b}\u{29}\u{3a}\u{20}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{66}\u{61}\u{69}\u{6c}\u{65}\u{64}\u{21}\u{24}")
402+assert((tonumber(line) == (debug.getinfo(0x1,"\u{6c}").currentline - 0x2)))
403+res,msg=pcall(assert,false,t)
404+assert((not (res and (msg == t))))
405+res,msg=pcall(assert,nil,nil)
406+assert((not (res and (msg == nil))))
407+res,msg=pcall(assert)
408+assert((not (res and string.find(msg,"\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}"))))
409+end
410+local a,b,c = xpcall(string.find,error,"\u{61}\u{6c}\u{6f}","\u{61}\u{6c}")
411+assert(((a and (b == 0x1)) and (c == 0x2)))
412+a,b,c=xpcall(string.find,function (x)
413+return {}
414+end,true,"\u{61}\u{6c}")
415+assert((not ((a and (type(b) == "\u{74}\u{61}\u{62}\u{6c}\u{65}")) and (c == nil))))
416+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{74}\u{6f}\u{6b}\u{65}\u{6e}\u{73}\u{20}\u{69}\u{6e}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{20}\u{6d}\u{65}\u{73}\u{73}\u{61}\u{67}\u{65}\u{73}")
417+checksyntax("\u{73}\u{79}\u{6e}\u{74}\u{61}\u{78}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}","","\u{65}\u{72}\u{72}\u{6f}\u{72}",0x1)
418+checksyntax("\u{31}\u{2e}\u{30}\u{30}\u{30}","","\u{31}\u{2e}\u{30}\u{30}\u{30}",0x1)
419+checksyntax("\u{5b}\u{5b}\u{61}\u{5d}\u{5d}","","\u{5b}\u{5b}\u{61}\u{5d}\u{5d}",0x1)
420+checksyntax("\u{27}\u{61}\u{61}\u{27}","","\u{27}\u{61}\u{61}\u{27}",0x1)
421+checksyntax("\u{77}\u{68}\u{69}\u{6c}\u{65}\u{20}\u{3c}\u{3c}\u{20}\u{64}\u{6f}\u{20}\u{65}\u{6e}\u{64}","","\u{3c}\u{3c}",0x1)
422+checksyntax("\u{66}\u{6f}\u{72}\u{20}\u{3e}\u{3e}\u{20}\u{64}\u{6f}\u{20}\u{65}\u{6e}\u{64}","","\u{3e}\u{3e}",0x1)
423+checksyntax("\u{61}\u{1}\u{61}\u{20}\u{3d}\u{20}\u{31}","","\u{3c}\u{5c}\u{31}\u{3e}",0x1)
424+checksyntax("\u{ff}\u{61}\u{20}\u{3d}\u{20}\u{31}","","\u{3c}\u{5c}\u{32}\u{35}\u{35}\u{3e}",0x1)
425+doit("\u{49}\u{20}\u{3d}\u{20}\u{6c}\u{6f}\u{61}\u{64}\u{28}\u{22}\u{61}\u{3d}\u{39}\u{2b}\u{22}\u{29}\u{3b}\u{20}\u{61}\u{61}\u{61}\u{3d}\u{33}")
426+assert(((_G.aaa == 0x3) and (not _G.I)))
427+_G.I,_G.aaa=nil
428+print("\u{2b}")
429+local lim = 0x3e8
430+if _soft then
431+lim=0x64
432+end
433+for i = 0x1, lim
434+do
435+doit("\u{61}\u{20}\u{3d}\u{20}")
436+doit("\u{61}\u{20}\u{3d}\u{20}\u{34}\u{2b}\u{6e}\u{69}\u{6c}")
437+end
438+local function testrep
439+(init,rep,close,repc,finalresult)
440+local s = (init .. (string.rep(rep,0x64) .. (close .. string.rep(repc,0x64))))
441+local res,msg = load(s)
442+assert(res)
443+if finalresult then
444+assert((res() == finalresult))
445+end
446+s=(init .. string.rep(rep,0x1f4))
447+local res,msg = load(s)
448+assert((not (res and (string.find(msg,"\u{74}\u{6f}\u{6f}\u{20}\u{6d}\u{61}\u{6e}\u{79}") or string.find(msg,"\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}")))))
449+end
450+testrep("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{3b}\u{20}\u{61}","\u{2c}\u{61}","\u{3d}\u{20}\u{31}","\u{2c}\u{31}")
451+testrep("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{3b}\u{20}\u{61}\u{3d}","\u{7b}","\u{30}","\u{7d}")
452+testrep("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}","\u{28}","\u{32}","\u{29}",0x2)
453+testrep("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{61}\u{20}\u{28}\u{78}\u{29}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{78}\u{20}\u{65}\u{6e}\u{64}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}","\u{61}\u{28}","\u{32}\u{2e}\u{32}","\u{29}",2.2)
454+testrep("","\u{64}\u{6f}\u{20}","","\u{20}\u{65}\u{6e}\u{64}")
455+testrep("","\u{77}\u{68}\u{69}\u{6c}\u{65}\u{20}\u{61}\u{20}\u{64}\u{6f}\u{20}","","\u{20}\u{65}\u{6e}\u{64}")
456+testrep("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{3b}\u{20}","\u{69}\u{66}\u{20}\u{61}\u{20}\u{74}\u{68}\u{65}\u{6e}\u{20}\u{65}\u{6c}\u{73}\u{65}\u{20}","","\u{20}\u{65}\u{6e}\u{64}")
457+testrep("","\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{66}\u{6f}\u{6f}\u{20}\u{28}\u{29}\u{20}","","\u{20}\u{65}\u{6e}\u{64}")
458+testrep("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{27}\u{27}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}","\u{61}\u{2e}\u{2e}","\u{27}\u{61}\u{27}","","\u{61}")
459+testrep("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}","\u{61}\u{5e}","\u{61}","",0x1)
460+checkmessage(("\u{61}\u{20}\u{3d}\u{20}\u{66}\u{28}\u{78}" .. (string.rep("\u{2c}\u{78}",0x104) .. "\u{29}")),"\u{74}\u{6f}\u{6f}\u{20}\u{6d}\u{61}\u{6e}\u{79}\u{20}\u{72}\u{65}\u{67}\u{69}\u{73}\u{74}\u{65}\u{72}\u{73}")
461+local lim = 0x7f
462+local s = "\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{66}\u{6f}\u{6f}\u{41}\u{20}\u{28}\u{29}\u{a}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}"
463+for j = 0x1, lim
464+do
465+s=(s .. ("\u{61}" .. (j .. "\u{2c}\u{20}")))
466+end
467+s=(s .. "\u{62}\u{2c}\u{63}\u{a}")
468+s=(s .. "\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{66}\u{6f}\u{6f}\u{42}\u{20}\u{28}\u{29}\u{a}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}")
469+for j = 0x1, lim
470+do
471+s=(s .. ("\u{62}" .. (j .. "\u{2c}\u{20}")))
472+end
473+s=(s .. "\u{62}\u{a}")
474+s=(s .. "\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{66}\u{6f}\u{6f}\u{43}\u{20}\u{28}\u{29}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{62}\u{2b}\u{63}")
475+local c = (0x1 + 0x2)
476+for j = 0x1, lim
477+do
478+s=(s .. ("\u{2b}\u{61}" .. (j .. ("\u{2b}\u{62}" .. j))))
479+c=(c + 0x2)
480+end
481+s=(s .. "\u{a}\u{65}\u{6e}\u{64}\u{20}\u{20}\u{65}\u{6e}\u{64}\u{20}\u{65}\u{6e}\u{64}")
482+local a,b = load(s)
483+assert((((c > 0xff) and string.find(b,"\u{74}\u{6f}\u{6f}\u{20}\u{6d}\u{61}\u{6e}\u{79}\u{20}\u{75}\u{70}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{73}")) and string.find(b,"\u{6c}\u{69}\u{6e}\u{65}\u{20}\u{35}")))
484+s="\u{a}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{66}\u{6f}\u{6f}\u{20}\u{28}\u{29}\u{a}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}"
485+for j = 0x1, 0x12c
486+do
487+s=(s .. ("\u{61}" .. (j .. "\u{2c}\u{20}")))
488+end
489+s=(s .. "\u{62}\u{a}")
490+local a,b = load(s)
491+assert((string.find(b,"\u{6c}\u{69}\u{6e}\u{65}\u{20}\u{32}") and string.find(b,"\u{74}\u{6f}\u{6f}\u{20}\u{6d}\u{61}\u{6e}\u{79}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{76}\u{61}\u{72}\u{69}\u{61}\u{62}\u{6c}\u{65}\u{73}")))
492+mt.__index=oldmm
493+print("\u{4f}\u{4b}")
desk/res/lua/cycled/events.luanew file+610
@@ -0,0 +1,610 @@
1+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{6d}\u{65}\u{74}\u{61}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{73}")
2+local debug = require("\u{64}\u{65}\u{62}\u{75}\u{67}")
3+X=0x14
4+;
5+B=0x1e
6+_ENV=setmetatable({},{["\u{5f}\u{5f}\u{69}\u{6e}\u{64}\u{65}\u{78}"] = _G})
7+collectgarbage()
8+X=(X + 0xa)
9+assert(((X == 0x1e) and (_G.X == 0x14)))
10+B=false
11+assert((B == false))
12+_ENV["\u{42}"]=undef
13+assert((B == 0x1e))
14+assert((getmetatable({}) == nil))
15+assert((getmetatable(0x4) == nil))
16+assert((getmetatable(nil) == nil))
17+a={["\u{6e}\u{61}\u{6d}\u{65}"] = "\u{4e}\u{41}\u{4d}\u{45}"}
18+;
19+setmetatable(a,{["\u{5f}\u{5f}\u{6d}\u{65}\u{74}\u{61}\u{74}\u{61}\u{62}\u{6c}\u{65}"] = "\u{78}\u{75}\u{78}\u{75}",["\u{5f}\u{5f}\u{74}\u{6f}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}"] = function (x)
20+return x.name
21+end})
22+assert((getmetatable(a) == "\u{78}\u{75}\u{78}\u{75}"))
23+assert((tostring(a) == "\u{4e}\u{41}\u{4d}\u{45}"))
24+assert((pcall(setmetatable,a,{}) == false))
25+a.name="\u{67}\u{6f}\u{72}\u{6f}\u{72}\u{6f}\u{62}\u{61}"
26+assert((tostring(a) == "\u{67}\u{6f}\u{72}\u{6f}\u{72}\u{6f}\u{62}\u{61}"))
27+local a,t = {0xa,0x14,0x1e,["\u{78}"] = "\u{31}\u{30}",["\u{79}"] = "\u{32}\u{30}"},{}
28+assert((setmetatable(a,t) == a))
29+assert((getmetatable(a) == t))
30+assert((setmetatable(a,nil) == a))
31+assert((getmetatable(a) == nil))
32+assert((setmetatable(a,t) == a))
33+function f(t,i,e)
34+assert((not e))
35+local p = rawget(t,"\u{70}\u{61}\u{72}\u{65}\u{6e}\u{74}")
36+return (p and (p[i] + 0x3)),"\u{64}\u{75}\u{6d}\u{6d}\u{79}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}"
37+end
38+t.__index=f
39+a.parent={["\u{7a}"] = 0x19,["\u{78}"] = 0xc,[0x4] = 0x18}
40+assert(((((a[0x1] == 0xa) and (a.z == 0x1c)) and (a[0x4] == 0x1b)) and (a.x == "\u{31}\u{30}")))
41+collectgarbage()
42+a=setmetatable({},t)
43+function f(t,i,v)
44+rawset(t,i,(v - 0x3))
45+end
46+setmetatable(t,t)
47+t.__newindex=f
48+a[0x1]=0x1e
49+;
50+a.x="\u{31}\u{30}\u{31}"
51+;
52+a[0x5]=0xc8
53+assert((((a[0x1] == 0x1b) and (a.x == 0x62)) and (a[0x5] == 0xc5)))
54+do
55+local mt = {}
56+mt.__newindex=mt
57+local t = setmetatable({},mt)
58+t[0x1]=0xa
59+assert((mt[0x1] == 0xa))
60+end
61+local c = {}
62+a=setmetatable({},t)
63+t.__newindex=c
64+t.__index=c
65+a[0x1]=0xa
66+;
67+a[0x2]=0x14
68+;
69+a[0x3]=0x5a
70+;
71+for i = 0x4, 0x14
72+do
73+a[i]=(i * 0xa)
74+end
75+assert((((a[0x1] == 0xa) and (a[0x2] == 0x14)) and (a[0x3] == 0x5a)))
76+for i = 0x4, 0x14
77+do
78+assert((a[i] == (i * 0xa)))
79+end
80+assert((next(a) == nil))
81+do
82+local a
83+;
84+a=setmetatable({},{["\u{5f}\u{5f}\u{69}\u{6e}\u{64}\u{65}\u{78}"] = setmetatable({},{["\u{5f}\u{5f}\u{69}\u{6e}\u{64}\u{65}\u{78}"] = setmetatable({},{["\u{5f}\u{5f}\u{69}\u{6e}\u{64}\u{65}\u{78}"] = function (_,n)
85+return (a[(n - 0x3)] + 0x4),"\u{6c}\u{69}\u{78}\u{6f}"
86+end})})})
87+a[0x0]=0x14
88+for i = 0x0, 0xa
89+do
90+assert((a[(i * 0x3)] == (0x14 + (i * 0x4))))
91+end
92+end
93+do
94+local foi
95+local a = {}
96+for i = 0x1, 0xa
97+do
98+a[i]=0x0
99+;
100+a[("\u{61}" .. i)]=0x0
101+;
102+end
103+setmetatable(a,{["\u{5f}\u{5f}\u{6e}\u{65}\u{77}\u{69}\u{6e}\u{64}\u{65}\u{78}"] = function (t,k,v)
104+foi=true
105+;
106+rawset(t,k,v)
107+end})
108+foi=false
109+;
110+a[0x1]=0x0
111+;
112+assert((not foi))
113+foi=false
114+;
115+a["\u{61}\u{31}"]=0x0
116+;
117+assert((not foi))
118+foi=false
119+;
120+a["\u{61}\u{31}\u{31}"]=0x0
121+;
122+assert(foi)
123+foi=false
124+;
125+a[0xb]=0x0
126+;
127+assert(foi)
128+foi=false
129+;
130+a[0x1]=undef
131+;
132+assert((not foi))
133+a[0x1]=undef
134+foi=false
135+;
136+a[0x1]=nil
137+;
138+assert(foi)
139+end
140+setmetatable(t,nil)
141+function f(t, ...)
142+return t,{...}
143+end
144+t.__call=f
145+do
146+local x,y = a(table.unpack({"\u{61}",0x1}))
147+assert(((((x == a) and (y[0x1] == "\u{61}")) and (y[0x2] == 0x1)) and (y[0x3] == undef)))
148+x,y=a()
149+assert(((x == a) and (y[0x1] == undef)))
150+end
151+local b = setmetatable({},t)
152+setmetatable(b,t)
153+function f(op)
154+return function (...)
155+cap={[0x0] = op,...}
156+;
157+return ...
158+end
159+end
160+t.__add=f("\u{61}\u{64}\u{64}")
161+t.__sub=f("\u{73}\u{75}\u{62}")
162+t.__mul=f("\u{6d}\u{75}\u{6c}")
163+t.__div=f("\u{64}\u{69}\u{76}")
164+t.__idiv=f("\u{69}\u{64}\u{69}\u{76}")
165+t.__mod=f("\u{6d}\u{6f}\u{64}")
166+t.__unm=f("\u{75}\u{6e}\u{6d}")
167+t.__pow=f("\u{70}\u{6f}\u{77}")
168+t.__len=f("\u{6c}\u{65}\u{6e}")
169+t.__band=f("\u{62}\u{61}\u{6e}\u{64}")
170+t.__bor=f("\u{62}\u{6f}\u{72}")
171+t.__bxor=f("\u{62}\u{78}\u{6f}\u{72}")
172+t.__shl=f("\u{73}\u{68}\u{6c}")
173+t.__shr=f("\u{73}\u{68}\u{72}")
174+t.__bnot=f("\u{62}\u{6e}\u{6f}\u{74}")
175+t.__lt=f("\u{6c}\u{74}")
176+t.__le=f("\u{6c}\u{65}")
177+local function checkcap
178+(t)
179+assert((# ((cap + 0x1) == (# t))))
180+for i = 0x1, (# t)
181+do
182+assert((cap[(i - 0x1)] == t[i]))
183+assert((math.type(cap[(i - 0x1)]) == math.type(t[i])))
184+end
185+end
186+assert(((b + 0x5) == b))
187+;
188+checkcap({"\u{61}\u{64}\u{64}",b,0x5})
189+assert(((5.2 + b) == 5.2))
190+;
191+checkcap({"\u{61}\u{64}\u{64}",5.2,b})
192+assert(((b + "\u{35}") == b))
193+;
194+checkcap({"\u{61}\u{64}\u{64}",b,"\u{35}"})
195+assert(((0x5 + b) == 0x5))
196+;
197+checkcap({"\u{61}\u{64}\u{64}",0x5,b})
198+assert((("\u{35}" + b) == "\u{35}"))
199+;
200+checkcap({"\u{61}\u{64}\u{64}","\u{35}",b})
201+b=(b - 0x3)
202+;
203+assert((getmetatable(b) == t))
204+;
205+checkcap({"\u{73}\u{75}\u{62}",b,0x3})
206+assert(((0x5 - a) == 0x5))
207+;
208+checkcap({"\u{73}\u{75}\u{62}",0x5,a})
209+assert((("\u{35}" - a) == "\u{35}"))
210+;
211+checkcap({"\u{73}\u{75}\u{62}","\u{35}",a})
212+assert(((a * a) == a))
213+;
214+checkcap({"\u{6d}\u{75}\u{6c}",a,a})
215+assert(((a / 0x0) == a))
216+;
217+checkcap({"\u{64}\u{69}\u{76}",a,0x0})
218+assert(((a / 0.0) == a))
219+;
220+checkcap({"\u{64}\u{69}\u{76}",a,0.0})
221+assert(((a % 0x2) == a))
222+;
223+checkcap({"\u{6d}\u{6f}\u{64}",a,0x2})
224+assert(((a // (0x1 / 0x0)) == a))
225+;
226+checkcap({"\u{69}\u{64}\u{69}\u{76}",a,(0x1 / 0x0)})
227+;
228+(function ()
229+assert(((a & "\u{68}\u{69}") == a))
230+end)()
231+;
232+checkcap({"\u{62}\u{61}\u{6e}\u{64}",a,"\u{68}\u{69}"})
233+;
234+(function ()
235+assert(((0xa & a) == 0xa))
236+end)()
237+;
238+checkcap({"\u{62}\u{61}\u{6e}\u{64}",0xa,a})
239+;
240+(function ()
241+assert(((a | 0xa) == a))
242+end)()
243+;
244+checkcap({"\u{62}\u{6f}\u{72}",a,0xa})
245+assert(((a | "\u{68}\u{69}") == a))
246+;
247+checkcap({"\u{62}\u{6f}\u{72}",a,"\u{68}\u{69}"})
248+assert((("\u{68}\u{69}" ~ a) == "\u{68}\u{69}"))
249+;
250+checkcap({"\u{62}\u{78}\u{6f}\u{72}","\u{68}\u{69}",a})
251+;
252+(function ()
253+assert(((0xa ~ a) == 0xa))
254+end)()
255+;
256+checkcap({"\u{62}\u{78}\u{6f}\u{72}",0xa,a})
257+assert((- (a == a)))
258+;
259+checkcap({"\u{75}\u{6e}\u{6d}",a,a})
260+assert(((a ^ 4.0) == a))
261+;
262+checkcap({"\u{70}\u{6f}\u{77}",a,4.0})
263+assert(((a ^ "\u{34}") == a))
264+;
265+checkcap({"\u{70}\u{6f}\u{77}",a,"\u{34}"})
266+assert(((0x4 ^ a) == 0x4))
267+;
268+checkcap({"\u{70}\u{6f}\u{77}",0x4,a})
269+assert((("\u{34}" ^ a) == "\u{34}"))
270+;
271+checkcap({"\u{70}\u{6f}\u{77}","\u{34}",a})
272+assert((# (a == a)))
273+;
274+checkcap({"\u{6c}\u{65}\u{6e}",a,a})
275+assert((~ (a == a)))
276+;
277+checkcap({"\u{62}\u{6e}\u{6f}\u{74}",a,a})
278+assert(((a << 0x3) == a))
279+;
280+checkcap({"\u{73}\u{68}\u{6c}",a,0x3})
281+assert(((1.5 >> a) == 1.5))
282+;
283+checkcap({"\u{73}\u{68}\u{72}",1.5,a})
284+assert((5.0 > a))
285+;
286+checkcap({"\u{6c}\u{74}",a,5.0})
287+assert((a >= 0xa))
288+;
289+checkcap({"\u{6c}\u{65}",0xa,a})
290+assert((a <= (- 10.0)))
291+;
292+checkcap({"\u{6c}\u{65}",a,(- 10.0)})
293+assert((a < (- 0xa)))
294+;
295+checkcap({"\u{6c}\u{74}",a,(- 0xa)})
296+t=setmetatable({0x1,0x2,0x3},{["\u{5f}\u{5f}\u{6c}\u{65}\u{6e}"] = function ()
297+return 0xa
298+end})
299+assert((# ((t == 0xa) and (rawlen(t) == 0x3))))
300+assert((rawlen("\u{61}\u{62}\u{63}") == 0x3))
301+assert((not pcall(rawlen,io.stdin)))
302+assert((not pcall(rawlen,0x22)))
303+assert((not pcall(rawlen)))
304+assert((rawlen(string.rep("\u{61}",0x3e8)) == 0x3e8))
305+t={}
306+t.__lt=function (a,b,c)
307+collectgarbage()
308+assert((c == nil))
309+if (type(a) == "\u{74}\u{61}\u{62}\u{6c}\u{65}") then
310+a=a.x
311+end
312+if (type(b) == "\u{74}\u{61}\u{62}\u{6c}\u{65}") then
313+b=b.x
314+end
315+return (a < b),"\u{64}\u{75}\u{6d}\u{6d}\u{79}"
316+end
317+t.__le=function (a,b,c)
318+assert((c == nil))
319+if (type(a) == "\u{74}\u{61}\u{62}\u{6c}\u{65}") then
320+a=a.x
321+end
322+if (type(b) == "\u{74}\u{61}\u{62}\u{6c}\u{65}") then
323+b=b.x
324+end
325+return (a <= b),"\u{64}\u{75}\u{6d}\u{6d}\u{79}"
326+end
327+t.__eq=function (a,b,c)
328+assert((c == nil))
329+if (type(a) == "\u{74}\u{61}\u{62}\u{6c}\u{65}") then
330+a=a.x
331+end
332+if (type(b) == "\u{74}\u{61}\u{62}\u{6c}\u{65}") then
333+b=b.x
334+end
335+return (a == b),"\u{64}\u{75}\u{6d}\u{6d}\u{79}"
336+end
337+function Op(x)
338+return setmetatable({["\u{78}"] = x},t)
339+end
340+local function test
341+(a,b,c)
342+assert((not (((Op(0x1) < Op(0x1)) and (Op(0x1) < Op(0x2))) and (not (Op(0x2) < Op(0x1))))))
343+assert((not (((0x1 < Op(0x1)) and (Op(0x1) < 0x2)) and (not (0x2 < Op(0x1))))))
344+assert((not (((Op("\u{61}") < Op("\u{61}")) and (Op("\u{61}") < Op("\u{62}"))) and (not (Op("\u{62}") < Op("\u{61}"))))))
345+assert((not ((("\u{61}" < Op("\u{61}")) and (Op("\u{61}") < "\u{62}")) and (not (Op("\u{62}") < Op("\u{61}"))))))
346+assert((((Op(0x1) <= Op(0x1)) and (Op(0x1) <= Op(0x2))) and (not (Op(0x2) <= Op(0x1)))))
347+assert((((Op("\u{61}") <= Op("\u{61}")) and (Op("\u{61}") <= Op("\u{62}"))) and (not (Op("\u{62}") <= Op("\u{61}")))))
348+assert((not ((Op(0x1) > Op(0x1)) and (not ((Op(0x1) > Op(0x2)) and (Op(0x2) > Op(0x1)))))))
349+assert((not ((Op("\u{61}") > Op("\u{61}")) and (not ((Op("\u{61}") > Op("\u{62}")) and (Op("\u{62}") > Op("\u{61}")))))))
350+assert(((Op(0x1) >= Op(0x1)) and (not ((Op(0x1) >= Op(0x2)) and (Op(0x2) >= Op(0x1))))))
351+assert(((0x1 >= Op(0x1)) and (not ((0x1 >= Op(0x2)) and (Op(0x2) >= 0x1)))))
352+assert(((Op("\u{61}") >= Op("\u{61}")) and (not ((Op("\u{61}") >= Op("\u{62}")) and (Op("\u{62}") >= Op("\u{61}"))))))
353+assert((("\u{61}" >= Op("\u{61}")) and (not ((Op("\u{61}") >= "\u{62}") and (Op("\u{62}") >= Op("\u{61}"))))))
354+assert(((Op(0x1) == Op(0x1)) and (Op(0x1) ~= Op(0x2))))
355+assert(((Op("\u{61}") == Op("\u{61}")) and (Op("\u{61}") ~= Op("\u{62}"))))
356+assert(((a == a) and (a ~= b)))
357+assert((Op(0x3) == c))
358+end
359+test(Op(0x1),Op(0x2),Op(0x3))
360+local function rawSet
361+(x)
362+local y = {}
363+for _,k in pairs(x)
364+do
365+y[k]=0x1
366+end
367+return y
368+end
369+local function Set
370+(x)
371+return setmetatable(rawSet(x),t)
372+end
373+t.__lt=function (a,b)
374+for k in pairs(a)
375+do
376+if (not b[k]) then
377+return false
378+end
379+b[k]=undef
380+end
381+return (next(b) ~= nil)
382+end
383+t.__le=function (a,b)
384+for k in pairs(a)
385+do
386+if (not b[k]) then
387+return false
388+end
389+end
390+return true
391+end
392+assert((Set({0x1,0x2,0x3}) < Set({0x1,0x2,0x3,0x4})))
393+assert((not (Set({0x1,0x2,0x3,0x4}) < Set({0x1,0x2,0x3,0x4}))))
394+assert((Set({0x1,0x2,0x3,0x4}) <= Set({0x1,0x2,0x3,0x4})))
395+assert((Set({0x1,0x2,0x3,0x4}) >= Set({0x1,0x2,0x3,0x4})))
396+assert((not (Set({0x1,0x3}) <= Set({0x3,0x5}))))
397+assert((not (Set({0x1,0x3}) <= Set({0x3,0x5}))))
398+assert((not (Set({0x1,0x3}) >= Set({0x3,0x5}))))
399+t.__eq=function (a,b)
400+for k in pairs(a)
401+do
402+if (not b[k]) then
403+return false
404+end
405+b[k]=undef
406+end
407+return (next(b) == nil)
408+end
409+local s = Set({0x1,0x3,0x5})
410+assert((s == Set({0x3,0x5,0x1})))
411+assert((not rawequal(s,Set({0x3,0x5,0x1}))))
412+assert(rawequal(s,s))
413+assert((Set({0x1,0x3,0x5,0x1}) == rawSet({0x3,0x5,0x1})))
414+assert((rawSet({0x1,0x3,0x5,0x1}) == Set({0x3,0x5,0x1})))
415+assert((Set({0x1,0x3,0x5}) ~= Set({0x3,0x5,0x1,0x6})))
416+t[Set({0x1,0x3,0x5})]=0x1
417+assert((t[Set({0x1,0x3,0x5})] == undef))
418+do
419+local mt = {["\u{5f}\u{5f}\u{65}\u{71}"] = true}
420+local a = setmetatable({0xa},mt)
421+local b = setmetatable({0xa},mt)
422+mt.__eq=nil
423+assert((a ~= b))
424+mt.__eq=function (x,y)
425+return (x[0x1] == y[0x1])
426+end
427+assert((a == b))
428+end
429+if (not T) then
430+(Message or print)("\u{a}\u{20}\u{3e}\u{3e}\u{3e}\u{20}\u{74}\u{65}\u{73}\u{74}\u{43}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{61}\u{63}\u{74}\u{69}\u{76}\u{65}\u{3a}\u{20}\u{73}\u{6b}\u{69}\u{70}\u{70}\u{69}\u{6e}\u{67}\u{20}\u{74}\u{65}\u{73}\u{74}\u{73}\u{20}\u{66}\u{6f}\u{72}\u{20}\u{75}\u{73}\u{65}\u{72}\u{64}\u{61}\u{74}\u{61}\u{20}\u{3c}\u{3c}\u{3c}\u{a}")
431+else
432+local u1 = T.newuserdata(0x0,0x1)
433+local u2 = T.newuserdata(0x0,0x1)
434+local u3 = T.newuserdata(0x0,0x1)
435+assert(((u1 ~= u2) and (u1 ~= u3)))
436+debug.setuservalue(u1,0x1)
437+;
438+debug.setuservalue(u2,0x2)
439+;
440+debug.setuservalue(u3,0x1)
441+;
442+debug.setmetatable(u1,{["\u{5f}\u{5f}\u{65}\u{71}"] = function (a,b)
443+return (debug.getuservalue(a) == debug.getuservalue(b))
444+end})
445+debug.setmetatable(u2,{["\u{5f}\u{5f}\u{65}\u{71}"] = function (a,b)
446+return true
447+end})
448+assert((((u1 == u3) and (u3 == u1)) and (u1 ~= u2)))
449+assert((((u2 == u1) and (u2 == u3)) and (u3 == u2)))
450+assert((u2 ~= {}))
451+assert((rawequal(u1,u1) and (not rawequal(u1,u3))))
452+local mirror = {}
453+debug.setmetatable(u3,{["\u{5f}\u{5f}\u{69}\u{6e}\u{64}\u{65}\u{78}"] = mirror,["\u{5f}\u{5f}\u{6e}\u{65}\u{77}\u{69}\u{6e}\u{64}\u{65}\u{78}"] = mirror})
454+for i = 0x1, 0xa
455+do
456+u3[i]=i
457+end
458+for i = 0x1, 0xa
459+do
460+assert((u3[i] == i))
461+end
462+end
463+t.__concat=function (a,b,c)
464+assert((c == nil))
465+if (type(a) == "\u{74}\u{61}\u{62}\u{6c}\u{65}") then
466+a=a.val
467+end
468+if (type(b) == "\u{74}\u{61}\u{62}\u{6c}\u{65}") then
469+b=b.val
470+end
471+if A then
472+return (a .. b)
473+else
474+return setmetatable({["\u{76}\u{61}\u{6c}"] = (a .. b)},t)
475+end
476+end
477+c={["\u{76}\u{61}\u{6c}"] = "\u{63}"}
478+;
479+setmetatable(c,t)
480+d={["\u{76}\u{61}\u{6c}"] = "\u{64}"}
481+;
482+setmetatable(d,t)
483+A=true
484+assert(((c .. d) == "\u{63}\u{64}"))
485+assert(((0x0 .. ("\u{61}" .. ("\u{62}" .. (c .. (d .. ("\u{65}" .. ("\u{66}" .. ((0x5 + 0x3) .. "\u{67}")))))))) == "\u{30}\u{61}\u{62}\u{63}\u{64}\u{65}\u{66}\u{38}\u{67}"))
486+A=false
487+assert(((c .. (d .. (c .. d))).val == "\u{63}\u{64}\u{63}\u{64}"))
488+x=(c .. d)
489+assert(((getmetatable(x) == t) and (x.val == "\u{63}\u{64}")))
490+x=(0x0 .. ("\u{61}" .. ("\u{62}" .. (c .. (d .. ("\u{65}" .. ("\u{66}" .. "\u{67}")))))))
491+assert((x.val == "\u{30}\u{61}\u{62}\u{63}\u{64}\u{65}\u{66}\u{67}"))
492+c={}
493+local x
494+setmetatable(c,{["\u{5f}\u{5f}\u{63}\u{6f}\u{6e}\u{63}\u{61}\u{74}"] = function (a,b)
495+assert((((type(a) == "\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}") and (b == c)) or ((type(b) == "\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}") and (a == c))))
496+return c
497+end})
498+assert((((c .. 0x5) == c) and ((0x5 .. c) == c)))
499+assert((((0x4 .. (c .. 0x5)) == c) and ((0x4 .. (0x5 .. (0x6 .. (0x7 .. c)))) == c)))
500+local t1,t2,c,d
501+t1={}
502+;
503+c={}
504+;
505+setmetatable(c,t1)
506+d={}
507+t1.__eq=function ()
508+return true
509+end
510+t1.__lt=function ()
511+return true
512+end
513+t1.__le=function ()
514+return false
515+end
516+setmetatable(d,t1)
517+assert((((c == d) and (c < d)) and (not (d <= c))))
518+t2={}
519+t2.__eq=t1.__eq
520+t2.__lt=t1.__lt
521+setmetatable(d,t2)
522+assert((((c == d) and (c < d)) and (not (d <= c))))
523+local i
524+local tt = {["\u{5f}\u{5f}\u{63}\u{61}\u{6c}\u{6c}"] = function (t, ...)
525+i=(i + 0x1)
526+if t.f then
527+return t.f(...)
528+else
529+return {...}
530+end
531+end}
532+local a = setmetatable({},tt)
533+local b = setmetatable({["\u{66}"] = a},tt)
534+local c = setmetatable({["\u{66}"] = b},tt)
535+i=0x0
536+x=c(0x3,0x4,0x5)
537+assert((((i == 0x3) and (x[0x1] == 0x3)) and (x[0x3] == 0x5)))
538+assert((_G.X == 0x14))
539+_G.X,_G.B=nil
540+print("\u{2b}")
541+local _g = _G
542+_ENV=setmetatable({},{["\u{5f}\u{5f}\u{69}\u{6e}\u{64}\u{65}\u{78}"] = function (_,k)
543+return _g[k]
544+end})
545+a={}
546+rawset(a,"\u{78}",0x1,0x2,0x3)
547+assert(((a.x == 0x1) and (rawget(a,"\u{78}",0x3) == 0x1)))
548+print("\u{2b}")
549+mt={["\u{5f}\u{5f}\u{69}\u{6e}\u{64}\u{65}\u{78}"] = function (a,b)
550+return (a + b)
551+end,["\u{5f}\u{5f}\u{6c}\u{65}\u{6e}"] = function (x)
552+return math.floor(x)
553+end}
554+debug.setmetatable(0xa,mt)
555+assert((getmetatable((- 0x2)) == mt))
556+assert(((0xa)[0x3] == 0xd))
557+assert(((0xa)["\u{33}"] == 0xd))
558+assert((# (3.45 == 0x3)))
559+debug.setmetatable(0x17,nil)
560+assert((getmetatable((- 0x2)) == nil))
561+debug.setmetatable(true,mt)
562+assert((getmetatable(false) == mt))
563+mt.__index=function (a,b)
564+return (a or b)
565+end
566+assert(((true)[false] == true))
567+assert(((false)[false] == false))
568+debug.setmetatable(false,nil)
569+assert((getmetatable(true) == nil))
570+debug.setmetatable(nil,mt)
571+assert((getmetatable(nil) == mt))
572+mt.__add=function (a,b)
573+return ((a or 0x1) + (b or 0x2))
574+end
575+assert(((0xa + nil) == 0xc))
576+assert(((nil + 0x17) == 0x18))
577+assert(((nil + nil) == 0x3))
578+debug.setmetatable(nil,nil)
579+assert((getmetatable(nil) == nil))
580+debug.setmetatable(nil,{})
581+a={}
582+;
583+setmetatable(a,a)
584+;
585+a.__index=a
586+;
587+a.__newindex=a
588+assert((not pcall(function (a,b)
589+return a[b]
590+end,a,0xa)))
591+assert((not pcall(function (a,b,c)
592+a[b]=c
593+end,a,0xa,true)))
594+T,K,V=nil
595+grandparent={}
596+grandparent.__newindex=function (t,k,v)
597+T=t
598+;
599+K=k
600+;
601+V=v
602+end
603+parent={}
604+parent.__newindex=parent
605+setmetatable(parent,grandparent)
606+child=setmetatable({},parent)
607+child.foo=0xa
608+assert((((T == parent) and (K == "\u{66}\u{6f}\u{6f}")) and (V == 0xa)))
609+print("\u{4f}\u{4b}")
610+return 0xc
desk/res/lua/cycled/files.luanew file+818
@@ -0,0 +1,818 @@
1+local debug = require("\u{64}\u{65}\u{62}\u{75}\u{67}")
2+local maxint = math.maxinteger
3+assert((type(os.getenv("\u{50}\u{41}\u{54}\u{48}")) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}"))
4+assert((io.input(io.stdin) == io.stdin))
5+assert((not pcall(io.input,"\u{6e}\u{6f}\u{6e}\u{2d}\u{65}\u{78}\u{69}\u{73}\u{74}\u{65}\u{6e}\u{74}\u{2d}\u{66}\u{69}\u{6c}\u{65}")))
6+assert((io.output(io.stdout) == io.stdout))
7+local function testerr
8+(msg,f, ...)
9+local stat,err = pcall(f,...)
10+return (not (stat and string.find(err,msg,0x1,true)))
11+end
12+local function checkerr
13+(msg,f, ...)
14+assert(testerr(msg,f,...))
15+end
16+assert((not (io.close(io.stdin) and (not (io.stdout:close() and (not io.stderr:close()))))))
17+checkerr("\u{67}\u{6f}\u{74}\u{20}\u{6e}\u{6f}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}",io.stdin.close)
18+assert(((type(io.input()) == "\u{75}\u{73}\u{65}\u{72}\u{64}\u{61}\u{74}\u{61}") and (io.type(io.output()) == "\u{66}\u{69}\u{6c}\u{65}")))
19+assert(((type(io.stdin) == "\u{75}\u{73}\u{65}\u{72}\u{64}\u{61}\u{74}\u{61}") and (io.type(io.stderr) == "\u{66}\u{69}\u{6c}\u{65}")))
20+assert((not io.type(0x8)))
21+local a = {}
22+;
23+setmetatable(a,{})
24+assert((not io.type(a)))
25+assert((getmetatable(io.input()).__name == "\u{46}\u{49}\u{4c}\u{45}\u{2a}"))
26+local a,b,c = io.open("\u{78}\u{75}\u{78}\u{75}\u{5f}\u{6e}\u{61}\u{6f}\u{5f}\u{65}\u{78}\u{69}\u{73}\u{74}\u{65}")
27+assert((not ((a and (type(b) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}")) and (type(c) == "\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}"))))
28+a,b,c=io.open("\u{2f}\u{61}\u{2f}\u{62}\u{2f}\u{63}\u{2f}\u{64}","\u{77}")
29+assert((not ((a and (type(b) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}")) and (type(c) == "\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}"))))
30+local file = os.tmpname()
31+local f,msg = io.open(file,"\u{77}")
32+if (not f) then
33+(Message or print)("\u{27}\u{6f}\u{73}\u{2e}\u{74}\u{6d}\u{70}\u{6e}\u{61}\u{6d}\u{65}\u{27}\u{20}\u{66}\u{69}\u{6c}\u{65}\u{20}\u{63}\u{61}\u{6e}\u{6e}\u{6f}\u{74}\u{20}\u{62}\u{65}\u{20}\u{6f}\u{70}\u{65}\u{6e}\u{3b}\u{20}\u{73}\u{6b}\u{69}\u{70}\u{70}\u{69}\u{6e}\u{67}\u{20}\u{66}\u{69}\u{6c}\u{65}\u{20}\u{74}\u{65}\u{73}\u{74}\u{73}")
34+else
35+f:close()
36+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{69}\u{2f}\u{6f}")
37+local otherfile = os.tmpname()
38+checkerr("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{6d}\u{6f}\u{64}\u{65}",io.open,file,"\u{72}\u{77}")
39+checkerr("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{6d}\u{6f}\u{64}\u{65}",io.open,file,"\u{72}\u{62}\u{2b}")
40+checkerr("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{6d}\u{6f}\u{64}\u{65}",io.open,file,"\u{72}\u{2b}\u{62}\u{6b}")
41+checkerr("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{6d}\u{6f}\u{64}\u{65}",io.open,file,"")
42+checkerr("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{6d}\u{6f}\u{64}\u{65}",io.open,file,"\u{2b}")
43+checkerr("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{6d}\u{6f}\u{64}\u{65}",io.open,file,"\u{62}")
44+assert(io.open(file,"\u{72}\u{2b}\u{62}")):close()
45+assert(io.open(file,"\u{72}\u{2b}")):close()
46+assert(io.open(file,"\u{72}\u{62}")):close()
47+assert(os.setlocale("\u{43}","\u{61}\u{6c}\u{6c}"))
48+io.input(io.stdin)
49+;
50+io.output(io.stdout)
51+;
52+os.remove(file)
53+assert((not loadfile(file)))
54+checkerr("",dofile,file)
55+assert((not io.open(file)))
56+io.output(file)
57+assert((io.output() ~= io.stdout))
58+if (not _port) then
59+local status,msg,code = io.stdin:seek("\u{73}\u{65}\u{74}",0x3e8)
60+assert((not ((status and (type(msg) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}")) and (type(code) == "\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}"))))
61+end
62+assert((io.output():seek() == 0x0))
63+assert((io.write("\u{61}\u{6c}\u{6f}\u{20}\u{61}\u{6c}\u{6f}"):seek() == string.len("\u{61}\u{6c}\u{6f}\u{20}\u{61}\u{6c}\u{6f}")))
64+assert((io.output():seek("\u{63}\u{75}\u{72}",(- 0x3)) == (string.len("\u{61}\u{6c}\u{6f}\u{20}\u{61}\u{6c}\u{6f}") - 0x3)))
65+assert(io.write("\u{6a}\u{6f}\u{61}\u{6f}"))
66+assert((io.output():seek("\u{65}\u{6e}\u{64}") == string.len("\u{61}\u{6c}\u{6f}\u{20}\u{6a}\u{6f}\u{61}\u{6f}")))
67+assert((io.output():seek("\u{73}\u{65}\u{74}") == 0x0))
68+assert(io.write("\u{22}\u{61}\u{6c}\u{6f}\u{22}","\u{7b}\u{61}\u{7d}\u{a}","\u{73}\u{65}\u{63}\u{6f}\u{6e}\u{64}\u{20}\u{6c}\u{69}\u{6e}\u{65}\u{a}","\u{74}\u{68}\u{69}\u{72}\u{64}\u{20}\u{6c}\u{69}\u{6e}\u{65}\u{20}\u{a}"))
69+assert(io.write("\u{58}\u{66}\u{6f}\u{75}\u{72}\u{74}\u{68}\u{5f}\u{6c}\u{69}\u{6e}\u{65}"))
70+io.output(io.stdout)
71+collectgarbage()
72+assert(((io.input() == io.stdin) and rawequal(io.output(),io.stdout)))
73+print("\u{2b}")
74+collectgarbage()
75+for i = 0x1, 0x78
76+do
77+for i = 0x1, 0x5
78+do
79+io.input(file)
80+assert(io.open(file,"\u{72}"))
81+io.lines(file)
82+end
83+collectgarbage()
84+end
85+io.input():close()
86+io.close()
87+assert(os.rename(file,otherfile))
88+assert((not os.rename(file,otherfile)))
89+io.output(io.open(otherfile,"\u{61}\u{62}"))
90+assert(io.write("\u{a}\u{a}\u{9}\u{9}\u{20}\u{20}",0xd7a,"\u{a}"))
91+;
92+io.close()
93+do
94+local F = nil
95+do
96+local f <close> = assert(io.open(file,"\u{77}"))
97+F=f
98+end
99+assert((tostring(F) == "\u{66}\u{69}\u{6c}\u{65}\u{20}\u{28}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{64}\u{29}"))
100+end
101+assert(os.remove(file))
102+do
103+local f <close> = assert(io.open(file,"\u{77}"))
104+f:write(maxint,"\u{a}")
105+f:write(string.format("\u{30}\u{58}\u{25}\u{78}\u{a}",maxint))
106+f:write("\u{30}\u{78}\u{41}\u{42}\u{43}\u{70}\u{2d}\u{33}","\u{a}")
107+f:write(0x0,"\u{a}")
108+f:write((- maxint),"\u{a}")
109+f:write(string.format("\u{30}\u{78}\u{25}\u{58}\u{a}",(- maxint)))
110+f:write("\u{2d}\u{30}\u{78}\u{41}\u{42}\u{43}\u{70}\u{2d}\u{33}","\u{a}")
111+assert(f:close())
112+local f <close> = assert(io.open(file,"\u{72}"))
113+assert((f:read("\u{6e}") == maxint))
114+assert((f:read("\u{6e}") == maxint))
115+assert((f:read("\u{6e}") == 343.5))
116+assert((f:read("\u{6e}") == 0x0))
117+assert((f:read("\u{2a}\u{6e}") == (- maxint)))
118+assert((f:read("\u{6e}") == (- maxint)))
119+assert((f:read("\u{2a}\u{6e}") == (- 343.5)))
120+end
121+assert(os.remove(file))
122+do
123+local f <close> = assert(io.open(file,"\u{77}"))
124+f:write("\u{61}\u{20}\u{6c}\u{69}\u{6e}\u{65}\u{a}\u{61}\u{6e}\u{6f}\u{74}\u{68}\u{65}\u{72}\u{20}\u{6c}\u{69}\u{6e}\u{65}\u{a}\u{31}\u{32}\u{33}\u{34}\u{a}\u{33}\u{2e}\u{34}\u{35}\u{a}\u{6f}\u{6e}\u{65}\u{a}\u{74}\u{77}\u{6f}\u{a}\u{74}\u{68}\u{72}\u{65}\u{65}\u{a}")
125+local l1,l2,l3,l4,n1,n2,c,dummy
126+assert(f:close())
127+local f <close> = assert(io.open(file,"\u{72}"))
128+l1,l2,n1,n2,dummy=f:read("\u{6c}","\u{4c}","\u{6e}","\u{6e}")
129+assert((((((l1 == "\u{61}\u{20}\u{6c}\u{69}\u{6e}\u{65}") and (l2 == "\u{61}\u{6e}\u{6f}\u{74}\u{68}\u{65}\u{72}\u{20}\u{6c}\u{69}\u{6e}\u{65}\u{a}")) and (n1 == 0x4d2)) and (n2 == 3.45)) and (dummy == nil)))
130+assert(f:close())
131+local f <close> = assert(io.open(file,"\u{72}"))
132+l1,l2,n1,n2,c,l3,l4,dummy=f:read(0x7,"\u{6c}","\u{6e}","\u{6e}",0x1,"\u{6c}","\u{6c}")
133+assert(((((((((l1 == "\u{61}\u{20}\u{6c}\u{69}\u{6e}\u{65}\u{a}") and (l2 == "\u{61}\u{6e}\u{6f}\u{74}\u{68}\u{65}\u{72}\u{20}\u{6c}\u{69}\u{6e}\u{65}")) and (c == "\u{a}")) and (n1 == 0x4d2)) and (n2 == 3.45)) and (l3 == "\u{6f}\u{6e}\u{65}")) and (l4 == "\u{74}\u{77}\u{6f}")) and (dummy == nil)))
134+assert(f:close())
135+local f <close> = assert(io.open(file,"\u{72}"))
136+l1,n1,n2,dummy=f:read("\u{6c}","\u{6e}","\u{6e}","\u{6c}")
137+assert(((l1 == "\u{61}\u{20}\u{6c}\u{69}\u{6e}\u{65}") and (not n1)))
138+end
139+assert(os.remove(file))
140+f=assert(io.open(file,"\u{77}"))
141+f:write("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{78}\u{2c}\u{20}\u{7a}\u{20}\u{3d}\u{20}\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}\u{2e}\u{79}\u{69}\u{65}\u{6c}\u{64}\u{28}\u{31}\u{30}\u{29}\u{a}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{79}\u{20}\u{3d}\u{20}\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}\u{2e}\u{79}\u{69}\u{65}\u{6c}\u{64}\u{28}\u{32}\u{30}\u{29}\u{a}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{78}\u{20}\u{2b}\u{20}\u{79}\u{20}\u{2a}\u{20}\u{7a}\u{a}")
142+assert(f:close())
143+f=coroutine.wrap(dofile)
144+assert((f(file) == 0xa))
145+assert((f(0x64,0x65) == 0x14))
146+assert((f(0xc8) == (0x64 + (0xc8 * 0x65))))
147+assert(os.remove(file))
148+f=assert(io.open(file,"\u{77}"))
149+f:write("\u{2d}\u{31}\u{32}\u{2e}\u{33}\u{2d}\u{9}\u{2d}\u{30}\u{78}\u{66}\u{66}\u{66}\u{66}\u{2b}\u{20}\u{20}\u{2e}\u{33}\u{7c}\u{35}\u{2e}\u{45}\u{2d}\u{33}\u{58}\u{20}\u{20}\u{2b}\u{32}\u{33}\u{34}\u{65}\u{2b}\u{31}\u{33}\u{45}\u{20}\u{30}\u{78}\u{44}\u{45}\u{41}\u{44}\u{42}\u{45}\u{45}\u{46}\u{44}\u{45}\u{41}\u{44}\u{42}\u{45}\u{45}\u{46}\u{78}\u{a}\u{30}\u{78}\u{31}\u{2e}\u{31}\u{33}\u{41}\u{70}\u{2b}\u{33}\u{65}\u{a}")
150+f:write("\u{31}\u{32}\u{33}\u{34}")
151+;
152+for i = 0x1, 0x3e8
153+do
154+f:write("\u{30}")
155+end
156+;
157+f:write("\u{a}")
158+f:write("\u{2e}\u{65}\u{2b}\u{9}\u{30}\u{2e}\u{65}\u{3b}\u{9}\u{2d}\u{2d}\u{3b}\u{20}\u{20}\u{30}\u{78}\u{58}\u{3b}\u{a}")
159+assert(f:close())
160+f=assert(io.open(file,"\u{72}"))
161+assert((f:read("\u{6e}") == (- 12.3)))
162+;
163+assert((f:read(0x1) == "\u{2d}"))
164+assert((f:read("\u{6e}") == (- 0xffff)))
165+;
166+assert((f:read(0x2) == "\u{2b}\u{20}"))
167+assert((f:read("\u{6e}") == 0.3))
168+;
169+assert((f:read(0x1) == "\u{7c}"))
170+assert((f:read("\u{6e}") == 5e-3))
171+;
172+assert((f:read(0x1) == "\u{58}"))
173+assert((f:read("\u{6e}") == 2.34e15))
174+;
175+assert((f:read(0x1) == "\u{45}"))
176+assert((f:read("\u{6e}") == 0xdeadbeefdeadbeef))
177+;
178+assert((f:read(0x2) == "\u{78}\u{a}"))
179+assert((f:read("\u{6e}") == 8.61328125))
180+;
181+assert((f:read(0x1) == "\u{65}"))
182+do
183+assert((not f:read("\u{6e}")))
184+local s = f:read("\u{4c}")
185+assert(string.find(s,"\u{5e}\u{30}\u{30}\u{2a}\u{a}\u{24}"))
186+end
187+assert((not f:read("\u{6e}")))
188+;
189+assert((f:read(0x2) == "\u{65}\u{2b}"))
190+assert((not f:read("\u{6e}")))
191+;
192+assert((f:read(0x1) == "\u{3b}"))
193+assert((not f:read("\u{6e}")))
194+;
195+assert((f:read(0x2) == "\u{2d}\u{3b}"))
196+assert((not f:read("\u{6e}")))
197+;
198+assert((f:read(0x1) == "\u{58}"))
199+assert((not f:read("\u{6e}")))
200+;
201+assert((f:read(0x1) == "\u{3b}"))
202+assert((not f:read("\u{6e}")))
203+;
204+assert((not f:read(0x0)))
205+assert(f:close())
206+assert(os.remove(file))
207+assert((not pcall(io.lines,"\u{6e}\u{6f}\u{6e}\u{2d}\u{65}\u{78}\u{69}\u{73}\u{74}\u{65}\u{6e}\u{74}\u{2d}\u{66}\u{69}\u{6c}\u{65}")))
208+assert(os.rename(otherfile,file))
209+io.output(otherfile)
210+local n = 0x0
211+local f = io.lines(file)
212+while f() do
213+n=(n + 0x1)
214+end
215+;
216+assert((n == 0x6))
217+checkerr("\u{66}\u{69}\u{6c}\u{65}\u{20}\u{69}\u{73}\u{20}\u{61}\u{6c}\u{72}\u{65}\u{61}\u{64}\u{79}\u{20}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{64}",f)
218+checkerr("\u{66}\u{69}\u{6c}\u{65}\u{20}\u{69}\u{73}\u{20}\u{61}\u{6c}\u{72}\u{65}\u{61}\u{64}\u{79}\u{20}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{64}",f)
219+n=0x0
220+for l in io.lines(file)
221+do
222+io.write(l,"\u{a}")
223+;
224+n=(n + 0x1)
225+end
226+io.close()
227+assert((n == 0x6))
228+local f = assert(io.open(otherfile))
229+assert((io.type(f) == "\u{66}\u{69}\u{6c}\u{65}"))
230+io.output(file)
231+assert((not io.output():read()))
232+n=0x0
233+for l in f:lines()
234+do
235+io.write(l,"\u{a}")
236+;
237+n=(n + 0x1)
238+end
239+assert((tostring(f):sub(0x1,0x5) == "\u{66}\u{69}\u{6c}\u{65}\u{20}"))
240+assert(f:close())
241+;
242+io.close()
243+assert((n == 0x6))
244+checkerr("\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{64}\u{20}\u{66}\u{69}\u{6c}\u{65}",io.close,f)
245+assert((tostring(f) == "\u{66}\u{69}\u{6c}\u{65}\u{20}\u{28}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{64}\u{29}"))
246+assert((io.type(f) == "\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{64}\u{20}\u{66}\u{69}\u{6c}\u{65}"))
247+io.input(file)
248+f=io.open(otherfile):lines()
249+n=0x0
250+for l in io.lines()
251+do
252+assert((l == f()))
253+;
254+n=(n + 0x1)
255+end
256+f=nil
257+;
258+collectgarbage()
259+assert((n == 0x6))
260+assert(os.remove(otherfile))
261+do
262+io.output(otherfile)
263+io.write(string.rep("\u{61}",0x12c),"\u{a}")
264+io.close()
265+local t = {}
266+;
267+for i = 0x1, 0xfa
268+do
269+t[i]=0x1
270+end
271+t={io.lines(otherfile,table.unpack(t))()}
272+assert((# (((t == 0xfa) and (t[0x1] == "\u{61}")) and (t[(# t)] == "\u{61}"))))
273+t[(# (t + 0x1))]=0x1
274+checkerr("\u{74}\u{6f}\u{6f}\u{20}\u{6d}\u{61}\u{6e}\u{79}\u{20}\u{61}\u{72}\u{67}\u{75}\u{6d}\u{65}\u{6e}\u{74}\u{73}",io.lines,otherfile,table.unpack(t))
275+collectgarbage()
276+assert(os.remove(otherfile))
277+end
278+io.input(file)
279+do
280+local a,b,c = io.input():write("\u{78}\u{75}\u{78}\u{75}")
281+assert((not ((a and (type(b) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}")) and (type(c) == "\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}"))))
282+end
283+checkerr("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{66}\u{6f}\u{72}\u{6d}\u{61}\u{74}",io.read,"\u{78}")
284+assert((io.read(0x0) == ""))
285+assert((io.read(0x5,"\u{6c}") == "\u{22}\u{61}\u{6c}\u{6f}\u{22}"))
286+assert((io.read(0x0) == ""))
287+assert((io.read() == "\u{73}\u{65}\u{63}\u{6f}\u{6e}\u{64}\u{20}\u{6c}\u{69}\u{6e}\u{65}"))
288+local x = io.input():seek()
289+assert((io.read() == "\u{74}\u{68}\u{69}\u{72}\u{64}\u{20}\u{6c}\u{69}\u{6e}\u{65}\u{20}"))
290+assert(io.input():seek("\u{73}\u{65}\u{74}",x))
291+assert((io.read("\u{4c}") == "\u{74}\u{68}\u{69}\u{72}\u{64}\u{20}\u{6c}\u{69}\u{6e}\u{65}\u{20}\u{a}"))
292+assert((io.read(0x1) == "\u{58}"))
293+assert((io.read(string.len("\u{66}\u{6f}\u{75}\u{72}\u{74}\u{68}\u{5f}\u{6c}\u{69}\u{6e}\u{65}")) == "\u{66}\u{6f}\u{75}\u{72}\u{74}\u{68}\u{5f}\u{6c}\u{69}\u{6e}\u{65}"))
294+assert(io.input():seek("\u{63}\u{75}\u{72}",(- string.len("\u{66}\u{6f}\u{75}\u{72}\u{74}\u{68}\u{5f}\u{6c}\u{69}\u{6e}\u{65}"))))
295+assert((io.read() == "\u{66}\u{6f}\u{75}\u{72}\u{74}\u{68}\u{5f}\u{6c}\u{69}\u{6e}\u{65}"))
296+assert((io.read() == ""))
297+assert((io.read("\u{6e}") == 0xd7a))
298+assert((io.read(0x1) == "\u{a}"))
299+assert((not io.read(0x0)))
300+assert((not io.read(0x1)))
301+assert((not io.read(0x7530)))
302+assert((({io.read(0x1)})[0x2] == undef))
303+assert((not io.read()))
304+assert((({io.read()})[0x2] == undef))
305+assert((not io.read("\u{6e}")))
306+assert((({io.read("\u{6e}")})[0x2] == undef))
307+assert((io.read("\u{61}") == ""))
308+assert((io.read("\u{61}") == ""))
309+collectgarbage()
310+print("\u{2b}")
311+io.close(io.input())
312+checkerr("\u{20}\u{69}\u{6e}\u{70}\u{75}\u{74}\u{20}\u{66}\u{69}\u{6c}\u{65}\u{20}\u{69}\u{73}\u{20}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{64}",io.read)
313+assert(os.remove(file))
314+local t = "\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}"
315+for i = 0x1, 0xa
316+do
317+t=(t .. t)
318+;
319+end
320+assert((string.len(t) == (0xa * (0x2 ^ 0xa))))
321+io.output(file)
322+io.write("\u{61}\u{6c}\u{6f}"):write("\u{a}")
323+io.close()
324+checkerr("\u{20}\u{6f}\u{75}\u{74}\u{70}\u{75}\u{74}\u{20}\u{66}\u{69}\u{6c}\u{65}\u{20}\u{69}\u{73}\u{20}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{64}",io.write)
325+local f = io.open(file,"\u{61}\u{2b}\u{62}")
326+io.output(f)
327+collectgarbage()
328+assert(io.write(("\u{20}" .. (t .. "\u{20}"))))
329+assert(io.write("\u{3b}","\u{65}\u{6e}\u{64}\u{20}\u{6f}\u{66}\u{20}\u{66}\u{69}\u{6c}\u{65}\u{a}"))
330+f:flush()
331+;
332+io.flush()
333+f:close()
334+print("\u{2b}")
335+io.input(file)
336+assert((io.read() == "\u{61}\u{6c}\u{6f}"))
337+assert((io.read(0x1) == "\u{20}"))
338+assert((io.read(string.len(t)) == t))
339+assert((io.read(0x1) == "\u{20}"))
340+assert(io.read(0x0))
341+assert((io.read("\u{61}") == "\u{3b}\u{65}\u{6e}\u{64}\u{20}\u{6f}\u{66}\u{20}\u{66}\u{69}\u{6c}\u{65}\u{a}"))
342+assert((not io.read(0x0)))
343+assert(io.close(io.input()))
344+do
345+local function ismsg
346+(m)
347+return ((type(m) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}") and (not tonumber(m)))
348+end
349+local f = io.open(file,"\u{77}")
350+local r,m,c = f:read()
351+assert((not ((r and ismsg(m)) and (type(c) == "\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}"))))
352+assert(f:close())
353+f=io.open(file,"\u{72}")
354+r,m,c=f:write("\u{77}\u{68}\u{61}\u{74}\u{65}\u{76}\u{65}\u{72}")
355+assert((not ((r and ismsg(m)) and (type(c) == "\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}"))))
356+assert(f:close())
357+f=io.open(file,"\u{77}")
358+r,m=pcall(f:lines())
359+assert(((r == false) and ismsg(m)))
360+assert(f:close())
361+end
362+assert(os.remove(file))
363+io.output(file)
364+;
365+io.write("\u{a}\u{a}\u{6c}\u{69}\u{6e}\u{65}\u{a}\u{6f}\u{74}\u{68}\u{65}\u{72}"):close()
366+io.input(file)
367+assert((io.read("\u{4c}") == "\u{a}"))
368+assert((io.read("\u{4c}") == "\u{a}"))
369+assert((io.read("\u{4c}") == "\u{6c}\u{69}\u{6e}\u{65}\u{a}"))
370+assert((io.read("\u{4c}") == "\u{6f}\u{74}\u{68}\u{65}\u{72}"))
371+assert((not io.read("\u{4c}")))
372+io.input():close()
373+local f = assert(io.open(file))
374+local s = ""
375+for l in f:lines("\u{4c}")
376+do
377+s=(s .. l)
378+end
379+assert((s == "\u{a}\u{a}\u{6c}\u{69}\u{6e}\u{65}\u{a}\u{6f}\u{74}\u{68}\u{65}\u{72}"))
380+f:close()
381+io.input(file)
382+s=""
383+for l in io.lines(nil,"\u{4c}")
384+do
385+s=(s .. l)
386+end
387+assert((s == "\u{a}\u{a}\u{6c}\u{69}\u{6e}\u{65}\u{a}\u{6f}\u{74}\u{68}\u{65}\u{72}"))
388+io.input():close()
389+s=""
390+for l in io.lines(file,"\u{4c}")
391+do
392+s=(s .. l)
393+end
394+assert((s == "\u{a}\u{a}\u{6c}\u{69}\u{6e}\u{65}\u{a}\u{6f}\u{74}\u{68}\u{65}\u{72}"))
395+s=""
396+for l in io.lines(file,"\u{6c}")
397+do
398+s=(s .. l)
399+end
400+assert((s == "\u{6c}\u{69}\u{6e}\u{65}\u{6f}\u{74}\u{68}\u{65}\u{72}"))
401+io.output(file)
402+;
403+io.write("\u{61}\u{20}\u{3d}\u{20}\u{31}\u{30}\u{20}\u{2b}\u{20}\u{33}\u{34}\u{a}\u{61}\u{20}\u{3d}\u{20}\u{32}\u{2a}\u{61}\u{a}\u{61}\u{20}\u{3d}\u{20}\u{2d}\u{61}\u{a}"):close()
404+local t = {}
405+assert(load(io.lines(file,"\u{4c}"),nil,nil,t))()
406+assert((t.a == (- ((0xa + 0x22) * 0x2))))
407+do
408+local function gettoclose
409+(lv)
410+lv=(lv + 0x1)
411+local stvar = 0x0
412+for i = 0x1, 0x3e8
413+do
414+local n,v = debug.getlocal(lv,i)
415+if (n == "\u{28}\u{66}\u{6f}\u{72}\u{20}\u{73}\u{74}\u{61}\u{74}\u{65}\u{29}") then
416+stvar=(stvar + 0x1)
417+if (stvar == 0x4) then
418+return v
419+end
420+end
421+end
422+end
423+local f
424+for l in io.lines(file)
425+do
426+f=gettoclose(0x1)
427+assert((io.type(f) == "\u{66}\u{69}\u{6c}\u{65}"))
428+break
429+end
430+assert((io.type(f) == "\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{64}\u{20}\u{66}\u{69}\u{6c}\u{65}"))
431+f=nil
432+local function foo
433+(name)
434+for l in io.lines(name)
435+do
436+f=gettoclose(0x1)
437+assert((io.type(f) == "\u{66}\u{69}\u{6c}\u{65}"))
438+error(f)
439+end
440+end
441+local st,msg = pcall(foo,file)
442+assert(((st == false) and (io.type(msg) == "\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{64}\u{20}\u{66}\u{69}\u{6c}\u{65}")))
443+end
444+io.output(file)
445+;
446+io.write("\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}"):close()
447+for a,b in io.lines(file,0x1,0x1)
448+do
449+if (a == "\u{a}") then
450+assert((not b))
451+else
452+assert((tonumber(a) == (tonumber(b) - 0x1)))
453+end
454+end
455+for a,b,c in io.lines(file,0x1,0x2,"\u{61}")
456+do
457+assert((((a == "\u{30}") and (b == "\u{31}\u{32}")) and (c == "\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}")))
458+end
459+for a,b,c in io.lines(file,"\u{61}",0x0,0x1)
460+do
461+if (a == "") then
462+break
463+end
464+assert(((a == "\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}") and (not (b and (not c)))))
465+end
466+collectgarbage()
467+io.output(file)
468+;
469+io.write("\u{30}\u{30}\u{a}\u{31}\u{30}\u{a}\u{32}\u{30}\u{a}\u{33}\u{30}\u{a}\u{34}\u{30}\u{a}"):close()
470+for a,b in io.lines(file,"\u{6e}","\u{6e}")
471+do
472+if (a == 0x28) then
473+assert((not b))
474+else
475+assert((a == (b - 0xa)))
476+end
477+end
478+io.output(file)
479+;
480+io.write("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{79}\u{a}\u{3d}\u{20}\u{58}\u{a}\u{58}\u{20}\u{3d}\u{a}\u{58}\u{20}\u{2a}\u{a}\u{32}\u{20}\u{2b}\u{a}\u{58}\u{3b}\u{a}\u{58}\u{20}\u{3d}\u{a}\u{58}\u{a}\u{2d}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{79}\u{3b}\u{a}"):close()
481+_G.X=0x1
482+assert((not load(io.lines(file))))
483+collectgarbage()
484+load(io.lines(file,"\u{4c}"))()
485+assert((_G.X == 0x2))
486+load(io.lines(file,0x1))()
487+assert((_G.X == 0x4))
488+load(io.lines(file,0x3))()
489+assert((_G.X == 0x8))
490+_G.X=nil
491+print("\u{2b}")
492+local x1 = "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{a}\u{a}\u{5c}\u{63}\u{6f}\u{6d}\u{20}\u{22}\u{22}\u{27}\u{27}\u{63}\u{6f}\u{69}\u{73}\u{61}\u{73}\u{20}\u{5b}\u{5b}\u{65}\u{73}\u{74}\u{72}\u{61}\u{6e}\u{68}\u{61}\u{73}\u{5d}\u{5d}\u{20}\u{5d}\u{5d}\u{27}"
493+io.output(file)
494+assert(io.write(string.format("\u{58}\u{32}\u{20}\u{3d}\u{20}\u{25}\u{71}\u{a}\u{2d}\u{2d}\u{20}\u{63}\u{6f}\u{6d}\u{6d}\u{65}\u{6e}\u{74}\u{20}\u{77}\u{69}\u{74}\u{68}\u{6f}\u{75}\u{74}\u{20}\u{65}\u{6e}\u{64}\u{69}\u{6e}\u{67}\u{20}\u{45}\u{4f}\u{53}",x1)))
495+io.close()
496+assert(loadfile(file))()
497+assert((x1 == _G.X2))
498+_G.X2=nil
499+print("\u{2b}")
500+assert(os.remove(file))
501+assert((not os.remove(file)))
502+assert((not os.remove(otherfile)))
503+local function testloadfile
504+(s,expres)
505+io.output(file)
506+if s then
507+io.write(s)
508+end
509+io.close()
510+local res = assert(loadfile(file))()
511+assert(os.remove(file))
512+assert((res == expres))
513+end
514+testloadfile(nil,nil)
515+testloadfile("\u{23}\u{20}\u{61}\u{20}\u{6e}\u{6f}\u{6e}\u{2d}\u{65}\u{6e}\u{64}\u{69}\u{6e}\u{67}\u{20}\u{63}\u{6f}\u{6d}\u{6d}\u{65}\u{6e}\u{74}",nil)
516+testloadfile("\u{ef}\u{bb}\u{bf}\u{23}\u{20}\u{73}\u{6f}\u{6d}\u{65}\u{20}\u{63}\u{6f}\u{6d}\u{6d}\u{65}\u{6e}\u{74}\u{a}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}\u{33}\u{34}",0xea)
517+testloadfile("\u{ef}\u{bb}\u{bf}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}\u{33}\u{39}",0xef)
518+testloadfile("\u{ef}\u{bb}\u{bf}",nil)
519+testloadfile("\u{23}\u{20}\u{61}\u{20}\u{63}\u{6f}\u{6d}\u{6d}\u{65}\u{6e}\u{74}\u{a}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{72}\u{65}\u{71}\u{75}\u{69}\u{72}\u{65}\u{27}\u{64}\u{65}\u{62}\u{75}\u{67}\u{27}\u{2e}\u{67}\u{65}\u{74}\u{69}\u{6e}\u{66}\u{6f}\u{28}\u{31}\u{29}\u{2e}\u{63}\u{75}\u{72}\u{72}\u{65}\u{6e}\u{74}\u{6c}\u{69}\u{6e}\u{65}",0x2)
520+io.output(io.open(file,"\u{77}\u{62}"))
521+assert(io.write(string.dump(function ()
522+return 0xa,"\u{0}\u{61}\u{6c}\u{6f}\u{ff}","\u{68}\u{69}"
523+end)))
524+io.close()
525+a,b,c=assert(loadfile(file))()
526+assert((((a == 0xa) and (b == "\u{0}\u{61}\u{6c}\u{6f}\u{ff}")) and (c == "\u{68}\u{69}")))
527+assert(os.remove(file))
528+do
529+io.output(io.open(file,"\u{77}\u{62}"))
530+assert(io.write(string.dump(function ()
531+return 0x1
532+end)))
533+io.close()
534+f=assert(loadfile(file,"\u{62}",{}))
535+assert(((type(f) == "\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}") and (f() == 0x1)))
536+assert(os.remove(file))
537+end
538+io.output(io.open(file,"\u{77}\u{62}"))
539+assert(io.write("\u{23}\u{74}\u{68}\u{69}\u{73}\u{20}\u{69}\u{73}\u{20}\u{61}\u{20}\u{63}\u{6f}\u{6d}\u{6d}\u{65}\u{6e}\u{74}\u{20}\u{66}\u{6f}\u{72}\u{20}\u{61}\u{20}\u{62}\u{69}\u{6e}\u{61}\u{72}\u{79}\u{20}\u{66}\u{69}\u{6c}\u{65}\u{0}\u{a}",string.dump(function ()
540+return 0x14,"\u{0}\u{0}\u{0}"
541+end)))
542+io.close()
543+a,b,c=assert(loadfile(file))()
544+assert((((a == 0x14) and (b == "\u{0}\u{0}\u{0}")) and (c == nil)))
545+assert(os.remove(file))
546+do
547+local f = io.open(file,"\u{77}")
548+f:write("\u{20}\u{20}\u{20}\u{20}\u{69}\u{66}\u{20}\u{28}\u{2e}\u{2e}\u{2e}\u{29}\u{20}\u{74}\u{68}\u{65}\u{6e}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{31}\u{35}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{62}\u{2c}\u{20}\u{63}\u{2c}\u{20}\u{64}\u{a}\u{20}\u{20}\u{20}\u{20}\u{65}\u{6c}\u{73}\u{65}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{5f}\u{45}\u{4e}\u{56}\u{a}\u{20}\u{20}\u{20}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{20}\u{20}")
549+f:close()
550+local t = {["\u{62}"] = 0xc,["\u{63}"] = "\u{78}\u{75}\u{78}\u{75}",["\u{64}"] = print}
551+local f = assert(loadfile(file,"\u{74}",t))
552+local b,c,d = f(0x1)
553+assert(((((t.a == 0xf) and (b == 0xc)) and (c == t.c)) and (d == print)))
554+assert((f() == t))
555+f=assert(loadfile(file,"\u{74}",nil))
556+assert((f() == nil))
557+f=assert(loadfile(file))
558+assert((f() == _G))
559+assert(os.remove(file))
560+end
561+do
562+io.open(file,"\u{77}"):write("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}\u{30}"):close()
563+local s,m = loadfile(file,"\u{62}")
564+assert((not (s and string.find(m,"\u{61}\u{20}\u{74}\u{65}\u{78}\u{74}\u{20}\u{63}\u{68}\u{75}\u{6e}\u{6b}"))))
565+io.open(file,"\u{77}"):write("\u{1b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}\u{30}"):close()
566+local s,m = loadfile(file,"\u{74}")
567+assert((not (s and string.find(m,"\u{61}\u{20}\u{62}\u{69}\u{6e}\u{61}\u{72}\u{79}\u{20}\u{63}\u{68}\u{75}\u{6e}\u{6b}"))))
568+assert(os.remove(file))
569+end
570+io.output(file)
571+assert(io.write("\u{71}\u{75}\u{61}\u{6c}\u{71}\u{75}\u{65}\u{72}\u{20}\u{63}\u{6f}\u{69}\u{73}\u{61}\u{a}"))
572+assert(io.write("\u{6d}\u{61}\u{69}\u{73}\u{20}\u{71}\u{75}\u{61}\u{6c}\u{71}\u{75}\u{65}\u{72}\u{20}\u{63}\u{6f}\u{69}\u{73}\u{61}"))
573+io.close()
574+assert(io.output(assert(io.open(otherfile,"\u{77}\u{62}"))):write("\u{6f}\u{75}\u{74}\u{72}\u{61}\u{20}\u{63}\u{6f}\u{69}\u{73}\u{61}\u{0}\u{1}\u{3}\u{0}\u{0}\u{0}\u{0}\u{ff}\u{0}"):close())
575+local filehandle = assert(io.open(file,"\u{72}\u{2b}"))
576+local otherfilehandle = assert(io.open(otherfile,"\u{72}\u{62}"))
577+assert((filehandle ~= otherfilehandle))
578+assert((type(filehandle) == "\u{75}\u{73}\u{65}\u{72}\u{64}\u{61}\u{74}\u{61}"))
579+assert((filehandle:read("\u{6c}") == "\u{71}\u{75}\u{61}\u{6c}\u{71}\u{75}\u{65}\u{72}\u{20}\u{63}\u{6f}\u{69}\u{73}\u{61}"))
580+io.input(otherfilehandle)
581+assert((io.read(string.len("\u{6f}\u{75}\u{74}\u{72}\u{61}\u{20}\u{63}\u{6f}\u{69}\u{73}\u{61}")) == "\u{6f}\u{75}\u{74}\u{72}\u{61}\u{20}\u{63}\u{6f}\u{69}\u{73}\u{61}"))
582+assert((filehandle:read("\u{6c}") == "\u{6d}\u{61}\u{69}\u{73}\u{20}\u{71}\u{75}\u{61}\u{6c}\u{71}\u{75}\u{65}\u{72}\u{20}\u{63}\u{6f}\u{69}\u{73}\u{61}"))
583+filehandle:close()
584+;
585+assert((type(filehandle) == "\u{75}\u{73}\u{65}\u{72}\u{64}\u{61}\u{74}\u{61}"))
586+io.input(otherfilehandle)
587+assert((io.read(0x4) == "\u{0}\u{1}\u{3}\u{0}"))
588+assert((io.read(0x3) == "\u{0}\u{0}\u{0}"))
589+assert((io.read(0x0) == ""))
590+assert((io.read(0x1) == "\u{ff}"))
591+assert((io.read("\u{61}") == "\u{0}"))
592+assert((not io.read(0x0)))
593+assert((otherfilehandle == io.input()))
594+otherfilehandle:close()
595+assert(os.remove(file))
596+assert(os.remove(otherfile))
597+collectgarbage()
598+io.output(file):write("\u{20}\u{31}\u{32}\u{33}\u{2e}\u{34}\u{9}\u{2d}\u{35}\u{36}\u{65}\u{2d}\u{32}\u{20}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{61}\u{20}\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}\u{a}\u{73}\u{65}\u{63}\u{6f}\u{6e}\u{64}\u{20}\u{6c}\u{69}\u{6e}\u{65}\u{a}\u{74}\u{68}\u{69}\u{72}\u{64}\u{20}\u{6c}\u{69}\u{6e}\u{65}\u{a}\u{a}\u{61}\u{6e}\u{64}\u{20}\u{74}\u{68}\u{65}\u{20}\u{72}\u{65}\u{73}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{74}\u{68}\u{65}\u{20}\u{66}\u{69}\u{6c}\u{65}\u{a}"):close()
599+io.input(file)
600+local _,a,b,c,d,e,h,__ = io.read(0x1,"\u{6e}","\u{6e}","\u{6c}","\u{6c}","\u{6c}","\u{61}",0xa)
601+assert(io.close(io.input()))
602+assert(((_ == "\u{20}") and (not __)))
603+assert((((type(a) == "\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}") and (a == 123.4)) and (b == (- 0.56))))
604+assert(((d == "\u{73}\u{65}\u{63}\u{6f}\u{6e}\u{64}\u{20}\u{6c}\u{69}\u{6e}\u{65}") and (e == "\u{74}\u{68}\u{69}\u{72}\u{64}\u{20}\u{6c}\u{69}\u{6e}\u{65}")))
605+assert((h == "\u{a}\u{61}\u{6e}\u{64}\u{20}\u{74}\u{68}\u{65}\u{20}\u{72}\u{65}\u{73}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{74}\u{68}\u{65}\u{20}\u{66}\u{69}\u{6c}\u{65}\u{a}"))
606+assert(os.remove(file))
607+collectgarbage()
608+do
609+local f = assert(io.open(file,"\u{77}"))
610+local fr = assert(io.open(file,"\u{72}"))
611+assert(f:setvbuf("\u{66}\u{75}\u{6c}\u{6c}",0x7d0))
612+f:write("\u{78}")
613+assert((fr:read("\u{61}\u{6c}\u{6c}") == ""))
614+f:close()
615+fr:seek("\u{73}\u{65}\u{74}")
616+assert((fr:read("\u{61}\u{6c}\u{6c}") == "\u{78}"))
617+f=assert(io.open(file),"\u{77}")
618+assert(f:setvbuf("\u{6e}\u{6f}"))
619+f:write("\u{78}")
620+fr:seek("\u{73}\u{65}\u{74}")
621+assert((fr:read("\u{61}\u{6c}\u{6c}") == "\u{78}"))
622+f:close()
623+f=assert(io.open(file,"\u{61}"))
624+assert(f:setvbuf("\u{6c}\u{69}\u{6e}\u{65}"))
625+f:write("\u{78}")
626+fr:seek("\u{73}\u{65}\u{74}",0x1)
627+assert((fr:read("\u{61}\u{6c}\u{6c}") == ""))
628+f:write("\u{61}\u{a}"):seek("\u{73}\u{65}\u{74}",0x1)
629+assert((fr:read("\u{61}\u{6c}\u{6c}") == "\u{78}\u{61}\u{a}"))
630+f:close()
631+;
632+fr:close()
633+assert(os.remove(file))
634+end
635+if (not _soft) then
636+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{6c}\u{61}\u{72}\u{67}\u{65}\u{20}\u{66}\u{69}\u{6c}\u{65}\u{73}\u{20}\u{28}\u{3e}\u{20}\u{42}\u{55}\u{46}\u{53}\u{49}\u{5a}\u{29}")
637+io.output(file)
638+for i = 0x1, 0x1389
639+do
640+io.write("\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}")
641+end
642+io.write("\u{a}\u{31}\u{32}\u{33}\u{34}\u{36}"):close()
643+io.input(file)
644+local x = io.read("\u{61}")
645+io.input():seek("\u{73}\u{65}\u{74}",0x0)
646+local y = (io.read(0x7531) .. (io.read(0x3ed) .. (io.read(0x0) .. (io.read(0x1) .. io.read(0x186a3)))))
647+assert(((x == y) and (string.len(x) == ((0x1389 * 0xd) + 0x6))))
648+io.input():seek("\u{73}\u{65}\u{74}",0x0)
649+y=io.read()
650+assert((x == (y .. ("\u{a}" .. io.read()))))
651+assert((not io.read()))
652+io.close(io.input())
653+assert(os.remove(file))
654+x=nil
655+;
656+y=nil
657+end
658+if (not _port) then
659+local progname
660+do
661+local arg = (arg or ARG)
662+local i = 0x0
663+while arg[i] do
664+i=(i - 0x1)
665+end
666+progname=("\u{22}" .. (arg[(i + 0x1)] .. "\u{22}"))
667+end
668+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{70}\u{6f}\u{70}\u{65}\u{6e}\u{2f}\u{70}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{65}\u{78}\u{65}\u{63}\u{75}\u{74}\u{65}")
669+checkerr("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{6d}\u{6f}\u{64}\u{65}",io.popen,"\u{63}\u{61}\u{74}","")
670+checkerr("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{6d}\u{6f}\u{64}\u{65}",io.popen,"\u{63}\u{61}\u{74}","\u{72}\u{2b}")
671+checkerr("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{6d}\u{6f}\u{64}\u{65}",io.popen,"\u{63}\u{61}\u{74}","\u{72}\u{77}")
672+do
673+local file = os.tmpname()
674+local f = assert(io.popen(("\u{63}\u{61}\u{74}\u{20}\u{2d}\u{20}\u{3e}\u{20}" .. file),"\u{77}"))
675+f:write("\u{61}\u{20}\u{6c}\u{69}\u{6e}\u{65}")
676+assert(f:close())
677+local f = assert(io.popen(("\u{63}\u{61}\u{74}\u{20}\u{2d}\u{20}\u{3c}\u{20}" .. file),"\u{72}"))
678+assert((f:read("\u{61}") == "\u{61}\u{20}\u{6c}\u{69}\u{6e}\u{65}"))
679+assert(f:close())
680+assert(os.remove(file))
681+end
682+local tests = {{"\u{6c}\u{73}\u{20}\u{3e}\u{20}\u{2f}\u{64}\u{65}\u{76}\u{2f}\u{6e}\u{75}\u{6c}\u{6c}","\u{6f}\u{6b}"},{"\u{6e}\u{6f}\u{74}\u{2d}\u{74}\u{6f}\u{2d}\u{62}\u{65}\u{2d}\u{66}\u{6f}\u{75}\u{6e}\u{64}\u{2d}\u{63}\u{6f}\u{6d}\u{6d}\u{61}\u{6e}\u{64}","\u{65}\u{78}\u{69}\u{74}"},{"\u{65}\u{78}\u{69}\u{74}\u{20}\u{33}","\u{65}\u{78}\u{69}\u{74}",0x3},{"\u{65}\u{78}\u{69}\u{74}\u{20}\u{31}\u{32}\u{39}","\u{65}\u{78}\u{69}\u{74}",0x81},{"\u{6b}\u{69}\u{6c}\u{6c}\u{20}\u{2d}\u{73}\u{20}\u{48}\u{55}\u{50}\u{20}\u{24}\u{24}","\u{73}\u{69}\u{67}\u{6e}\u{61}\u{6c}",0x1},{"\u{6b}\u{69}\u{6c}\u{6c}\u{20}\u{2d}\u{73}\u{20}\u{4b}\u{49}\u{4c}\u{4c}\u{20}\u{24}\u{24}","\u{73}\u{69}\u{67}\u{6e}\u{61}\u{6c}",0x9},{"\u{73}\u{68}\u{20}\u{2d}\u{63}\u{20}\u{27}\u{6b}\u{69}\u{6c}\u{6c}\u{20}\u{2d}\u{73}\u{20}\u{48}\u{55}\u{50}\u{20}\u{24}\u{24}\u{27}","\u{65}\u{78}\u{69}\u{74}"},{(progname .. "\u{20}\u{2d}\u{65}\u{20}\u{22}\u{20}\u{22}"),"\u{6f}\u{6b}"},{(progname .. "\u{20}\u{2d}\u{65}\u{20}\u{22}\u{6f}\u{73}\u{2e}\u{65}\u{78}\u{69}\u{74}\u{28}\u{30}\u{2c}\u{20}\u{74}\u{72}\u{75}\u{65}\u{29}\u{22}"),"\u{6f}\u{6b}"},{(progname .. "\u{20}\u{2d}\u{65}\u{20}\u{22}\u{6f}\u{73}\u{2e}\u{65}\u{78}\u{69}\u{74}\u{28}\u{32}\u{30}\u{2c}\u{20}\u{74}\u{72}\u{75}\u{65}\u{29}\u{22}"),"\u{65}\u{78}\u{69}\u{74}",0x14}}
683+print("\u{a}\u{28}\u{73}\u{6f}\u{6d}\u{65}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{20}\u{6d}\u{65}\u{73}\u{73}\u{61}\u{67}\u{65}\u{73}\u{20}\u{61}\u{72}\u{65}\u{20}\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}\u{20}\u{6e}\u{6f}\u{77}\u{29}")
684+for _,v in ipairs(tests)
685+do
686+local x,y,z = io.popen(v[0x1]):close()
687+local x1,y1,z1 = os.execute(v[0x1])
688+assert((((x == x1) and (y == y1)) and (z == z1)))
689+if (v[0x2] == "\u{6f}\u{6b}") then
690+assert(((x and (y == "\u{65}\u{78}\u{69}\u{74}")) and (z == 0x0)))
691+else
692+assert((not (x and (y == v[0x2]))))
693+assert((((v[0x3] == nil) and (z > 0x0)) or (v[0x3] == z)))
694+end
695+end
696+end
697+f=io.tmpfile()
698+assert((io.type(f) == "\u{66}\u{69}\u{6c}\u{65}"))
699+f:write("\u{61}\u{6c}\u{6f}")
700+f:seek("\u{73}\u{65}\u{74}")
701+assert((f:read("\u{61}") == "\u{61}\u{6c}\u{6f}"))
702+end
703+print("\u{2b}")
704+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{64}\u{61}\u{74}\u{65}\u{2f}\u{74}\u{69}\u{6d}\u{65}")
705+assert((os.date("") == ""))
706+assert((os.date("\u{21}") == ""))
707+assert((os.date("\u{0}\u{0}") == "\u{0}\u{0}"))
708+assert((os.date("\u{21}\u{0}\u{0}") == "\u{0}\u{0}"))
709+local x = string.rep("\u{61}",0x2710)
710+assert((os.date(x) == x))
711+local t = os.time()
712+D=os.date("\u{2a}\u{74}",t)
713+assert((os.date(string.rep("\u{25}\u{64}",0x3e8),t) == string.rep(os.date("\u{25}\u{64}",t),0x3e8)))
714+assert((os.date(string.rep("\u{25}",0xc8)) == string.rep("\u{25}",0x64)))
715+local function checkDateTable
716+(t)
717+_G.D=os.date("\u{2a}\u{74}",t)
718+assert((os.time(D) == t))
719+load(os.date("\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{44}\u{2e}\u{79}\u{65}\u{61}\u{72}\u{3d}\u{3d}\u{25}\u{59}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{44}\u{2e}\u{6d}\u{6f}\u{6e}\u{74}\u{68}\u{3d}\u{3d}\u{25}\u{6d}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{44}\u{2e}\u{64}\u{61}\u{79}\u{3d}\u{3d}\u{25}\u{64}\u{20}\u{61}\u{6e}\u{64}\u{a}\u{20}\u{20}\u{20}\u{20}\u{44}\u{2e}\u{68}\u{6f}\u{75}\u{72}\u{3d}\u{3d}\u{25}\u{48}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{44}\u{2e}\u{6d}\u{69}\u{6e}\u{3d}\u{3d}\u{25}\u{4d}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{44}\u{2e}\u{73}\u{65}\u{63}\u{3d}\u{3d}\u{25}\u{53}\u{20}\u{61}\u{6e}\u{64}\u{a}\u{20}\u{20}\u{20}\u{20}\u{44}\u{2e}\u{77}\u{64}\u{61}\u{79}\u{3d}\u{3d}\u{25}\u{77}\u{2b}\u{31}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{44}\u{2e}\u{79}\u{64}\u{61}\u{79}\u{3d}\u{3d}\u{25}\u{6a}\u{29}",t))()
720+_G.D=nil
721+end
722+checkDateTable(os.time())
723+if (not _port) then
724+checkDateTable(0x0)
725+checkDateTable(0x1)
726+checkDateTable(0x3e8)
727+checkDateTable(0x7fffffff)
728+checkDateTable(0x80000000)
729+end
730+checkerr("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{63}\u{6f}\u{6e}\u{76}\u{65}\u{72}\u{73}\u{69}\u{6f}\u{6e}\u{20}\u{73}\u{70}\u{65}\u{63}\u{69}\u{66}\u{69}\u{65}\u{72}",os.date,"\u{25}")
731+checkerr("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{63}\u{6f}\u{6e}\u{76}\u{65}\u{72}\u{73}\u{69}\u{6f}\u{6e}\u{20}\u{73}\u{70}\u{65}\u{63}\u{69}\u{66}\u{69}\u{65}\u{72}",os.date,"\u{25}\u{39}")
732+checkerr("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{63}\u{6f}\u{6e}\u{76}\u{65}\u{72}\u{73}\u{69}\u{6f}\u{6e}\u{20}\u{73}\u{70}\u{65}\u{63}\u{69}\u{66}\u{69}\u{65}\u{72}",os.date,"\u{25}")
733+checkerr("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{63}\u{6f}\u{6e}\u{76}\u{65}\u{72}\u{73}\u{69}\u{6f}\u{6e}\u{20}\u{73}\u{70}\u{65}\u{63}\u{69}\u{66}\u{69}\u{65}\u{72}",os.date,"\u{25}\u{4f}")
734+checkerr("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{63}\u{6f}\u{6e}\u{76}\u{65}\u{72}\u{73}\u{69}\u{6f}\u{6e}\u{20}\u{73}\u{70}\u{65}\u{63}\u{69}\u{66}\u{69}\u{65}\u{72}",os.date,"\u{25}\u{45}")
735+checkerr("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{63}\u{6f}\u{6e}\u{76}\u{65}\u{72}\u{73}\u{69}\u{6f}\u{6e}\u{20}\u{73}\u{70}\u{65}\u{63}\u{69}\u{66}\u{69}\u{65}\u{72}",os.date,"\u{25}\u{45}\u{61}")
736+checkerr("\u{6e}\u{6f}\u{74}\u{20}\u{61}\u{6e}\u{20}\u{69}\u{6e}\u{74}\u{65}\u{67}\u{65}\u{72}",os.time,{["\u{79}\u{65}\u{61}\u{72}"] = 0x3e8,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 0x1,["\u{64}\u{61}\u{79}"] = 0x1,["\u{68}\u{6f}\u{75}\u{72}"] = "\u{78}"})
737+checkerr("\u{6e}\u{6f}\u{74}\u{20}\u{61}\u{6e}\u{20}\u{69}\u{6e}\u{74}\u{65}\u{67}\u{65}\u{72}",os.time,{["\u{79}\u{65}\u{61}\u{72}"] = 0x3e8,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 0x1,["\u{64}\u{61}\u{79}"] = 0x1,["\u{68}\u{6f}\u{75}\u{72}"] = 1.5})
738+checkerr("\u{6d}\u{69}\u{73}\u{73}\u{69}\u{6e}\u{67}",os.time,{["\u{68}\u{6f}\u{75}\u{72}"] = 0xc})
739+if (string.packsize("\u{69}") == 0x4) then
740+checkerr("\u{66}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{27}\u{79}\u{65}\u{61}\u{72}\u{27}\u{20}\u{69}\u{73}\u{20}\u{6f}\u{75}\u{74}\u{2d}\u{6f}\u{66}\u{2d}\u{62}\u{6f}\u{75}\u{6e}\u{64}",os.time,{["\u{79}\u{65}\u{61}\u{72}"] = (- ((0x1 << 0x1f) + 0x76b)),["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 0x1,["\u{64}\u{61}\u{79}"] = 0x1})
741+checkerr("\u{66}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{27}\u{79}\u{65}\u{61}\u{72}\u{27}\u{20}\u{69}\u{73}\u{20}\u{6f}\u{75}\u{74}\u{2d}\u{6f}\u{66}\u{2d}\u{62}\u{6f}\u{75}\u{6e}\u{64}",os.time,{["\u{79}\u{65}\u{61}\u{72}"] = (- (0x1 << 0x1f)),["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 0x1,["\u{64}\u{61}\u{79}"] = 0x1})
742+if (math.maxinteger > (0x2 ^ 0x1f)) then
743+checkerr("\u{66}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{27}\u{79}\u{65}\u{61}\u{72}\u{27}\u{20}\u{69}\u{73}\u{20}\u{6f}\u{75}\u{74}\u{2d}\u{6f}\u{66}\u{2d}\u{62}\u{6f}\u{75}\u{6e}\u{64}",os.time,{["\u{79}\u{65}\u{61}\u{72}"] = ((0x1 << 0x1f) + 0x76c),["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 0x1,["\u{64}\u{61}\u{79}"] = 0x1})
744+end
745+end
746+if (not _port) then
747+assert((type(os.date("\u{25}\u{45}\u{78}")) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}"))
748+assert((type(os.date("\u{25}\u{4f}\u{79}")) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}"))
749+local t0 = os.time({["\u{79}\u{65}\u{61}\u{72}"] = 0x7b2,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 0x1,["\u{64}\u{61}\u{79}"] = 0x0})
750+local t1 = os.time({["\u{79}\u{65}\u{61}\u{72}"] = 0x7b2,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 0x1,["\u{64}\u{61}\u{79}"] = 0x0,["\u{73}\u{65}\u{63}"] = ((0x1 << 0x1f) - 0x1)})
751+assert(((t1 - t0) == ((0x1 << 0x1f) - 0x1)))
752+t0=os.time({["\u{79}\u{65}\u{61}\u{72}"] = 0x7b2,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 0x1,["\u{64}\u{61}\u{79}"] = 0x1})
753+t1=os.time({["\u{79}\u{65}\u{61}\u{72}"] = 0x7b2,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 0x1,["\u{64}\u{61}\u{79}"] = 0x1,["\u{73}\u{65}\u{63}"] = (- (0x1 << 0x1f))})
754+assert(((t1 - t0) == (- (0x1 << 0x1f))))
755+if (maxint >= (0x2 ^ 0x3e)) then
756+checkerr("\u{6f}\u{75}\u{74}\u{2d}\u{6f}\u{66}\u{2d}\u{62}\u{6f}\u{75}\u{6e}\u{64}",os.time,{["\u{79}\u{65}\u{61}\u{72}"] = (- maxint),["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 0x1,["\u{64}\u{61}\u{79}"] = 0x1})
757+if (string.packsize("\u{69}") == 0x4) then
758+if testerr("\u{6f}\u{75}\u{74}\u{2d}\u{6f}\u{66}\u{2d}\u{62}\u{6f}\u{75}\u{6e}\u{64}",os.date,"\u{25}\u{59}",(0x2 ^ 0x28)) then
759+print("\u{20}\u{20}\u{34}\u{2d}\u{62}\u{79}\u{74}\u{65}\u{20}\u{74}\u{69}\u{6d}\u{65}\u{5f}\u{74}")
760+checkerr("\u{63}\u{61}\u{6e}\u{6e}\u{6f}\u{74}\u{20}\u{62}\u{65}\u{20}\u{72}\u{65}\u{70}\u{72}\u{65}\u{73}\u{65}\u{6e}\u{74}\u{65}\u{64}",os.time,{["\u{79}\u{65}\u{61}\u{72}"] = 0xfa0,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 0x1,["\u{64}\u{61}\u{79}"] = 0x1})
761+else
762+print("\u{20}\u{20}\u{38}\u{2d}\u{62}\u{79}\u{74}\u{65}\u{20}\u{74}\u{69}\u{6d}\u{65}\u{5f}\u{74}")
763+checkerr("\u{63}\u{61}\u{6e}\u{6e}\u{6f}\u{74}\u{20}\u{62}\u{65}\u{20}\u{72}\u{65}\u{70}\u{72}\u{65}\u{73}\u{65}\u{6e}\u{74}\u{65}\u{64}",os.date,"\u{25}\u{59}",(0x2 ^ 0x3c))
764+assert(tonumber(os.time({["\u{79}\u{65}\u{61}\u{72}"] = ((0x1 << 0x1f) + 0x76b),["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 0xc,["\u{64}\u{61}\u{79}"] = 0x1f,["\u{68}\u{6f}\u{75}\u{72}"] = 0x17,["\u{6d}\u{69}\u{6e}"] = 0x3b,["\u{73}\u{65}\u{63}"] = 0x3b})))
765+checkerr("\u{72}\u{65}\u{70}\u{72}\u{65}\u{73}\u{65}\u{6e}\u{74}\u{65}\u{64}",os.time,{["\u{79}\u{65}\u{61}\u{72}"] = ((0x1 << 0x1f) + 0x76b),["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 0xc,["\u{64}\u{61}\u{79}"] = 0x1f,["\u{68}\u{6f}\u{75}\u{72}"] = 0x17,["\u{6d}\u{69}\u{6e}"] = 0x3b,["\u{73}\u{65}\u{63}"] = 0x3c})
766+end
767+checkerr("\u{66}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{27}\u{64}\u{61}\u{79}\u{27}\u{20}\u{69}\u{73}\u{20}\u{6f}\u{75}\u{74}\u{2d}\u{6f}\u{66}\u{2d}\u{62}\u{6f}\u{75}\u{6e}\u{64}",os.time,{["\u{79}\u{65}\u{61}\u{72}"] = 0x0,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 0x1,["\u{64}\u{61}\u{79}"] = (0x2 ^ 0x20)})
768+checkerr("\u{66}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{27}\u{6d}\u{6f}\u{6e}\u{74}\u{68}\u{27}\u{20}\u{69}\u{73}\u{20}\u{6f}\u{75}\u{74}\u{2d}\u{6f}\u{66}\u{2d}\u{62}\u{6f}\u{75}\u{6e}\u{64}",os.time,{["\u{79}\u{65}\u{61}\u{72}"] = 0x0,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = (- ((0x1 << 0x1f) + 0x1)),["\u{64}\u{61}\u{79}"] = 0x1})
769+checkerr("\u{66}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{27}\u{79}\u{65}\u{61}\u{72}\u{27}\u{20}\u{69}\u{73}\u{20}\u{6f}\u{75}\u{74}\u{2d}\u{6f}\u{66}\u{2d}\u{62}\u{6f}\u{75}\u{6e}\u{64}",os.time,{["\u{79}\u{65}\u{61}\u{72}"] = ((0x1 << 0x1f) + 0x76c),["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 0x1,["\u{64}\u{61}\u{79}"] = 0x1})
770+else
771+print("\u{20}\u{20}\u{38}\u{2d}\u{62}\u{79}\u{74}\u{65}\u{20}\u{74}\u{69}\u{6d}\u{65}\u{5f}\u{74}")
772+assert(tonumber(os.date("\u{25}\u{59}",(0x2 ^ 0x3c))))
773+checkerr("\u{63}\u{61}\u{6e}\u{6e}\u{6f}\u{74}\u{20}\u{62}\u{65}\u{20}\u{72}\u{65}\u{70}\u{72}\u{65}\u{73}\u{65}\u{6e}\u{74}\u{65}\u{64}",os.time,{["\u{79}\u{65}\u{61}\u{72}"] = (0x2 ^ 0x3c),["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 0x1,["\u{64}\u{61}\u{79}"] = 0x1})
774+end
775+end
776+end
777+do
778+local D = os.date("\u{2a}\u{74}")
779+local t = os.time(D)
780+if (D.isdst == nil) then
781+print("\u{6e}\u{6f}\u{20}\u{64}\u{61}\u{79}\u{6c}\u{69}\u{67}\u{68}\u{74}\u{20}\u{73}\u{61}\u{76}\u{69}\u{6e}\u{67}\u{20}\u{69}\u{6e}\u{66}\u{6f}\u{72}\u{6d}\u{61}\u{74}\u{69}\u{6f}\u{6e}")
782+else
783+assert((type(D.isdst) == "\u{62}\u{6f}\u{6f}\u{6c}\u{65}\u{61}\u{6e}"))
784+end
785+D.isdst=nil
786+local t1 = os.time(D)
787+assert((t == t1))
788+end
789+local D = os.date("\u{2a}\u{74}")
790+t=os.time(D)
791+D.year=(D.year - 0x1)
792+;
793+local t1 = os.time(D)
794+assert((math.abs(((os.difftime(t,t1) / (0x18 * 0xe10)) - 0x16d)) < 0x2))
795+t=os.time()
796+t1=os.time(os.date("\u{2a}\u{74}"))
797+local diff = os.difftime(t1,t)
798+assert(((0x0 <= diff) and (diff <= 0x1)))
799+diff=os.difftime(t,t1)
800+assert((- ((0x1 <= diff) and (diff <= 0x0))))
801+local t1 = os.time({["\u{79}\u{65}\u{61}\u{72}"] = 0x7d0,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 0xa,["\u{64}\u{61}\u{79}"] = 0x1,["\u{68}\u{6f}\u{75}\u{72}"] = 0x17,["\u{6d}\u{69}\u{6e}"] = 0xc})
802+local t2 = os.time({["\u{79}\u{65}\u{61}\u{72}"] = 0x7d0,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 0xa,["\u{64}\u{61}\u{79}"] = 0x1,["\u{68}\u{6f}\u{75}\u{72}"] = 0x17,["\u{6d}\u{69}\u{6e}"] = 0xa,["\u{73}\u{65}\u{63}"] = 0x13})
803+assert((os.difftime(t1,t2) == ((0x3c * 0x2) - 0x13)))
804+t1={["\u{79}\u{65}\u{61}\u{72}"] = 0x7d5,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 0x1,["\u{64}\u{61}\u{79}"] = 0x1,["\u{68}\u{6f}\u{75}\u{72}"] = 0x1,["\u{6d}\u{69}\u{6e}"] = 0x0,["\u{73}\u{65}\u{63}"] = (- 0xe12)}
805+os.time(t1)
806+assert((((((((t1.day == 0x1f) and (t1.month == 0xc)) and (t1.year == 0x7d4)) and (t1.hour == 0x17)) and (t1.min == 0x3b)) and (t1.sec == 0x3a)) and (t1.yday == 0x16e)))
807+io.output(io.stdout)
808+local t = os.date("\u{25}\u{64}\u{20}\u{25}\u{6d}\u{20}\u{25}\u{59}\u{20}\u{25}\u{48}\u{20}\u{25}\u{4d}\u{20}\u{25}\u{53}")
809+local d,m,a,h,min,s = string.match(t,"\u{28}\u{25}\u{64}\u{2b}\u{29}\u{20}\u{28}\u{25}\u{64}\u{2b}\u{29}\u{20}\u{28}\u{25}\u{64}\u{2b}\u{29}\u{20}\u{28}\u{25}\u{64}\u{2b}\u{29}\u{20}\u{28}\u{25}\u{64}\u{2b}\u{29}\u{20}\u{28}\u{25}\u{64}\u{2b}\u{29}")
810+d=tonumber(d)
811+m=tonumber(m)
812+a=tonumber(a)
813+h=tonumber(h)
814+min=tonumber(min)
815+s=tonumber(s)
816+io.write(string.format("\u{74}\u{65}\u{73}\u{74}\u{20}\u{64}\u{6f}\u{6e}\u{65}\u{20}\u{6f}\u{6e}\u{20}\u{25}\u{32}\u{2e}\u{32}\u{64}\u{2f}\u{25}\u{32}\u{2e}\u{32}\u{64}\u{2f}\u{25}\u{64}",d,m,a))
817+io.write(string.format("\u{2c}\u{20}\u{61}\u{74}\u{20}\u{25}\u{32}\u{2e}\u{32}\u{64}\u{3a}\u{25}\u{32}\u{2e}\u{32}\u{64}\u{3a}\u{25}\u{32}\u{2e}\u{32}\u{64}\u{a}",h,min,s))
818+io.write(string.format("\u{25}\u{73}\u{a}",_VERSION))
desk/res/lua/cycled/foo.luanew file+82
@@ -0,0 +1,82 @@
1+foosjis=nil
2+az=bar[nil]
3+baz=bar(0x1).foo
4+i=0x3
5+i,a[i]=(i + 0x1),(0x14 >> 0x9)
6+hello="\u{68}\u{65}\u{6c}\u{6c}\u{6f}\u{64}\u{6b}\u{6e}\u{64}\u{6a}\u{d0}\u{b2}\u{d0}\u{b3}\u{d0}\u{be}\u{d0}\u{b2}\u{d1}\u{88}\u{d0}\u{be}\u{d0}\u{b2}"
7+x={[hello] = 0x8,["\u{68}\u{65}\u{6c}\u{6c}\u{6f}"] = 0xc}
8+;
9+test_cases={{0x7fffffff,"\u{32}\u{31}\u{34}\u{37}\u{34}\u{38}\u{33}\u{36}\u{34}\u{37}"},{0x7fffffff,"\u{32}\u{31}\u{34}\u{37}\u{34}\u{38}\u{33}\u{36}\u{34}\u{37}"},{0xffffffff,"\u{34}\u{32}\u{39}\u{34}\u{39}\u{36}\u{37}\u{32}\u{39}\u{35}"},{0xffffffff,"\u{34}\u{32}\u{39}\u{34}\u{39}\u{36}\u{37}\u{32}\u{39}\u{35}"},{0x7fffffffffffffff,"\u{39}\u{2e}\u{32}\u{32}\u{33}\u{33}\u{37}\u{32}\u{30}\u{33}\u{36}\u{38}\u{35}\u{34}\u{38}\u{65}\u{2b}\u{31}\u{38}"},{0x7fffffffffffffff,"\u{39}\u{2e}\u{32}\u{32}\u{33}\u{33}\u{37}\u{32}\u{30}\u{33}\u{36}\u{38}\u{35}\u{34}\u{38}\u{65}\u{2b}\u{31}\u{38}"},{0x100000000,"\u{34}\u{32}\u{39}\u{34}\u{39}\u{36}\u{37}\u{32}\u{39}\u{36}"},{0x100000000,"\u{34}\u{32}\u{39}\u{34}\u{39}\u{36}\u{37}\u{32}\u{39}\u{36}"},{0x100000000000,"\u{31}\u{37}\u{35}\u{39}\u{32}\u{31}\u{38}\u{36}\u{30}\u{34}\u{34}\u{34}\u{31}\u{36}"},{0x100000000000,"\u{31}\u{37}\u{35}\u{39}\u{32}\u{31}\u{38}\u{36}\u{30}\u{34}\u{34}\u{34}\u{31}\u{36}"},{0x80000000,"\u{32}\u{31}\u{34}\u{37}\u{34}\u{38}\u{33}\u{36}\u{34}\u{38}"},{0x80000000,"\u{32}\u{31}\u{34}\u{37}\u{34}\u{38}\u{33}\u{36}\u{34}\u{38}"},{0x800000000000,"\u{31}\u{2e}\u{34}\u{30}\u{37}\u{33}\u{37}\u{34}\u{38}\u{38}\u{33}\u{35}\u{35}\u{33}\u{33}\u{65}\u{2b}\u{31}\u{34}"},{0x800000000000,"\u{31}\u{2e}\u{34}\u{30}\u{37}\u{33}\u{37}\u{34}\u{38}\u{38}\u{33}\u{35}\u{35}\u{33}\u{33}\u{65}\u{2b}\u{31}\u{34}"}}
10+::helli::
11+foo={3.0,3.1416,3.1416,3.1416,340.0,0.1171875,162.1875,162.1875,3.141592653589793,1984.0}
12+do
13+foo=0x1
14+return 0x8,foo
15+end
16+print("\u{74}\u{68}\u{65}\u{20}\u{77}\u{61}\u{79}\u{20}\u{6f}\u{66}\u{20}\u{74}\u{68}\u{65}\u{20}\u{66}\u{75}\u{74}\u{75}\u{72}\u{65}")
17+print("\u{68}\u{65}\u{6c}\u{6c}\u{6f}")
18+h({["\u{6b}\u{65}\u{79}\u{31}"] = "\u{53}\u{6f}\u{6e}\u{6d}\u{69}\u{7e}\u{34}\u{35}\u{31}"})
19+goto helli
20+break
21+while true do
22+break
23+end
24+repeat
25+do
26+foo=0x9
27+;
28+end
29+until true
30+if (l == 0x3) then
31+a=(a + 0x1)
32+;
33+assert((getlocal(0x2,0x1) == "\u{28}\u{74}\u{65}\u{6d}\u{70}\u{6f}\u{72}\u{61}\u{72}\u{79}\u{29}"))
34+elseif (l == 0x4) then
35+a=(a + 0x1)
36+;
37+assert((getlocal(0x2,0x1) == "\u{41}"))
38+else
39+;
40+end
41+for i = 0x1, 0x64
42+do
43+karlSum=(karlSum + i)
44+end
45+for j = 0x64, 0x1, 0x1
46+do
47+fredSum=(fredSum + j)
48+end
49+for key,val in pairs(u)
50+do
51+print(key,val)
52+end
53+function Dog:new()
54+newObj={["\u{73}\u{6f}\u{75}\u{6e}\u{64}"] = "\u{77}\u{6f}\u{6f}\u{66}"}
55+self.__index=self
56+return setmetatable(newObj,self)
57+end
58+function Dog:makeSound()
59+print(("\u{49}\u{20}\u{73}\u{61}\u{79}\u{20}" .. self.sound))
60+end
61+local function g
62+(x)
63+return math.sin(x)
64+end
65+local a = require("\u{6d}\u{6f}\u{64}\u{32}")
66+local b = require("\u{6d}\u{6f}\u{64}\u{32}")
67+function adder(x)
68+return function (y)
69+return (x + y)
70+end
71+end
72+x=(- (0x1 + 0x8))
73+if (_VERSION ~= version) then
74+io.stderr:write("\u{54}\u{68}\u{69}\u{73}\u{20}\u{74}\u{65}\u{73}\u{74}\u{20}\u{73}\u{75}\u{69}\u{74}\u{65}\u{20}\u{69}\u{73}\u{20}\u{66}\u{6f}\u{72}\u{20}",version,"\u{2c}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{66}\u{6f}\u{72}\u{20}",_VERSION,"\u{a}\u{45}\u{78}\u{69}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{74}\u{65}\u{73}\u{74}\u{73}")
75+return
76+end
77+math.randomseed()
78+local random_x,random_y = math.randomseed()
79+do
80+local random_x,random_y = math.randomseed()
81+print(string.format("\u{72}\u{61}\u{6e}\u{64}\u{6f}\u{6d}\u{20}\u{73}\u{65}\u{65}\u{64}\u{73}\u{3a}\u{20}\u{25}\u{64}\u{2c}\u{20}\u{25}\u{64}",random_x,random_y))
82+end
desk/res/lua/cycled/gc.luanew file+790
@@ -0,0 +1,790 @@
1+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{69}\u{6e}\u{63}\u{72}\u{65}\u{6d}\u{65}\u{6e}\u{74}\u{61}\u{6c}\u{20}\u{67}\u{61}\u{72}\u{62}\u{61}\u{67}\u{65}\u{20}\u{63}\u{6f}\u{6c}\u{6c}\u{65}\u{63}\u{74}\u{69}\u{6f}\u{6e}")
2+local debug = require("\u{64}\u{65}\u{62}\u{75}\u{67}")
3+assert(collectgarbage("\u{69}\u{73}\u{72}\u{75}\u{6e}\u{6e}\u{69}\u{6e}\u{67}"))
4+collectgarbage()
5+local oldmode = collectgarbage("\u{69}\u{6e}\u{63}\u{72}\u{65}\u{6d}\u{65}\u{6e}\u{74}\u{61}\u{6c}")
6+assert((collectgarbage("\u{67}\u{65}\u{6e}\u{65}\u{72}\u{61}\u{74}\u{69}\u{6f}\u{6e}\u{61}\u{6c}") == "\u{69}\u{6e}\u{63}\u{72}\u{65}\u{6d}\u{65}\u{6e}\u{74}\u{61}\u{6c}"))
7+assert((collectgarbage("\u{67}\u{65}\u{6e}\u{65}\u{72}\u{61}\u{74}\u{69}\u{6f}\u{6e}\u{61}\u{6c}") == "\u{67}\u{65}\u{6e}\u{65}\u{72}\u{61}\u{74}\u{69}\u{6f}\u{6e}\u{61}\u{6c}"))
8+assert((collectgarbage("\u{69}\u{6e}\u{63}\u{72}\u{65}\u{6d}\u{65}\u{6e}\u{74}\u{61}\u{6c}") == "\u{67}\u{65}\u{6e}\u{65}\u{72}\u{61}\u{74}\u{69}\u{6f}\u{6e}\u{61}\u{6c}"))
9+assert((collectgarbage("\u{69}\u{6e}\u{63}\u{72}\u{65}\u{6d}\u{65}\u{6e}\u{74}\u{61}\u{6c}") == "\u{69}\u{6e}\u{63}\u{72}\u{65}\u{6d}\u{65}\u{6e}\u{74}\u{61}\u{6c}"))
10+local function nop
11+()
12+
13+end
14+local function gcinfo
15+()
16+return (collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}") * 0x400)
17+end
18+do
19+local a = collectgarbage("\u{73}\u{65}\u{74}\u{70}\u{61}\u{75}\u{73}\u{65}",0xc8)
20+local b = collectgarbage("\u{73}\u{65}\u{74}\u{73}\u{74}\u{65}\u{70}\u{6d}\u{75}\u{6c}",0xc8)
21+local t = {0x0,0x2,0xa,0x5a,0x1f4,0x1388,0x7530,0x7ffffffe}
22+for i = 0x1, (# t)
23+do
24+local p = t[i]
25+for j = 0x1, (# t)
26+do
27+local m = t[j]
28+collectgarbage("\u{73}\u{65}\u{74}\u{70}\u{61}\u{75}\u{73}\u{65}",p)
29+collectgarbage("\u{73}\u{65}\u{74}\u{73}\u{74}\u{65}\u{70}\u{6d}\u{75}\u{6c}",m)
30+collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
31+collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x2710)
32+end
33+end
34+collectgarbage("\u{73}\u{65}\u{74}\u{70}\u{61}\u{75}\u{73}\u{65}",a)
35+collectgarbage("\u{73}\u{65}\u{74}\u{73}\u{74}\u{65}\u{70}\u{6d}\u{75}\u{6c}",b)
36+collectgarbage()
37+end
38+_G["\u{77}\u{68}\u{69}\u{6c}\u{65}"]=0xea
39+local function GC1
40+()
41+local u
42+local b
43+local finish = false
44+u=setmetatable({},{["\u{5f}\u{5f}\u{67}\u{63}"] = function ()
45+finish=true
46+end})
47+b={0x22}
48+repeat
49+u={}
50+until finish
51+assert((b[0x1] == 0x22))
52+finish=false
53+;
54+local i = 0x1
55+u=setmetatable({},{["\u{5f}\u{5f}\u{67}\u{63}"] = function ()
56+finish=true
57+end})
58+repeat
59+i=(i + 0x1)
60+;
61+u=(tostring(i) .. tostring(i))
62+until finish
63+assert((b[0x1] == 0x22))
64+finish=false
65+u=setmetatable({},{["\u{5f}\u{5f}\u{67}\u{63}"] = function ()
66+finish=true
67+end})
68+repeat
69+local i
70+;
71+u=function ()
72+return i
73+end
74+until finish
75+assert((b[0x1] == 0x22))
76+end
77+local function GC2
78+()
79+local u
80+local finish = false
81+u={setmetatable({},{["\u{5f}\u{5f}\u{67}\u{63}"] = function ()
82+finish=true
83+end})}
84+local b = {0x22}
85+repeat
86+u={{}}
87+until finish
88+assert((b[0x1] == 0x22))
89+finish=false
90+;
91+local i = 0x1
92+u={setmetatable({},{["\u{5f}\u{5f}\u{67}\u{63}"] = function ()
93+finish=true
94+end})}
95+repeat
96+i=(i + 0x1)
97+;
98+u={(tostring(i) .. tostring(i))}
99+until finish
100+assert((b[0x1] == 0x22))
101+finish=false
102+u={setmetatable({},{["\u{5f}\u{5f}\u{67}\u{63}"] = function ()
103+finish=true
104+end})}
105+repeat
106+local i
107+;
108+u={function ()
109+return i
110+end}
111+until finish
112+assert((b[0x1] == 0x22))
113+end
114+local function GC
115+()
116+GC1()
117+;
118+GC2()
119+end
120+do
121+print("\u{63}\u{72}\u{65}\u{61}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{6d}\u{61}\u{6e}\u{79}\u{20}\u{6f}\u{62}\u{6a}\u{65}\u{63}\u{74}\u{73}")
122+local limit = 0x1388
123+for i = 0x1, limit
124+do
125+local a = {}
126+;
127+a=nil
128+end
129+local a = "\u{61}"
130+for i = 0x1, limit
131+do
132+a=(i .. "\u{62}")
133+;
134+a=string.gsub(a,"\u{28}\u{25}\u{64}\u{25}\u{64}\u{2a}\u{29}","\u{25}\u{31}\u{20}\u{25}\u{31}")
135+a="\u{61}"
136+end
137+a={}
138+function a:test()
139+for i = 0x1, limit
140+do
141+load(string.format("\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{74}\u{65}\u{6d}\u{70}\u{28}\u{61}\u{29}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{27}\u{61}\u{25}\u{64}\u{27}\u{20}\u{65}\u{6e}\u{64}",i),"")()
142+assert((temp() == string.format("\u{61}\u{25}\u{64}",i)))
143+end
144+end
145+a:test()
146+_G.temp=nil
147+end
148+do
149+local f = function ()
150+
151+end
152+end
153+print("\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{73}\u{20}\u{77}\u{69}\u{74}\u{68}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{73}")
154+local prog = "\u{64}\u{6f}\u{a}\u{20}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{31}\u{30}\u{3b}\u{a}\u{20}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{66}\u{6f}\u{6f}\u{28}\u{78}\u{2c}\u{79}\u{29}\u{a}\u{20}\u{20}\u{20}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{73}\u{69}\u{6e}\u{28}\u{61}\u{2b}\u{30}\u{2e}\u{34}\u{35}\u{36}\u{2d}\u{30}\u{2e}\u{32}\u{33}\u{65}\u{2d}\u{31}\u{32}\u{29}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{28}\u{7a}\u{29}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{73}\u{69}\u{6e}\u{28}\u{25}\u{78}\u{2b}\u{7a}\u{29}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{20}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{78}\u{20}\u{3d}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{28}\u{77}\u{29}\u{20}\u{61}\u{3d}\u{61}\u{2b}\u{77}\u{3b}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{65}\u{6e}\u{64}\u{a}"
155+do
156+local step = 0x1
157+if _soft then
158+step=0xd
159+end
160+for i = 0x1, string.len(prog), step
161+do
162+for j = i, string.len(prog), step
163+do
164+pcall(load(string.sub(prog,i,j),""))
165+end
166+end
167+end
168+rawset(_G,"\u{61}",nil)
169+_G.x=nil
170+do
171+foo=nil
172+print("\u{6c}\u{6f}\u{6e}\u{67}\u{20}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{73}")
173+local x = "\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}"
174+assert((string.len(x) == 0x50))
175+local s = ""
176+local k = math.min(0x12c,((math.maxinteger // 0x50) // 0x2))
177+for n = 0x1, k
178+do
179+s=(s .. x)
180+;
181+local j = tostring(n)
182+end
183+assert((string.len(s) == (k * 0x50)))
184+s=string.sub(s,0x1,0x2710)
185+local s,i = string.gsub(s,"\u{28}\u{25}\u{64}\u{25}\u{64}\u{25}\u{64}\u{25}\u{64}\u{29}","")
186+assert((i == (0x2710 // 0x4)))
187+assert((_G["\u{77}\u{68}\u{69}\u{6c}\u{65}"] == 0xea))
188+_G["\u{77}\u{68}\u{69}\u{6c}\u{65}"]=nil
189+end
190+do
191+print("\u{73}\u{74}\u{65}\u{70}\u{73}")
192+print("\u{73}\u{74}\u{65}\u{70}\u{73}\u{20}\u{28}\u{32}\u{29}")
193+local function dosteps
194+(siz)
195+collectgarbage()
196+local a = {}
197+for i = 0x1, 0x64
198+do
199+a[i]={{}}
200+;
201+local b = {}
202+end
203+local x = gcinfo()
204+local i = 0x0
205+repeat
206+i=(i + 0x1)
207+until collectgarbage("\u{73}\u{74}\u{65}\u{70}",siz)
208+assert((gcinfo() < x))
209+return i
210+end
211+collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
212+if (not _port) then
213+assert((dosteps(0xa) < dosteps(0x2)))
214+end
215+assert((dosteps(0x4e20) == 0x1))
216+assert((collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x4e20) == true))
217+assert((collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x4e20) == true))
218+assert((not collectgarbage("\u{69}\u{73}\u{72}\u{75}\u{6e}\u{6e}\u{69}\u{6e}\u{67}")))
219+collectgarbage("\u{72}\u{65}\u{73}\u{74}\u{61}\u{72}\u{74}")
220+assert(collectgarbage("\u{69}\u{73}\u{72}\u{75}\u{6e}\u{6e}\u{69}\u{6e}\u{67}"))
221+end
222+if (not _port) then
223+collectgarbage()
224+;
225+collectgarbage()
226+local x = gcinfo()
227+collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
228+repeat
229+local a = {}
230+until (gcinfo() > (0x3 * x))
231+collectgarbage("\u{72}\u{65}\u{73}\u{74}\u{61}\u{72}\u{74}")
232+assert(collectgarbage("\u{69}\u{73}\u{72}\u{75}\u{6e}\u{6e}\u{69}\u{6e}\u{67}"))
233+repeat
234+local a = {}
235+until (gcinfo() <= (x * 0x2))
236+end
237+print("\u{63}\u{6c}\u{65}\u{61}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{73}")
238+local lim = 0xf
239+local a = {}
240+for i = 0x1, lim
241+do
242+a[{}]=i
243+end
244+b={}
245+for k,v in pairs(a)
246+do
247+b[k]=v
248+end
249+for n in pairs(b)
250+do
251+a[n]=undef
252+assert(((type(n) == "\u{74}\u{61}\u{62}\u{6c}\u{65}") and (next(n) == nil)))
253+collectgarbage()
254+end
255+b=nil
256+collectgarbage()
257+for n in pairs(a)
258+do
259+error("\u{63}\u{61}\u{6e}\u{6e}\u{6f}\u{74}\u{20}\u{62}\u{65}\u{20}\u{68}\u{65}\u{72}\u{65}")
260+end
261+for i = 0x1, lim
262+do
263+a[i]=i
264+end
265+for i = 0x1, lim
266+do
267+assert((a[i] == i))
268+end
269+print("\u{77}\u{65}\u{61}\u{6b}\u{20}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{73}")
270+a={}
271+;
272+setmetatable(a,{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{6b}"})
273+;
274+for i = 0x1, lim
275+do
276+a[{}]=i
277+end
278+for i = 0x1, lim
279+do
280+a[i]=i
281+end
282+for i = 0x1, lim
283+do
284+local s = string.rep("\u{40}",i)
285+;
286+a[s]=(s .. "\u{23}")
287+end
288+collectgarbage()
289+local i = 0x0
290+for k,v in pairs(a)
291+do
292+assert(((k == v) or ((k .. "\u{23}") == v)))
293+;
294+i=(i + 0x1)
295+end
296+assert((i == (0x2 * lim)))
297+a={}
298+;
299+setmetatable(a,{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{76}"})
300+;
301+a[0x1]=string.rep("\u{62}",0x15)
302+collectgarbage()
303+assert(a[0x1])
304+a[0x1]=undef
305+for i = 0x1, lim
306+do
307+a[i]={}
308+end
309+for i = 0x1, lim
310+do
311+a[(i .. "\u{78}")]={}
312+end
313+for i = 0x1, lim
314+do
315+local t = {}
316+;
317+a[t]=t
318+end
319+for i = 0x1, lim
320+do
321+a[(i + lim)]=(i .. "\u{78}")
322+end
323+collectgarbage()
324+local i = 0x0
325+for k,v in pairs(a)
326+do
327+assert(((k == v) or (((k - lim) .. "\u{78}") == v)))
328+;
329+i=(i + 0x1)
330+end
331+assert((i == (0x2 * lim)))
332+a={}
333+;
334+setmetatable(a,{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{6b}\u{76}"})
335+;
336+local x,y,z = {},{},{}
337+a[0x1],a[0x2],a[0x3]=x,y,z
338+a[string.rep("\u{24}",0xb)]=string.rep("\u{24}",0xb)
339+for i = 0x4, lim
340+do
341+a[i]={}
342+end
343+for i = 0x1, lim
344+do
345+a[{}]=i
346+end
347+for i = 0x1, lim
348+do
349+local t = {}
350+;
351+a[t]=t
352+end
353+collectgarbage()
354+assert((next(a) ~= nil))
355+local i = 0x0
356+for k,v in pairs(a)
357+do
358+assert((((((k == 0x1) and (v == x)) or ((k == 0x2) and (v == y))) or ((k == 0x3) and (v == z))) or (k == v)))
359+;
360+i=(i + 0x1)
361+end
362+assert((i == 0x4))
363+x,y,z=nil
364+collectgarbage()
365+assert((next(a) == string.rep("\u{24}",0xb)))
366+a={}
367+local t = {["\u{78}"] = 0xa}
368+local C = setmetatable({["\u{6b}\u{65}\u{79}"] = t},{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{76}"})
369+local C1 = setmetatable({[t] = 0x1},{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{6b}"})
370+a.x=t
371+setmetatable(a,{["\u{5f}\u{5f}\u{67}\u{63}"] = function (u)
372+assert((C.key == nil))
373+assert((type(next(C1)) == "\u{74}\u{61}\u{62}\u{6c}\u{65}"))
374+end})
375+a,t=nil
376+collectgarbage()
377+collectgarbage()
378+assert(((next(C) == nil) and (next(C1) == nil)))
379+C,C1=nil
380+local mt = {["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{6b}"}
381+a={{0xa},{0x14},{0x1e},{0x28}}
382+;
383+setmetatable(a,mt)
384+x=nil
385+for i = 0x1, 0x64
386+do
387+local n = {}
388+;
389+a[n]={["\u{6b}"] = {x}}
390+;
391+x=n
392+end
393+GC()
394+local n = x
395+local i = 0x0
396+while n do
397+n=a[n].k[0x1]
398+;
399+i=(i + 0x1)
400+end
401+assert((i == 0x64))
402+x=nil
403+GC()
404+for i = 0x1, 0x4
405+do
406+assert((a[i][0x1] == (i * 0xa)))
407+;
408+a[i]=undef
409+end
410+assert((next(a) == nil))
411+local K = {}
412+a[K]={}
413+for i = 0x1, 0xa
414+do
415+a[K][i]={}
416+;
417+a[a[K][i]]=setmetatable({},mt)
418+end
419+x=nil
420+local k = 0x1
421+for j = 0x1, 0x64
422+do
423+local n = {}
424+;
425+local nk = ((k % 0xa) + 0x1)
426+a[a[K][nk]][n]={x,["\u{6b}"] = k}
427+;
428+x=n
429+;
430+k=nk
431+end
432+GC()
433+local n = x
434+local i = 0x0
435+while n do
436+local t = a[a[K][k]][n]
437+;
438+n=t[0x1]
439+;
440+k=t.k
441+;
442+i=(i + 0x1)
443+end
444+assert((i == 0x64))
445+K=nil
446+GC()
447+if T then
448+collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
449+local u = {}
450+local s = {}
451+;
452+setmetatable(s,{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{6b}"})
453+setmetatable(u,{["\u{5f}\u{5f}\u{67}\u{63}"] = function (o)
454+local i = s[o]
455+s[i]=true
456+assert((not s[(i - 0x1)]))
457+if (i == 0x8) then
458+error("\u{40}\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}\u{40}")
459+end
460+end})
461+for i = 0x6, 0xa
462+do
463+local n = setmetatable({},getmetatable(u))
464+s[n]=i
465+end
466+warn("\u{40}\u{6f}\u{6e}")
467+;
468+warn("\u{40}\u{73}\u{74}\u{6f}\u{72}\u{65}")
469+collectgarbage()
470+assert(string.find(_WARN,"\u{65}\u{72}\u{72}\u{6f}\u{72}\u{20}\u{69}\u{6e}\u{20}\u{5f}\u{5f}\u{67}\u{63}"))
471+assert((string.match(_WARN,"\u{40}\u{28}\u{2e}\u{2d}\u{29}\u{40}") == "\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}"))
472+;
473+_WARN=false
474+for i = 0x8, 0xa
475+do
476+assert(s[i])
477+end
478+for i = 0x1, 0x5
479+do
480+local n = setmetatable({},getmetatable(u))
481+s[n]=i
482+end
483+collectgarbage()
484+for i = 0x1, 0xa
485+do
486+assert(s[i])
487+end
488+getmetatable(u).__gc=nil
489+warn("\u{40}\u{6e}\u{6f}\u{72}\u{6d}\u{61}\u{6c}")
490+end
491+print("\u{2b}")
492+if (T == nil) then
493+(Message or print)("\u{a}\u{20}\u{3e}\u{3e}\u{3e}\u{20}\u{74}\u{65}\u{73}\u{74}\u{43}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{61}\u{63}\u{74}\u{69}\u{76}\u{65}\u{3a}\u{20}\u{73}\u{6b}\u{69}\u{70}\u{70}\u{69}\u{6e}\u{67}\u{20}\u{75}\u{73}\u{65}\u{72}\u{64}\u{61}\u{74}\u{61}\u{20}\u{47}\u{43}\u{20}\u{74}\u{65}\u{73}\u{74}\u{73}\u{20}\u{3c}\u{3c}\u{3c}\u{a}")
494+else
495+local function newproxy
496+(u)
497+return debug.setmetatable(T.newuserdata(0x0),debug.getmetatable(u))
498+end
499+collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
500+local u = newproxy(nil)
501+debug.setmetatable(u,{["\u{5f}\u{5f}\u{67}\u{63}"] = true})
502+local s = 0x0
503+local a = {[u] = 0x0}
504+;
505+setmetatable(a,{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{76}\u{6b}"})
506+for i = 0x1, 0xa
507+do
508+a[newproxy(u)]=i
509+end
510+for k in pairs(a)
511+do
512+assert((getmetatable(k) == getmetatable(u)))
513+end
514+local a1 = {}
515+;
516+for k,v in pairs(a)
517+do
518+a1[k]=v
519+end
520+for k,v in pairs(a1)
521+do
522+a[v]=k
523+end
524+for i = 0x1, 0xa
525+do
526+assert(a[i])
527+end
528+getmetatable(u).a=a1
529+getmetatable(u).u=u
530+do
531+local u = u
532+getmetatable(u).__gc=function (o)
533+assert((a[o] == (0xa - s)))
534+assert((a[(0xa - s)] == undef))
535+assert((getmetatable(o) == getmetatable(u)))
536+assert((getmetatable(o).a[o] == (0xa - s)))
537+s=(s + 0x1)
538+end
539+end
540+a1,u=nil
541+assert((next(a) ~= nil))
542+collectgarbage()
543+assert((s == 0xb))
544+collectgarbage()
545+assert((next(a) == nil))
546+end
547+local u = setmetatable({},{["\u{5f}\u{5f}\u{67}\u{63}"] = true})
548+setmetatable(getmetatable(u),{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{76}"})
549+getmetatable(u).__gc=function (o)
550+os.exit(0x1)
551+end
552+u=nil
553+collectgarbage()
554+local u = setmetatable({},{["\u{5f}\u{5f}\u{67}\u{63}"] = true})
555+local m = getmetatable(u)
556+m.x={[{0x0}] = 0x1,[0x0] = {0x1}}
557+;
558+setmetatable(m.x,{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{6b}\u{76}"})
559+;
560+m.__gc=function (o)
561+assert((next(getmetatable(o).x) == nil))
562+m=0xa
563+end
564+u,m=nil
565+collectgarbage()
566+assert((m == 0xa))
567+do
568+collectgarbage()
569+;
570+collectgarbage()
571+local m = collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}")
572+local a = setmetatable({},{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{6b}\u{76}"})
573+a[string.rep("\u{61}",(0x2 ^ 0x16))]=0x19
574+a[string.rep("\u{62}",(0x2 ^ 0x16))]={}
575+a[{}]=0xe
576+assert((collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}") > (m + (0x2 ^ 0xd))))
577+collectgarbage()
578+assert(((collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}") >= (m + (0x2 ^ 0xc))) and (collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}") < (m + (0x2 ^ 0xd)))))
579+local k,v = next(a)
580+assert(((k == string.rep("\u{61}",(0x2 ^ 0x16))) and (v == 0x19)))
581+assert((next(a,k) == nil))
582+assert((a[string.rep("\u{62}",(0x2 ^ 0x16))] == undef))
583+a[k]=undef
584+k=nil
585+collectgarbage()
586+assert((next(a) == nil))
587+assert((a[string.rep("\u{62}",0x64)] == undef))
588+assert((collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}") <= (m + 0x1)))
589+end
590+if T then
591+warn("\u{40}\u{73}\u{74}\u{6f}\u{72}\u{65}")
592+u=setmetatable({},{["\u{5f}\u{5f}\u{67}\u{63}"] = function ()
593+error("\u{40}\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}")
594+end})
595+u=nil
596+collectgarbage()
597+assert(string.find(_WARN,"\u{40}\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}"))
598+;
599+_WARN=false
600+warn("\u{40}\u{6e}\u{6f}\u{72}\u{6d}\u{61}\u{6c}")
601+end
602+if (not _soft) then
603+print("\u{6c}\u{6f}\u{6e}\u{67}\u{20}\u{6c}\u{69}\u{73}\u{74}")
604+local a = {}
605+for i = 0x1, 0x30d40
606+do
607+a={["\u{6e}\u{65}\u{78}\u{74}"] = a}
608+end
609+a=nil
610+collectgarbage()
611+end
612+print("\u{73}\u{65}\u{6c}\u{66}\u{2d}\u{72}\u{65}\u{66}\u{65}\u{72}\u{65}\u{6e}\u{63}\u{65}\u{64}\u{20}\u{74}\u{68}\u{72}\u{65}\u{61}\u{64}\u{73}")
613+local thread_id = 0x0
614+local threads = {}
615+local function fn
616+(thread)
617+local x = {}
618+threads[thread_id]=function ()
619+thread=x
620+end
621+coroutine.yield()
622+end
623+while (thread_id < 0x3e8) do
624+local thread = coroutine.create(fn)
625+coroutine.resume(thread,thread)
626+thread_id=(thread_id + 0x1)
627+end
628+do
629+local collected = false
630+collectgarbage()
631+;
632+collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
633+do
634+local function f
635+(param)
636+;
637+(function ()
638+assert(((type(f) == "\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}") and (type(param) == "\u{74}\u{68}\u{72}\u{65}\u{61}\u{64}")))
639+param={param,f}
640+setmetatable(param,{["\u{5f}\u{5f}\u{67}\u{63}"] = function ()
641+collected=true
642+end})
643+coroutine.yield(0x64)
644+end)()
645+end
646+local co = coroutine.create(f)
647+assert(coroutine.resume(co,co))
648+end
649+collectgarbage()
650+assert(collected)
651+collectgarbage("\u{72}\u{65}\u{73}\u{74}\u{61}\u{72}\u{74}")
652+end
653+do
654+collectgarbage()
655+collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
656+collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
657+local x = gcinfo()
658+repeat
659+for i = 0x1, 0x3e8
660+do
661+_ENV.a={}
662+end
663+until (gcinfo() > (0x2 * x))
664+collectgarbage("\u{72}\u{65}\u{73}\u{74}\u{61}\u{72}\u{74}")
665+_ENV.a=nil
666+end
667+if T then
668+local function foo
669+()
670+local a = {["\u{78}"] = 0x14}
671+coroutine.yield(function ()
672+return a.x
673+end)
674+assert((a.x == 0x14))
675+a={["\u{78}"] = 0x1e}
676+assert((T.gccolor(a) == "\u{77}\u{68}\u{69}\u{74}\u{65}"))
677+coroutine.yield(0x64)
678+end
679+local t = setmetatable({},{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{6b}\u{76}"})
680+collectgarbage()
681+;
682+collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
683+t.co=coroutine.wrap(foo)
684+local f = t.co()
685+T.gcstate("\u{61}\u{74}\u{6f}\u{6d}\u{69}\u{63}")
686+assert((T.gcstate() == "\u{61}\u{74}\u{6f}\u{6d}\u{69}\u{63}"))
687+assert((t.co() == 0x64))
688+assert((T.gccolor(t.co) == "\u{77}\u{68}\u{69}\u{74}\u{65}"))
689+T.gcstate("\u{70}\u{61}\u{75}\u{73}\u{65}")
690+assert(((t.co == nil) and (f() == 0x1e)))
691+collectgarbage("\u{72}\u{65}\u{73}\u{74}\u{61}\u{72}\u{74}")
692+local u = T.newuserdata(0x0,0x1)
693+collectgarbage()
694+collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
695+local a = {}
696+T.gcstate("\u{61}\u{74}\u{6f}\u{6d}\u{69}\u{63}")
697+T.gcstate("\u{73}\u{77}\u{65}\u{65}\u{70}\u{61}\u{6c}\u{6c}\u{67}\u{63}")
698+local x = {}
699+assert((T.gccolor(u) == "\u{62}\u{6c}\u{61}\u{63}\u{6b}"))
700+assert((T.gccolor(x) == "\u{77}\u{68}\u{69}\u{74}\u{65}"))
701+debug.setuservalue(u,x)
702+assert((T.gccolor(u) == "\u{67}\u{72}\u{61}\u{79}"))
703+collectgarbage("\u{72}\u{65}\u{73}\u{74}\u{61}\u{72}\u{74}")
704+print("\u{2b}")
705+end
706+if T then
707+local debug = require("\u{64}\u{65}\u{62}\u{75}\u{67}")
708+collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
709+local x = T.newuserdata(0x0)
710+local y = T.newuserdata(0x0)
711+debug.setmetatable(y,{["\u{5f}\u{5f}\u{67}\u{63}"] = nop})
712+debug.setmetatable(x,{["\u{5f}\u{5f}\u{67}\u{63}"] = nop})
713+assert((T.gccolor(y) == "\u{77}\u{68}\u{69}\u{74}\u{65}"))
714+T.checkmemory()
715+collectgarbage("\u{72}\u{65}\u{73}\u{74}\u{61}\u{72}\u{74}")
716+end
717+if T then
718+print("\u{65}\u{6d}\u{65}\u{72}\u{67}\u{65}\u{6e}\u{63}\u{79}\u{20}\u{63}\u{6f}\u{6c}\u{6c}\u{65}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{73}")
719+collectgarbage()
720+collectgarbage()
721+T.totalmem((T.totalmem() + 0xc8))
722+for i = 0x1, 0xc8
723+do
724+local a = {}
725+end
726+T.totalmem(0x0)
727+collectgarbage()
728+local t = T.totalmem("\u{74}\u{61}\u{62}\u{6c}\u{65}")
729+local a = {{},{},{}}
730+assert((T.totalmem("\u{74}\u{61}\u{62}\u{6c}\u{65}") == (t + 0x4)))
731+t=T.totalmem("\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}")
732+a=function ()
733+
734+end
735+assert((T.totalmem("\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}") == (t + 0x1)))
736+t=T.totalmem("\u{74}\u{68}\u{72}\u{65}\u{61}\u{64}")
737+a=coroutine.create(function ()
738+
739+end)
740+assert((T.totalmem("\u{74}\u{68}\u{72}\u{65}\u{61}\u{64}") == (t + 0x1)))
741+end
742+do
743+local setmetatable,assert,type,print,getmetatable = setmetatable,assert,type,print,getmetatable
744+local tt = {}
745+tt.__gc=function (o)
746+assert((getmetatable(o) == tt))
747+local a = ("\u{78}\u{75}\u{78}\u{75}" .. ((0xa + 0x3) .. "\u{6a}\u{6f}\u{61}\u{6f}")),{}
748+___Glob=o
749+setmetatable({},tt)
750+print(("\u{3e}\u{3e}\u{3e}\u{20}\u{63}\u{6c}\u{6f}\u{73}\u{69}\u{6e}\u{67}\u{20}\u{73}\u{74}\u{61}\u{74}\u{65}\u{20}" .. "\u{3c}\u{3c}\u{3c}\u{a}"))
751+end
752+local u = setmetatable({},tt)
753+___Glob={u}
754+end
755+if T then
756+local error,assert,find,warn = error,assert,string.find,warn
757+local n = 0x0
758+local lastmsg
759+local mt = {["\u{5f}\u{5f}\u{67}\u{63}"] = function (o)
760+n=(n + 0x1)
761+assert((n == o[0x1]))
762+if (n == 0x1) then
763+_WARN=false
764+elseif (n == 0x2) then
765+assert(find(_WARN,"\u{40}\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}\u{20}\u{77}\u{61}\u{72}\u{6e}\u{69}\u{6e}\u{67}"))
766+lastmsg=_WARN
767+else
768+assert((lastmsg == _WARN))
769+end
770+warn("\u{40}\u{73}\u{74}\u{6f}\u{72}\u{65}")
771+;
772+_WARN=false
773+error("\u{40}\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}\u{20}\u{77}\u{61}\u{72}\u{6e}\u{69}\u{6e}\u{67}")
774+end}
775+for i = 0xa, 0x1, (- 0x1)
776+do
777+table.insert(___Glob,setmetatable({i},mt))
778+end
779+end
780+assert(collectgarbage("\u{69}\u{73}\u{72}\u{75}\u{6e}\u{6e}\u{69}\u{6e}\u{67}"))
781+do
782+local res = true
783+setmetatable({},{["\u{5f}\u{5f}\u{67}\u{63}"] = function ()
784+res=collectgarbage()
785+end})
786+collectgarbage()
787+assert((not res))
788+end
789+collectgarbage(oldmode)
790+print("\u{4f}\u{4b}")
desk/res/lua/cycled/gengc.luanew file+108
@@ -0,0 +1,108 @@
1+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{67}\u{65}\u{6e}\u{65}\u{72}\u{61}\u{74}\u{69}\u{6f}\u{6e}\u{61}\u{6c}\u{20}\u{67}\u{61}\u{72}\u{62}\u{61}\u{67}\u{65}\u{20}\u{63}\u{6f}\u{6c}\u{6c}\u{65}\u{63}\u{74}\u{69}\u{6f}\u{6e}")
2+local debug = require("\u{64}\u{65}\u{62}\u{75}\u{67}")
3+assert(collectgarbage("\u{69}\u{73}\u{72}\u{75}\u{6e}\u{6e}\u{69}\u{6e}\u{67}"))
4+collectgarbage()
5+local oldmode = collectgarbage("\u{67}\u{65}\u{6e}\u{65}\u{72}\u{61}\u{74}\u{69}\u{6f}\u{6e}\u{61}\u{6c}")
6+do
7+local U = {}
8+collectgarbage()
9+assert((not (T or (T.gcage(U) == "\u{6f}\u{6c}\u{64}"))))
10+U[0x1]={["\u{78}"] = {0xea}}
11+assert((not (T or ((T.gcage(U) == "\u{74}\u{6f}\u{75}\u{63}\u{68}\u{65}\u{64}\u{31}") and (T.gcage(U[0x1]) == "\u{6e}\u{65}\u{77}")))))
12+collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
13+assert((not (T or ((T.gcage(U) == "\u{74}\u{6f}\u{75}\u{63}\u{68}\u{65}\u{64}\u{32}") and (T.gcage(U[0x1]) == "\u{73}\u{75}\u{72}\u{76}\u{69}\u{76}\u{61}\u{6c}")))))
14+collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
15+assert((not (T or ((T.gcage(U) == "\u{6f}\u{6c}\u{64}") and (T.gcage(U[0x1]) == "\u{6f}\u{6c}\u{64}\u{31}")))))
16+assert((U[0x1].x[0x1] == 0xea))
17+end
18+do
19+local function foo
20+()
21+
22+end
23+local old = {0xa}
24+collectgarbage()
25+assert((not (T or (T.gcage(old) == "\u{6f}\u{6c}\u{64}"))))
26+setmetatable(old,{})
27+assert((not (T or (T.gcage(getmetatable(old)) == "\u{6f}\u{6c}\u{64}\u{30}"))))
28+collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
29+assert((not (T or (T.gcage(getmetatable(old)) == "\u{6f}\u{6c}\u{64}\u{31}"))))
30+setmetatable(getmetatable(old),{["\u{5f}\u{5f}\u{67}\u{63}"] = foo})
31+collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
32+end
33+do
34+local A = {}
35+A[0x1]=false
36+local function gcf
37+(obj)
38+A[0x1]=obj
39+assert((not (T or (T.gcage(obj) == "\u{6f}\u{6c}\u{64}\u{31}"))))
40+obj=nil
41+collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
42+print(getmetatable(A[0x1]).x)
43+end
44+collectgarbage()
45+local obj = {}
46+collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
47+assert((not (T or (T.gcage(obj) == "\u{73}\u{75}\u{72}\u{76}\u{69}\u{76}\u{61}\u{6c}"))))
48+setmetatable(obj,{["\u{5f}\u{5f}\u{67}\u{63}"] = gcf,["\u{78}"] = "\u{2b}"})
49+assert((not (T or (T.gcage(getmetatable(obj)) == "\u{6e}\u{65}\u{77}"))))
50+obj=nil
51+collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
52+end
53+do
54+local old = {0xa}
55+collectgarbage()
56+local co = coroutine.create(function ()
57+local x = nil
58+local f = function ()
59+return x[0x1]
60+end
61+x=coroutine.yield(f)
62+coroutine.yield()
63+end)
64+local _,f = coroutine.resume(co)
65+collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
66+old[0x1]={"\u{68}\u{65}\u{6c}\u{6c}\u{6f}"}
67+coroutine.resume(co,{0x7b})
68+co=nil
69+collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
70+assert(((f() == 0x7b) and (old[0x1][0x1] == "\u{68}\u{65}\u{6c}\u{6c}\u{6f}")))
71+collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
72+assert(((f() == 0x7b) and (old[0x1][0x1] == "\u{68}\u{65}\u{6c}\u{6c}\u{6f}")))
73+end
74+do
75+local t = setmetatable({},{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{6b}\u{76}"})
76+collectgarbage()
77+assert((not (T or (T.gcage(t) == "\u{6f}\u{6c}\u{64}"))))
78+t[0x1]={0xa}
79+assert((not (T or ((T.gcage(t) == "\u{74}\u{6f}\u{75}\u{63}\u{68}\u{65}\u{64}\u{31}") and (T.gccolor(t) == "\u{67}\u{72}\u{61}\u{79}")))))
80+collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
81+assert((not (T or ((T.gcage(t) == "\u{74}\u{6f}\u{75}\u{63}\u{68}\u{65}\u{64}\u{32}") and (T.gccolor(t) == "\u{62}\u{6c}\u{61}\u{63}\u{6b}")))))
82+collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
83+assert((not (T or (T.gcage(t) == "\u{6f}\u{6c}\u{64}"))))
84+t[0x1]={0xa}
85+collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
86+assert((t[0x1] == nil))
87+end
88+if (T == nil) then
89+(Message or print)("\u{a}\u{20}\u{3e}\u{3e}\u{3e}\u{20}\u{74}\u{65}\u{73}\u{74}\u{43}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{61}\u{63}\u{74}\u{69}\u{76}\u{65}\u{3a}\u{20}\u{73}\u{6b}\u{69}\u{70}\u{70}\u{69}\u{6e}\u{67}\u{20}\u{73}\u{6f}\u{6d}\u{65}\u{20}\u{67}\u{65}\u{6e}\u{65}\u{72}\u{61}\u{74}\u{69}\u{6f}\u{6e}\u{61}\u{6c}\u{20}\u{74}\u{65}\u{73}\u{74}\u{73}\u{20}\u{3c}\u{3c}\u{3c}\u{a}")
90+print("\u{4f}\u{4b}")
91+return
92+end
93+do
94+local U = T.newuserdata(0x0,0x1)
95+collectgarbage()
96+assert((T.gcage(U) == "\u{6f}\u{6c}\u{64}"))
97+debug.setuservalue(U,{["\u{78}"] = {0xea}})
98+assert(((T.gcage(U) == "\u{74}\u{6f}\u{75}\u{63}\u{68}\u{65}\u{64}\u{31}") and (T.gcage(debug.getuservalue(U)) == "\u{6e}\u{65}\u{77}")))
99+collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
100+assert(((T.gcage(U) == "\u{74}\u{6f}\u{75}\u{63}\u{68}\u{65}\u{64}\u{32}") and (T.gcage(debug.getuservalue(U)) == "\u{73}\u{75}\u{72}\u{76}\u{69}\u{76}\u{61}\u{6c}")))
101+collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
102+assert(((T.gcage(U) == "\u{6f}\u{6c}\u{64}") and (T.gcage(debug.getuservalue(U)) == "\u{6f}\u{6c}\u{64}\u{31}")))
103+assert((debug.getuservalue(U).x[0x1] == 0xea))
104+end
105+assert(collectgarbage("\u{69}\u{73}\u{72}\u{75}\u{6e}\u{6e}\u{69}\u{6e}\u{67}"))
106+assert(collectgarbage("\u{69}\u{73}\u{72}\u{75}\u{6e}\u{6e}\u{69}\u{6e}\u{67}"))
107+collectgarbage(oldmode)
108+print("\u{4f}\u{4b}")
desk/res/lua/cycled/goto.luanew file+275
@@ -0,0 +1,275 @@
1+collectgarbage()
2+local function errmsg
3+(code,m)
4+local st,msg = load(code)
5+assert((not (st and string.find(msg,m))))
6+end
7+errmsg("\u{20}\u{67}\u{6f}\u{74}\u{6f}\u{20}\u{6c}\u{31}\u{3b}\u{20}\u{64}\u{6f}\u{20}\u{3a}\u{3a}\u{6c}\u{31}\u{3a}\u{3a}\u{20}\u{65}\u{6e}\u{64}\u{20}","\u{6c}\u{61}\u{62}\u{65}\u{6c}\u{20}\u{27}\u{6c}\u{31}\u{27}")
8+errmsg("\u{20}\u{64}\u{6f}\u{20}\u{3a}\u{3a}\u{6c}\u{31}\u{3a}\u{3a}\u{20}\u{65}\u{6e}\u{64}\u{20}\u{67}\u{6f}\u{74}\u{6f}\u{20}\u{6c}\u{31}\u{3b}\u{20}","\u{6c}\u{61}\u{62}\u{65}\u{6c}\u{20}\u{27}\u{6c}\u{31}\u{27}")
9+errmsg("\u{20}\u{3a}\u{3a}\u{6c}\u{31}\u{3a}\u{3a}\u{20}\u{3a}\u{3a}\u{6c}\u{31}\u{3a}\u{3a}\u{20}","\u{6c}\u{61}\u{62}\u{65}\u{6c}\u{20}\u{27}\u{6c}\u{31}\u{27}")
10+errmsg("\u{20}\u{3a}\u{3a}\u{6c}\u{31}\u{3a}\u{3a}\u{20}\u{64}\u{6f}\u{20}\u{3a}\u{3a}\u{6c}\u{31}\u{3a}\u{3a}\u{20}\u{65}\u{6e}\u{64}","\u{6c}\u{61}\u{62}\u{65}\u{6c}\u{20}\u{27}\u{6c}\u{31}\u{27}")
11+errmsg("\u{20}\u{67}\u{6f}\u{74}\u{6f}\u{20}\u{6c}\u{31}\u{3b}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{61}\u{20}\u{3a}\u{3a}\u{6c}\u{31}\u{3a}\u{3a}\u{20}\u{3a}\u{3a}\u{6c}\u{32}\u{3a}\u{3a}\u{20}\u{70}\u{72}\u{69}\u{6e}\u{74}\u{28}\u{33}\u{29}\u{20}","\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{27}\u{61}\u{61}\u{27}")
12+errmsg("\u{64}\u{6f}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{62}\u{62}\u{2c}\u{20}\u{63}\u{63}\u{3b}\u{20}\u{67}\u{6f}\u{74}\u{6f}\u{20}\u{6c}\u{31}\u{3b}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{61}\u{a}\u{3a}\u{3a}\u{6c}\u{31}\u{3a}\u{3a}\u{20}\u{70}\u{72}\u{69}\u{6e}\u{74}\u{28}\u{33}\u{29}\u{a}","\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{27}\u{61}\u{61}\u{27}")
13+errmsg("\u{20}\u{64}\u{6f}\u{20}\u{3a}\u{3a}\u{6c}\u{31}\u{3a}\u{3a}\u{20}\u{65}\u{6e}\u{64}\u{20}\u{67}\u{6f}\u{74}\u{6f}\u{20}\u{6c}\u{31}\u{20}","\u{6c}\u{61}\u{62}\u{65}\u{6c}\u{20}\u{27}\u{6c}\u{31}\u{27}")
14+errmsg("\u{20}\u{67}\u{6f}\u{74}\u{6f}\u{20}\u{6c}\u{31}\u{20}\u{64}\u{6f}\u{20}\u{3a}\u{3a}\u{6c}\u{31}\u{3a}\u{3a}\u{20}\u{65}\u{6e}\u{64}\u{20}","\u{6c}\u{61}\u{62}\u{65}\u{6c}\u{20}\u{27}\u{6c}\u{31}\u{27}")
15+errmsg("\u{20}\u{20}\u{72}\u{65}\u{70}\u{65}\u{61}\u{74}\u{a}\u{20}\u{20}\u{20}\u{20}\u{69}\u{66}\u{20}\u{78}\u{20}\u{74}\u{68}\u{65}\u{6e}\u{20}\u{67}\u{6f}\u{74}\u{6f}\u{20}\u{63}\u{6f}\u{6e}\u{74}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{20}\u{20}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{78}\u{75}\u{78}\u{75}\u{20}\u{3d}\u{20}\u{31}\u{30}\u{a}\u{20}\u{20}\u{20}\u{20}\u{3a}\u{3a}\u{63}\u{6f}\u{6e}\u{74}\u{3a}\u{3a}\u{a}\u{20}\u{20}\u{75}\u{6e}\u{74}\u{69}\u{6c}\u{20}\u{78}\u{75}\u{78}\u{75}\u{20}\u{3c}\u{20}\u{78}\u{a}","\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{27}\u{78}\u{75}\u{78}\u{75}\u{27}")
16+local x
17+do
18+local y = 0xc
19+goto l1
20+::l2::
21+x=(x + 0x1)
22+;
23+goto l3
24+::l1::
25+x=y
26+;
27+goto l2
28+end
29+::l3::
30+::l3_1::
31+assert((x == 0xd))
32+do
33+local prog = "\u{20}\u{20}\u{64}\u{6f}\u{a}\u{20}\u{20}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{31}\u{a}\u{20}\u{20}\u{20}\u{20}\u{67}\u{6f}\u{74}\u{6f}\u{20}\u{6c}\u{25}\u{73}\u{61}\u{3b}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{61}\u{20}\u{2b}\u{20}\u{31}\u{a}\u{20}\u{20}\u{20}\u{3a}\u{3a}\u{6c}\u{25}\u{73}\u{61}\u{3a}\u{3a}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{61}\u{20}\u{2b}\u{20}\u{31}\u{30}\u{a}\u{20}\u{20}\u{20}\u{20}\u{67}\u{6f}\u{74}\u{6f}\u{20}\u{6c}\u{25}\u{73}\u{62}\u{3b}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{61}\u{20}\u{2b}\u{20}\u{32}\u{a}\u{20}\u{20}\u{20}\u{3a}\u{3a}\u{6c}\u{25}\u{73}\u{62}\u{3a}\u{3a}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{61}\u{20}\u{2b}\u{20}\u{32}\u{30}\u{a}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{61}\u{a}\u{20}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{20}\u{20}"
34+local label = string.rep("\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",0x28)
35+prog=string.format(prog,label,label,label,label)
36+assert((assert(load(prog))() == 0x1f))
37+end
38+do
39+goto l1
40+local a = 0x17
41+x=a
42+::l1::
43+;
44+end
45+while true do
46+goto l4
47+goto l1
48+goto l1
49+local x = 0x2d
50+::l1::
51+;
52+;
53+;
54+end
55+::l4::
56+assert((x == 0xd))
57+if print then
58+goto l1
59+error("\u{73}\u{68}\u{6f}\u{75}\u{6c}\u{64}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{62}\u{65}\u{20}\u{68}\u{65}\u{72}\u{65}")
60+goto l2
61+local x
62+::l1::
63+;
64+::l2::
65+;
66+;
67+else
68+
69+end
70+local function foo
71+()
72+local a = {}
73+goto l3
74+::l1::
75+a[(# (a + 0x1))]=0x1
76+;
77+goto l2
78+;
79+::l2::
80+a[(# (a + 0x1))]=0x2
81+;
82+goto l5
83+;
84+::l3::
85+::l3a::
86+a[(# (a + 0x1))]=0x3
87+;
88+goto l1
89+;
90+::l4::
91+a[(# (a + 0x1))]=0x4
92+;
93+goto l6
94+;
95+::l5::
96+a[(# (a + 0x1))]=0x5
97+;
98+goto l4
99+;
100+::l6::
101+assert((((((a[0x1] == 0x3) and (a[0x2] == 0x1)) and (a[0x3] == 0x2)) and (a[0x4] == 0x5)) and (a[0x5] == 0x4)))
102+if (not a[0x6]) then
103+a[0x6]=true
104+;
105+goto l3a
106+end
107+end
108+::l6::
109+foo()
110+do
111+local x
112+::L1::
113+local y
114+assert((y == nil))
115+y=true
116+if (x == nil) then
117+x=0x1
118+goto L1
119+else
120+x=(x + 0x1)
121+end
122+assert(((x == 0x2) and (y == true)))
123+end
124+do
125+local first = true
126+local a = false
127+if true then
128+goto LBL
129+::loop::
130+a=true
131+::LBL::
132+if first then
133+first=false
134+goto loop
135+end
136+end
137+assert(a)
138+end
139+do
140+goto escape
141+::a::
142+goto a
143+::b::
144+goto c
145+::c::
146+goto b
147+end
148+::escape::
149+local debug = require("\u{64}\u{65}\u{62}\u{75}\u{67}")
150+local function foo
151+()
152+local t = {}
153+do
154+local i = 0x1
155+local a,b,c,d
156+t[0x1]=function ()
157+return a,b,c,d
158+end
159+::l1::
160+local b
161+do
162+local c
163+t[(# (t + 0x1))]=function ()
164+return a,b,c,d
165+end
166+if (i > 0x2) then
167+goto l2
168+end
169+do
170+local d
171+t[(# (t + 0x1))]=function ()
172+return a,b,c,d
173+end
174+i=(i + 0x1)
175+local a
176+goto l1
177+end
178+end
179+end
180+::l2::
181+return t
182+end
183+local a = foo()
184+assert((# (a == 0x6)))
185+for i = 0x2, 0x6
186+do
187+assert((debug.upvalueid(a[0x1],0x1) == debug.upvalueid(a[i],0x1)))
188+end
189+for i = 0x2, 0x6
190+do
191+assert((debug.upvalueid(a[0x1],0x2) ~= debug.upvalueid(a[i],0x2)))
192+assert((debug.upvalueid(a[0x1],0x3) ~= debug.upvalueid(a[i],0x3)))
193+end
194+for i = 0x3, 0x5, 0x2
195+do
196+assert((debug.upvalueid(a[i],0x2) == debug.upvalueid(a[(i - 0x1)],0x2)))
197+assert((debug.upvalueid(a[i],0x3) == debug.upvalueid(a[(i - 0x1)],0x3)))
198+assert((debug.upvalueid(a[i],0x2) ~= debug.upvalueid(a[(i + 0x1)],0x2)))
199+assert((debug.upvalueid(a[i],0x3) ~= debug.upvalueid(a[(i + 0x1)],0x3)))
200+end
201+for i = 0x2, 0x6, 0x2
202+do
203+assert((debug.upvalueid(a[0x1],0x4) == debug.upvalueid(a[i],0x4)))
204+end
205+for i = 0x3, 0x5, 0x2
206+do
207+for j = 0x1, 0x6
208+do
209+assert(((debug.upvalueid(a[i],0x4) == debug.upvalueid(a[j],0x4)) == (i == j)))
210+end
211+end
212+local function testG
213+(a)
214+if (a == 0x1) then
215+goto l1
216+error("\u{73}\u{68}\u{6f}\u{75}\u{6c}\u{64}\u{20}\u{6e}\u{65}\u{76}\u{65}\u{72}\u{20}\u{62}\u{65}\u{20}\u{68}\u{65}\u{72}\u{65}\u{21}")
217+elseif (a == 0x2) then
218+goto l2
219+elseif (a == 0x3) then
220+goto l3
221+elseif (a == 0x4) then
222+goto l1
223+error("\u{73}\u{68}\u{6f}\u{75}\u{6c}\u{64}\u{20}\u{6e}\u{65}\u{76}\u{65}\u{72}\u{20}\u{62}\u{65}\u{20}\u{68}\u{65}\u{72}\u{65}\u{21}")
224+::l1::
225+a=(a + 0x1)
226+else
227+goto l4
228+::l4a::
229+a=(a * 0x2)
230+;
231+goto l4b
232+error("\u{73}\u{68}\u{6f}\u{75}\u{6c}\u{64}\u{20}\u{6e}\u{65}\u{76}\u{65}\u{72}\u{20}\u{62}\u{65}\u{20}\u{68}\u{65}\u{72}\u{65}\u{21}")
233+::l4::
234+goto l4a
235+error("\u{73}\u{68}\u{6f}\u{75}\u{6c}\u{64}\u{20}\u{6e}\u{65}\u{76}\u{65}\u{72}\u{20}\u{62}\u{65}\u{20}\u{68}\u{65}\u{72}\u{65}\u{21}")
236+::l4b::
237+end
238+do
239+return a
240+end
241+::l2::
242+do
243+return "\u{32}"
244+end
245+::l3::
246+do
247+return "\u{33}"
248+end
249+::l1::
250+return "\u{31}"
251+end
252+assert((testG(0x1) == "\u{31}"))
253+assert((testG(0x2) == "\u{32}"))
254+assert((testG(0x3) == "\u{33}"))
255+assert((testG(0x4) == 0x5))
256+assert((testG(0x5) == 0xa))
257+do
258+local X
259+goto L1
260+::L2::
261+goto L3
262+::L1::
263+do
264+local a <close> = setmetatable({},{["\u{5f}\u{5f}\u{63}\u{6c}\u{6f}\u{73}\u{65}"] = function ()
265+X=true
266+end})
267+assert((X == nil))
268+if a then
269+goto L2
270+end
271+end
272+::L3::
273+assert((X == true))
274+end
275+print("\u{4f}\u{4b}")
desk/res/lua/cycled/heavy.luanew file+126
@@ -0,0 +1,126 @@
1+local function teststring
2+()
3+print("\u{63}\u{72}\u{65}\u{61}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{61}\u{20}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{74}\u{6f}\u{6f}\u{20}\u{6c}\u{6f}\u{6e}\u{67}")
4+do
5+local a = "\u{78}"
6+local st,msg = pcall(function ()
7+while true do
8+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 .. a)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
9+print(string.format("\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{77}\u{69}\u{74}\u{68}\u{20}\u{25}\u{64}\u{20}\u{62}\u{79}\u{74}\u{65}\u{73}",(# a)))
10+end
11+end)
12+assert((not (st and (string.find(msg,"\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{6c}\u{65}\u{6e}\u{67}\u{74}\u{68}\u{20}\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}") or string.find(msg,"\u{6e}\u{6f}\u{74}\u{20}\u{65}\u{6e}\u{6f}\u{75}\u{67}\u{68}\u{20}\u{6d}\u{65}\u{6d}\u{6f}\u{72}\u{79}")))))
13+print(("\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{6c}\u{65}\u{6e}\u{67}\u{74}\u{68}\u{20}\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}\u{20}\u{77}\u{69}\u{74}\u{68}\u{20}" .. (# (a * 0x64))))
14+end
15+print("\u{2b}")
16+end
17+local function loadrep
18+(x,what)
19+local p = (0x1 << 0x14)
20+local s = string.rep(x,p)
21+local count = 0x0
22+local function f
23+()
24+count=(count + p)
25+if ((count % (0x80 * p)) == 0x0) then
26+io.stderr:write("\u{28}",(count // (0x2 ^ 0x14)),"\u{20}\u{4d}\u{29}")
27+end
28+return s
29+end
30+local st,msg = load(f,"\u{3d}\u{62}\u{69}\u{67}")
31+print("\u{a}\u{6d}\u{65}\u{6d}\u{6f}\u{72}\u{79}\u{3a}\u{20}",(collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}") * 0x400))
32+msg=string.match(msg,"\u{5e}\u{5b}\u{5e}\u{a}\u{5d}\u{2b}")
33+print(string.format("\u{74}\u{6f}\u{74}\u{61}\u{6c}\u{3a}\u{20}\u{30}\u{78}\u{25}\u{78}\u{20}\u{25}\u{73}\u{20}\u{28}\u{27}\u{25}\u{73}\u{27}\u{29}",count,what,msg))
34+return st,msg
35+end
36+function controlstruct()
37+print("\u{63}\u{6f}\u{6e}\u{74}\u{72}\u{6f}\u{6c}\u{20}\u{73}\u{74}\u{72}\u{75}\u{63}\u{74}\u{75}\u{72}\u{65}\u{20}\u{74}\u{6f}\u{6f}\u{20}\u{6c}\u{6f}\u{6e}\u{67}")
38+local lim = (((0x1 << 0x18) - 0x2) // 0x3)
39+local s = string.rep("\u{61}\u{20}\u{3d}\u{20}\u{61}\u{20}\u{2b}\u{20}\u{31}\u{a}",lim)
40+s=("\u{77}\u{68}\u{69}\u{6c}\u{65}\u{20}\u{74}\u{72}\u{75}\u{65}\u{20}\u{64}\u{6f}\u{20}" .. (s .. "\u{65}\u{6e}\u{64}"))
41+assert(load(s))
42+print(("\u{6f}\u{6b}\u{20}\u{77}\u{69}\u{74}\u{68}\u{20}" .. (lim .. "\u{20}\u{6c}\u{69}\u{6e}\u{65}\u{73}")))
43+lim=(lim + 0x3)
44+s=string.rep("\u{61}\u{20}\u{3d}\u{20}\u{61}\u{20}\u{2b}\u{20}\u{31}\u{a}",lim)
45+s=("\u{77}\u{68}\u{69}\u{6c}\u{65}\u{20}\u{74}\u{72}\u{75}\u{65}\u{20}\u{64}\u{6f}\u{20}" .. (s .. "\u{65}\u{6e}\u{64}"))
46+local st,msg = load(s)
47+assert((not (st and string.find(msg,"\u{74}\u{6f}\u{6f}\u{20}\u{6c}\u{6f}\u{6e}\u{67}"))))
48+print(msg)
49+end
50+function manylines()
51+print("\u{6c}\u{6f}\u{61}\u{64}\u{69}\u{6e}\u{67}\u{20}\u{63}\u{68}\u{75}\u{6e}\u{6b}\u{20}\u{77}\u{69}\u{74}\u{68}\u{20}\u{74}\u{6f}\u{6f}\u{20}\u{6d}\u{61}\u{6e}\u{79}\u{20}\u{6c}\u{69}\u{6e}\u{65}\u{73}")
52+local st,msg = loadrep("\u{a}","\u{6c}\u{69}\u{6e}\u{65}\u{73}")
53+assert((not (st and string.find(msg,"\u{74}\u{6f}\u{6f}\u{20}\u{6d}\u{61}\u{6e}\u{79}\u{20}\u{6c}\u{69}\u{6e}\u{65}\u{73}"))))
54+print("\u{2b}")
55+end
56+function hugeid()
57+print("\u{6c}\u{6f}\u{61}\u{64}\u{69}\u{6e}\u{67}\u{20}\u{63}\u{68}\u{75}\u{6e}\u{6b}\u{20}\u{77}\u{69}\u{74}\u{68}\u{20}\u{68}\u{75}\u{67}\u{65}\u{20}\u{69}\u{64}\u{65}\u{6e}\u{74}\u{69}\u{66}\u{69}\u{65}\u{72}")
58+local st,msg = loadrep("\u{61}","\u{63}\u{68}\u{61}\u{72}\u{73}")
59+assert((not (st and (string.find(msg,"\u{6c}\u{65}\u{78}\u{69}\u{63}\u{61}\u{6c}\u{20}\u{65}\u{6c}\u{65}\u{6d}\u{65}\u{6e}\u{74}\u{20}\u{74}\u{6f}\u{6f}\u{20}\u{6c}\u{6f}\u{6e}\u{67}") or string.find(msg,"\u{6e}\u{6f}\u{74}\u{20}\u{65}\u{6e}\u{6f}\u{75}\u{67}\u{68}\u{20}\u{6d}\u{65}\u{6d}\u{6f}\u{72}\u{79}")))))
60+print("\u{2b}")
61+end
62+function toomanyinst()
63+print("\u{6c}\u{6f}\u{61}\u{64}\u{69}\u{6e}\u{67}\u{20}\u{63}\u{68}\u{75}\u{6e}\u{6b}\u{20}\u{77}\u{69}\u{74}\u{68}\u{20}\u{74}\u{6f}\u{6f}\u{20}\u{6d}\u{61}\u{6e}\u{79}\u{20}\u{69}\u{6e}\u{73}\u{74}\u{72}\u{75}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{73}")
64+local st,msg = loadrep("\u{61}\u{20}\u{3d}\u{20}\u{31}\u{30}\u{3b}\u{20}","\u{69}\u{6e}\u{73}\u{74}\u{72}\u{75}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{73}")
65+print("\u{2b}")
66+end
67+local function loadrepfunc
68+(prefix,f)
69+local count = (- 0x1)
70+local function aux
71+()
72+count=(count + 0x1)
73+if (count == 0x0) then
74+return prefix
75+else
76+if ((count % 0x100000) == 0x0) then
77+io.stderr:write("\u{28}",(count // (0x2 ^ 0x14)),"\u{20}\u{4d}\u{29}")
78+end
79+return f(count)
80+end
81+end
82+local st,msg = load(aux,"\u{6b}")
83+print("\u{a}\u{6d}\u{65}\u{6d}\u{6f}\u{72}\u{79}\u{3a}\u{20}",(collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}") * 0x400))
84+msg=string.match(msg,"\u{5e}\u{5b}\u{5e}\u{a}\u{5d}\u{2b}")
85+print("\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{3a}\u{20}",msg)
86+end
87+function toomanyconst()
88+print("\u{6c}\u{6f}\u{61}\u{64}\u{69}\u{6e}\u{67}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{77}\u{69}\u{74}\u{68}\u{20}\u{74}\u{6f}\u{6f}\u{20}\u{6d}\u{61}\u{6e}\u{79}\u{20}\u{63}\u{6f}\u{6e}\u{73}\u{74}\u{61}\u{6e}\u{74}\u{73}")
89+loadrepfunc("\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{66}\u{6f}\u{6f}\u{20}\u{28}\u{29}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{7b}\u{30}\u{2c}",function (n)
90+return string.char(0x22,(((n // (0x80 ^ 0x0)) & 0x7f) + 0x80),(((n // (0x80 ^ 0x1)) & 0x7f) + 0x80),(((n // (0x80 ^ 0x2)) & 0x7f) + 0x80),(((n // (0x80 ^ 0x3)) & 0x7f) + 0x80),(((n // (0x80 ^ 0x4)) & 0x7f) + 0x80),0x22,0x2c)
91+end)
92+end
93+function toomanystr()
94+local a = {}
95+local st,msg = pcall(function ()
96+for i = 0x1, math.huge
97+do
98+if ((i % 0x100000) == 0x0) then
99+io.stderr:write("\u{28}",(i // (0x2 ^ 0x14)),"\u{20}\u{4d}\u{29}")
100+end
101+a[i]=string.pack("\u{49}",i)
102+end
103+end)
104+local size = (# a)
105+a=collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}")
106+print("\u{a}\u{6d}\u{65}\u{6d}\u{6f}\u{72}\u{79}\u{3a}",(a * 0x400))
107+print("\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{3a}",msg)
108+print("\u{73}\u{69}\u{7a}\u{65}\u{3a}",size)
109+end
110+function toomanyidx()
111+local a = {}
112+local st,msg = pcall(function ()
113+for i = 0x1, math.huge
114+do
115+if ((i % 0x100000) == 0x0) then
116+io.stderr:write("\u{28}",(i // (0x2 ^ 0x14)),"\u{20}\u{4d}\u{29}")
117+end
118+a[i]=i
119+end
120+end)
121+print("\u{a}\u{6d}\u{65}\u{6d}\u{6f}\u{72}\u{79}\u{3a}\u{20}",(collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}") * 0x400))
122+print("\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{3a}\u{20}",msg)
123+print("\u{73}\u{69}\u{7a}\u{65}\u{3a}",(# a))
124+end
125+toomanyidx()
126+print("\u{4f}\u{4b}")
desk/res/lua/cycled/literals.luanew file+199
@@ -0,0 +1,199 @@
1+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{73}\u{63}\u{61}\u{6e}\u{6e}\u{65}\u{72}")
2+local debug = require("\u{64}\u{65}\u{62}\u{75}\u{67}")
3+local function dostring
4+(x)
5+return assert(load(x),"")()
6+end
7+dostring("\u{78}\u{20}\u{b}\u{c}\u{20}\u{3d}\u{20}\u{9}\u{d}\u{20}\u{27}\u{61}\u{0}\u{61}\u{27}\u{20}\u{b}\u{c}\u{c}")
8+assert(((x == "\u{61}\u{0}\u{61}") and (string.len(x) == 0x3)))
9+_G.x=nil
10+assert(("\u{a}\u{22}\u{27}\u{5c}" == "\u{a}\u{22}\u{27}\u{5c}"))
11+assert(string.find("\u{7}\u{8}\u{c}\u{a}\u{d}\u{9}\u{b}","\u{5e}\u{25}\u{63}\u{25}\u{63}\u{25}\u{63}\u{25}\u{63}\u{25}\u{63}\u{25}\u{63}\u{25}\u{63}\u{24}"))
12+assert(("\u{63}\u{31}\u{32}" == "\u{63}\u{31}\u{32}"))
13+assert(("\u{63}\u{61}\u{62}" == "\u{63}\u{61}\u{62}"))
14+assert(("\u{63}" == "\u{63}"))
15+assert(("\u{63}\u{a}" == "\u{63}\u{a}"))
16+assert(("\u{0}\u{0}\u{0}\u{61}\u{6c}\u{6f}" == ("\u{0}" .. ("\u{0}\u{0}" .. "\u{61}\u{6c}\u{6f}"))))
17+assert((0xa .. (0x14 .. (- (0x1e == "\u{31}\u{30}\u{32}\u{30}\u{2d}\u{33}\u{30}")))))
18+assert(("\u{0}\u{5}\u{10}\u{1f}\u{3c}\u{ff}\u{e8}" == "\u{0}\u{5}\u{10}\u{1f}\u{3c}\u{ff}\u{e8}"))
19+local function lexstring
20+(x,y,n)
21+local f = assert(load(("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}" .. (x .. "\u{2c}\u{20}\u{72}\u{65}\u{71}\u{75}\u{69}\u{72}\u{65}\u{22}\u{64}\u{65}\u{62}\u{75}\u{67}\u{22}\u{2e}\u{67}\u{65}\u{74}\u{69}\u{6e}\u{66}\u{6f}\u{28}\u{31}\u{29}\u{2e}\u{63}\u{75}\u{72}\u{72}\u{65}\u{6e}\u{74}\u{6c}\u{69}\u{6e}\u{65}")),""))
22+local s,l = f()
23+assert(((s == y) and (l == n)))
24+end
25+lexstring("\u{27}\u{61}\u{62}\u{63}\u{5c}\u{7a}\u{20}\u{20}\u{a}\u{20}\u{20}\u{20}\u{65}\u{66}\u{67}\u{27}","\u{61}\u{62}\u{63}\u{65}\u{66}\u{67}",0x2)
26+lexstring("\u{27}\u{61}\u{62}\u{63}\u{5c}\u{7a}\u{20}\u{20}\u{a}\u{a}\u{a}\u{27}","\u{61}\u{62}\u{63}",0x4)
27+lexstring("\u{27}\u{5c}\u{7a}\u{20}\u{20}\u{a}\u{9}\u{c}\u{b}\u{a}\u{27}","",0x3)
28+lexstring("\u{5b}\u{5b}\u{a}\u{61}\u{6c}\u{6f}\u{a}\u{61}\u{6c}\u{6f}\u{a}\u{a}\u{5d}\u{5d}","\u{61}\u{6c}\u{6f}\u{a}\u{61}\u{6c}\u{6f}\u{a}\u{a}",0x5)
29+lexstring("\u{5b}\u{5b}\u{a}\u{61}\u{6c}\u{6f}\u{d}\u{61}\u{6c}\u{6f}\u{a}\u{a}\u{5d}\u{5d}","\u{61}\u{6c}\u{6f}\u{a}\u{61}\u{6c}\u{6f}\u{a}\u{a}",0x5)
30+lexstring("\u{5b}\u{5b}\u{a}\u{61}\u{6c}\u{6f}\u{d}\u{61}\u{6c}\u{6f}\u{d}\u{a}\u{5d}\u{5d}","\u{61}\u{6c}\u{6f}\u{a}\u{61}\u{6c}\u{6f}\u{a}",0x4)
31+lexstring("\u{5b}\u{5b}\u{d}\u{61}\u{6c}\u{6f}\u{a}\u{d}\u{61}\u{6c}\u{6f}\u{d}\u{a}\u{5d}\u{5d}","\u{61}\u{6c}\u{6f}\u{a}\u{61}\u{6c}\u{6f}\u{a}",0x4)
32+lexstring("\u{5b}\u{5b}\u{61}\u{6c}\u{6f}\u{5d}\u{a}\u{5d}\u{61}\u{6c}\u{6f}\u{5d}\u{5d}","\u{61}\u{6c}\u{6f}\u{5d}\u{a}\u{5d}\u{61}\u{6c}\u{6f}",0x2)
33+assert(("\u{61}\u{62}\u{63}\u{64}\u{65}\u{66}\u{67}\u{68}\u{69}" == "\u{61}\u{62}\u{63}\u{64}\u{65}\u{66}\u{67}\u{68}\u{69}"))
34+assert(("\u{0}\u{0}\u{0}\u{0}" == string.char(0x0,0x0,0x0,0x0)))
35+assert(("\u{0}\u{7f}" == "\u{0}\u{7f}"))
36+assert(("\u{80}\u{7ff}" == "\u{c2}\u{80}\u{df}\u{bf}"))
37+assert(("\u{800}\u{ffff}" == "\u{e0}\u{a0}\u{80}\u{ef}\u{bf}\u{bf}"))
38+assert(("\u{10000}\u{1fffff}" == "\u{f0}\u{90}\u{80}\u{80}\u{f7}\u{bf}\u{bf}\u{bf}"))
39+assert(("\u{200000}\u{3ffffff}" == "\u{f8}\u{88}\u{80}\u{80}\u{80}\u{fb}\u{bf}\u{bf}\u{bf}\u{bf}"))
40+assert(("\u{4000000}\u{7fffffff}" == "\u{fc}\u{84}\u{80}\u{80}\u{80}\u{80}\u{fd}\u{bf}\u{bf}\u{bf}\u{bf}\u{bf}"))
41+local function lexerror
42+(s,err)
43+local st,msg = load(("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}" .. s),"")
44+if (err ~= "\u{3c}\u{65}\u{6f}\u{66}\u{3e}") then
45+err=(err .. "\u{27}")
46+end
47+assert((not (st and string.find(msg,("\u{6e}\u{65}\u{61}\u{72}\u{20}\u{2e}\u{2d}" .. err)))))
48+end
49+lexerror("\u{22}\u{61}\u{62}\u{63}\u{5c}\u{78}\u{22}","\u{5c}\u{78}\u{22}")
50+lexerror("\u{22}\u{61}\u{62}\u{63}\u{5c}\u{78}","\u{5c}\u{78}")
51+lexerror("\u{22}\u{5c}\u{78}","\u{5c}\u{78}")
52+lexerror("\u{22}\u{5c}\u{78}\u{35}\u{22}","\u{5c}\u{78}\u{35}\u{22}")
53+lexerror("\u{22}\u{5c}\u{78}\u{35}","\u{5c}\u{78}\u{35}")
54+lexerror("\u{22}\u{5c}\u{78}\u{72}\u{22}","\u{5c}\u{78}\u{72}")
55+lexerror("\u{22}\u{5c}\u{78}\u{72}","\u{5c}\u{78}\u{72}")
56+lexerror("\u{22}\u{5c}\u{78}\u{2e}","\u{5c}\u{78}\u{2e}")
57+lexerror("\u{22}\u{5c}\u{78}\u{38}\u{25}\u{22}","\u{5c}\u{78}\u{38}\u{25}\u{25}")
58+lexerror("\u{22}\u{5c}\u{78}\u{41}\u{47}","\u{5c}\u{78}\u{41}\u{47}")
59+lexerror("\u{22}\u{5c}\u{67}\u{22}","\u{5c}\u{67}")
60+lexerror("\u{22}\u{5c}\u{67}","\u{5c}\u{67}")
61+lexerror("\u{22}\u{5c}\u{2e}\u{22}","\u{5c}\u{25}\u{2e}")
62+lexerror("\u{22}\u{5c}\u{39}\u{39}\u{39}\u{22}","\u{5c}\u{39}\u{39}\u{39}\u{22}")
63+lexerror("\u{22}\u{78}\u{79}\u{7a}\u{5c}\u{33}\u{30}\u{30}\u{22}","\u{5c}\u{33}\u{30}\u{30}\u{22}")
64+lexerror("\u{22}\u{20}\u{20}\u{20}\u{5c}\u{32}\u{35}\u{36}\u{22}","\u{5c}\u{32}\u{35}\u{36}\u{22}")
65+lexerror("\u{22}\u{61}\u{62}\u{63}\u{5c}\u{75}\u{7b}\u{31}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{7d}\u{22}","\u{61}\u{62}\u{63}\u{5c}\u{75}\u{7b}\u{31}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}")
66+lexerror("\u{22}\u{61}\u{62}\u{63}\u{5c}\u{75}\u{31}\u{31}\u{72}\u{22}","\u{61}\u{62}\u{63}\u{5c}\u{75}\u{31}")
67+lexerror("\u{22}\u{61}\u{62}\u{63}\u{5c}\u{75}\u{22}","\u{61}\u{62}\u{63}\u{5c}\u{75}\u{22}")
68+lexerror("\u{22}\u{61}\u{62}\u{63}\u{5c}\u{75}\u{7b}\u{31}\u{31}\u{72}\u{22}","\u{61}\u{62}\u{63}\u{5c}\u{75}\u{7b}\u{31}\u{31}\u{72}")
69+lexerror("\u{22}\u{61}\u{62}\u{63}\u{5c}\u{75}\u{7b}\u{31}\u{31}\u{22}","\u{61}\u{62}\u{63}\u{5c}\u{75}\u{7b}\u{31}\u{31}\u{22}")
70+lexerror("\u{22}\u{61}\u{62}\u{63}\u{5c}\u{75}\u{7b}\u{31}\u{31}","\u{61}\u{62}\u{63}\u{5c}\u{75}\u{7b}\u{31}\u{31}")
71+lexerror("\u{22}\u{61}\u{62}\u{63}\u{5c}\u{75}\u{7b}\u{72}\u{22}","\u{61}\u{62}\u{63}\u{5c}\u{75}\u{7b}\u{72}")
72+lexerror("\u{5b}\u{3d}\u{5b}\u{61}\u{6c}\u{6f}\u{5d}\u{5d}","\u{3c}\u{65}\u{6f}\u{66}\u{3e}")
73+lexerror("\u{5b}\u{3d}\u{5b}\u{61}\u{6c}\u{6f}\u{5d}\u{3d}","\u{3c}\u{65}\u{6f}\u{66}\u{3e}")
74+lexerror("\u{5b}\u{3d}\u{5b}\u{61}\u{6c}\u{6f}\u{5d}","\u{3c}\u{65}\u{6f}\u{66}\u{3e}")
75+lexerror("\u{27}\u{61}\u{6c}\u{6f}","\u{3c}\u{65}\u{6f}\u{66}\u{3e}")
76+lexerror("\u{27}\u{61}\u{6c}\u{6f}\u{20}\u{5c}\u{7a}\u{20}\u{20}\u{a}\u{a}","\u{3c}\u{65}\u{6f}\u{66}\u{3e}")
77+lexerror("\u{27}\u{61}\u{6c}\u{6f}\u{20}\u{5c}\u{7a}","\u{3c}\u{65}\u{6f}\u{66}\u{3e}")
78+lexerror("\u{27}\u{61}\u{6c}\u{6f}\u{20}\u{5c}\u{39}\u{38}","\u{3c}\u{65}\u{6f}\u{66}\u{3e}")
79+for i = 0x0, 0xff
80+do
81+local s = string.char(i)
82+assert((not (string.find(s,"\u{5b}\u{61}\u{2d}\u{7a}\u{41}\u{2d}\u{5a}\u{5f}\u{5d}") == (not load((s .. "\u{3d}\u{31}"),"")))))
83+assert((not (string.find(s,"\u{5b}\u{61}\u{2d}\u{7a}\u{41}\u{2d}\u{5a}\u{5f}\u{30}\u{2d}\u{39}\u{5d}") == (not load(("\u{61}" .. (s .. "\u{31}\u{20}\u{3d}\u{20}\u{31}")),"")))))
84+end
85+local var1 = (string.rep("\u{61}",0x3a98) .. "\u{31}")
86+local var2 = (string.rep("\u{61}",0x3a98) .. "\u{32}")
87+local prog = string.format("\u{20}\u{20}\u{25}\u{73}\u{20}\u{3d}\u{20}\u{35}\u{a}\u{20}\u{20}\u{25}\u{73}\u{20}\u{3d}\u{20}\u{25}\u{73}\u{20}\u{2b}\u{20}\u{31}\u{a}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{28}\u{29}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{25}\u{73}\u{20}\u{2d}\u{20}\u{25}\u{73}\u{20}\u{65}\u{6e}\u{64}\u{a}",var1,var2,var1,var1,var2)
88+local f = dostring(prog)
89+assert((((_G[var1] == 0x5) and (_G[var2] == 0x6)) and (f() == (- 0x1))))
90+_G[var1],_G[var2]=nil
91+print("\u{2b}")
92+assert(("\u{a}\u{9}" == "\u{a}\u{9}"))
93+assert(("\u{a}\u{20}\u{24}\u{64}\u{65}\u{62}\u{75}\u{67}" == "\u{a}\u{20}\u{24}\u{64}\u{65}\u{62}\u{75}\u{67}"))
94+assert(("\u{20}\u{5b}\u{20}" ~= "\u{20}\u{5d}\u{20}"))
95+local b = "\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}"
96+assert((string.len(b) == 0x3c0))
97+prog="\u{70}\u{72}\u{69}\u{6e}\u{74}\u{28}\u{27}\u{2b}\u{27}\u{29}\u{a}\u{a}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{31}\u{20}\u{3d}\u{20}\u{5b}\u{5b}\u{22}\u{74}\u{68}\u{69}\u{73}\u{20}\u{69}\u{73}\u{20}\u{61}\u{20}\u{27}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{27}\u{20}\u{77}\u{69}\u{74}\u{68}\u{20}\u{73}\u{65}\u{76}\u{65}\u{72}\u{61}\u{6c}\u{20}\u{27}\u{71}\u{75}\u{6f}\u{74}\u{65}\u{73}\u{27}\u{22}\u{5d}\u{5d}\u{a}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{32}\u{20}\u{3d}\u{20}\u{22}\u{27}\u{71}\u{75}\u{6f}\u{74}\u{65}\u{73}\u{27}\u{22}\u{a}\u{a}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{2e}\u{66}\u{69}\u{6e}\u{64}\u{28}\u{61}\u{31}\u{2c}\u{20}\u{61}\u{32}\u{29}\u{20}\u{3d}\u{3d}\u{20}\u{33}\u{34}\u{29}\u{a}\u{70}\u{72}\u{69}\u{6e}\u{74}\u{28}\u{27}\u{2b}\u{27}\u{29}\u{a}\u{a}\u{61}\u{31}\u{20}\u{3d}\u{20}\u{5b}\u{3d}\u{3d}\u{5b}\u{74}\u{65}\u{6d}\u{70}\u{20}\u{3d}\u{20}\u{5b}\u{5b}\u{61}\u{6e}\u{20}\u{61}\u{72}\u{62}\u{69}\u{74}\u{72}\u{61}\u{72}\u{79}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{5d}\u{5d}\u{3b}\u{20}\u{5d}\u{3d}\u{3d}\u{5d}\u{a}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{6c}\u{6f}\u{61}\u{64}\u{28}\u{61}\u{31}\u{29}\u{29}\u{28}\u{29}\u{a}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{74}\u{65}\u{6d}\u{70}\u{20}\u{3d}\u{3d}\u{20}\u{27}\u{61}\u{6e}\u{20}\u{61}\u{72}\u{62}\u{69}\u{74}\u{72}\u{61}\u{72}\u{79}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{27}\u{29}\u{a}\u{5f}\u{47}\u{2e}\u{74}\u{65}\u{6d}\u{70}\u{20}\u{3d}\u{20}\u{6e}\u{69}\u{6c}\u{a}\u{2d}\u{2d}\u{20}\u{6c}\u{6f}\u{6e}\u{67}\u{20}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{73}\u{20}\u{2d}\u{2d}\u{a}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{62}\u{20}\u{3d}\u{20}\u{22}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{22}\u{a}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{2e}\u{6c}\u{65}\u{6e}\u{28}\u{62}\u{29}\u{20}\u{3d}\u{3d}\u{20}\u{39}\u{36}\u{30}\u{29}\u{a}\u{70}\u{72}\u{69}\u{6e}\u{74}\u{28}\u{27}\u{2b}\u{27}\u{29}\u{a}\u{a}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{5b}\u{5b}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}\u{30}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{a}\u{5d}\u{5d}\u{a}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{2e}\u{6c}\u{65}\u{6e}\u{28}\u{61}\u{29}\u{20}\u{3d}\u{3d}\u{20}\u{31}\u{38}\u{36}\u{33}\u{29}\u{a}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{2e}\u{73}\u{75}\u{62}\u{28}\u{61}\u{2c}\u{20}\u{31}\u{2c}\u{20}\u{34}\u{30}\u{29}\u{20}\u{3d}\u{3d}\u{20}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{2e}\u{73}\u{75}\u{62}\u{28}\u{62}\u{2c}\u{20}\u{31}\u{2c}\u{20}\u{34}\u{30}\u{29}\u{29}\u{a}\u{78}\u{20}\u{3d}\u{20}\u{31}\u{a}"
98+print("\u{2b}")
99+_G.x=nil
100+dostring(prog)
101+assert(x)
102+_G.x=nil
103+do
104+local function getadd
105+(s)
106+return string.format("\u{25}\u{70}",s)
107+end
108+local s1 <const> = "\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}"
109+local s2 <const> = "\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}"
110+local s3 = "\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}"
111+local function foo
112+()
113+return s1
114+end
115+local function foo1
116+()
117+return s3
118+end
119+local function foo2
120+()
121+return "\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}"
122+end
123+local a1 = getadd(s1)
124+assert((a1 == getadd(s2)))
125+assert((a1 == getadd(foo())))
126+assert((a1 == getadd(foo1())))
127+assert((a1 == getadd(foo2())))
128+local sd = ("\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}" .. "\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}")
129+assert(((sd == s1) and (getadd(sd) ~= a1)))
130+end
131+prog="\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{31}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{2d}\u{2d}\u{20}\u{61}\u{20}\u{63}\u{6f}\u{6d}\u{6d}\u{65}\u{6e}\u{74}\u{a}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{62}\u{20}\u{3d}\u{20}\u{32}\u{a}\u{a}\u{a}\u{78}\u{20}\u{3d}\u{20}\u{5b}\u{3d}\u{5b}\u{a}\u{68}\u{69}\u{a}\u{5d}\u{3d}\u{5d}\u{a}\u{79}\u{20}\u{3d}\u{20}\u{22}\u{5c}\u{a}\u{68}\u{65}\u{6c}\u{6c}\u{6f}\u{5c}\u{72}\u{5c}\u{6e}\u{5c}\u{a}\u{22}\u{a}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{72}\u{65}\u{71}\u{75}\u{69}\u{72}\u{65}\u{22}\u{64}\u{65}\u{62}\u{75}\u{67}\u{22}\u{2e}\u{67}\u{65}\u{74}\u{69}\u{6e}\u{66}\u{6f}\u{28}\u{31}\u{29}\u{2e}\u{63}\u{75}\u{72}\u{72}\u{65}\u{6e}\u{74}\u{6c}\u{69}\u{6e}\u{65}\u{a}"
132+for _,n in pairs({"\u{a}","\u{d}","\u{a}\u{d}","\u{d}\u{a}"})
133+do
134+local prog,nn = string.gsub(prog,"\u{a}",n)
135+assert((dostring(prog) == nn))
136+assert(((_G.x == "\u{68}\u{69}\u{a}") and (_G.y == "\u{a}\u{68}\u{65}\u{6c}\u{6c}\u{6f}\u{d}\u{a}\u{a}")))
137+end
138+_G.x,_G.y=nil
139+local a = "\u{5d}\u{3d}"
140+assert((a == "\u{5d}\u{3d}"))
141+a="\u{5b}\u{3d}\u{3d}\u{3d}\u{5b}\u{5b}\u{3d}\u{5b}\u{5d}\u{5d}\u{3d}\u{5d}\u{5b}\u{3d}\u{3d}\u{3d}\u{3d}\u{5b}\u{5d}\u{5d}\u{3d}\u{3d}\u{3d}\u{5d}\u{3d}\u{3d}\u{3d}"
142+assert((a == "\u{5b}\u{3d}\u{3d}\u{3d}\u{5b}\u{5b}\u{3d}\u{5b}\u{5d}\u{5d}\u{3d}\u{5d}\u{5b}\u{3d}\u{3d}\u{3d}\u{3d}\u{5b}\u{5d}\u{5d}\u{3d}\u{3d}\u{3d}\u{5d}\u{3d}\u{3d}\u{3d}"))
143+a="\u{5b}\u{3d}\u{3d}\u{3d}\u{5b}\u{5b}\u{3d}\u{5b}\u{5d}\u{5d}\u{3d}\u{5d}\u{5b}\u{3d}\u{3d}\u{3d}\u{3d}\u{5b}\u{5d}\u{5d}\u{3d}\u{3d}\u{3d}\u{5d}\u{3d}\u{3d}\u{3d}"
144+assert((a == "\u{5b}\u{3d}\u{3d}\u{3d}\u{5b}\u{5b}\u{3d}\u{5b}\u{5d}\u{5d}\u{3d}\u{5d}\u{5b}\u{3d}\u{3d}\u{3d}\u{3d}\u{5b}\u{5d}\u{5d}\u{3d}\u{3d}\u{3d}\u{5d}\u{3d}\u{3d}\u{3d}"))
145+a="\u{5d}\u{5d}\u{5d}\u{5d}\u{5d}\u{5d}\u{5d}\u{5d}"
146+assert((a == "\u{5d}\u{5d}\u{5d}\u{5d}\u{5d}\u{5d}\u{5d}\u{5d}"))
147+local x = {"\u{3d}","\u{5b}","\u{5d}","\u{a}"}
148+local len = 0x4
149+local function gen
150+(c,n)
151+if (n == 0x0) then
152+coroutine.yield(c)
153+else
154+for _,a in pairs(x)
155+do
156+gen((c .. a),(n - 0x1))
157+end
158+end
159+end
160+for s in coroutine.wrap(function ()
161+gen("",len)
162+end)
163+do
164+assert((s == load(("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{5b}\u{3d}\u{3d}\u{3d}\u{3d}\u{5b}\u{a}" .. (s .. "\u{5d}\u{3d}\u{3d}\u{3d}\u{3d}\u{5d}")),"")()))
165+end
166+if (os.setlocale("\u{70}\u{74}\u{5f}\u{42}\u{52}") or os.setlocale("\u{70}\u{74}\u{62}")) then
167+assert(((tonumber("\u{33}\u{2c}\u{34}") == 3.4) and (tonumber("\u{33}\u{2e}\u{34}") == 3.4)))
168+assert((tonumber("\u{20}\u{20}\u{2d}\u{2e}\u{34}\u{20}\u{20}") == (- 0.4)))
169+assert((tonumber("\u{20}\u{20}\u{2b}\u{30}\u{78}\u{2e}\u{34}\u{31}\u{20}\u{20}") == 0.25390625))
170+assert((not load("\u{61}\u{20}\u{3d}\u{20}\u{28}\u{33}\u{2c}\u{34}\u{29}")))
171+assert((assert(load("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{33}\u{2e}\u{34}"))() == 3.4))
172+assert((assert(load("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2e}\u{34}\u{2c}\u{33}"))() == 0.4))
173+assert((assert(load("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{34}\u{2e}"))() == 4.0))
174+assert((assert(load("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{34}\u{2e}\u{2b}\u{2e}\u{35}"))() == 4.5))
175+assert(((("\u{20}\u{30}\u{78}\u{2e}\u{31}\u{20}" + "\u{20}\u{30}\u{78}\u{2c}\u{31}") + "\u{2d}\u{30}\u{58}\u{2e}\u{31}\u{9}") == 0.0625))
176+assert((not (tonumber("\u{69}\u{6e}\u{66}") and (not tonumber("\u{4e}\u{41}\u{4e}")))))
177+assert((assert(load(string.format("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{25}\u{71}",4.51)))() == 4.51))
178+local a,b = load("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{34}\u{2e}\u{35}\u{2e}")
179+assert(string.find(b,"\u{27}\u{34}\u{25}\u{2e}\u{35}\u{25}\u{2e}\u{27}"))
180+assert(os.setlocale("\u{43}"))
181+else
182+(Message or print)("\u{a}\u{20}\u{3e}\u{3e}\u{3e}\u{20}\u{70}\u{74}\u{5f}\u{42}\u{52}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{65}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{61}\u{76}\u{61}\u{69}\u{6c}\u{61}\u{62}\u{6c}\u{65}\u{3a}\u{20}\u{73}\u{6b}\u{69}\u{70}\u{70}\u{69}\u{6e}\u{67}\u{20}\u{64}\u{65}\u{63}\u{69}\u{6d}\u{61}\u{6c}\u{20}\u{70}\u{6f}\u{69}\u{6e}\u{74}\u{20}\u{74}\u{65}\u{73}\u{74}\u{73}\u{20}\u{3c}\u{3c}\u{3c}\u{a}")
183+end
184+local s = "\u{61}\u{20}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{77}\u{69}\u{74}\u{68}\u{20}\u{d}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{a}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{d}\u{a}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{a}\u{d}"
185+local c = string.format("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{25}\u{71}",s)
186+assert((assert(load(c))() == s))
187+assert((not load("\u{61}\u{20}\u{3d}\u{20}\u{27}\u{6e}\u{6f}\u{6e}\u{2d}\u{65}\u{6e}\u{64}\u{69}\u{6e}\u{67}\u{20}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}")))
188+assert((not load("\u{61}\u{20}\u{3d}\u{20}\u{27}\u{6e}\u{6f}\u{6e}\u{2d}\u{65}\u{6e}\u{64}\u{69}\u{6e}\u{67}\u{20}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{a}\u{27}")))
189+assert((not load("\u{61}\u{20}\u{3d}\u{20}\u{27}\u{5c}\u{33}\u{34}\u{35}\u{27}")))
190+assert((not load("\u{61}\u{20}\u{3d}\u{20}\u{5b}\u{3d}\u{78}\u{5d}")))
191+local function malformednum
192+(n,exp)
193+local s,msg = load(("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}" .. n))
194+assert((not (s and string.find(msg,exp))))
195+end
196+malformednum("\u{30}\u{78}\u{65}\u{2d}","\u{6e}\u{65}\u{61}\u{72}\u{20}\u{3c}\u{65}\u{6f}\u{66}\u{3e}")
197+malformednum("\u{30}\u{78}\u{65}\u{70}\u{2d}\u{70}","\u{6d}\u{61}\u{6c}\u{66}\u{6f}\u{72}\u{6d}\u{65}\u{64}\u{20}\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}")
198+malformednum("\u{31}\u{70}\u{72}\u{69}\u{6e}\u{74}\u{28}\u{29}","\u{6d}\u{61}\u{6c}\u{66}\u{6f}\u{72}\u{6d}\u{65}\u{64}\u{20}\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}")
199+print("\u{4f}\u{4b}")
desk/res/lua/cycled/locals.luanew file+1050
@@ -0,0 +1,1050 @@
1+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{76}\u{61}\u{72}\u{69}\u{61}\u{62}\u{6c}\u{65}\u{73}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{65}\u{6e}\u{76}\u{69}\u{72}\u{6f}\u{6e}\u{6d}\u{65}\u{6e}\u{74}\u{73}")
2+local debug = require("\u{64}\u{65}\u{62}\u{75}\u{67}")
3+local tracegc = require("\u{74}\u{72}\u{61}\u{63}\u{65}\u{67}\u{63}")
4+local function f
5+(x)
6+x=nil
7+;
8+return x
9+end
10+assert((f(0xa) == nil))
11+local function f
12+()
13+local x
14+;
15+return x
16+end
17+assert((f(0xa) == nil))
18+local function f
19+(x)
20+x=nil
21+;
22+local y
23+;
24+return x,y
25+end
26+assert(((f(0xa) == nil) and (select(0x2,f(0x14)) == nil)))
27+do
28+local i = 0xa
29+do
30+local i = 0x64
31+;
32+assert((i == 0x64))
33+end
34+do
35+local i = 0x3e8
36+;
37+assert((i == 0x3e8))
38+end
39+assert((i == 0xa))
40+if (i ~= 0xa) then
41+local i = 0x14
42+else
43+local i = 0x1e
44+assert((i == 0x1e))
45+end
46+end
47+f=nil
48+local f
49+local x = 0x1
50+a=nil
51+load("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{7b}\u{7d}")()
52+assert((a == nil))
53+function f(a)
54+local _1,_2,_3,_4,_5
55+local _6,_7,_8,_9,_10
56+local x = 0x3
57+local b = a
58+local c,d = a,b
59+if (d == b) then
60+local x = "\u{71}"
61+x=b
62+assert((x == 0x2))
63+else
64+assert(nil)
65+end
66+assert((x == 0x3))
67+local f = 0xa
68+end
69+local b = 0xa
70+local a
71+;
72+repeat
73+local b
74+;
75+a,b=0x1,0x2
76+;
77+assert(((a + 0x1) == b))
78+;
79+until ((a + b) == 0x3)
80+assert((x == 0x1))
81+f(0x2)
82+assert((type(f) == "\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}"))
83+local function getenv
84+(f)
85+local a,b = debug.getupvalue(f,0x1)
86+assert((a == "\u{5f}\u{45}\u{4e}\u{56}"))
87+return b
88+end
89+assert((getenv(load("\u{61}\u{3d}\u{33}")) == _G))
90+local c = {}
91+;
92+local f = load("\u{61}\u{20}\u{3d}\u{20}\u{33}",nil,nil,c)
93+assert((getenv(f) == c))
94+assert((c.a == nil))
95+f()
96+assert((c.a == 0x3))
97+do
98+local i = 0x2
99+local p = 0x4
100+repeat
101+for j = (- 0x3), 0x3
102+do
103+assert(load(string.format("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{3d}\u{25}\u{73}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{61}\u{3d}\u{61}\u{2b}\u{25}\u{73}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{61}\u{20}\u{3d}\u{3d}\u{32}\u{5e}\u{25}\u{73}\u{29}",j,(p - j),i),""))()
104+assert(load(string.format("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{3d}\u{25}\u{73}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{61}\u{3d}\u{61}\u{2d}\u{25}\u{73}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{61}\u{3d}\u{3d}\u{2d}\u{32}\u{5e}\u{25}\u{73}\u{29}",(- j),(p - j),i),""))()
105+assert(load(string.format("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{2c}\u{62}\u{3d}\u{30}\u{2c}\u{25}\u{73}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{61}\u{3d}\u{62}\u{2d}\u{25}\u{73}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{61}\u{3d}\u{3d}\u{2d}\u{32}\u{5e}\u{25}\u{73}\u{29}",(- j),(p - j),i),""))()
106+end
107+p=(0x2 * p)
108+;
109+i=(i + 0x1)
110+until (p <= 0x0)
111+end
112+print("\u{2b}")
113+if rawget(_G,"\u{54}") then
114+collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
115+local a = {[{}] = 0x4,[0x3] = 0x0,["\u{61}\u{6c}\u{6f}"] = 0x1,["\u{61}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}"] = 0xa}
116+local t = T.querytab(a)
117+for k,_ in pairs(a)
118+do
119+a[k]=undef
120+end
121+collectgarbage()
122+for i = 0x0, (t - 0x1)
123+do
124+local k = querytab(a,i)
125+assert((((k == nil) or (type(k) == "\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}")) or (k == "\u{61}\u{6c}\u{6f}")))
126+end
127+local a = {}
128+local function additems
129+()
130+a.x=true
131+;
132+a.y=true
133+;
134+a.z=true
135+a[0x1]=true
136+a[0x2]=true
137+end
138+for i = 0x1, math.huge
139+do
140+T.alloccount(i)
141+local st,msg = pcall(additems)
142+T.alloccount()
143+local count = 0x0
144+for k,v in pairs(a)
145+do
146+assert((a[k] == v))
147+count=(count + 0x1)
148+end
149+if st then
150+assert((count == 0x5))
151+;
152+break
153+end
154+end
155+end
156+assert((_ENV == _G))
157+do
158+local dummy
159+local _ENV = (function (...)
160+return ...
161+end)(_G,dummy)
162+do
163+local _ENV = {["\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}"] = assert}
164+;
165+assert(true)
166+end
167+local mt = {["\u{5f}\u{47}"] = _G}
168+local foo,x
169+A=false
170+do
171+local _ENV = mt
172+function foo(x)
173+A=x
174+do
175+local _ENV = _G
176+;
177+A=0x3e8
178+end
179+return function (x)
180+return (A .. x)
181+end
182+end
183+end
184+assert((getenv(foo) == mt))
185+x=foo("\u{68}\u{69}")
186+;
187+assert(((mt.A == "\u{68}\u{69}") and (A == 0x3e8)))
188+assert((x("\u{2a}") == (mt.A .. "\u{2a}")))
189+do
190+local _ENV = {["\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}"] = assert,["\u{41}"] = 0xa}
191+;
192+do
193+local _ENV = {["\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}"] = assert,["\u{41}"] = 0x14}
194+;
195+assert((A == 0x14))
196+;
197+x=A
198+end
199+assert(((A == 0xa) and (x == 0x14)))
200+end
201+assert((x == 0x14))
202+A=nil
203+do
204+local a <const>,b,c <const> = 0xa,0x14,0x1e
205+b=((a + c) + b)
206+assert((((a == 0xa) and (b == 0x3c)) and (c == 0x1e)))
207+local function checkro
208+(name,code)
209+local st,msg = load(code)
210+local gab = string.format("\u{61}\u{74}\u{74}\u{65}\u{6d}\u{70}\u{74}\u{20}\u{74}\u{6f}\u{20}\u{61}\u{73}\u{73}\u{69}\u{67}\u{6e}\u{20}\u{74}\u{6f}\u{20}\u{63}\u{6f}\u{6e}\u{73}\u{74}\u{20}\u{76}\u{61}\u{72}\u{69}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{27}\u{25}\u{73}\u{27}",name)
211+assert((not (st and string.find(msg,gab))))
212+end
213+checkro("\u{79}","\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{78}\u{2c}\u{20}\u{79}\u{20}\u{3c}\u{63}\u{6f}\u{6e}\u{73}\u{74}\u{3e}\u{2c}\u{20}\u{7a}\u{20}\u{3d}\u{20}\u{31}\u{30}\u{2c}\u{20}\u{32}\u{30}\u{2c}\u{20}\u{33}\u{30}\u{3b}\u{20}\u{78}\u{20}\u{3d}\u{20}\u{31}\u{31}\u{3b}\u{20}\u{79}\u{20}\u{3d}\u{20}\u{31}\u{32}")
214+checkro("\u{78}","\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{78}\u{20}\u{3c}\u{63}\u{6f}\u{6e}\u{73}\u{74}\u{3e}\u{2c}\u{20}\u{79}\u{2c}\u{20}\u{7a}\u{20}\u{3c}\u{63}\u{6f}\u{6e}\u{73}\u{74}\u{3e}\u{20}\u{3d}\u{20}\u{31}\u{30}\u{2c}\u{20}\u{32}\u{30}\u{2c}\u{20}\u{33}\u{30}\u{3b}\u{20}\u{78}\u{20}\u{3d}\u{20}\u{31}\u{31}")
215+checkro("\u{7a}","\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{78}\u{20}\u{3c}\u{63}\u{6f}\u{6e}\u{73}\u{74}\u{3e}\u{2c}\u{20}\u{79}\u{2c}\u{20}\u{7a}\u{20}\u{3c}\u{63}\u{6f}\u{6e}\u{73}\u{74}\u{3e}\u{20}\u{3d}\u{20}\u{31}\u{30}\u{2c}\u{20}\u{32}\u{30}\u{2c}\u{20}\u{33}\u{30}\u{3b}\u{20}\u{79}\u{20}\u{3d}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{7a}\u{20}\u{3d}\u{20}\u{31}\u{31}")
216+checkro("\u{66}\u{6f}\u{6f}","\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{66}\u{6f}\u{6f}\u{20}\u{3c}\u{63}\u{6f}\u{6e}\u{73}\u{74}\u{3e}\u{20}\u{3d}\u{20}\u{31}\u{30}\u{3b}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{66}\u{6f}\u{6f}\u{28}\u{29}\u{20}\u{65}\u{6e}\u{64}")
217+checkro("\u{66}\u{6f}\u{6f}","\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{66}\u{6f}\u{6f}\u{20}\u{3c}\u{63}\u{6f}\u{6e}\u{73}\u{74}\u{3e}\u{20}\u{3d}\u{20}\u{7b}\u{7d}\u{3b}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{66}\u{6f}\u{6f}\u{28}\u{29}\u{20}\u{65}\u{6e}\u{64}")
218+checkro("\u{7a}","\u{20}\u{20}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{2c}\u{20}\u{7a}\u{20}\u{3c}\u{63}\u{6f}\u{6e}\u{73}\u{74}\u{3e}\u{2c}\u{20}\u{62}\u{20}\u{3d}\u{20}\u{31}\u{30}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{66}\u{6f}\u{6f}\u{28}\u{29}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{32}\u{30}\u{3b}\u{20}\u{7a}\u{20}\u{3d}\u{20}\u{33}\u{32}\u{3b}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{20}\u{20}")
219+checkro("\u{76}\u{61}\u{72}\u{31}","\u{20}\u{20}\u{20}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{2c}\u{20}\u{76}\u{61}\u{72}\u{31}\u{20}\u{3c}\u{63}\u{6f}\u{6e}\u{73}\u{74}\u{3e}\u{20}\u{3d}\u{20}\u{31}\u{30}\u{3b}\u{a}\u{20}\u{20}\u{20}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{66}\u{6f}\u{6f}\u{28}\u{29}\u{20}\u{61}\u{20}\u{3d}\u{20}\u{32}\u{30}\u{3b}\u{20}\u{7a}\u{20}\u{3d}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{28}\u{29}\u{20}\u{76}\u{61}\u{72}\u{31}\u{20}\u{3d}\u{20}\u{31}\u{32}\u{3b}\u{20}\u{65}\u{6e}\u{64}\u{20}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{20}\u{20}")
220+end
221+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{74}\u{6f}\u{2d}\u{62}\u{65}\u{2d}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{64}\u{20}\u{76}\u{61}\u{72}\u{69}\u{61}\u{62}\u{6c}\u{65}\u{73}")
222+local function stack
223+(n)
224+n=((n == 0x0) or stack((n - 0x1)))
225+end
226+local function func2close
227+(f,x,y)
228+local obj = setmetatable({},{["\u{5f}\u{5f}\u{63}\u{6c}\u{6f}\u{73}\u{65}"] = f})
229+if x then
230+return x,obj,y
231+else
232+return obj
233+end
234+end
235+do
236+local a = {}
237+do
238+local b <close> = false
239+local x <close> = setmetatable({"\u{78}"},{["\u{5f}\u{5f}\u{63}\u{6c}\u{6f}\u{73}\u{65}"] = function (self)
240+a[(# (a + 0x1))]=self[0x1]
241+end})
242+local w,y <close>,z = func2close(function (self,err)
243+assert((err == nil))
244+;
245+a[(# (a + 0x1))]="\u{79}"
246+end,0xa,0x14)
247+local c <close> = nil
248+a[(# (a + 0x1))]="\u{69}\u{6e}"
249+assert(((w == 0xa) and (z == 0x14)))
250+end
251+a[(# (a + 0x1))]="\u{6f}\u{75}\u{74}"
252+assert(((((a[0x1] == "\u{69}\u{6e}") and (a[0x2] == "\u{79}")) and (a[0x3] == "\u{78}")) and (a[0x4] == "\u{6f}\u{75}\u{74}")))
253+end
254+do
255+local X = false
256+local x,closescope = func2close(function (_,msg)
257+stack(0xa)
258+;
259+assert((msg == nil))
260+X=true
261+end,0x64)
262+assert((x == 0x64))
263+;
264+x=0x65
265+;
266+local function foo
267+(x)
268+local _ <close> = closescope
269+return x,X,0x17
270+end
271+local a,b,c = foo(1.5)
272+assert(((((a == 1.5) and (b == false)) and (c == 0x17)) and (X == true)))
273+X=false
274+foo=function (x)
275+local _ <close> = func2close(function (_,msg)
276+assert((debug.getinfo(0x2).name == "\u{66}\u{6f}\u{6f}"))
277+assert((msg == nil))
278+end)
279+local _ <close> = closescope
280+local y = 0xf
281+return y
282+end
283+assert(((foo() == 0xf) and (X == true)))
284+X=false
285+foo=function ()
286+local x <close> = closescope
287+return x
288+end
289+assert(((foo() == closescope) and (X == true)))
290+end
291+do
292+local flag = false
293+local x = setmetatable({},{["\u{5f}\u{5f}\u{63}\u{6c}\u{6f}\u{73}\u{65}"] = function ()
294+assert((flag == false))
295+;
296+flag=true
297+end})
298+local y <const> = nil
299+local z <const> = nil
300+do
301+local a <close> = x
302+end
303+assert(flag)
304+end
305+do
306+local flag = false
307+local x = setmetatable({},{["\u{5f}\u{5f}\u{63}\u{6c}\u{6f}\u{73}\u{65}"] = function ()
308+assert((flag == false))
309+;
310+flag=true
311+end})
312+local function a
313+()
314+return function ()
315+return nil
316+end,nil,nil,x
317+end
318+local v <const> = 0x1
319+local w <const> = 0x1
320+local x <const> = 0x1
321+local y <const> = 0x1
322+local z <const> = 0x1
323+for k in a()
324+do
325+a=k
326+end
327+assert(flag)
328+end
329+do
330+local X,Y
331+local function foo
332+()
333+local _ <close> = func2close(function ()
334+Y=0xa
335+end)
336+assert(((X == true) and (Y == nil)))
337+return 0x1,0x2,0x3
338+end
339+local function bar
340+()
341+local _ <close> = func2close(function ()
342+X=false
343+end)
344+X=true
345+do
346+return foo()
347+end
348+end
349+local a,b,c,d = bar()
350+assert(((((((a == 0x1) and (b == 0x2)) and (c == 0x3)) and (X == false)) and (Y == 0xa)) and (d == nil)))
351+end
352+do
353+local closed = false
354+local function foo
355+()
356+return function ()
357+return true
358+end,0x0,0x0,func2close(function ()
359+closed=true
360+end)
361+end
362+local function tail
363+()
364+return closed
365+end
366+local function foo1
367+()
368+for k in foo()
369+do
370+return tail()
371+end
372+end
373+assert((foo1() == false))
374+assert((closed == true))
375+end
376+do
377+local closed = false
378+local o1 = setmetatable({},{["\u{5f}\u{5f}\u{63}\u{6c}\u{6f}\u{73}\u{65}"] = function ()
379+closed=true
380+end})
381+local function test
382+()
383+for k,v in next,{},nil,o1
384+do
385+local function f
386+()
387+return k
388+end
389+break
390+end
391+assert(closed)
392+end
393+test()
394+end
395+do
396+print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{73}\u{20}\u{69}\u{6e}\u{20}\u{5f}\u{5f}\u{63}\u{6c}\u{6f}\u{73}\u{65}")
397+local function foo
398+()
399+local x <close> = func2close(function (self,msg)
400+assert(string.find(msg,"\u{40}\u{79}"))
401+error("\u{40}\u{78}")
402+end)
403+local x1 <close> = func2close(function (self,msg)
404+assert(string.find(msg,"\u{40}\u{79}"))
405+end)
406+local gc <close> = func2close(function ()
407+collectgarbage()
408+end)
409+local y <close> = func2close(function (self,msg)
410+assert(string.find(msg,"\u{40}\u{7a}"))
411+error("\u{40}\u{79}")
412+end)
413+local z <close> = func2close(function (self,msg)
414+assert((msg == nil))
415+error("\u{40}\u{7a}")
416+end)
417+return 0xc8
418+end
419+local stat,msg = pcall(foo,false)
420+assert(string.find(msg,"\u{40}\u{78}"))
421+local function foo
422+()
423+local x <close> = func2close(function (self,msg)
424+assert((debug.getinfo(0x2).name == "\u{70}\u{63}\u{61}\u{6c}\u{6c}"))
425+assert(string.find(msg,"\u{40}\u{78}\u{31}"))
426+end)
427+local x1 <close> = func2close(function (self,msg)
428+assert((debug.getinfo(0x2).name == "\u{70}\u{63}\u{61}\u{6c}\u{6c}"))
429+assert(string.find(msg,"\u{40}\u{79}"))
430+error("\u{40}\u{78}\u{31}")
431+end)
432+local gc <close> = func2close(function ()
433+collectgarbage()
434+end)
435+local y <close> = func2close(function (self,msg)
436+assert((debug.getinfo(0x2).name == "\u{70}\u{63}\u{61}\u{6c}\u{6c}"))
437+assert(string.find(msg,"\u{40}\u{7a}"))
438+error("\u{40}\u{79}")
439+end)
440+local first = true
441+local z <close> = func2close(function (self,msg)
442+assert((debug.getinfo(0x2).name == "\u{70}\u{63}\u{61}\u{6c}\u{6c}"))
443+assert((first and (msg == 0x4)))
444+first=false
445+error("\u{40}\u{7a}")
446+end)
447+error(0x4)
448+end
449+local stat,msg = pcall(foo,true)
450+assert(string.find(msg,"\u{40}\u{78}\u{31}"))
451+local function foo
452+(...)
453+do
454+local x1 <close> = func2close(function (self,msg)
455+assert(string.find(msg,"\u{40}\u{58}"))
456+error("\u{40}\u{59}")
457+end)
458+local x123 <close> = func2close(function (_,msg)
459+assert((msg == nil))
460+error("\u{40}\u{58}")
461+end)
462+end
463+os.exit(false)
464+end
465+local st,msg = xpcall(foo,debug.traceback)
466+assert(string.match(msg,"\u{5e}\u{5b}\u{5e}\u{20}\u{5d}\u{2a}\u{20}\u{40}\u{59}"))
467+local function foo
468+(...)
469+local x123 <close> = func2close(function ()
470+error("\u{40}\u{78}\u{31}\u{32}\u{33}")
471+end)
472+end
473+local st,msg = xpcall(foo,debug.traceback)
474+assert(string.match(msg,"\u{5e}\u{5b}\u{5e}\u{20}\u{5d}\u{2a}\u{20}\u{40}\u{78}\u{31}\u{32}\u{33}"))
475+assert(string.find(msg,"\u{69}\u{6e}\u{20}\u{6d}\u{65}\u{74}\u{61}\u{6d}\u{65}\u{74}\u{68}\u{6f}\u{64}\u{20}\u{27}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{27}"))
476+end
477+do
478+local function foo
479+()
480+local x <close> = {}
481+os.exit(false)
482+end
483+local stat,msg = pcall(foo)
484+assert((not (stat and string.find(msg,"\u{76}\u{61}\u{72}\u{69}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{27}\u{78}\u{27}\u{20}\u{67}\u{6f}\u{74}\u{20}\u{61}\u{20}\u{6e}\u{6f}\u{6e}\u{25}\u{2d}\u{63}\u{6c}\u{6f}\u{73}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}"))))
485+local function foo
486+()
487+local xyz <close> = setmetatable({},{["\u{5f}\u{5f}\u{63}\u{6c}\u{6f}\u{73}\u{65}"] = print})
488+getmetatable(xyz).__close=nil
489+end
490+local stat,msg = pcall(foo)
491+assert((not (stat and string.find(msg,"\u{6d}\u{65}\u{74}\u{61}\u{6d}\u{65}\u{74}\u{68}\u{6f}\u{64}\u{20}\u{27}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{27}"))))
492+local function foo
493+()
494+local a1 <close> = func2close(function (_,msg)
495+assert(string.find(msg,"\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}"))
496+error(0xc)
497+end)
498+local a2 <close> = setmetatable({},{["\u{5f}\u{5f}\u{63}\u{6c}\u{6f}\u{73}\u{65}"] = print})
499+local a3 <close> = func2close(function (_,msg)
500+assert((msg == nil))
501+error(0x7b)
502+end)
503+getmetatable(a2).__close=0x4
504+end
505+local stat,msg = pcall(foo)
506+assert((not (stat and (msg == 0xc))))
507+end
508+do
509+local track = {}
510+local function foo
511+()
512+local x <close> = func2close(function ()
513+local xx <close> = func2close(function (_,msg)
514+assert((msg == nil))
515+track[(# (track + 0x1))]="\u{78}\u{78}"
516+end)
517+track[(# (track + 0x1))]="\u{78}"
518+end)
519+track[(# (track + 0x1))]="\u{66}\u{6f}\u{6f}"
520+return 0x14,0x1e,0x28
521+end
522+local a,b,c,d = foo()
523+assert(((((a == 0x14) and (b == 0x1e)) and (c == 0x28)) and (d == nil)))
524+assert((((track[0x1] == "\u{66}\u{6f}\u{6f}") and (track[0x2] == "\u{78}")) and (track[0x3] == "\u{78}\u{78}")))
525+local track = {}
526+local function foo
527+()
528+local x0 <close> = func2close(function (_,msg)
529+assert((msg == 0xca))
530+track[(# (track + 0x1))]="\u{78}\u{30}"
531+end)
532+local x <close> = func2close(function ()
533+local xx <close> = func2close(function (_,msg)
534+assert((msg == 0x65))
535+track[(# (track + 0x1))]="\u{78}\u{78}"
536+error(0xca)
537+end)
538+track[(# (track + 0x1))]="\u{78}"
539+error(0x65)
540+end)
541+track[(# (track + 0x1))]="\u{66}\u{6f}\u{6f}"
542+return 0x14,0x1e,0x28
543+end
544+local st,msg = pcall(foo)
545+assert((not (st and (msg == 0xca))))
546+assert(((((track[0x1] == "\u{66}\u{6f}\u{6f}") and (track[0x2] == "\u{78}")) and (track[0x3] == "\u{78}\u{78}")) and (track[0x4] == "\u{78}\u{30}")))
547+end
548+local function checktable
549+(t1,t2)
550+assert((# (t1 == (# t2))))
551+for i = 0x1, (# t1)
552+do
553+assert((t1[i] == t2[i]))
554+end
555+end
556+do
557+local function overflow
558+(n)
559+overflow((n + 0x1))
560+end
561+local function errorh
562+(m)
563+assert(string.find(m,"\u{73}\u{74}\u{61}\u{63}\u{6b}\u{20}\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}"))
564+local x <close> = func2close(function (o)
565+o[0x1]=0xa
566+end)
567+return x
568+end
569+local flag
570+local st,obj
571+local co = coroutine.wrap(function ()
572+local y <close> = func2close(function (obj,msg)
573+assert((msg == nil))
574+obj[0x1]=0x64
575+flag=obj
576+end)
577+tracegc.stop()
578+st,obj=xpcall(overflow,errorh,0x0)
579+tracegc.start()
580+end)
581+co()
582+assert((not ((st and (obj[0x1] == 0xa)) and (flag[0x1] == 0x64))))
583+end
584+if rawget(_G,"\u{54}") then
585+do
586+collectgarbage()
587+;
588+collectgarbage()
589+;
590+collectgarbage()
591+local function loop
592+(n)
593+if (n < 0x190) then
594+loop((n + 0x1))
595+end
596+end
597+local o = setmetatable({},{["\u{5f}\u{5f}\u{63}\u{6c}\u{6f}\u{73}\u{65}"] = function ()
598+loop(0x0)
599+end})
600+local script = "\u{74}\u{6f}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{20}\u{32}\u{3b}\u{20}\u{73}\u{65}\u{74}\u{74}\u{6f}\u{70}\u{20}\u{31}\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}"
601+assert((T.testC(script,o) == script))
602+end
603+local function foo
604+()
605+local y <close> = func2close(function ()
606+T.alloccount()
607+end)
608+local x <close> = setmetatable({},{["\u{5f}\u{5f}\u{63}\u{6c}\u{6f}\u{73}\u{65}"] = function ()
609+T.alloccount(0x0)
610+;
611+local x = {}
612+end})
613+error(0x3e8)
614+end
615+stack(0x5)
616+local _,msg = pcall(foo)
617+assert((msg == "\u{6e}\u{6f}\u{74}\u{20}\u{65}\u{6e}\u{6f}\u{75}\u{67}\u{68}\u{20}\u{6d}\u{65}\u{6d}\u{6f}\u{72}\u{79}"))
618+local closemsg
619+local close = func2close(function (self,msg)
620+T.alloccount()
621+closemsg=msg
622+end)
623+local function enter
624+(count)
625+stack(0xa)
626+T.alloccount(count)
627+closemsg=nil
628+return close
629+end
630+local function test
631+()
632+local x <close> = enter(0x0)
633+local y = {}
634+end
635+local _,msg = pcall(test)
636+assert(((msg == "\u{6e}\u{6f}\u{74}\u{20}\u{65}\u{6e}\u{6f}\u{75}\u{67}\u{68}\u{20}\u{6d}\u{65}\u{6d}\u{6f}\u{72}\u{79}") and (closemsg == "\u{6e}\u{6f}\u{74}\u{20}\u{65}\u{6e}\u{6f}\u{75}\u{67}\u{68}\u{20}\u{6d}\u{65}\u{6d}\u{6f}\u{72}\u{79}")))
637+local function test
638+()
639+local xxx <close> = func2close(function (self,msg)
640+assert((msg == "\u{6e}\u{6f}\u{74}\u{20}\u{65}\u{6e}\u{6f}\u{75}\u{67}\u{68}\u{20}\u{6d}\u{65}\u{6d}\u{6f}\u{72}\u{79}"))
641+;
642+error(0x3e8)
643+end)
644+local xx <close> = func2close(function (self,msg)
645+assert((msg == "\u{6e}\u{6f}\u{74}\u{20}\u{65}\u{6e}\u{6f}\u{75}\u{67}\u{68}\u{20}\u{6d}\u{65}\u{6d}\u{6f}\u{72}\u{79}"))
646+;
647+end)
648+local x <close> = enter(0x0)
649+local y = {}
650+end
651+local _,msg = pcall(test)
652+assert(((msg == 0x3e8) and (closemsg == "\u{6e}\u{6f}\u{74}\u{20}\u{65}\u{6e}\u{6f}\u{75}\u{67}\u{68}\u{20}\u{6d}\u{65}\u{6d}\u{6f}\u{72}\u{79}")))
653+do
654+collectgarbage()
655+local s = string.rep("\u{61}",0x2710)
656+local m = T.totalmem()
657+collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
658+s=string.upper(s)
659+assert(((T.totalmem() - m) <= 0x2af8))
660+collectgarbage("\u{72}\u{65}\u{73}\u{74}\u{61}\u{72}\u{74}")
661+end
662+do
663+local lim = 0x2710
664+local extra = 0x7d0
665+local s = string.rep("\u{61}",lim)
666+local a = {s,s}
667+collectgarbage()
668+;
669+collectgarbage()
670+local m = T.totalmem()
671+collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
672+T.totalmem((m + extra))
673+assert((not pcall(table.concat,a)))
674+assert(((T.totalmem() - m) <= extra))
675+T.totalmem(((m + lim) + extra))
676+assert((not pcall(table.concat,a)))
677+assert(((T.totalmem() - m) <= extra))
678+T.totalmem(((m + (0x2 * lim)) + extra))
679+assert((not pcall(table.concat,a)))
680+assert(((T.totalmem() - m) <= extra))
681+T.totalmem(((m + (0x4 * lim)) + extra))
682+assert((# (table.concat(a) == (0x2 * lim))))
683+T.totalmem(0x0)
684+collectgarbage("\u{72}\u{65}\u{73}\u{74}\u{61}\u{72}\u{74}")
685+print("\u{2b}")
686+end
687+do
688+local trace = {}
689+local function hook
690+(event)
691+trace[(# (trace + 0x1))]=(event .. ("\u{20}" .. (debug.getinfo(0x2).name or "\u{3f}")))
692+end
693+local x = func2close(function (_,msg)
694+trace[(# (trace + 0x1))]="\u{78}"
695+end)
696+local y = func2close(function (_,msg)
697+trace[(# (trace + 0x1))]="\u{79}"
698+end)
699+debug.sethook(hook,"\u{72}")
700+local t = {T.testC("\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{74}\u{6f}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{20}\u{32}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{78}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{6e}\u{75}\u{6d}\u{20}\u{31}\u{30}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{70}\u{75}\u{73}\u{68}\u{69}\u{6e}\u{74}\u{20}\u{32}\u{30}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{74}\u{6f}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{20}\u{33}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{23}\u{20}\u{79}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{32}\u{a}\u{20}\u{20}\u{20}\u{20}",x,y)}
701+debug.sethook()
702+checktable(trace,{"\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{73}\u{65}\u{74}\u{68}\u{6f}\u{6f}\u{6b}","\u{79}","\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{3f}","\u{78}","\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{3f}","\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{74}\u{65}\u{73}\u{74}\u{43}"})
703+checktable(t,{0xa,0x14})
704+end
705+end
706+do
707+local trace = {}
708+local function hook
709+(event)
710+trace[(# (trace + 0x1))]=(event .. ("\u{20}" .. debug.getinfo(0x2).name))
711+end
712+local function foo
713+(...)
714+local x <close> = func2close(function (_,msg)
715+trace[(# (trace + 0x1))]="\u{78}"
716+end)
717+local y <close> = func2close(function (_,msg)
718+debug.sethook(hook,"\u{72}")
719+end)
720+return ...
721+end
722+local t = {foo(0xa,0x14,0x1e)}
723+debug.sethook()
724+checktable(t,{0xa,0x14,0x1e})
725+checktable(trace,{"\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{73}\u{65}\u{74}\u{68}\u{6f}\u{6f}\u{6b}","\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{63}\u{6c}\u{6f}\u{73}\u{65}","\u{78}","\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{63}\u{6c}\u{6f}\u{73}\u{65}","\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{66}\u{6f}\u{6f}"})
726+end
727+print("\u{74}\u{6f}\u{2d}\u{62}\u{65}\u{2d}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{64}\u{20}\u{76}\u{61}\u{72}\u{69}\u{61}\u{62}\u{6c}\u{65}\u{73}\u{20}\u{69}\u{6e}\u{20}\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}\u{73}")
728+do
729+local trace = {}
730+local co = coroutine.wrap(function ()
731+trace[(# (trace + 0x1))]="\u{6e}\u{6f}\u{77}\u{58}"
732+local x <close> = func2close(function (_,msg)
733+assert((msg == nil))
734+trace[(# (trace + 0x1))]="\u{78}\u{31}"
735+coroutine.yield("\u{78}")
736+trace[(# (trace + 0x1))]="\u{78}\u{32}"
737+end)
738+return pcall(function ()
739+do
740+local z <close> = func2close(function (_,msg)
741+assert((msg == nil))
742+trace[(# (trace + 0x1))]="\u{7a}\u{31}"
743+coroutine.yield("\u{7a}")
744+trace[(# (trace + 0x1))]="\u{7a}\u{32}"
745+end)
746+end
747+trace[(# (trace + 0x1))]="\u{6e}\u{6f}\u{77}\u{59}"
748+local y <close> = func2close(function (_,msg)
749+assert((msg == nil))
750+trace[(# (trace + 0x1))]="\u{79}\u{31}"
751+coroutine.yield("\u{79}")
752+trace[(# (trace + 0x1))]="\u{79}\u{32}"
753+end)
754+return 0xa,0x14,0x1e
755+end)
756+end)
757+assert((co() == "\u{7a}"))
758+assert((co() == "\u{79}"))
759+assert((co() == "\u{78}"))
760+checktable({co()},{true,0xa,0x14,0x1e})
761+checktable(trace,{"\u{6e}\u{6f}\u{77}\u{58}","\u{7a}\u{31}","\u{7a}\u{32}","\u{6e}\u{6f}\u{77}\u{59}","\u{79}\u{31}","\u{79}\u{32}","\u{78}\u{31}","\u{78}\u{32}"})
762+end
763+do
764+local extrares
765+local function check
766+(body,extra, ...)
767+local t = table.pack(...)
768+local co = coroutine.wrap(body)
769+if extra then
770+extrares=co()
771+end
772+local res = table.pack(co())
773+assert(((res.n == 0x2) and (res[0x2] == nil)))
774+local res2 = table.pack(co())
775+assert((res2.n == t.n))
776+for i = 0x1, (# t)
777+do
778+if (t[i] == "\u{78}") then
779+assert((res2[i] == res[0x1]))
780+else
781+assert((res2[i] == t[i]))
782+end
783+end
784+end
785+local function foo
786+()
787+local x <close> = func2close(coroutine.yield)
788+local extra <close> = func2close(function (self)
789+assert((self == extrares))
790+coroutine.yield(0x64)
791+end)
792+extrares=extra
793+return table.unpack({0xa,x,0x1e})
794+end
795+check(foo,true,0xa,"\u{78}",0x1e)
796+assert((extrares == 0x64))
797+local function foo
798+()
799+local x <close> = func2close(coroutine.yield)
800+return
801+end
802+check(foo,false)
803+local function foo
804+()
805+local x <close> = func2close(coroutine.yield)
806+local y,z = 0x14,0x1e
807+return x
808+end
809+check(foo,false,"\u{78}")
810+local function foo
811+()
812+local x <close> = func2close(coroutine.yield)
813+local extra <close> = func2close(coroutine.yield)
814+return table.unpack({},0x1,0x64)
815+end
816+check(foo,true,table.unpack({},0x1,0x64))
817+end
818+do
819+local co = coroutine.wrap(function ()
820+local function foo
821+(err)
822+local z <close> = func2close(function (_,msg)
823+assert(((msg == nil) or (msg == (err + 0x14))))
824+coroutine.yield("\u{7a}")
825+return 0x64,0xc8
826+end)
827+local y <close> = func2close(function (_,msg)
828+assert(((msg == err) or ((msg == nil) and (err == 0x1))))
829+coroutine.yield("\u{79}")
830+if err then
831+error((err + 0x14))
832+end
833+end)
834+local x <close> = func2close(function (_,msg)
835+assert(((msg == err) or ((msg == nil) and (err == 0x1))))
836+coroutine.yield("\u{78}")
837+return 0x64,0xc8
838+end)
839+if (err == 0xa) then
840+error(err)
841+else
842+return 0xa,0x14
843+end
844+end
845+coroutine.yield(pcall(foo,nil))
846+coroutine.yield(pcall(foo,0x1))
847+return pcall(foo,0xa)
848+end)
849+local a,b = co()
850+assert(((a == "\u{78}") and (b == nil)))
851+a,b=co()
852+assert(((a == "\u{79}") and (b == nil)))
853+a,b=co()
854+assert(((a == "\u{7a}") and (b == nil)))
855+local a,b,c = co()
856+assert(((a and (b == 0xa)) and (c == 0x14)))
857+local a,b = co()
858+assert(((a == "\u{78}") and (b == nil)))
859+a,b=co()
860+assert(((a == "\u{79}") and (b == nil)))
861+a,b=co()
862+assert(((a == "\u{7a}") and (b == nil)))
863+local st,msg = co()
864+assert((not (st and (msg == 0x15))))
865+local a,b = co()
866+assert(((a == "\u{78}") and (b == nil)))
867+a,b=co()
868+assert(((a == "\u{79}") and (b == nil)))
869+a,b=co()
870+assert(((a == "\u{7a}") and (b == nil)))
871+local st,msg = co()
872+assert((not (st and (msg == (0xa + 0x14)))))
873+end
874+do
875+local x = false
876+local y = false
877+local co = coroutine.wrap(function ()
878+local xv <close> = func2close(function ()
879+x=true
880+end)
881+do
882+local yv <close> = func2close(function ()
883+y=true
884+end)
885+coroutine.yield(0x64)
886+end
887+coroutine.yield(0xc8)
888+error(0x17)
889+end)
890+local b = co()
891+assert(((b == 0x64) and (not (x and (not y)))))
892+b=co()
893+assert(((b == 0xc8) and (not (x and y))))
894+local a,b = pcall(co)
895+assert((not (((a and (b == 0x17)) and x) and y)))
896+end
897+do
898+local x = 0x0
899+local co = coroutine.wrap(function ()
900+local xx <close> = func2close(function (_,msg)
901+x=(x + 0x1)
902+;
903+assert(string.find(msg,"\u{40}\u{58}\u{58}\u{58}"))
904+error("\u{40}\u{59}\u{59}\u{59}")
905+end)
906+local xv <close> = func2close(function ()
907+x=(x + 0x1)
908+;
909+error("\u{40}\u{58}\u{58}\u{58}")
910+end)
911+coroutine.yield(0x64)
912+error(0xc8)
913+end)
914+assert((co() == 0x64))
915+;
916+assert((x == 0x0))
917+local st,msg = pcall(co)
918+;
919+assert((x == 0x2))
920+assert((not (st and string.find(msg,"\u{40}\u{59}\u{59}\u{59}"))))
921+local x = 0x0
922+local y = 0x0
923+co=coroutine.wrap(function ()
924+local xx <close> = func2close(function (_,err)
925+y=(y + 0x1)
926+;
927+assert(string.find(err,"\u{58}\u{58}\u{58}"))
928+error("\u{59}\u{59}\u{59}")
929+end)
930+local xv <close> = func2close(function ()
931+x=(x + 0x1)
932+;
933+error("\u{58}\u{58}\u{58}")
934+end)
935+coroutine.yield(0x64)
936+return 0xc8
937+end)
938+assert((co() == 0x64))
939+;
940+assert((x == 0x0))
941+local st,msg = pcall(co)
942+assert(((x == 0x1) and (y == 0x1)))
943+assert((not (st and string.find(msg,"\u{25}\u{77}\u{2b}\u{25}\u{2e}\u{25}\u{77}\u{2b}\u{3a}\u{25}\u{64}\u{2b}\u{3a}\u{20}\u{59}\u{59}\u{59}"))))
944+end
945+local co
946+co=coroutine.wrap(function ()
947+local x <close> = func2close(function ()
948+os.exit(false)
949+end)
950+co=nil
951+coroutine.yield()
952+end)
953+co()
954+assert((co == nil))
955+collectgarbage()
956+if rawget(_G,"\u{54}") then
957+print("\u{74}\u{6f}\u{2d}\u{62}\u{65}\u{2d}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{64}\u{20}\u{76}\u{61}\u{72}\u{69}\u{61}\u{62}\u{6c}\u{65}\u{73}\u{20}\u{78}\u{20}\u{63}\u{6f}\u{72}\u{6f}\u{75}\u{74}\u{69}\u{6e}\u{65}\u{73}\u{20}\u{69}\u{6e}\u{20}\u{43}")
958+do
959+local token = 0x0
960+local count = 0x0
961+local f = T.makeCfunc("\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{74}\u{6f}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{20}\u{31}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{74}\u{6f}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{20}\u{32}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2e}\u{a}\u{20}\u{20}\u{20}\u{20}")
962+local obj = func2close(function (_,msg)
963+count=(count + 0x1)
964+token=coroutine.yield(count,token)
965+end)
966+local co = coroutine.wrap(f)
967+local ct,res = co(obj,obj,0xa,0x14,0x1e,0x3)
968+assert(((ct == 0x1) and (res == 0x0)))
969+ct,res=co(0x64)
970+assert(((ct == 0x2) and (res == 0x64)))
971+res={co(0xc8)}
972+assert(((((res[0x1] == 0xa) and (res[0x2] == 0x14)) and (res[0x3] == 0x1e)) and (res[0x4] == nil)))
973+assert((token == 0xc8))
974+end
975+do
976+local f = T.makeCfunc("\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{74}\u{6f}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{20}\u{31}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2e}\u{a}\u{20}\u{20}\u{20}\u{20}")
977+local obj = func2close(function ()
978+local temp
979+local x <close> = func2close(function ()
980+coroutine.yield(temp)
981+return 0x1,0x2,0x3
982+end)
983+temp=coroutine.yield("\u{63}\u{6c}\u{6f}\u{73}\u{69}\u{6e}\u{67}\u{20}\u{6f}\u{62}\u{6a}")
984+return 0x1,0x2,0x3
985+end)
986+local co = coroutine.wrap(f)
987+local res = co(obj,0xa,0x1e,0x1)
988+assert((res == "\u{63}\u{6c}\u{6f}\u{73}\u{69}\u{6e}\u{67}\u{20}\u{6f}\u{62}\u{6a}"))
989+res=co("\u{63}\u{6c}\u{6f}\u{73}\u{69}\u{6e}\u{67}\u{20}\u{78}")
990+assert((res == "\u{63}\u{6c}\u{6f}\u{73}\u{69}\u{6e}\u{67}\u{20}\u{78}"))
991+res={co()}
992+assert(((res[0x1] == 0x1e) and (res[0x2] == nil)))
993+end
994+do
995+local f = T.makeCfunc("\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{74}\u{6f}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{20}\u{31}\u{a}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{73}\u{6c}\u{6f}\u{74}\u{20}\u{31}\u{a}\u{20}\u{20}\u{20}\u{20}")
996+local obj = func2close(coroutine.yield)
997+local co = coroutine.create(f)
998+local st,msg = coroutine.resume(co,obj)
999+assert((not (st and string.find(msg,"\u{61}\u{74}\u{74}\u{65}\u{6d}\u{70}\u{74}\u{20}\u{74}\u{6f}\u{20}\u{79}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{61}\u{63}\u{72}\u{6f}\u{73}\u{73}"))))
1000+local f = T.makeCfunc("\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{74}\u{6f}\u{63}\u{6c}\u{6f}\u{73}\u{65}\u{20}\u{31}\u{a}\u{20}\u{20}\u{20}\u{20}")
1001+local st,msg = pcall(f,obj)
1002+assert((not (st and string.find(msg,"\u{61}\u{74}\u{74}\u{65}\u{6d}\u{70}\u{74}\u{20}\u{74}\u{6f}\u{20}\u{79}\u{69}\u{65}\u{6c}\u{64}\u{20}\u{66}\u{72}\u{6f}\u{6d}\u{20}\u{6f}\u{75}\u{74}\u{73}\u{69}\u{64}\u{65}"))))
1003+end
1004+end
1005+do
1006+local numopen = 0x0
1007+local function open
1008+(x)
1009+numopen=(numopen + 0x1)
1010+return function ()
1011+x=(x - 0x1)
1012+if (x > 0x0) then
1013+return x
1014+end
1015+end,nil,nil,func2close(function ()
1016+numopen=(numopen - 0x1)
1017+end)
1018+end
1019+local s = 0x0
1020+for i in open(0xa)
1021+do
1022+s=(s + i)
1023+end
1024+assert(((s == 0x2d) and (numopen == 0x0)))
1025+local s = 0x0
1026+for i in open(0xa)
1027+do
1028+if (i < 0x5) then
1029+break
1030+end
1031+s=(s + i)
1032+end
1033+assert(((s == 0x23) and (numopen == 0x0)))
1034+local s = 0x0
1035+for i in open(0xa)
1036+do
1037+for j in open(0xa)
1038+do
1039+if ((i + j) < 0x5) then
1040+goto endloop
1041+end
1042+s=(s + i)
1043+end
1044+end
1045+::endloop::
1046+assert(((s == 0x177) and (numopen == 0x0)))
1047+end
1048+print("\u{4f}\u{4b}")
1049+return 0x5,f
1050+end
desk/res/lua/cycled/main.luanew file+312

This diff is too big to show here.

desk/res/lua/cycled/math.luanew file+879

This diff is too big to show here.

desk/res/lua/cycled/nextvar.luanew file+1055

This diff is too big to show here.

desk/res/lua/cycled/pm.luanew file+404

This diff is too big to show here.

desk/res/lua/cycled/sort.luanew file+309

This diff is too big to show here.

desk/res/lua/cycled/strings.luanew file+441

This diff is too big to show here.

desk/res/lua/cycled/tpack.luanew file+259

This diff is too big to show here.

desk/res/lua/cycled/tracegc.luanew file+24

This diff is too big to show here.

desk/res/lua/cycled/utf8.luanew file+203

This diff is too big to show here.

desk/res/lua/cycled/vararg.luanew file+137

This diff is too big to show here.

desk/res/lua/cycled/verybig.luanew file+59

This diff is too big to show here.

desk/res/lua/db.luanew file+1054

This diff is too big to show here.

desk/res/lua/errors.luanew file+696

This diff is too big to show here.

desk/res/lua/events.luanew file+491

This diff is too big to show here.

desk/res/lua/files.luanew file+951

This diff is too big to show here.

desk/res/lua/foo.luanew file+122

This diff is too big to show here.

desk/res/lua/gc.luanew file+695

This diff is too big to show here.

desk/res/lua/gengc.luanew file+172

This diff is too big to show here.

desk/res/lua/goto.luanew file+271

This diff is too big to show here.

desk/res/lua/heavy.luanew file+173

This diff is too big to show here.

desk/res/lua/literals.luanew file+343

This diff is too big to show here.

desk/res/lua/locals.luanew file+1181

This diff is too big to show here.

desk/res/lua/main.luanew file+563

This diff is too big to show here.

desk/res/lua/math.luanew file+1024

This diff is too big to show here.

desk/res/lua/nextvar.luanew file+825

This diff is too big to show here.

desk/res/lua/pm.luanew file+440

This diff is too big to show here.

desk/res/lua/sort.luanew file+311

This diff is too big to show here.

desk/res/lua/strings.luanew file+526

This diff is too big to show here.

desk/res/lua/tpack.luanew file+322

This diff is too big to show here.

desk/res/lua/tracegc.luanew file+40

This diff is too big to show here.

desk/res/lua/utf8.luanew file+259

This diff is too big to show here.

desk/res/lua/vararg.luanew file+151

This diff is too big to show here.

desk/res/lua/verybig.luanew file+152

This diff is too big to show here.

desk/sur/interlist.hoonnew file+8

This diff is too big to show here.

desk/sur/lua.hoonnew file+123

This diff is too big to show here.

desk/sur/spider.hoonnew file+27

This diff is too big to show here.

zod/luau/sys.kelvin → desk/sys.kelvinrenamed

The content is the same.

desk/ted/eval-lua.hoonnew file+19

This diff is too big to show here.

desk/ted/test-lua.hoonnew file+87

This diff is too big to show here.

zod/luau/TODO.mddeleted−5

This diff is too big to show here.

zod/luau/lib/interlist.hoondeleted−32

This diff is too big to show here.

zod/luau/lib/lua.hoondeleted−671

This diff is too big to show here.

zod/luau/mar/lua.hoondeleted−20

This diff is too big to show here.

zod/luau/tests/foo.luadeleted−46

This diff is too big to show here.

zod/luau/tmp.hoondeleted−9

This diff is too big to show here.