finished ints/floats

This commit is contained in:
iko 2024-07-28 17:46:17 +03:00
parent 7cd9444e7d
commit e8a619d2df
Signed by untrusted user: iko
GPG Key ID: 82C257048D1026F2
39 changed files with 4211 additions and 4172 deletions

View File

@ -2,5 +2,6 @@
- [x] functioncall
- [x] any string apart from the basic string with no escapes
- [ ] check if int fits in int or make it a float
- [x] check if int fits in int or make it a float
- [x] should `print-blok` have `do`-`end`? This is fucked.
- [ ] binary operator priority

View File

@ -1,4 +1,5 @@
/- *lua
/+ st
/+ *interlist
=<
apex
@ -248,7 +249,7 @@ apex
parse-hex-float
::
%+ cook
|= x=@u [%int x]
|= x=@u [%int (new:st x)]
;~ pfix
(just '0')
(mask "xX")
@ -260,7 +261,10 @@ apex
parse-float
::
%+ cook
|= x=@u [%int x]
|= x=@u
?: (gth x max-int)
[%float (sun:rd x)]
[%int (new:st x)]
(bass 10 (plus dit))
==
++ parse-exprlist
@ -888,4 +892,5 @@ apex
|= =blok
^- ?
&(?=(~ body.blok) ?=(~ ret.blok))
++ max-int 9.223.372.036.854.775.807
--

View File

@ -1,4 +1,5 @@
/- *lua
/+ st
=<
print
|%
@ -143,7 +144,7 @@ print
|= [num=numeral]
^- tape
?- -.num
%int (show-u +.num)
%int (z-co:co +.num)
%float (show-float +.num)
==
:: exprlist
@ -503,7 +504,7 @@ print
%- zing
%+ join "." l
++ show-s
|=(s=@s `tape`[?:((syn:si s) %$ '-') (slag 2 (scow %ui (abs:si s)))])
|=(s=@s `tape`(zing [?:((syn:si s) "" "-") ~[(slag 2 (scow %ui (abs:si s)))]]))
++ show-u
|=(u=@u `tape`(slag 2 (scow %ui u)))
++ show-float

35
zod/luau/lib/st.hoon Normal file
View File

@ -0,0 +1,35 @@
:: Two's complement encoded 64-bit signed integer
=<
|%
:: coerce an unsigned int to a signed int
::
++ new
|= x=@u
^- @st
(dis mask x)
++ to-s
|= x=@st
^- @s
(new:si ?!((sig x)) (abs x))
++ sig
|= x=@st
^- ?
?! =(0 (dis sign-mask x))
++ abs
|= x=@st
^- @u
?. (sig x) `@u`x
(dis mask +((mix mask x)))
++ inc
|= x=@st
^- @st
(dis mask +(x))
++ add
|= [x=@st y=@st]
^- @st
(dis mask (^add x y))
--
|%
++ mask 0xffff.ffff.ffff.ffff
++ sign-mask 0x8000.0000.0000.0000
--

View File

@ -34,7 +34,7 @@ local msgs = {}
function Message(m)
if not _nomsg then
print(m)
msgs[# msgs + 1]=string.sub(m,3,- 3)
msgs[# msgs + 0x1]=string.sub(m,0x3,- 0x3)
end
end
assert(os.setlocale("\u{43}"))
@ -46,28 +46,28 @@ local function round
m=m + 0.04999
return format("\u{25}\u{2e}\u{31}\u{66}",m)
end
if m < 1000 then
if m < 0x3e8 then
return m
else
m=m / 1000
if m < 1000 then
m=m / 0x3e8
if m < 0x3e8 then
return round(m) .. "\u{4b}"
else
return round(m / 1000) .. "\u{4d}"
return round(m / 0x3e8) .. "\u{4d}"
end
end
end
local Cstacklevel
local showmem
if not T then
local max = 0
local max = 0x0
showmem=function ()
local m = collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}") * 1024
local m = collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}") * 0x400
max=(m > max) and m or max
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)))
end
Cstacklevel=function ()
return 0
return 0x0
end
else
showmem=function ()
@ -110,9 +110,9 @@ _G.deep=nil
olddofile("\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{73}\u{2e}\u{6c}\u{75}\u{61}")
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}")
dofile("\u{74}\u{70}\u{61}\u{63}\u{6b}\u{2e}\u{6c}\u{75}\u{61}")
assert(dofile("\u{61}\u{74}\u{74}\u{72}\u{69}\u{62}\u{2e}\u{6c}\u{75}\u{61}") == 27)
assert(dofile("\u{61}\u{74}\u{74}\u{72}\u{69}\u{62}\u{2e}\u{6c}\u{75}\u{61}") == 0x1b)
dofile("\u{67}\u{65}\u{6e}\u{67}\u{63}\u{2e}\u{6c}\u{75}\u{61}")
assert(dofile("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{73}\u{2e}\u{6c}\u{75}\u{61}") == 5)
assert(dofile("\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{73}\u{2e}\u{6c}\u{75}\u{61}") == 0x5)
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}")
dofile("\u{63}\u{6f}\u{64}\u{65}\u{2e}\u{6c}\u{75}\u{61}",true)
if not _G._soft then
@ -126,7 +126,7 @@ dofile("\u{6e}\u{65}\u{78}\u{74}\u{76}\u{61}\u{72}\u{2e}\u{6c}\u{75}\u{61}")
dofile("\u{70}\u{6d}\u{2e}\u{6c}\u{75}\u{61}")
dofile("\u{75}\u{74}\u{66}\u{38}\u{2e}\u{6c}\u{75}\u{61}")
dofile("\u{61}\u{70}\u{69}\u{2e}\u{6c}\u{75}\u{61}")
assert(dofile("\u{65}\u{76}\u{65}\u{6e}\u{74}\u{73}\u{2e}\u{6c}\u{75}\u{61}") == 12)
assert(dofile("\u{65}\u{76}\u{65}\u{6e}\u{74}\u{73}\u{2e}\u{6c}\u{75}\u{61}") == 0xc)
dofile("\u{76}\u{61}\u{72}\u{61}\u{72}\u{67}\u{2e}\u{6c}\u{75}\u{61}")
dofile("\u{63}\u{6c}\u{6f}\u{73}\u{75}\u{72}\u{65}\u{2e}\u{6c}\u{75}\u{61}")
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}")
@ -135,11 +135,11 @@ dofile("\u{65}\u{72}\u{72}\u{6f}\u{72}\u{73}\u{2e}\u{6c}\u{75}\u{61}")
dofile("\u{6d}\u{61}\u{74}\u{68}\u{2e}\u{6c}\u{75}\u{61}")
dofile("\u{73}\u{6f}\u{72}\u{74}\u{2e}\u{6c}\u{75}\u{61}",true)
dofile("\u{62}\u{69}\u{74}\u{77}\u{69}\u{73}\u{65}\u{2e}\u{6c}\u{75}\u{61}")
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) == 10)
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)
;
collectgarbage()
dofile("\u{66}\u{69}\u{6c}\u{65}\u{73}\u{2e}\u{6c}\u{75}\u{61}")
if # msgs > 0 then
if # msgs > 0x0 then
local m = table.concat(msgs,"\u{a}\u{20}\u{20}")
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}")
end
@ -153,7 +153,7 @@ warn("\u{40}\u{6f}\u{6e}")
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}")
assert(debug == nil)
local debug = require("\u{64}\u{65}\u{62}\u{75}\u{67}")
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}") * 8,string.packsize("\u{6e}") * 8))
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))
debug.sethook(function (a)
assert(type(a) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}")
end,"\u{63}\u{72}")
@ -176,7 +176,7 @@ end
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}")
for n in pairs(_G)
do
if not ({["\u{5f}\u{5f}\u{5f}\u{47}\u{6c}\u{6f}\u{62}"] = 1,["\u{74}\u{6f}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}"] = 1})[n] then
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
_G[n]=undef
end
end
@ -196,7 +196,7 @@ lasttime=lasttime or clocktime
local diff = (clocktime - lasttime) / lasttime
local tolerance = 0.05
if (diff >= tolerance or diff <= - tolerance) then
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 * 100))
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))
end
assert(open(fname,"\u{77}")):write(clocktime):close()
end

File diff suppressed because it is too large Load Diff

View File

@ -12,16 +12,16 @@ assert(type(package.preload) == "\u{74}\u{61}\u{62}\u{6c}\u{65}")
assert(type(package.config) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}")
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}"))
do
local max = _soft and 100 or 2000
local max = _soft and 0x64 or 0x7d0
local t = {}
for i = 1, max
for i = 0x1, max
do
t[i]=string.rep("\u{3f}",i % 10 + 1)
t[i]=string.rep("\u{3f}",i % 0xa + 0x1)
end
t[# t + 1]="\u{3b}"
t[# t + 0x1]="\u{3b}"
local path = table.concat(t,"\u{3b}")
local s,err = package.searchpath("\u{78}\u{75}\u{78}\u{75}",path)
assert(not s and string.find(err,string.rep("\u{78}\u{75}\u{78}\u{75}",10)) and # string.gsub(err,"\u{5b}\u{5e}\u{a}\u{5d}","") >= max)
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)
local path = string.rep("\u{3f}",max)
local s,err = package.searchpath("\u{78}\u{75}\u{78}\u{75}",path)
assert(not s and string.find(err,string.rep("\u{78}\u{75}\u{78}\u{75}",max)))
@ -98,20 +98,20 @@ assert(rr == r)
assert(ext == x)
end
local a = require("\u{6e}\u{61}\u{6d}\u{65}\u{73}")
assert(a[1] == "\u{6e}\u{61}\u{6d}\u{65}\u{73}" and a[2] == D("\u{6e}\u{61}\u{6d}\u{65}\u{73}\u{2e}\u{6c}\u{75}\u{61}"))
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}"))
local st,msg = pcall(require,"\u{65}\u{72}\u{72}")
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 == 15)
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)
st,msg=pcall(require,"\u{73}\u{79}\u{6e}\u{65}\u{72}\u{72}")
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}"))
assert(package.searchpath("\u{43}",package.path) == D("\u{43}\u{2e}\u{6c}\u{75}\u{61}"))
assert(require("\u{43}") == 25)
assert(require("\u{43}") == 25)
assert(require("\u{43}") == 0x19)
assert(require("\u{43}") == 0x19)
AA=nil
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}")
assert(package.loaded.B)
assert(require("\u{42}") == true)
assert(package.loaded.A)
assert(require("\u{43}") == 25)
assert(require("\u{43}") == 0x19)
package.loaded.A=nil
try("\u{42}",nil,true,nil)
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}")
@ -133,19 +133,19 @@ local _G = _G
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)
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}"}
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}")
AA=0
AA=0x0
local m,ext = assert(require("\u{50}\u{31}"))
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}")
assert(AA == 0 and m.AA == 10)
assert(AA == 0x0 and m.AA == 0xa)
assert(require("\u{50}\u{31}") == m)
assert(require("\u{50}\u{31}") == m)
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}"))
m.xuxu,ext=assert(require("\u{50}\u{31}\u{2e}\u{78}\u{75}\u{78}\u{75}"))
assert(AA == 0 and m.xuxu.AA == 20)
assert(AA == 0x0 and m.xuxu.AA == 0x14)
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}")
assert(require("\u{50}\u{31}\u{2e}\u{78}\u{75}\u{78}\u{75}") == m.xuxu)
assert(require("\u{50}\u{31}\u{2e}\u{78}\u{75}\u{78}\u{75}") == m.xuxu)
assert(require("\u{50}\u{31}") == m and m.AA == 10)
assert(require("\u{50}\u{31}") == m and m.AA == 0xa)
removefiles(files)
AA=nil
package.path=""
@ -158,11 +158,11 @@ local m,err = pcall(require,fname)
for t in string.gmatch(package.path .. "\u{3b}" .. package.cpath,"\u{5b}\u{5e}\u{3b}\u{5d}\u{2b}")
do
t=string.gsub(t,"\u{3f}",fname)
assert(string.find(err,t,1,true))
assert(string.find(err,t,0x1,true))
end
do
local searchers = package.searchers
package.searchers=3
package.searchers=0x3
local st,msg = pcall(require,"\u{61}")
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}"))
package.searchers=searchers
@ -171,7 +171,7 @@ local function import
(...)
local f = {...}
return function (m)
for i = 1, # f
for i = 0x1, # f
do
m[f[i]]=_G[f[i]]
end
@ -188,10 +188,10 @@ assert(not f and type(err) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}" and when ==
print(err,when)
else
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}"))
local a,b = f(15,25)
assert(a == 25 and b == 15)
local a,b = f(0xf,0x19)
assert(a == 0x19 and b == 0xf)
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}"))
assert(f(10,20) == "\u{31}\u{30}\u{25}\u{32}\u{30}\u{a}")
assert(f(0xa,0x14) == "\u{31}\u{30}\u{25}\u{32}\u{30}\u{a}")
local f,err,when = package.loadlib(DC("\u{6c}\u{69}\u{62}\u{31}"),p .. "\u{78}\u{75}\u{78}\u{75}")
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}")
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}")
@ -200,13 +200,13 @@ f=assert(package.loadlib(DC("\u{6c}\u{69}\u{62}\u{31}\u{31}"),p .. "\u{6c}\u{75}
assert(f() == "\u{65}\u{78}\u{70}\u{6f}\u{72}\u{74}\u{65}\u{64}")
package.cpath=DC("\u{3f}")
local lib2,ext = require("\u{6c}\u{69}\u{62}\u{32}\u{2d}\u{76}\u{32}")
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}",1,true))
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))
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}"))
assert(lib2.id("\u{78}") == true)
local fs,ext = require("\u{6c}\u{69}\u{62}\u{31}\u{2e}\u{73}\u{75}\u{62}")
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}"))
assert(string.find(ext,"\u{6c}\u{69}\u{62}\u{73}\u{2f}\u{6c}\u{69}\u{62}\u{31}",1,true))
assert(fs.id(45) == 45)
assert(string.find(ext,"\u{6c}\u{69}\u{62}\u{73}\u{2f}\u{6c}\u{69}\u{62}\u{31}",0x1,true))
assert(fs.id(0x2d) == 0x2d)
_ENV.x,_ENV.y=nil
end
_ENV=_G
@ -216,37 +216,37 @@ package={}
p.preload.pl=function (...)
local _ENV = {...}
function xuxu(x)
return x + 20
return x + 0x14
end
return _ENV
end
local pl,ext = require("\u{70}\u{6c}")
assert(require("\u{70}\u{6c}") == pl)
assert(pl.xuxu(10) == 30)
assert(pl[1] == "\u{70}\u{6c}" and pl[2] == "\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}")
assert(pl.xuxu(0xa) == 0x1e)
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}")
package=p
assert(type(package.path) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}")
end
print("\u{2b}")
end
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}")
local res,res2 = 27
local a,b = 1,2 + 3
assert(a == 1 and b == 5)
local res,res2 = 0x1b
local a,b = 0x1,0x2 + 0x3
assert(a == 0x1 and b == 0x5)
a={}
local function f
()
return 10,11,12
return 0xa,0xb,0xc
end
a.x,b,a[1]=1,2,f()
assert(a.x == 1 and b == 2 and a[1] == 10)
a[f()],b,a[f() + 3]=f(),a,"\u{78}"
assert(a[10] == 10 and b == a and a[13] == "\u{78}")
a.x,b,a[0x1]=0x1,0x2,f()
assert(a.x == 0x1 and b == 0x2 and a[0x1] == 0xa)
a[f()],b,a[f() + 0x3]=f(),a,"\u{78}"
assert(a[0xa] == 0xa and b == a and a[0xd] == "\u{78}")
do
local f = function (n)
local x = {}
;
for i = 1, n
for i = 0x1, n
do
x[i]=i
end
@ -255,67 +255,67 @@ return table.unpack(x)
end
;
local a,b,c
a,b=0,f(1)
assert(a == 0 and b == 1)
a,b=0,f(1)
assert(a == 0 and b == 1)
a,b,c=0,5,f(4)
assert(a == 0 and b == 5 and c == 1)
a,b,c=0,5,f(0)
assert(a == 0 and b == 5 and c == nil)
a,b=0x0,f(0x1)
assert(a == 0x0 and b == 0x1)
a,b=0x0,f(0x1)
assert(a == 0x0 and b == 0x1)
a,b,c=0x0,0x5,f(0x4)
assert(a == 0x0 and b == 0x5 and c == 0x1)
a,b,c=0x0,0x5,f(0x0)
assert(a == 0x0 and b == 0x5 and c == nil)
end
local a,b,c,d = 1 and nil,1 or nil,(1 and (nil or 1)),6
assert(not a and b and c and d == 6)
d=20
local a,b,c,d = 0x1 and nil,0x1 or nil,(0x1 and (nil or 0x1)),0x6
assert(not a and b and c and d == 0x6)
d=0x14
a,b,c,d=f()
assert(a == 10 and b == 11 and c == 12 and d == nil)
a,b=f(),1,2,3,f()
assert(a == 10 and b == 1)
assert(a == 0xa and b == 0xb and c == 0xc and d == nil)
a,b=f(),0x1,0x2,0x3,f()
assert(a == 0xa and b == 0x1)
assert(a < b == false and a > b == true)
assert((10 and 2) == 2)
assert((10 or 2) == 10)
assert((10 or assert(nil)) == 10)
assert((0xa and 0x2) == 0x2)
assert((0xa or 0x2) == 0xa)
assert((0xa or assert(nil)) == 0xa)
assert(not (nil and assert(nil)))
assert((nil or "\u{61}\u{6c}\u{6f}") == "\u{61}\u{6c}\u{6f}")
assert((nil and 10) == nil)
assert((false and 10) == false)
assert((true or 10) == true)
assert((false or 10) == 10)
assert((nil and 0xa) == nil)
assert((false and 0xa) == false)
assert((true or 0xa) == true)
assert((false or 0xa) == 0xa)
assert(false ~= nil)
assert(nil ~= false)
assert(not nil == true)
assert(not not nil == false)
assert(not not 1 == true)
assert(not not 0x1 == true)
assert(not not a == true)
assert(not not (6 or nil) == true)
assert(not not (nil and 56) == false)
assert(not not (0x6 or nil) == true)
assert(not not (nil and 0x38) == false)
assert(not not (nil and true) == false)
assert(not 10 == false)
assert(not 0xa == false)
assert(not {} == false)
assert(not 0.5 == false)
assert(not "\u{78}" == false)
assert({} ~= {})
print("\u{2b}")
a={}
a[true]=20
a[false]=10
assert(a[1 < 2] == 20 and a[1 > 2] == 10)
a[true]=0x14
a[false]=0xa
assert(a[0x1 < 0x2] == 0x14 and a[0x1 > 0x2] == 0xa)
function f(a)
return a
end
local a = {}
for i = 3000, - 3000, - 1
for i = 0xbb8, - 0xbb8, - 0x1
do
a[i + 0.0]=i
;
end
a[1e31]="\u{61}\u{6c}\u{6f}"
;
a[true]=10
a[true]=0xa
;
a[false]=20
assert(a[1e31] == "\u{61}\u{6c}\u{6f}" and a[not 1] == 20 and a[10 < 20] == 10)
for i = 3000, - 3000, - 1
a[false]=0x14
assert(a[1e31] == "\u{61}\u{6c}\u{6f}" and a[not 0x1] == 0x14 and a[0xa < 0x14] == 0xa)
for i = 0xbb8, - 0xbb8, - 0x1
do
assert(a[i] == i)
;
@ -328,79 +328,79 @@ a[print](a[a[f]] == a[print])
assert(not pcall(function ()
local a = {}
;
a[nil]=10
a[nil]=0xa
end))
assert(not pcall(function ()
local a = {[nil] = 10}
local a = {[nil] = 0xa}
end))
assert(a[nil] == undef)
a=nil
local a,b,c
a={10,9,8,7,6,5,4,3,2,[- 3] = "\u{61}",[f] = print,["\u{61}"] = "\u{61}",["\u{62}"] = "\u{61}\u{62}"}
a,a.x,a.y=a,a[- 3]
assert(a[1] == 10 and a[- 3] == a.a and a[f] == print and a.x == "\u{61}" and not a.y)
a[1],f(a)[2],b,c={["\u{61}\u{6c}\u{6f}"] = assert},10,a[1],a[f],6,10,23,f(a),2
a[1].alo(a[2] == 10 and b == 10 and c == print)
a.aVeryLongName012345678901234567890123456789012345678901234567890123456789=10
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}"}
a,a.x,a.y=a,a[- 0x3]
assert(a[0x1] == 0xa and a[- 0x3] == a.a and a[f] == print and a.x == "\u{61}" and not a.y)
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
a[0x1].alo(a[0x2] == 0xa and b == 0xa and c == print)
a.aVeryLongName012345678901234567890123456789012345678901234567890123456789=0xa
local function foo
()
return a.aVeryLongName012345678901234567890123456789012345678901234567890123456789
end
assert(foo() == 10 and a.aVeryLongName012345678901234567890123456789012345678901234567890123456789 == 10)
assert(foo() == 0xa and a.aVeryLongName012345678901234567890123456789012345678901234567890123456789 == 0xa)
do
local function foo
()
local _ENV <const> = 11
local _ENV <const> = 0xb
X="\u{68}\u{69}"
end
local st,msg = pcall(foo)
assert(not st and string.find(msg,"\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}"))
end
local maxint = math.maxinteger
while maxint ~= (maxint + 0.0) or (maxint - 1) ~= (maxint - 1.0) do
maxint=maxint // 2
while maxint ~= (maxint + 0.0) or (maxint - 0x1) ~= (maxint - 1.0) do
maxint=maxint // 0x2
end
local maxintF = maxint + 0.0
assert(maxintF == maxint and math.type(maxintF) == "\u{66}\u{6c}\u{6f}\u{61}\u{74}" and maxintF >= 2.0 ^ 14)
a[maxintF]=10
assert(maxintF == maxint and math.type(maxintF) == "\u{66}\u{6c}\u{6f}\u{61}\u{74}" and maxintF >= 2.0 ^ 0xe)
a[maxintF]=0xa
;
a[maxintF - 1.0]=11
a[maxintF - 1.0]=0xb
;
a[- maxintF]=12
a[- maxintF]=0xc
;
a[- maxintF + 1.0]=13
a[- maxintF + 1.0]=0xd
;
assert(a[maxint] == 10 and a[maxint - 1] == 11 and a[- maxint] == 12 and a[- maxint + 1] == 13)
a[maxint]=20
a[- maxint]=22
assert(a[maxintF] == 20 and a[maxintF - 1.0] == 11 and a[- maxintF] == 22 and a[- maxintF + 1.0] == 13)
assert(a[maxint] == 0xa and a[maxint - 0x1] == 0xb and a[- maxint] == 0xc and a[- maxint + 0x1] == 0xd)
a[maxint]=0x14
a[- maxint]=0x16
assert(a[maxintF] == 0x14 and a[maxintF - 1.0] == 0xb and a[- maxintF] == 0x16 and a[- maxintF + 1.0] == 0xd)
a=nil
do
local a,i,j,b
a={"\u{61}","\u{62}"}
;
i=1
i=0x1
;
j=2
j=0x2
;
b=a
i,a[i],a,j,a[j],a[i + j]=j,i,i,b,j,i
assert(i == 2 and b[1] == 1 and a == 1 and j == b and b[2] == 2 and b[3] == 1)
assert(i == 0x2 and b[0x1] == 0x1 and a == 0x1 and j == b and b[0x2] == 0x2 and b[0x3] == 0x1)
a={}
local function foo
()
b,a.x,a=a,10,20
b,a.x,a=a,0xa,0x14
end
foo()
assert(a == 20 and b.x == 10)
assert(a == 0x14 and b.x == 0xa)
end
do
local a,i,j,b
a={"\u{61}","\u{62}"}
;
i=1
i=0x1
;
j=2
j=0x2
;
b=a
local function foo
@ -408,24 +408,24 @@ local function foo
i,a[i],a,j,a[j],a[i + j]=j,i,i,b,j,i
end
foo()
assert(i == 2 and b[1] == 1 and a == 1 and j == b and b[2] == 2 and b[3] == 1)
assert(i == 0x2 and b[0x1] == 0x1 and a == 0x1 and j == b and b[0x2] == 0x2 and b[0x3] == 0x1)
local t = {}
(function (a)
t[a],a=10,20
end)(1)
t[a],a=0xa,0x14
end)(0x1)
;
assert(t[1] == 10)
assert(t[0x1] == 0xa)
end
local function foo
()
local a
return function ()
local b
a,b=3,14
a,b=0x3,0xe
return a,b
end
end
local a,b = foo()()
assert(a == 3 and b == 14)
assert(a == 0x3 and b == 0xe)
print("\u{4f}\u{4b}")
return res

View File

@ -3,21 +3,21 @@ return "\u{61}"
end
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}")
local debug = require("\u{64}\u{65}\u{62}\u{75}\u{67}")
local lim = 2 ^ 18 + 1000
local lim = 0x2 ^ 0x12 + 0x3e8
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}"}
for i = 1, lim
for i = 0x1, lim
do
prog[# prog + 1]=i
prog[# prog + 0x1]=i
end
prog[# prog + 1]="\u{7d}\u{a}"
prog[# prog + 1]="\u{58}\u{20}\u{3d}\u{20}\u{79}\u{a}"
prog[# prog + 1]=("\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 - 1,lim - 2)
prog[# prog + 1]="\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{30}"
prog[# prog + 0x1]="\u{7d}\u{a}"
prog[# prog + 0x1]="\u{58}\u{20}\u{3d}\u{20}\u{79}\u{a}"
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)
prog[# prog + 0x1]="\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{30}"
prog=table.concat(prog,"\u{3b}")
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}
local f = assert(load(prog,nil,nil,env))
f()
assert(env.X[lim] == lim - 1 and env.X[lim + 1] == lim)
assert(env.X[lim] == lim - 0x1 and env.X[lim + 0x1] == lim)
for k in pairs(env)
do
env[k]=undef
@ -36,8 +36,8 @@ local co = coroutine.wrap(f)
assert(co() == "\u{73}")
assert(co() == "\u{67}")
assert(co() == "\u{67}")
assert(co() == 0)
assert(X[lim] == lim - 1 and X[lim + 1] == lim)
assert(co() == 0x0)
assert(X[lim] == lim - 0x1 and X[lim + 0x1] == lim)
getmetatable(env).__index=function ()
end
@ -53,11 +53,11 @@ local e,m = xpcall(f,debug.traceback)
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}"))
f,X=nil
coroutine.yield("\u{62}")
if 2 ^ 32 == 0 then
if 0x2 ^ 0x20 == 0x0 then
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}")
local repstrings = 192
local ssize = math.ceil(2.0 ^ 32 / repstrings) + 1
assert(repstrings * ssize > 2.0 ^ 32)
local repstrings = 0xc0
local ssize = math.ceil(2.0 ^ 0x20 / repstrings) + 0x1
assert(repstrings * ssize > 2.0 ^ 0x20)
local longs = string.rep("\u{0}",ssize)
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}")))
local a,b = pcall(rep,longs)

View File

@ -1,23 +1,23 @@
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}")
require("\u{62}\u{77}\u{63}\u{6f}\u{65}\u{72}\u{63}\u{69}\u{6f}\u{6e}")
local numbits = string.packsize("\u{6a}") * 8
assert(~ 0 == - 1)
assert((1 << (numbits - 1)) == math.mininteger)
local numbits = string.packsize("\u{6a}") * 0x8
assert(~ 0x0 == - 0x1)
assert((0x1 << (numbits - 0x1)) == math.mininteger)
local a,b,c,d
a=18446744073709551615
assert(a == - 1 and a & - 1 == a and a & 35 == 35)
a=17361641481138401520
assert(a | - 1 == - 1)
assert(a ~ a == 0 and a ~ 0 == a and a ~ ~ a == - 1)
assert(a >> 4 == ~ a)
a=240
a=0xffffffffffffffff
assert(a == - 0x1 and a & - 0x1 == a and a & 0x23 == 0x23)
a=0xf0f0f0f0f0f0f0f0
assert(a | - 0x1 == - 0x1)
assert(a ~ a == 0x0 and a ~ 0x0 == a and a ~ ~ a == - 0x1)
assert(a >> 0x4 == ~ a)
a=0xf0
;
b=204
b=0xcc
;
c=170
c=0xaa
;
d=253
assert(a | b ~ c & d == 244)
d=0xfd
assert(a | b ~ c & d == 0xf4)
a=240.0
;
b=204.0
@ -25,55 +25,55 @@ b=204.0
c="\u{30}\u{78}\u{41}\u{41}\u{2e}\u{30}"
;
d="\u{30}\u{78}\u{46}\u{44}\u{2e}\u{30}"
assert(a | b ~ c & d == 244)
a=4026531840
assert(a | b ~ c & d == 0xf4)
a=0xf0000000
;
b=3422552064
b=0xcc000000
;
c=2852126720
c=0xaa000000
;
d=4244635648
assert(a | b ~ c & d == 4093640704)
assert(~ ~ a == a and ~ a == - 1 ~ a and - d == ~ d + 1)
a=a << 32
b=b << 32
c=c << 32
d=d << 32
assert(a | b ~ c & d == 4093640704 << 32)
assert(~ ~ a == a and ~ a == - 1 ~ a and - d == ~ d + 1)
d=0xfd000000
assert(a | b ~ c & d == 0xf4000000)
assert(~ ~ a == a and ~ a == - 0x1 ~ a and - d == ~ d + 0x1)
a=a << 0x20
b=b << 0x20
c=c << 0x20
d=d << 0x20
assert(a | b ~ c & d == 0xf4000000 << 0x20)
assert(~ ~ a == a and ~ a == - 0x1 ~ a and - d == ~ d + 0x1)
do
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)
assert(load(code)() == 0)
assert(load(code)() == 0x0)
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)
assert(load(code)() == 0)
assert(load(code)() == 0x0)
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)
assert(load(code)() == 0)
assert(load(code)() == 0x0)
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)
assert(load(code)() == 0)
assert(load(code)() == 0x0)
end
assert(- 1 >> 1 == (1 << (numbits - 1)) - 1 and 1 << 31 == 2147483648)
assert(- 1 >> (numbits - 1) == 1)
assert(- 1 >> numbits == 0 and - 1 >> - numbits == 0 and - 1 << numbits == 0 and - 1 << - numbits == 0)
assert(1 >> math.mininteger == 0)
assert(1 >> math.maxinteger == 0)
assert(1 << math.mininteger == 0)
assert(1 << math.maxinteger == 0)
assert((2 ^ 30 - 1) << 2 ^ 30 == 0)
assert((2 ^ 30 - 1) >> 2 ^ 30 == 0)
assert(1 >> - 3 == 1 << 3 and 1000 >> 5 == 1000 << - 5)
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}" | 0 == - 1)
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}" == - 2)
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}" == 2)
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}" == - 45 * 4)
assert("\u{31}\u{32}\u{33}\u{34}\u{2e}\u{30}" << "\u{35}\u{2e}\u{30}" == 1234 * 32)
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}" == 21845)
assert(~ "\u{30}\u{78}\u{30}\u{2e}\u{30}\u{30}\u{30}\u{70}\u{34}" == - 1)
assert(("\u{37}" .. 3) << 1 == 146)
assert(4294967295 >> (1 .. "\u{39}") == 8191)
assert(10 | (1 .. "\u{39}") == 27)
assert(- 0x1 >> 0x1 == (0x1 << (numbits - 0x1)) - 0x1 and 0x1 << 0x1f == 0x80000000)
assert(- 0x1 >> (numbits - 0x1) == 0x1)
assert(- 0x1 >> numbits == 0x0 and - 0x1 >> - numbits == 0x0 and - 0x1 << numbits == 0x0 and - 0x1 << - numbits == 0x0)
assert(0x1 >> math.mininteger == 0x0)
assert(0x1 >> math.maxinteger == 0x0)
assert(0x1 << math.mininteger == 0x0)
assert(0x1 << math.maxinteger == 0x0)
assert((0x2 ^ 0x1e - 0x1) << 0x2 ^ 0x1e == 0x0)
assert((0x2 ^ 0x1e - 0x1) >> 0x2 ^ 0x1e == 0x0)
assert(0x1 >> - 0x3 == 0x1 << 0x3 and 0x3e8 >> 0x5 == 0x3e8 << - 0x5)
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)
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)
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)
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)
assert("\u{31}\u{32}\u{33}\u{34}\u{2e}\u{30}" << "\u{35}\u{2e}\u{30}" == 0x4d2 * 0x20)
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)
assert(~ "\u{30}\u{78}\u{30}\u{2e}\u{30}\u{30}\u{30}\u{70}\u{34}" == - 0x1)
assert(("\u{37}" .. 0x3) << 0x1 == 0x92)
assert(0xffffffff >> (0x1 .. "\u{39}") == 0x1fff)
assert(0xa | (0x1 .. "\u{39}") == 0x1b)
do
local st,msg = pcall(function ()
return 4 & "\u{61}"
return 0x4 & "\u{61}"
end)
assert(string.find(msg,"\u{27}\u{62}\u{61}\u{6e}\u{64}\u{27}"))
local st,msg = pcall(function ()
@ -82,89 +82,89 @@ end)
assert(string.find(msg,"\u{27}\u{62}\u{6e}\u{6f}\u{74}\u{27}"))
end
assert(not pcall(function ()
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}" | 0
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
end))
assert(not pcall(function ()
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}" | 0
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
end))
print("\u{2b}")
package.preload.bit32=function ()
local bit = {}
function bit.bnot(a)
return ~ a & 4294967295
return ~ a & 0xffffffff
end
function bit.band(x,y,z, ...)
if not z then
return ((x or - 1) & (y or - 1)) & 4294967295
return ((x or - 0x1) & (y or - 0x1)) & 0xffffffff
else
local arg = {...}
local res = x & y & z
for i = 1, # arg
for i = 0x1, # arg
do
res=res & arg[i]
end
return res & 4294967295
return res & 0xffffffff
end
end
function bit.bor(x,y,z, ...)
if not z then
return ((x or 0) | (y or 0)) & 4294967295
return ((x or 0x0) | (y or 0x0)) & 0xffffffff
else
local arg = {...}
local res = x | y | z
for i = 1, # arg
for i = 0x1, # arg
do
res=res | arg[i]
end
return res & 4294967295
return res & 0xffffffff
end
end
function bit.bxor(x,y,z, ...)
if not z then
return ((x or 0) ~ (y or 0)) & 4294967295
return ((x or 0x0) ~ (y or 0x0)) & 0xffffffff
else
local arg = {...}
local res = x ~ y ~ z
for i = 1, # arg
for i = 0x1, # arg
do
res=res ~ arg[i]
end
return res & 4294967295
return res & 0xffffffff
end
end
function bit.btest(...)
return bit.band(...) ~= 0
return bit.band(...) ~= 0x0
end
function bit.lshift(a,b)
return ((a & 4294967295) << b) & 4294967295
return ((a & 0xffffffff) << b) & 0xffffffff
end
function bit.rshift(a,b)
return ((a & 4294967295) >> b) & 4294967295
return ((a & 0xffffffff) >> b) & 0xffffffff
end
function bit.arshift(a,b)
a=a & 4294967295
if b <= 0 or (a & 2147483648) == 0 then
return (a >> b) & 4294967295
a=a & 0xffffffff
if b <= 0x0 or (a & 0x80000000) == 0x0 then
return (a >> b) & 0xffffffff
else
return ((a >> b) | ~ (4294967295 >> b)) & 4294967295
return ((a >> b) | ~ (0xffffffff >> b)) & 0xffffffff
end
end
function bit.lrotate(a,b)
b=b & 31
a=a & 4294967295
a=(a << b) | (a >> (32 - b))
return a & 4294967295
b=b & 0x1f
a=a & 0xffffffff
a=(a << b) | (a >> (0x20 - b))
return a & 0xffffffff
end
function bit.rrotate(a,b)
return bit.lrotate(a,- b)
end
local function checkfield
(f,w)
w=w or 1
assert(f >= 0,"\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}")
assert(w > 0,"\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}")
assert(f + w <= 32,"\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}")
return f,~ (- 1 << w)
w=w or 0x1
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}")
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}")
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}")
return f,~ (- 0x1 << w)
end
function bit.extract(a,f,w)
local f,mask = checkfield(f,w)
@ -174,136 +174,136 @@ function bit.replace(a,v,f,w)
local f,mask = checkfield(f,w)
v=v & mask
a=(a & ~ (mask << f)) | (v << f)
return a & 4294967295
return a & 0xffffffff
end
return bit
end
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}")
local bit32 = require("\u{62}\u{69}\u{74}\u{33}\u{32}")
assert(bit32.band() == bit32.bnot(0))
assert(bit32.band() == bit32.bnot(0x0))
assert(bit32.btest() == true)
assert(bit32.bor() == 0)
assert(bit32.bxor() == 0)
assert(bit32.band() == bit32.band(4294967295))
assert(bit32.band(1,2) == 0)
assert(bit32.band(- 1) == 4294967295)
assert(bit32.band((1 << 33) - 1) == 4294967295)
assert(bit32.band(- (1 << 33) - 1) == 4294967295)
assert(bit32.band((1 << 33) + 1) == 1)
assert(bit32.band(- (1 << 33) + 1) == 1)
assert(bit32.band(- (1 << 40)) == 0)
assert(bit32.band(1 << 40) == 0)
assert(bit32.band(- (1 << 40) - 2) == 4294967294)
assert(bit32.band((1 << 40) - 4) == 4294967292)
assert(bit32.lrotate(0,- 1) == 0)
assert(bit32.lrotate(0,7) == 0)
assert(bit32.lrotate(305419896,0) == 305419896)
assert(bit32.lrotate(305419896,32) == 305419896)
assert(bit32.lrotate(305419896,4) == 591751041)
assert(bit32.rrotate(305419896,- 4) == 591751041)
assert(bit32.lrotate(305419896,- 8) == 2014458966)
assert(bit32.rrotate(305419896,8) == 2014458966)
assert(bit32.lrotate(2863311530,2) == 2863311530)
assert(bit32.lrotate(2863311530,- 2) == 2863311530)
for i = - 50, 50
assert(bit32.bor() == 0x0)
assert(bit32.bxor() == 0x0)
assert(bit32.band() == bit32.band(0xffffffff))
assert(bit32.band(0x1,0x2) == 0x0)
assert(bit32.band(- 0x1) == 0xffffffff)
assert(bit32.band((0x1 << 0x21) - 0x1) == 0xffffffff)
assert(bit32.band(- (0x1 << 0x21) - 0x1) == 0xffffffff)
assert(bit32.band((0x1 << 0x21) + 0x1) == 0x1)
assert(bit32.band(- (0x1 << 0x21) + 0x1) == 0x1)
assert(bit32.band(- (0x1 << 0x28)) == 0x0)
assert(bit32.band(0x1 << 0x28) == 0x0)
assert(bit32.band(- (0x1 << 0x28) - 0x2) == 0xfffffffe)
assert(bit32.band((0x1 << 0x28) - 0x4) == 0xfffffffc)
assert(bit32.lrotate(0x0,- 0x1) == 0x0)
assert(bit32.lrotate(0x0,0x7) == 0x0)
assert(bit32.lrotate(0x12345678,0x0) == 0x12345678)
assert(bit32.lrotate(0x12345678,0x20) == 0x12345678)
assert(bit32.lrotate(0x12345678,0x4) == 0x23456781)
assert(bit32.rrotate(0x12345678,- 0x4) == 0x23456781)
assert(bit32.lrotate(0x12345678,- 0x8) == 0x78123456)
assert(bit32.rrotate(0x12345678,0x8) == 0x78123456)
assert(bit32.lrotate(0xaaaaaaaa,0x2) == 0xaaaaaaaa)
assert(bit32.lrotate(0xaaaaaaaa,- 0x2) == 0xaaaaaaaa)
for i = - 0x32, 0x32
do
assert(bit32.lrotate(2309737967,i) == bit32.lrotate(2309737967,i % 32))
assert(bit32.lrotate(0x89abcdef,i) == bit32.lrotate(0x89abcdef,i % 0x20))
end
assert(bit32.lshift(305419896,4) == 591751040)
assert(bit32.lshift(305419896,8) == 878082048)
assert(bit32.lshift(305419896,- 4) == 19088743)
assert(bit32.lshift(305419896,- 8) == 1193046)
assert(bit32.lshift(305419896,32) == 0)
assert(bit32.lshift(305419896,- 32) == 0)
assert(bit32.rshift(305419896,4) == 19088743)
assert(bit32.rshift(305419896,8) == 1193046)
assert(bit32.rshift(305419896,32) == 0)
assert(bit32.rshift(305419896,- 32) == 0)
assert(bit32.arshift(305419896,0) == 305419896)
assert(bit32.arshift(305419896,1) == 305419896 // 2)
assert(bit32.arshift(305419896,- 1) == 305419896 * 2)
assert(bit32.arshift(- 1,1) == 4294967295)
assert(bit32.arshift(- 1,24) == 4294967295)
assert(bit32.arshift(- 1,32) == 4294967295)
assert(bit32.arshift(- 1,- 1) == bit32.band(- 1 * 2,4294967295))
assert(305419896 << 4 == 4886718336)
assert(305419896 << 8 == 78187493376)
assert(305419896 << - 4 == 19088743)
assert(305419896 << - 8 == 1193046)
assert(305419896 << 32 == 1311768464867721216)
assert(305419896 << - 32 == 0)
assert(305419896 >> 4 == 19088743)
assert(305419896 >> 8 == 1193046)
assert(305419896 >> 32 == 0)
assert(305419896 >> - 32 == 1311768464867721216)
assert(bit32.lshift(0x12345678,0x4) == 0x23456780)
assert(bit32.lshift(0x12345678,0x8) == 0x34567800)
assert(bit32.lshift(0x12345678,- 0x4) == 0x1234567)
assert(bit32.lshift(0x12345678,- 0x8) == 0x123456)
assert(bit32.lshift(0x12345678,0x20) == 0x0)
assert(bit32.lshift(0x12345678,- 0x20) == 0x0)
assert(bit32.rshift(0x12345678,0x4) == 0x1234567)
assert(bit32.rshift(0x12345678,0x8) == 0x123456)
assert(bit32.rshift(0x12345678,0x20) == 0x0)
assert(bit32.rshift(0x12345678,- 0x20) == 0x0)
assert(bit32.arshift(0x12345678,0x0) == 0x12345678)
assert(bit32.arshift(0x12345678,0x1) == 0x12345678 // 0x2)
assert(bit32.arshift(0x12345678,- 0x1) == 0x12345678 * 0x2)
assert(bit32.arshift(- 0x1,0x1) == 0xffffffff)
assert(bit32.arshift(- 0x1,0x18) == 0xffffffff)
assert(bit32.arshift(- 0x1,0x20) == 0xffffffff)
assert(bit32.arshift(- 0x1,- 0x1) == bit32.band(- 0x1 * 0x2,0xffffffff))
assert(0x12345678 << 0x4 == 0x123456780)
assert(0x12345678 << 0x8 == 0x1234567800)
assert(0x12345678 << - 0x4 == 0x1234567)
assert(0x12345678 << - 0x8 == 0x123456)
assert(0x12345678 << 0x20 == 0x1234567800000000)
assert(0x12345678 << - 0x20 == 0x0)
assert(0x12345678 >> 0x4 == 0x1234567)
assert(0x12345678 >> 0x8 == 0x123456)
assert(0x12345678 >> 0x20 == 0x0)
assert(0x12345678 >> - 0x20 == 0x1234567800000000)
print("\u{2b}")
local c = {0,1,2,3,10,2147483648,2863311530,1431655765,4294967295,2147483647}
local c = {0x0,0x1,0x2,0x3,0xa,0x80000000,0xaaaaaaaa,0x55555555,0xffffffff,0x7fffffff}
for _,b in pairs(c)
do
assert(bit32.band(b) == b)
assert(bit32.band(b,b) == b)
assert(bit32.band(b,b,b,b) == b)
assert(bit32.btest(b,b) == (b ~= 0))
assert(bit32.btest(b,b) == (b ~= 0x0))
assert(bit32.band(b,b,b) == b)
assert(bit32.band(b,b,b,~ b) == 0)
assert(bit32.btest(b,b,b) == (b ~= 0))
assert(bit32.band(b,bit32.bnot(b)) == 0)
assert(bit32.bor(b,bit32.bnot(b)) == bit32.bnot(0))
assert(bit32.band(b,b,b,~ b) == 0x0)
assert(bit32.btest(b,b,b) == (b ~= 0x0))
assert(bit32.band(b,bit32.bnot(b)) == 0x0)
assert(bit32.bor(b,bit32.bnot(b)) == bit32.bnot(0x0))
assert(bit32.bor(b) == b)
assert(bit32.bor(b,b) == b)
assert(bit32.bor(b,b,b) == b)
assert(bit32.bor(b,b,0,~ b) == 4294967295)
assert(bit32.bor(b,b,0x0,~ b) == 0xffffffff)
assert(bit32.bxor(b) == b)
assert(bit32.bxor(b,b) == 0)
assert(bit32.bxor(b,b) == 0x0)
assert(bit32.bxor(b,b,b) == b)
assert(bit32.bxor(b,b,b,b) == 0)
assert(bit32.bxor(b,0) == b)
assert(bit32.bxor(b,b,b,b) == 0x0)
assert(bit32.bxor(b,0x0) == b)
assert(bit32.bnot(b) ~= b)
assert(bit32.bnot(bit32.bnot(b)) == b)
assert(bit32.bnot(b) == (1 << 32) - 1 - b)
assert(bit32.lrotate(b,32) == b)
assert(bit32.rrotate(b,32) == b)
assert(bit32.lshift(bit32.lshift(b,- 4),4) == bit32.band(b,bit32.bnot(15)))
assert(bit32.rshift(bit32.rshift(b,4),- 4) == bit32.band(b,bit32.bnot(15)))
assert(bit32.bnot(b) == (0x1 << 0x20) - 0x1 - b)
assert(bit32.lrotate(b,0x20) == b)
assert(bit32.rrotate(b,0x20) == b)
assert(bit32.lshift(bit32.lshift(b,- 0x4),0x4) == bit32.band(b,bit32.bnot(0xf)))
assert(bit32.rshift(bit32.rshift(b,0x4),- 0x4) == bit32.band(b,bit32.bnot(0xf)))
end
c={0,1,2,3,10,8388608,11184810,5592405,16777215,8388607}
c={0x0,0x1,0x2,0x3,0xa,0x800000,0xaaaaaa,0x555555,0xffffff,0x7fffff}
for _,b in pairs(c)
do
for i = - 40, 40
for i = - 0x28, 0x28
do
local x = bit32.lshift(b,i)
local y = math.floor(math.fmod(b * 2.0 ^ i,2.0 ^ 32))
assert(math.fmod(x - y,2.0 ^ 32) == 0)
local y = math.floor(math.fmod(b * 2.0 ^ i,2.0 ^ 0x20))
assert(math.fmod(x - y,2.0 ^ 0x20) == 0x0)
end
end
assert(not pcall(bit32.band,{}))
assert(not pcall(bit32.bnot,"\u{61}"))
assert(not pcall(bit32.lshift,45))
assert(not pcall(bit32.lshift,45,print))
assert(not pcall(bit32.rshift,45,print))
assert(not pcall(bit32.lshift,0x2d))
assert(not pcall(bit32.lshift,0x2d,print))
assert(not pcall(bit32.rshift,0x2d,print))
print("\u{2b}")
assert(bit32.extract(305419896,0,4) == 8)
assert(bit32.extract(305419896,4,4) == 7)
assert(bit32.extract(2684358929,28,4) == 10)
assert(bit32.extract(2684358929,31,1) == 1)
assert(bit32.extract(1342177553,31,1) == 0)
assert(bit32.extract(4063516281,0,32) == 4063516281)
assert(not pcall(bit32.extract,0,- 1))
assert(not pcall(bit32.extract,0,32))
assert(not pcall(bit32.extract,0,0,33))
assert(not pcall(bit32.extract,0,31,2))
assert(bit32.replace(305419896,5,28,4) == 1379161720)
assert(bit32.replace(305419896,2271560481,0,32) == 2271560481)
assert(bit32.replace(0,1,2) == 2 ^ 2)
assert(bit32.replace(0,- 1,4) == 2 ^ 4)
assert(bit32.replace(- 1,0,31) == (1 << 31) - 1)
assert(bit32.replace(- 1,0,1,2) == (1 << 32) - 7)
assert(bit32.bor(3.0) == 3)
assert(bit32.bor(- 4.0) == 4294967292)
if 2.0 ^ 50 < 2.0 ^ 50 + 1.0 and 2.0 ^ 50 < (- 1 >> 1) then
assert(bit32.bor(2.0 ^ 32 - 5.0) == 4294967291)
assert(bit32.bor(- 2.0 ^ 32 - 6.0) == 4294967290)
assert(bit32.bor(2.0 ^ 48 - 5.0) == 4294967291)
assert(bit32.bor(- 2.0 ^ 48 - 6.0) == 4294967290)
assert(bit32.extract(0x12345678,0x0,0x4) == 0x8)
assert(bit32.extract(0x12345678,0x4,0x4) == 0x7)
assert(bit32.extract(0xa0001111,0x1c,0x4) == 0xa)
assert(bit32.extract(0xa0001111,0x1f,0x1) == 0x1)
assert(bit32.extract(0x50000111,0x1f,0x1) == 0x0)
assert(bit32.extract(0xf2345679,0x0,0x20) == 0xf2345679)
assert(not pcall(bit32.extract,0x0,- 0x1))
assert(not pcall(bit32.extract,0x0,0x20))
assert(not pcall(bit32.extract,0x0,0x0,0x21))
assert(not pcall(bit32.extract,0x0,0x1f,0x2))
assert(bit32.replace(0x12345678,0x5,0x1c,0x4) == 0x52345678)
assert(bit32.replace(0x12345678,0x87654321,0x0,0x20) == 0x87654321)
assert(bit32.replace(0x0,0x1,0x2) == 0x2 ^ 0x2)
assert(bit32.replace(0x0,- 0x1,0x4) == 0x2 ^ 0x4)
assert(bit32.replace(- 0x1,0x0,0x1f) == (0x1 << 0x1f) - 0x1)
assert(bit32.replace(- 0x1,0x0,0x1,0x2) == (0x1 << 0x20) - 0x7)
assert(bit32.bor(3.0) == 0x3)
assert(bit32.bor(- 4.0) == 0xfffffffc)
if 2.0 ^ 0x32 < 2.0 ^ 0x32 + 1.0 and 2.0 ^ 0x32 < (- 0x1 >> 0x1) then
assert(bit32.bor(2.0 ^ 0x20 - 5.0) == 0xfffffffb)
assert(bit32.bor(- 2.0 ^ 0x20 - 6.0) == 0xfffffffa)
assert(bit32.bor(2.0 ^ 0x30 - 5.0) == 0xfffffffb)
assert(bit32.bor(- 2.0 ^ 0x30 - 6.0) == 0xfffffffa)
end
print("\u{4f}\u{4b}")

View File

@ -20,7 +20,7 @@ if mm then
return mm(x,y)
end
end
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,3) .. "\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),4)
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)
end
local function checkargs
(x,y,mtname)

View File

@ -1,8 +1,8 @@
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}")
local debug = require("\u{64}\u{65}\u{62}\u{75}\u{67}")
assert(type(1 < 2) == "\u{62}\u{6f}\u{6f}\u{6c}\u{65}\u{61}\u{6e}")
assert(type(0x1 < 0x2) == "\u{62}\u{6f}\u{6f}\u{6c}\u{65}\u{61}\u{6e}")
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}")
assert(type(nil) == "\u{6e}\u{69}\u{6c}" and type(- 3) == "\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}")
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}")
assert(type(assert) == type(print))
local function f
(x)
@ -12,53 +12,53 @@ assert(type(f) == "\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}")
assert(not pcall(type))
fact=false
do
local res = 1
local res = 0x1
local function fact
(n)
if n == 0 then
if n == 0x0 then
return res
else
return n * fact(n - 1)
return n * fact(n - 0x1)
end
end
assert(fact(5) == 120)
assert(fact(0x5) == 0x78)
end
assert(fact == false)
fact=nil
local a = {["\u{69}"] = 10}
local self = 20
local a = {["\u{69}"] = 0xa}
local self = 0x14
function a:x(x)
return x + self.i
end
function a.y(x)
return x + self
end
assert(a:x(1) + 10 == a.y(1))
a.t={["\u{69}"] = - 100}
assert(a:x(0x1) + 0xa == a.y(0x1))
a.t={["\u{69}"] = - 0x64}
a["\u{74}"].x=function (self,a,b)
return self.i + a + b
end
assert(a.t:x(2,3) == - 95)
assert(a.t:x(0x2,0x3) == - 0x5f)
do
local a = {["\u{78}"] = 0}
local a = {["\u{78}"] = 0x0}
function a:add(x)
self.x,a.y=self.x + x,20
self.x,a.y=self.x + x,0x14
;
return self
end
assert(a:add(10):add(20):add(30).x == 60 and a.y == 20)
assert(a:add(0xa):add(0x14):add(0x1e).x == 0x3c and a.y == 0x14)
end
local a = {["\u{62}"] = {["\u{63}"] = {}}}
function a.b.c.f1(x)
return x + 1
return x + 0x1
end
function a.b.c:f2(x,y)
self[x]=y
end
assert(a.b.c.f1(4) == 5)
a.b.c:f2("\u{6b}",12)
assert(a.b.c.f1(0x4) == 0x5)
a.b.c:f2("\u{6b}",0xc)
;
assert(a.b.c.k == 12)
assert(a.b.c.k == 0xc)
print("\u{2b}")
t=nil
function f(a,b,c)
@ -66,94 +66,94 @@ local d = "\u{61}"
;
t={a,b,c,d}
end
f(1,2)
assert(t[1] == 1 and t[2] == 2 and t[3] == nil and t[4] == "\u{61}")
f(1,2,3,4)
assert(t[1] == 1 and t[2] == 2 and t[3] == 3 and t[4] == "\u{61}")
f(0x1,0x2)
assert(t[0x1] == 0x1 and t[0x2] == 0x2 and t[0x3] == nil and t[0x4] == "\u{61}")
f(0x1,0x2,0x3,0x4)
assert(t[0x1] == 0x1 and t[0x2] == 0x2 and t[0x3] == 0x3 and t[0x4] == "\u{61}")
t=nil
function fat(x)
if x <= 1 then
return 1
if x <= 0x1 then
return 0x1
else
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 - 1 .. "\u{29}","")()
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}","")()
end
end
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}"))()
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}")
local a,b = a()
assert(a == 120 and b == 3)
assert(a == 0x78 and b == 0x3)
fat=nil
print("\u{2b}")
local function err_on_n
(n)
if n == 0 then
if n == 0x0 then
error()
;
exit(1)
exit(0x1)
;
else
err_on_n(n - 1)
err_on_n(n - 0x1)
;
exit(1)
exit(0x1)
;
end
end
do
local function dummy
(n)
if n > 0 then
if n > 0x0 then
assert(not pcall(err_on_n,n))
dummy(n - 1)
dummy(n - 0x1)
end
end
dummy(10)
dummy(0xa)
end
_G.deep=nil
function deep(n)
if n > 0 then
deep(n - 1)
if n > 0x0 then
deep(n - 0x1)
end
end
deep(10)
deep(180)
deep(0xa)
deep(0xb4)
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}")
function deep(n)
if n > 0 then
return deep(n - 1)
if n > 0x0 then
return deep(n - 0x1)
else
return 101
return 0x65
end
end
assert(deep(30000) == 101)
assert(deep(0x7530) == 0x65)
a={}
function a:deep(n)
if n > 0 then
return self:deep(n - 1)
if n > 0x0 then
return self:deep(n - 0x1)
else
return 101
return 0x65
end
end
assert(a:deep(30000) == 101)
assert(a:deep(0x7530) == 0x65)
do
local function foo
(x, ...)
local a = {...}
;
return x,a[1],a[2]
return x,a[0x1],a[0x2]
end
local function foo1
(x)
return foo(10,x,x + 1)
return foo(0xa,x,x + 0x1)
end
local a,b,c = foo1(- 2)
assert(a == 10 and b == - 2 and c == - 1)
local a,b,c = foo1(- 0x2)
assert(a == 0xa and b == - 0x2 and c == - 0x1)
local t = setmetatable({},{["\u{5f}\u{5f}\u{63}\u{61}\u{6c}\u{6c}"] = foo})
local function foo2
(x)
return t(10,x)
return t(0xa,x)
end
a,b,c=foo2(100)
assert(a == t and b == 10 and c == 100)
a,b,c=foo2(0x64)
assert(a == t and b == 0xa and c == 0x64)
a,b=(function ()
return foo()
end)()
@ -172,13 +172,13 @@ local function foo1
return foo(...)
end
local a,b,c = foo1()
assert(X == nil and Y == nil and # A == 0)
a,b,c=foo1(10)
assert(X == 10 and Y == nil and # A == 0)
a,b,c=foo1(10,20)
assert(X == 10 and Y == 20 and # A == 0)
a,b,c=foo1(10,20,30)
assert(X == 10 and Y == 20 and # A == 1 and A[1] == 30)
assert(X == nil and Y == nil and # A == 0x0)
a,b,c=foo1(0xa)
assert(X == 0xa and Y == nil and # A == 0x0)
a,b,c=foo1(0xa,0x14)
assert(X == 0xa and Y == 0x14 and # A == 0x0)
a,b,c=foo1(0xa,0x14,0x1e)
assert(X == 0xa and Y == 0x14 and # A == 0x1 and A[0x1] == 0x1e)
end
do
local function loop
@ -189,48 +189,48 @@ local err,msg = xpcall(loop,loop)
assert(not err and string.find(msg,"\u{65}\u{72}\u{72}\u{6f}\u{72}"))
end
do
local n = 10000
local n = 0x2710
local function foo
()
if n == 0 then
return 1023
if n == 0x0 then
return 0x3ff
else
n=n - 1
n=n - 0x1
;
return foo()
end
end
for i = 1, 100
for i = 0x1, 0x64
do
foo=setmetatable({},{["\u{5f}\u{5f}\u{63}\u{61}\u{6c}\u{6c}"] = foo})
end
assert(coroutine.wrap(function ()
return foo()
end)() == 1023)
end)() == 0x3ff)
end
print("\u{2b}")
do
local N = 20
local N = 0x14
local u = table.pack
for i = 1, N
for i = 0x1, N
do
u=setmetatable({i},{["\u{5f}\u{5f}\u{63}\u{61}\u{6c}\u{6c}"] = u})
end
local Res = u("\u{61}","\u{62}","\u{63}")
assert(Res.n == N + 3)
for i = 1, N
assert(Res.n == N + 0x3)
for i = 0x1, N
do
assert(Res[i][1] == i)
assert(Res[i][0x1] == i)
end
assert(Res[N + 1] == "\u{61}" and Res[N + 2] == "\u{62}" and Res[N + 3] == "\u{63}")
assert(Res[N + 0x1] == "\u{61}" and Res[N + 0x2] == "\u{62}" and Res[N + 0x3] == "\u{63}")
end
a=nil
(function (x)
a=x
end)(23)
assert(a == 23 and (function (x)
return x * 2
end)(20) == 40)
end)(0x17)
assert(a == 0x17 and (function (x)
return x * 0x2
end)(0x14) == 0x28)
local Z = function (le)
local function a
(f)
@ -242,15 +242,15 @@ return a(a)
end
local F = function (f)
return function (n)
if n == 0 then
return 1
if n == 0x0 then
return 0x1
else
return n * f(n - 1)
return n * f(n - 0x1)
end
end
end
local fat = Z(F)
assert(fat(0) == 1 and fat(4) == 24 and Z(F)(5) == 5 * Z(F)(4))
assert(fat(0x0) == 0x1 and fat(0x4) == 0x18 and Z(F)(0x5) == 0x5 * Z(F)(0x4))
local function g
(z)
local function f
@ -259,22 +259,22 @@ return function (x,y)
return a + b + c + d + a + x + y + z
end
end
return f(z,z + 1,z + 2,z + 3)
return f(z,z + 0x1,z + 0x2,z + 0x3)
end
local f = g(10)
assert(f(9,16) == 10 + 11 + 12 + 13 + 10 + 9 + 16 + 10)
local f = g(0xa)
assert(f(0x9,0x10) == 0xa + 0xb + 0xc + 0xd + 0xa + 0x9 + 0x10 + 0xa)
print("\u{2b}")
local function unlpack
(t,i)
i=i or 1
i=i or 0x1
if (i <= # t) then
return t[i],unlpack(t,i + 1)
return t[i],unlpack(t,i + 0x1)
end
end
local function equaltab
(t1,t2)
assert(# t1 == # t2)
for i = 1, # t1
for i = 0x1, # t1
do
assert(t1[i] == t2[i])
end
@ -284,38 +284,38 @@ return (table.pack(...))
end
local function f
()
return 1,2,30,4
return 0x1,0x2,0x1e,0x4
end
local function ret2
(a,b)
return a,b
end
local a,b,c,d = unlpack({1,2,3})
assert(a == 1 and b == 2 and c == 3 and d == nil)
a={1,2,3,4,false,10,"\u{61}\u{6c}\u{6f}",false,assert}
local a,b,c,d = unlpack({0x1,0x2,0x3})
assert(a == 0x1 and b == 0x2 and c == 0x3 and d == nil)
a={0x1,0x2,0x3,0x4,false,0xa,"\u{61}\u{6c}\u{6f}",false,assert}
equaltab(pack(unlpack(a)),a)
equaltab(pack(unlpack(a),- 1),{1,- 1})
equaltab(pack(unlpack(a),- 0x1),{0x1,- 0x1})
a,b,c,d=ret2(f()),ret2(f())
assert(a == 1 and b == 1 and c == 2 and d == nil)
assert(a == 0x1 and b == 0x1 and c == 0x2 and d == nil)
a,b,c,d=unlpack(pack(ret2(f()),ret2(f())))
assert(a == 1 and b == 1 and c == 2 and d == nil)
assert(a == 0x1 and b == 0x1 and c == 0x2 and d == nil)
a,b,c,d=unlpack(pack(ret2(f()),(ret2(f()))))
assert(a == 1 and b == 1 and c == nil and d == nil)
a=ret2({unlpack({1,2,3}),unlpack({3,2,1}),unlpack({"\u{61}","\u{62}"})})
assert(a[1] == 1 and a[2] == 3 and a[3] == "\u{61}" and a[4] == "\u{62}")
rawget({},"\u{78}",1)
rawset({},"\u{78}",1,2)
assert(math.sin(1,2) == math.sin(1))
table.sort({10,9,8,4,19,23,0,0},function (a,b)
assert(a == 0x1 and b == 0x1 and c == nil and d == nil)
a=ret2({unlpack({0x1,0x2,0x3}),unlpack({0x3,0x2,0x1}),unlpack({"\u{61}","\u{62}"})})
assert(a[0x1] == 0x1 and a[0x2] == 0x3 and a[0x3] == "\u{61}" and a[0x4] == "\u{62}")
rawget({},"\u{78}",0x1)
rawset({},"\u{78}",0x1,0x2)
assert(math.sin(0x1,0x2) == math.sin(0x1))
table.sort({0xa,0x9,0x8,0x4,0x13,0x17,0x0,0x0},function (a,b)
return a < b
end,"\u{65}\u{78}\u{74}\u{72}\u{61}\u{20}\u{61}\u{72}\u{67}")
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}"
local function read1
(x)
local i = 0
local i = 0x0
return function ()
collectgarbage()
i=i + 1
i=i + 0x1
return string.sub(x,i,i)
end
end
@ -324,7 +324,7 @@ local function cannotload
assert(not a and string.find(b,msg))
end
a=assert(load(read1(x),"\u{6d}\u{6f}\u{64}\u{6e}\u{61}\u{6d}\u{65}","\u{74}",_G))
assert(a() == "\u{0}" and _G.x == 33)
assert(a() == "\u{0}" and _G.x == 0x21)
assert(debug.getinfo(a).source == "\u{6d}\u{6f}\u{64}\u{6e}\u{61}\u{6d}\u{65}")
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}",{}))
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}"))
@ -337,13 +337,13 @@ return true
end))
local t = {nil,"\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}","\u{33}"}
f,msg=load(function ()
return table.remove(t,1)
return table.remove(t,0x1)
end)
assert(f() == nil)
f=load(string.dump(function ()
return 1
return 0x1
end),nil,"\u{62}",{})
assert(type(f) == "\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}" and f() == 1)
assert(type(f) == "\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}" and f() == 0x1)
do
local f = string.dump(function ()
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}"
@ -353,7 +353,7 @@ assert(f() == "\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30
end
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}"))
a=assert(load(read1(x),nil,"\u{62}"))
assert(a() == 1 and _G.x == 1)
assert(a() == 0x1 and _G.x == 0x1)
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}"))
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}"))
_G.x=nil
@ -363,10 +363,10 @@ cannotload("\u{75}\u{6e}\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}\u{20}\u
cannotload("\u{68}\u{68}\u{69}",load(function ()
error("\u{68}\u{68}\u{69}")
end))
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,123)() == 123)
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)
local x
;
XX=123
XX=0x7b
local function h
()
local y = x
@ -374,117 +374,117 @@ return XX
end
local d = string.dump(h)
x=load(d,"","\u{62}")
assert(debug.getupvalue(x,2) == "\u{5f}\u{45}\u{4e}\u{56}")
debug.setupvalue(x,2,_G)
assert(x() == 123)
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}"] = 13}))(4) == 17)
assert(debug.getupvalue(x,0x2) == "\u{5f}\u{45}\u{4e}\u{56}")
debug.setupvalue(x,0x2,_G)
assert(x() == 0x7b)
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)
XX=nil
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}"
a=assert(load(read1(x),"\u{72}\u{65}\u{61}\u{64}","\u{74}"))
assert(a()(2)(3)(10) == 15)
assert(a()(0x2)(0x3)(0xa) == 0xf)
x=string.dump(a)
a=assert(load(read1(x),"\u{72}\u{65}\u{61}\u{64}","\u{62}"))
assert(a()(2)(3)(10) == 15)
local a,b = 20,30
assert(a()(0x2)(0x3)(0xa) == 0xf)
local a,b = 0x14,0x1e
x=load(string.dump(function (x)
if x == "\u{73}\u{65}\u{74}" then
a=10 + b
a=0xa + b
;
b=b + 1
b=b + 0x1
else
return a
end
end),"","\u{62}",nil)
assert(x() == nil)
assert(debug.setupvalue(x,1,"\u{68}\u{69}") == "\u{61}")
assert(debug.setupvalue(x,0x1,"\u{68}\u{69}") == "\u{61}")
assert(x() == "\u{68}\u{69}")
assert(debug.setupvalue(x,2,13) == "\u{62}")
assert(not debug.setupvalue(x,3,10))
assert(debug.setupvalue(x,0x2,0xd) == "\u{62}")
assert(not debug.setupvalue(x,0x3,0xa))
x("\u{73}\u{65}\u{74}")
assert(x() == 23)
assert(x() == 0x17)
x("\u{73}\u{65}\u{74}")
assert(x() == 24)
assert(x() == 0x18)
do
local nup = 200
local nup = 0xc8
local prog = {"\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{61}\u{31}"}
for i = 2, nup
for i = 0x2, nup
do
prog[# prog + 1]="\u{2c}\u{20}\u{61}" .. i
prog[# prog + 0x1]="\u{2c}\u{20}\u{61}" .. i
end
prog[# prog + 1]="\u{20}\u{3d}\u{20}\u{31}"
for i = 2, nup
prog[# prog + 0x1]="\u{20}\u{3d}\u{20}\u{31}"
for i = 0x2, nup
do
prog[# prog + 1]="\u{2c}\u{20}" .. i
prog[# prog + 0x1]="\u{2c}\u{20}" .. i
end
local sum = 1
prog[# prog + 1]="\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}"
for i = 2, nup
local sum = 0x1
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}"
for i = 0x2, nup
do
prog[# prog + 1]="\u{20}\u{2b}\u{20}\u{61}" .. i
prog[# prog + 0x1]="\u{20}\u{2b}\u{20}\u{61}" .. i
;
sum=sum + i
end
prog[# prog + 1]="\u{20}\u{65}\u{6e}\u{64}"
prog[# prog + 0x1]="\u{20}\u{65}\u{6e}\u{64}"
prog=table.concat(prog)
local f = assert(load(prog))()
assert(f() == sum)
f=load(string.dump(f))
local a = 10
local a = 0xa
local h = function ()
return a
end
for i = 1, nup
for i = 0x1, nup
do
debug.upvaluejoin(f,i,h,1)
debug.upvaluejoin(f,i,h,0x1)
end
assert(f() == 10 * nup)
assert(f() == 0xa * nup)
end
do
local t = {["\u{78}"] = 1}
local t = {["\u{78}"] = 0x1}
function t:_012345678901234567890123456789012345678901234567890123456789()
return self.x
end
assert(t:_012345678901234567890123456789012345678901234567890123456789() == 1)
assert(t:_012345678901234567890123456789012345678901234567890123456789() == 0x1)
end
assert((function ()
return nil
end)(4) == nil)
end)(0x4) == nil)
assert((function ()
local a
;
return a
end)(4) == nil)
end)(0x4) == nil)
assert((function (a)
return a
end)() == nil)
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}")
do
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}",84,0,"\u{19}\u{93}\u{d}\u{a}\u{1a}\u{a}",4,string.packsize("\u{6a}"),string.packsize("\u{6e}"))
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}"))
local c = string.dump(function ()
local a = 1
local a = 0x1
;
local b = 3
local b = 0x3
;
local f = function ()
return a + b + _ENV.c
end
local s1 = "\u{61}\u{20}\u{63}\u{6f}\u{6e}\u{73}\u{74}\u{61}\u{6e}\u{74}"
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}"
return a + b * 3
return a + b * 0x3
end)
assert(assert(load(c))() == 10)
assert(string.sub(c,1,# header) == header)
local ci,cn = string.unpack("\u{6a}\u{6e}",c,# header + 1)
assert(ci == 22136 and cn == 370.5)
for i = 1, # header
assert(assert(load(c))() == 0xa)
assert(string.sub(c,0x1,# header) == header)
local ci,cn = string.unpack("\u{6a}\u{6e}",c,# header + 0x1)
assert(ci == 0x5678 and cn == 370.5)
for i = 0x1, # header
do
local s = string.sub(c,1,i - 1) .. string.char(string.byte(string.sub(c,i,i)) + 1) .. string.sub(c,i + 1,- 1)
local s = string.sub(c,0x1,i - 0x1) .. string.char(string.byte(string.sub(c,i,i)) + 0x1) .. string.sub(c,i + 0x1,- 0x1)
assert(# s == # c)
assert(not load(s))
end
for i = 1, # c - 1
for i = 0x1, # c - 0x1
do
local st,msg = load(string.sub(c,1,i))
local st,msg = load(string.sub(c,0x1,i))
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}"))
end
end

View File

@ -1,14 +1,14 @@
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}")
local A,B = 0,{["\u{67}"] = 10}
local A,B = 0x0,{["\u{67}"] = 0xa}
local function f
(x)
local a = {}
for i = 1, 1000
for i = 0x1, 0x3e8
do
local y = 0
local y = 0x0
do
a[i]=function ()
B.g=B.g + 1
B.g=B.g + 0x1
;
y=y + x
;
@ -20,43 +20,43 @@ local dummy = function ()
return a[A]
end
collectgarbage()
A=1
A=0x1
;
assert(dummy() == a[1])
assert(dummy() == a[0x1])
;
A=0
A=0x0
;
assert(a[1]() == x)
assert(a[3]() == x)
assert(a[0x1]() == x)
assert(a[0x3]() == x)
collectgarbage()
assert(B.g == 12)
assert(B.g == 0xc)
return a
end
local a = f(10)
local x = {[1] = {}}
local a = f(0xa)
local x = {[0x1] = {}}
setmetatable(x,{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{6b}\u{76}"})
while x[1] do
while x[0x1] do
local a = A .. A .. A .. A
A=A + 1
A=A + 0x1
end
assert(a[1]() == 20 + A)
assert(a[1]() == 30 + A)
assert(a[2]() == 10 + A)
assert(a[0x1]() == 0x14 + A)
assert(a[0x1]() == 0x1e + A)
assert(a[0x2]() == 0xa + A)
collectgarbage()
assert(a[2]() == 20 + A)
assert(a[2]() == 30 + A)
assert(a[3]() == 20 + A)
assert(a[8]() == 10 + A)
assert(a[0x2]() == 0x14 + A)
assert(a[0x2]() == 0x1e + A)
assert(a[0x3]() == 0x14 + A)
assert(a[0x8]() == 0xa + A)
assert(getmetatable(x).__mode == "\u{6b}\u{76}")
assert(B.g == 19)
assert(B.g == 0x13)
a={}
for i = 1, 5
for i = 0x1, 0x5
do
a[i]=function (x)
return i + a + _ENV
end
end
assert(a[3] ~= a[4] and a[4] ~= a[5])
assert(a[0x3] ~= a[0x4] and a[0x4] ~= a[0x5])
do
local a = function (x)
return math.sin(_ENV[x])
@ -68,26 +68,26 @@ end
assert(f() == f())
end
a={}
for i = 1, 10
for i = 0x1, 0xa
do
a[i]={["\u{73}\u{65}\u{74}"] = function (x)
i=x
end,["\u{67}\u{65}\u{74}"] = function ()
return i
end}
if i == 3 then
if i == 0x3 then
break
end
end
assert(a[4] == undef)
a[1].set(10)
assert(a[2].get() == 2)
a[2].set("\u{61}")
assert(a[3].get() == 3)
assert(a[2].get() == "\u{61}")
assert(a[0x4] == undef)
a[0x1].set(0xa)
assert(a[0x2].get() == 0x2)
a[0x2].set("\u{61}")
assert(a[0x3].get() == 0x3)
assert(a[0x2].get() == "\u{61}")
a={}
local t = {"\u{61}","\u{62}"}
for i = 1, # t
for i = 0x1, # t
do
local k = t[i]
a[i]={["\u{73}\u{65}\u{74}"] = function (x,y)
@ -97,28 +97,28 @@ k=y
end,["\u{67}\u{65}\u{74}"] = function ()
return i,k
end}
if i == 2 then
if i == 0x2 then
break
end
end
a[1].set(10,20)
local r,s = a[2].get()
assert(r == 2 and s == "\u{62}")
r,s=a[1].get()
assert(r == 10 and s == 20)
a[2].set("\u{61}","\u{62}")
r,s=a[2].get()
a[0x1].set(0xa,0x14)
local r,s = a[0x2].get()
assert(r == 0x2 and s == "\u{62}")
r,s=a[0x1].get()
assert(r == 0xa and s == 0x14)
a[0x2].set("\u{61}","\u{62}")
r,s=a[0x2].get()
assert(r == "\u{61}" and s == "\u{62}")
local f
for i = 1, 3
for i = 0x1, 0x3
do
f=function ()
return i
end
break
end
assert(f() == 1)
for k = 1, # t
assert(f() == 0x1)
for k = 0x1, # t
do
local v = t[k]
f=function ()
@ -126,13 +126,13 @@ return k,v
end
break
end
assert(({f()})[1] == 1)
assert(({f()})[2] == "\u{61}")
assert(({f()})[0x1] == 0x1)
assert(({f()})[0x2] == "\u{61}")
local b
function f(x)
local first = 1
while 1 do
if x == 3 and not first then
local first = 0x1
while 0x1 do
if x == 0x3 and not first then
return
end
local a = "\u{78}\u{75}\u{78}\u{75}"
@ -143,35 +143,35 @@ else
return a
end
end
if x == 1 then
if x == 0x1 then
do
break
end
elseif x == 2 then
elseif x == 0x2 then
return
else
if x ~= 3 then
if x ~= 0x3 then
error()
end
end
first=nil
end
end
for i = 1, 3
for i = 0x1, 0x3
do
f(i)
assert(b("\u{67}\u{65}\u{74}") == "\u{78}\u{75}\u{78}\u{75}")
b("\u{73}\u{65}\u{74}",10)
b("\u{73}\u{65}\u{74}",0xa)
;
assert(b("\u{67}\u{65}\u{74}") == 10 + i)
assert(b("\u{67}\u{65}\u{74}") == 0xa + i)
b=nil
end
pcall(f,4)
pcall(f,0x4)
;
assert(b("\u{67}\u{65}\u{74}") == "\u{78}\u{75}\u{78}\u{75}")
b("\u{73}\u{65}\u{74}",10)
b("\u{73}\u{65}\u{74}",0xa)
;
assert(b("\u{67}\u{65}\u{74}") == 14)
assert(b("\u{67}\u{65}\u{74}") == 0xe)
local y,w
function f(x)
return function (y)
@ -180,14 +180,14 @@ return w + x + y + z
end
end
end
y=f(10)
y=f(0xa)
w=1.345
assert(y(20)(30) == 60 + w)
assert(y(0x14)(0x1e) == 0x3c + w)
do
local X,Y
local a = math.sin(0)
local a = math.sin(0x0)
while a do
local b = 10
local b = 0xa
X=function ()
return b
end
@ -196,29 +196,29 @@ break
end
end
do
local b = 20
local b = 0x14
Y=function ()
return b
end
end
assert(X() == 10 and Y() == 20)
assert(X() == 0xa and Y() == 0x14)
end
local a = {}
local i = 1
local i = 0x1
repeat
local x = i
a[i]=function ()
i=x + 1
i=x + 0x1
;
return x
end
until i > 10 or a[i]() ~= x
assert(i == 11 and a[1]() == 1 and a[3]() == 3 and i == 4)
until i > 0xa or a[i]() ~= x
assert(i == 0xb and a[0x1]() == 0x1 and a[0x3]() == 0x3 and i == 0x4)
a={}
for i = 1, 10
for i = 0x1, 0xa
do
if i % 3 == 0 then
local y = 0
if i % 0x3 == 0x0 then
local y = 0x0
a[i]=function (x)
local t = y
;
@ -226,11 +226,11 @@ y=x
;
return t
end
elseif i % 3 == 1 then
elseif i % 0x3 == 0x1 then
goto L1
error("\u{6e}\u{6f}\u{74}\u{20}\u{68}\u{65}\u{72}\u{65}")
::L1::
local y = 1
local y = 0x1
a[i]=function (x)
local t = y
;
@ -238,7 +238,7 @@ y=x
;
return t
end
elseif i % 3 == 2 then
elseif i % 0x3 == 0x2 then
local t
goto l4
::l4a::
@ -247,7 +247,7 @@ a[i]=t
goto l4b
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}")
::l4::
local y = 2
local y = 0x2
t=function (x)
local t = y
;
@ -260,9 +260,9 @@ 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}\
::l4b::
end
end
for i = 1, 10
for i = 0x1, 0xa
do
assert(a[i](i * 10) == i % 3 and a[i]() == i * 10)
assert(a[i](i * 0xa) == i % 0x3 and a[i]() == i * 0xa)
end
print("\u{2b}")
local function t
@ -273,9 +273,9 @@ assert(a == "\u{74}\u{65}\u{73}\u{74}" and b == "\u{4f}\u{4b}")
end
local function v
(f, ...)
c("\u{74}\u{65}\u{73}\u{74}",f() ~= 1 and "\u{46}\u{41}\u{49}\u{4c}\u{45}\u{44}" or "\u{4f}\u{4b}")
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}")
end
local x = 1
local x = 0x1
return v(function ()
return x
end)
@ -284,7 +284,7 @@ t()
local debug = require("\u{64}\u{65}\u{62}\u{75}\u{67}")
local foo1,foo2,foo3
do
local a,b,c = 3,5,7
local a,b,c = 0x3,0x5,0x7
foo1=function ()
return a + b
end
@ -294,34 +294,34 @@ return b + a
end
;
do
local a = 10
local a = 0xa
foo3=function ()
return a + b
end
;
end
end
assert(debug.upvalueid(foo1,1))
assert(debug.upvalueid(foo1,2))
assert(not debug.upvalueid(foo1,3))
assert(debug.upvalueid(foo1,1) == debug.upvalueid(foo2,2))
assert(debug.upvalueid(foo1,2) == debug.upvalueid(foo2,1))
assert(debug.upvalueid(foo3,1))
assert(debug.upvalueid(foo1,1) ~= debug.upvalueid(foo3,1))
assert(debug.upvalueid(foo1,2) == debug.upvalueid(foo3,2))
assert(debug.upvalueid(string.gmatch("\u{78}","\u{78}"),1) ~= nil)
assert(foo1() == 3 + 5 and foo2() == 5 + 3)
debug.upvaluejoin(foo1,2,foo2,2)
assert(foo1() == 3 + 3 and foo2() == 5 + 3)
assert(foo3() == 10 + 5)
debug.upvaluejoin(foo3,2,foo2,1)
assert(foo3() == 10 + 5)
debug.upvaluejoin(foo3,2,foo2,2)
assert(foo3() == 10 + 3)
assert(not pcall(debug.upvaluejoin,foo1,3,foo2,1))
assert(not pcall(debug.upvaluejoin,foo1,1,foo2,3))
assert(not pcall(debug.upvaluejoin,foo1,0,foo2,1))
assert(not pcall(debug.upvaluejoin,print,1,foo2,1))
assert(not pcall(debug.upvaluejoin,{},1,foo2,1))
assert(not pcall(debug.upvaluejoin,foo1,1,print,1))
assert(debug.upvalueid(foo1,0x1))
assert(debug.upvalueid(foo1,0x2))
assert(not debug.upvalueid(foo1,0x3))
assert(debug.upvalueid(foo1,0x1) == debug.upvalueid(foo2,0x2))
assert(debug.upvalueid(foo1,0x2) == debug.upvalueid(foo2,0x1))
assert(debug.upvalueid(foo3,0x1))
assert(debug.upvalueid(foo1,0x1) ~= debug.upvalueid(foo3,0x1))
assert(debug.upvalueid(foo1,0x2) == debug.upvalueid(foo3,0x2))
assert(debug.upvalueid(string.gmatch("\u{78}","\u{78}"),0x1) ~= nil)
assert(foo1() == 0x3 + 0x5 and foo2() == 0x5 + 0x3)
debug.upvaluejoin(foo1,0x2,foo2,0x2)
assert(foo1() == 0x3 + 0x3 and foo2() == 0x5 + 0x3)
assert(foo3() == 0xa + 0x5)
debug.upvaluejoin(foo3,0x2,foo2,0x1)
assert(foo3() == 0xa + 0x5)
debug.upvaluejoin(foo3,0x2,foo2,0x2)
assert(foo3() == 0xa + 0x3)
assert(not pcall(debug.upvaluejoin,foo1,0x3,foo2,0x1))
assert(not pcall(debug.upvaluejoin,foo1,0x1,foo2,0x3))
assert(not pcall(debug.upvaluejoin,foo1,0x0,foo2,0x1))
assert(not pcall(debug.upvaluejoin,print,0x1,foo2,0x1))
assert(not pcall(debug.upvaluejoin,{},0x1,foo2,0x1))
assert(not pcall(debug.upvaluejoin,foo1,0x1,print,0x1))
print("\u{4f}\u{4b}")

View File

@ -3,15 +3,15 @@ if T == nil then
return
end
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}")
local k0aux <const> = 0
local k0aux <const> = 0x0
local k0 <const> = k0aux
local k1 <const> = 1
local k3 <const> = 3
local k1 <const> = 0x1
local k3 <const> = 0x3
local k6 <const> = k3 + (k3 << k0)
local kFF0 <const> = 4080
local kFF0 <const> = 0xff0
local k3_78 <const> = 3.78
local x,k3_78_4 <const> = 10,k3_78 / 4
assert(x == 10)
local x,k3_78_4 <const> = 0xa,k3_78 / 0x4
assert(x == 0xa)
local kx <const> = "\u{78}"
local kTrue <const> = true
local kFalse <const> = false
@ -29,7 +29,7 @@ local function checkKlist
(func,list)
local k = T.listk(func)
assert(# k == # list)
for i = 1, # k
for i = 0x1, # k
do
assert(k[i] == list[i] and math.type(k[i]) == math.type(list[i]))
end
@ -39,79 +39,79 @@ local function foo
local a
a=k3
;
a=0
a=0x0
;
a=0.0
;
a=- 7 + 7
a=k3_78 / 4
a=- 0x7 + 0x7
a=k3_78 / 0x4
;
a=k3_78_4
a=- k3_78 / 4
a=- k3_78 / 0x4
;
a=k3_78 / 4
a=k3_78 / 0x4
;
a=- 3.78 / 4
a=- 3.79 / 4
a=- 3.78 / 0x4
a=- 3.79 / 0x4
;
a=0.0
;
a=- 0
a=- 0x0
;
a=k3
;
a=3.0
;
a=3
a=0x3
;
a=3.0
end
checkKlist(foo,{3.78 / 4,- 3.78 / 4,- 3.79 / 4})
checkKlist(foo,{3.78 / 0x4,- 3.78 / 0x4,- 3.79 / 0x4})
foo=function (f,a)
f(100 * 1000)
f(100.0 * 1000)
f(- 100 * 1000)
f(- 100 * 1e3)
f(100000)
f(0x64 * 0x3e8)
f(100.0 * 0x3e8)
f(- 0x64 * 0x3e8)
f(- 0x64 * 1e3)
f(0x186a0)
f(1e5)
f(- 100000)
f(- 0x186a0)
f(- 1e5)
end
checkKlist(foo,{100000,1e5,- 100000,- 1e5})
checkKlist(foo,{0x186a0,1e5,- 0x186a0,- 1e5})
foo=function (t,a)
t[a]=1
t[a]=0x1
;
t[a]=1.0
t[a]=1
t[a]=0x1
;
t[a]=1.0
t[a]=2
t[a]=0x2
;
t[a]=2.0
t[a]=0
t[a]=0x0
;
t[a]=0.0
t[a]=1
t[a]=0x1
;
t[a]=1.0
t[a]=2
t[a]=0x2
;
t[a]=2.0
t[a]=0
t[a]=0x0
;
t[a]=0.0
end
checkKlist(foo,{1,1.0,2,2.0,0,0.0})
checkKlist(foo,{0x1,1.0,0x2,2.0,0x0,0.0})
local function check
(f, ...)
local arg = {...}
local c = T.listcode(f)
for i = 1, # arg
for i = 0x1, # arg
do
local opcode = string.match(c[i],"\u{25}\u{75}\u{25}\u{77}\u{2b}")
assert(arg[i] == opcode)
end
assert(c[# arg + 2] == undef)
assert(c[# arg + 0x2] == undef)
end
local function checkR
(f,p,r, ...)
@ -124,7 +124,7 @@ local function checkequal
a=T.listcode(a)
b=T.listcode(b)
assert(# a == # b)
for i = 1, # a
for i = 0x1, # a
do
a[i]=string.gsub(a[i],"\u{25}\u{62}\u{28}\u{29}","")
b[i]=string.gsub(b[i],"\u{25}\u{62}\u{28}\u{29}","")
@ -162,7 +162,7 @@ c=nil
;
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}")
check(function ()
local a,b,c,d = 1,1,1,1
local a,b,c,d = 0x1,0x1,0x1,0x1
d=nil
;
c=nil
@ -172,7 +172,7 @@ b=nil
a=nil
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}")
do
local a,b,c,d = 1,1,1,1
local a,b,c,d = 0x1,0x1,0x1,0x1
d=nil
;
c=nil
@ -187,17 +187,17 @@ return a
end,"\u{52}\u{45}\u{54}\u{55}\u{52}\u{4e}\u{31}")
check(function ()
while kTrue do
local a = - 1
local a = - 0x1
end
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}")
check(function ()
while 1 do
local a = - 1
while 0x1 do
local a = - 0x1
end
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}")
check(function ()
repeat
local x = 1
local x = 0x1
until true
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}")
check(function (a,b,c,d)
@ -228,86 +228,86 @@ a.x=b
a[b]="\u{78}"
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}")
check(function (a)
local k255 <const> = 255
a[1]=a[100]
a[k255]=a[256]
a[256]=5
local k255 <const> = 0xff
a[0x1]=a[0x64]
a[k255]=a[0x100]
a[0x100]=0x5
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}")
check(function ()
local a,b
a=a - a
b=a / a
b=5 - 4
b=0x5 - 0x4
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}")
check(function ()
local a,b
a[kTrue]=false
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}")
checkR(function (a)
if a == 1 then
return 2
if a == 0x1 then
return 0x2
end
end,1,2,"\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}")
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}")
checkR(function (a)
if - 4.0 == a then
return 2
return 0x2
end
end,- 4,2,"\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}")
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}")
checkR(function (a)
if a == "\u{68}\u{69}" then
return 2
return 0x2
end
end,10,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}")
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}")
checkR(function (a)
if a == 10000 then
return 2
if a == 0x2710 then
return 0x2
end
end,1,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}")
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}")
checkR(function (a)
if - 10000 == a then
return 2
if - 0x2710 == a then
return 0x2
end
end,- 10000,2,"\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}")
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}")
checkR(function (a)
if - 10 <= a then
return 2
if - 0xa <= a then
return 0x2
end
end,- 10,2,"\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}")
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}")
checkR(function (a)
if 128.0 > a then
return 2
return 0x2
end
end,129,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}")
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}")
checkR(function (a)
if - 127.0 < a then
return 2
return 0x2
end
end,- 127,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}")
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}")
checkR(function (a)
if 10 < a then
return 2
if 0xa < a then
return 0x2
end
end,11,2,"\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}")
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}")
checkR(function (a)
if 129 < a then
return 2
if 0x81 < a then
return 0x2
end
end,130,2,"\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}")
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}")
checkR(function (a)
if a >= 23.0 then
return 2
return 0x2
end
end,25,2,"\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}")
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}")
checkR(function (a)
if a >= 23.1 then
return 2
return 0x2
end
end,0,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}")
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}")
checkR(function (a)
if a > 2300.0 then
return 2
return 0x2
end
end,0,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}")
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}")
local function checkK
(func,val)
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}")
@ -331,47 +331,47 @@ return 0.0
end,0.0)
checkI(function ()
return k0
end,0)
end,0x0)
checkI(function ()
return - k0 // 1
end,0)
return - k0 // 0x1
end,0x0)
checkK(function ()
return 3 ^ - 1
end,1 / 3)
return 0x3 ^ - 0x1
end,0x1 / 0x3)
checkK(function ()
return (1 + 1) ^ (50 + 50)
end,2 ^ 100)
return (0x1 + 0x1) ^ (0x32 + 0x32)
end,0x2 ^ 0x64)
checkK(function ()
return (- 2) ^ (31 - 2)
end,- 536870912 + 0.0)
return (- 0x2) ^ (0x1f - 0x2)
end,- 0x20000000 + 0.0)
checkF(function ()
return (- k3 ^ 0 + 5) // 3.0
return (- k3 ^ 0x0 + 0x5) // 3.0
end,1.0)
checkI(function ()
return - k3 % 5
end,2)
return - k3 % 0x5
end,0x2)
checkF(function ()
return - ((2.0 ^ 8 + - (- 1)) % 8) / 2 * 4 - 3
return - ((2.0 ^ 0x8 + - (- 0x1)) % 0x8) / 0x2 * 0x4 - 0x3
end,- 5.0)
checkF(function ()
return - ((2 ^ 8 + - (- 1)) % 8) // 2 * 4 - 3
return - ((0x2 ^ 0x8 + - (- 0x1)) % 0x8) // 0x2 * 0x4 - 0x3
end,- 7.0)
checkI(function ()
return 240.0 | 204.0 ~ 170 & 253
end,244)
return 240.0 | 204.0 ~ 0xaa & 0xfd
end,0xf4)
checkI(function ()
return ~ (~ kFF0 | kFF0)
end,0)
end,0x0)
checkI(function ()
return ~ ~ - 1024.0
end,- 1024)
end,- 0x400)
checkI(function ()
return ((100 << k6) << - 4) >> 2
end,100)
local a = 17
return ((0x64 << k6) << - 0x4) >> 0x2
end,0x64)
local a = 0x11
;
local sbx = ((1 << a) - 1) >> 1
local border <const> = 65535
local sbx = ((0x1 << a) - 0x1) >> 0x1
local border <const> = 0xffff
checkI(function ()
return border
end,sbx)
@ -379,14 +379,14 @@ checkI(function ()
return - border
end,- sbx)
checkI(function ()
return border + 1
end,sbx + 1)
return border + 0x1
end,sbx + 0x1)
checkK(function ()
return border + 2
end,sbx + 2)
return border + 0x2
end,sbx + 0x2)
checkK(function ()
return - (border + 1)
end,- (sbx + 1))
return - (border + 0x1)
end,- (sbx + 0x1))
local border <const> = 65535.0
checkF(function ()
return border
@ -395,112 +395,112 @@ checkF(function ()
return - border
end,- sbx + 0.0)
checkF(function ()
return border + 1
return border + 0x1
end,(sbx + 1.0))
checkK(function ()
return border + 2
return border + 0x2
end,(sbx + 2.0))
checkK(function ()
return - (border + 1)
return - (border + 0x1)
end,- (sbx + 1.0))
checkR(function (x)
return x + k1
end,10,11,"\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}")
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}")
checkR(function (x)
return x - 127
end,10,- 117,"\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}")
return x - 0x7f
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}")
checkR(function (x)
return 128 + x
return 0x80 + x
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}")
checkR(function (x)
return x * - 127
return x * - 0x7f
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}")
checkR(function (x)
return 20 * x
end,2,40,"\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}")
return 0x14 * x
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}")
checkR(function (x)
return x ^ - 2
end,2,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}")
return x ^ - 0x2
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}")
checkR(function (x)
return x / 40
end,40,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}")
return x / 0x28
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}")
checkR(function (x)
return x // 1
return x // 0x1
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}")
checkR(function (x)
return x % (100 - 10)
end,91,1,"\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}")
return x % (0x64 - 0xa)
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}")
checkR(function (x)
return k1 << x
end,3,8,"\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}")
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}")
checkR(function (x)
return x << 127
end,10,0,"\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}")
return x << 0x7f
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}")
checkR(function (x)
return x << - 127
end,10,0,"\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}")
return x << - 0x7f
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}")
checkR(function (x)
return x >> 128
end,8,0,"\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}")
return x >> 0x80
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}")
checkR(function (x)
return x >> - 127
end,8,0,"\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}")
return x >> - 0x7f
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}")
checkR(function (x)
return x & 1
end,9,1,"\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}")
return x & 0x1
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}")
checkR(function (x)
return 10 | x
end,1,11,"\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}")
return 0xa | x
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}")
checkR(function (x)
return - 10 ~ x
end,- 1,9,"\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}")
return - 0xa ~ x
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}")
checkR(function (x)
return x + 0.0
end,1,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}")
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}")
checkR(function (x)
return x * - 10000
end,2,- 20000,"\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}")
return x * - 0x2710
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}")
checkR(function (x)
return x ^ 0.5
end,4,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}")
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}")
checkR(function (x)
return x / 2.0
end,4,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}")
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}")
checkR(function (x)
return x // 10000
end,10000,1,"\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}")
return x // 0x2710
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}")
checkR(function (x)
return x % (100.0 - 10)
end,91,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}")
return x % (100.0 - 0xa)
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}")
check(function ()
return - 0.0
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}")
check(function ()
return k3 / 0
return k3 / 0x0
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}")
check(function ()
return 0 % 0
return 0x0 % 0x0
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}")
check(function ()
return - 4 // 0
return - 0x4 // 0x0
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}")
check(function (x)
return x >> 2.0
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}")
check(function (x)
return x << 128
return x << 0x80
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}")
check(function (x)
return x & 2.0
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}")
check(function ()
for i = - 10, 10.5
for i = - 0xa, 10.5
do
end
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}")
check(function ()
for i = 268435455, 10.0, 1
for i = 0xfffffff, 10.0, 0x1
do
end
@ -540,28 +540,28 @@ end)
checkequal(function (l)
local a
;
return 0 <= a and a <= l
return 0x0 <= a and a <= l
end,function (l)
local a
;
return not (not (a >= 0) or not (a <= l))
return not (not (a >= 0x0) or not (a <= l))
end)
check(function (a,b)
while a do
if b then
break
else
a=a + 1
a=a + 0x1
end
end
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}")
checkequal(function ()
return 6 or true or nil
return 0x6 or true or nil
end,function ()
return k6 or kTrue or kNil
end)
checkequal(function ()
return 6 and true or nil
return 0x6 and true or nil
end,function ()
return k6 and kTrue or kNil
end)
@ -580,7 +580,7 @@ local f2 = f1()
local f3 = f2()
assert(f3() == k0)
checkK(f3,k0)
assert(T.listk(f1)[1] == nil)
assert(T.listk(f2)[1] == nil)
assert(T.listk(f1)[0x1] == nil)
assert(T.listk(f2)[0x1] == nil)
end
print("\u{4f}\u{4b}")

View File

@ -6,7 +6,7 @@ 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}\
local debug = require("\u{64}\u{65}\u{62}\u{75}\u{67}")
local function checkload
(s,msg)
assert(string.find(select(2,load(s)),msg))
assert(string.find(select(0x2,load(s)),msg))
end
local a
do
@ -17,66 +17,66 @@ end
;
do
;
a=3
a=0x3
;
assert(a == 3)
assert(a == 0x3)
end
;
;
if false then
a=3 // 0
a=0x3 // 0x0
;
a=0 % 0
a=0x0 % 0x0
end
assert(2 ^ 3 ^ 2 == 2 ^ (3 ^ 2))
assert(0x2 ^ 0x3 ^ 0x2 == 0x2 ^ (0x3 ^ 0x2))
;
assert(2 ^ 3 * 4 == (2 ^ 3) * 4)
assert(0x2 ^ 0x3 * 0x4 == (0x2 ^ 0x3) * 0x4)
;
assert(2.0 ^ - 2 == 1 / 4 and - 2 ^ - - 2 == - - - 4)
assert(2.0 ^ - 0x2 == 0x1 / 0x4 and - 0x2 ^ - - 0x2 == - - - 0x4)
;
assert(not nil and 2 and not (2 > 3 or 3 < 2))
assert(not nil and 0x2 and not (0x2 > 0x3 or 0x3 < 0x2))
;
assert(- 3 - 1 - 5 == 0 + 0 - 9)
assert(- 0x3 - 0x1 - 0x5 == 0x0 + 0x0 - 0x9)
;
assert(- 2 ^ 2 == - 4 and (- 2) ^ 2 == 4 and 2 * 2 - 3 - 1 == 0)
assert(- 0x2 ^ 0x2 == - 0x4 and (- 0x2) ^ 0x2 == 0x4 and 0x2 * 0x2 - 0x3 - 0x1 == 0x0)
;
assert(- 3 % 5 == 2 and - 3 + 5 == 2)
assert(2 * 1 + 3 / 3 == 3 and 1 + 2 .. 3 * 1 == "\u{33}\u{33}")
assert(- 0x3 % 0x5 == 0x2 and - 0x3 + 0x5 == 0x2)
assert(0x2 * 0x1 + 0x3 / 0x3 == 0x3 and 0x1 + 0x2 .. 0x3 * 0x1 == "\u{33}\u{33}")
;
assert(not (2 + 1 > 3 * 1) and "\u{61}" .. "\u{62}" > "\u{61}")
assert(not (0x2 + 0x1 > 0x3 * 0x1) and "\u{61}" .. "\u{62}" > "\u{61}")
;
assert(240 | 204 ~ 170 & 253 == 244)
assert(253 & 170 ~ 204 | 240 == 244)
assert(240 & 15 + 1 == 16)
assert(3 ^ 4 // 2 ^ 3 // 5 == 2)
assert(- 3 + 4 * 5 // 2 ^ 3 ^ 2 // 9 + 4 % 10 / 3 == (- 3) + (((4 * 5) // (2 ^ (3 ^ 2))) // 9) + ((4 % 10) / 3))
assert(0xf0 | 0xcc ~ 0xaa & 0xfd == 0xf4)
assert(0xfd & 0xaa ~ 0xcc | 0xf0 == 0xf4)
assert(0xf0 & 0xf + 0x1 == 0x10)
assert(0x3 ^ 0x4 // 0x2 ^ 0x3 // 0x5 == 0x2)
assert(- 0x3 + 0x4 * 0x5 // 0x2 ^ 0x3 ^ 0x2 // 0x9 + 0x4 % 0xa / 0x3 == (- 0x3) + (((0x4 * 0x5) // (0x2 ^ (0x3 ^ 0x2))) // 0x9) + ((0x4 % 0xa) / 0x3))
assert(not ((true or false) and nil))
assert(true or false and nil)
assert((((1 or false) and true) or false) == true)
assert((((0x1 or false) and true) or false) == true)
assert((((nil and true) or false) and true) == false)
local a,b = 1,nil
local a,b = 0x1,nil
;
assert(- (1 or 2) == - 1 and (1 and 2) + (- 1.25 or - 4) == 0.75)
assert(- (0x1 or 0x2) == - 0x1 and (0x1 and 0x2) + (- 1.25 or - 0x4) == 0.75)
;
local x = ((b or a) + 1 == 2 and (10 or a) + 1 == 11)
local x = ((b or a) + 0x1 == 0x2 and (0xa or a) + 0x1 == 0xb)
;
assert(x)
;
x=(((2 < 3) or 1) == true and (2 < 3 and 4) == 4)
x=(((0x2 < 0x3) or 0x1) == true and (0x2 < 0x3 and 0x4) == 0x4)
;
assert(x)
;
local x,y = 1,2
local x,y = 0x1,0x2
;
assert((x > y) and x or y == 2)
assert((x > y) and x or y == 0x2)
;
x,y=2,1
x,y=0x2,0x1
;
assert((x > y) and x or y == 2)
assert((x > y) and x or y == 0x2)
;
assert(1234567890 == tonumber("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}") and 1234567890 + 1 == 1234567891)
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)
do
local operand = {3,100,5.0,- 10,- 5.0,10000,- 10000}
local operand = {0x3,0x64,5.0,- 0xa,- 5.0,0x2710,- 0x2710}
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}"}
for _,op in ipairs(operator)
do
@ -105,7 +105,7 @@ _ENV.XX=nil
end
repeat
until 1
until 0x1
;
repeat
@ -124,20 +124,20 @@ local a
;
local function f
(x)
x={["\u{61}"] = 1}
x={["\u{61}"] = 0x1}
;
x={["\u{78}"] = 1}
x={["\u{78}"] = 0x1}
;
x={["\u{47}"] = 1}
x={["\u{47}"] = 0x1}
end
end
do
local code = {"\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{78}\u{20}\u{3d}\u{20}\u{7b}"}
for i = 1, 257
for i = 0x1, 0x101
do
code[# code + 1]=i .. "\u{2e}\u{31}\u{2c}"
code[# code + 0x1]=i .. "\u{2e}\u{31}\u{2c}"
end
code[# code + 1]="\u{7d}\u{3b}"
code[# code + 0x1]="\u{7d}\u{3b}"
code=table.concat(code)
local function check
(ret,val)
@ -145,10 +145,10 @@ local code = code .. ret
code=load(code)
assert(code() == val)
end
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}",1 ~ 2)
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}",1 | 2)
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}",1 + 2)
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}",1 << 2)
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)
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)
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)
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)
end
local function f
(i)
@ -156,125 +156,125 @@ if type(i) ~= "\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}" then
return i,"\u{6a}\u{6f}\u{6a}\u{6f}"
end
;
if i > 0 then
return i,f(i - 1)
if i > 0x0 then
return i,f(i - 0x1)
end
;
end
x={f(3),f(5),f(10)}
x={f(0x3),f(0x5),f(0xa)}
;
assert(x[1] == 3 and x[2] == 5 and x[3] == 10 and x[4] == 9 and x[12] == 1)
assert(x[0x1] == 0x3 and x[0x2] == 0x5 and x[0x3] == 0xa and x[0x4] == 0x9 and x[0xc] == 0x1)
;
assert(x[nil] == nil)
x={f("\u{61}\u{6c}\u{6f}"),f("\u{78}\u{69}\u{78}\u{69}"),nil}
;
assert(x[1] == "\u{61}\u{6c}\u{6f}" and x[2] == "\u{78}\u{69}\u{78}\u{69}" and x[3] == nil)
assert(x[0x1] == "\u{61}\u{6c}\u{6f}" and x[0x2] == "\u{78}\u{69}\u{78}\u{69}" and x[0x3] == nil)
;
x={f("\u{61}\u{6c}\u{6f}") .. "\u{78}\u{69}\u{78}\u{69}"}
;
assert(x[1] == "\u{61}\u{6c}\u{6f}\u{78}\u{69}\u{78}\u{69}")
assert(x[0x1] == "\u{61}\u{6c}\u{6f}\u{78}\u{69}\u{78}\u{69}")
x={f({})}
assert(x[2] == "\u{6a}\u{6f}\u{6a}\u{6f}" and type(x[1]) == "\u{74}\u{61}\u{62}\u{6c}\u{65}")
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}")
local f = function (i)
if i < 10 then
if i < 0xa then
return "\u{61}"
elseif i < 20 then
elseif i < 0x14 then
return "\u{62}"
elseif i < 30 then
elseif i < 0x1e then
return "\u{63}"
end
;
end
assert(f(3) == "\u{61}" and f(12) == "\u{62}" and f(26) == "\u{63}" and f(100) == nil)
for i = 1, 1000
assert(f(0x3) == "\u{61}" and f(0xc) == "\u{62}" and f(0x1a) == "\u{63}" and f(0x64) == nil)
for i = 0x1, 0x3e8
do
break
;
end
;
local n = 100
local n = 0x64
;
local i = 3
local i = 0x3
;
local t = {}
;
local a = nil
while not a do
a=0
a=0x0
;
for i = 1, n
for i = 0x1, n
do
for i = i, 1, - 1
for i = i, 0x1, - 0x1
do
a=a + 1
a=a + 0x1
;
t[i]=1
t[i]=0x1
;
end
;
end
;
end
assert(a == n * (n + 1) / 2 and i == 3)
assert(a == n * (n + 0x1) / 0x2 and i == 0x3)
;
assert(t[1] and t[n] and not t[0] and not t[n + 1])
assert(t[0x1] and t[n] and not t[0x0] and not t[n + 0x1])
function f(b)
local x = 1
local x = 0x1
;
repeat
local a
;
if b == 1 then
local b = 1
if b == 0x1 then
local b = 0x1
;
x=10
x=0xa
;
break
elseif b == 2 then
x=20
elseif b == 0x2 then
x=0x14
;
break
;
elseif b == 3 then
x=30
elseif b == 0x3 then
x=0x1e
;
else
local a,b,c,d = math.sin(1)
local a,b,c,d = math.sin(0x1)
;
x=x + 1
x=x + 0x1
;
end
until x >= 12
until x >= 0xc
;
return x
end
;
assert(f(1) == 10 and f(2) == 20 and f(3) == 30 and f(4) == 12)
assert(f(0x1) == 0xa and f(0x2) == 0x14 and f(0x3) == 0x1e and f(0x4) == 0xc)
local f = function (i)
if i < 10 then
if i < 0xa then
return "\u{61}"
elseif i < 20 then
elseif i < 0x14 then
return "\u{62}"
elseif i < 30 then
elseif i < 0x1e then
return "\u{63}"
else
return 8
return 0x8
end
end
assert(f(3) == "\u{61}" and f(12) == "\u{62}" and f(26) == "\u{63}" and f(100) == 8)
local a,b = nil,23
x={f(100) * 2 + 3 or a,a or b + 2}
assert(x[1] == 19 and x[2] == 25)
x={["\u{66}"] = 2 + 3 or a,["\u{61}"] = b + 2}
assert(x.f == 5 and x.a == 25)
a={["\u{79}"] = 1}
assert(f(0x3) == "\u{61}" and f(0xc) == "\u{62}" and f(0x1a) == "\u{63}" and f(0x64) == 0x8)
local a,b = nil,0x17
x={f(0x64) * 0x2 + 0x3 or a,a or b + 0x2}
assert(x[0x1] == 0x13 and x[0x2] == 0x19)
x={["\u{66}"] = 0x2 + 0x3 or a,["\u{61}"] = b + 0x2}
assert(x.f == 0x5 and x.a == 0x19)
a={["\u{79}"] = 0x1}
x={a.y}
assert(x[1] == 1)
assert(x[0x1] == 0x1)
local function f
(i)
while 1 do
if i > 0 then
i=i - 1
while 0x1 do
if i > 0x0 then
i=i - 0x1
;
else
return
@ -286,32 +286,32 @@ end
;
local function g
(i)
while 1 do
if i > 0 then
i=i - 1
while 0x1 do
if i > 0x0 then
i=i - 0x1
else
return
end
end
end
f(10)
f(0xa)
;
g(10)
g(0xa)
;
do
function f()
return 1,2,3
return 0x1,0x2,0x3
end
local a,b,c = f()
;
assert(a == 1 and b == 2 and c == 3)
assert(a == 0x1 and b == 0x2 and c == 0x3)
a,b,c=(f())
;
assert(a == 1 and b == nil and c == nil)
assert(a == 0x1 and b == nil and c == nil)
end
local a,b = 3 and f()
local a,b = 0x3 and f()
;
assert(a == 1 and b == nil)
assert(a == 0x1 and b == nil)
function g()
f()
;
@ -323,7 +323,7 @@ function g()
return nil or f()
end
a,b=g()
assert(a == 1 and b == nil)
assert(a == 0x1 and b == nil)
print("\u{2b}")
;
do
@ -338,71 +338,71 @@ f=string.gsub(f,"\u{25}\u{73}\u{2b}","\u{a}")
;
f,a=load(f)()
;
assert(a.a == 1 and a.b)
assert(a.a == 0x1 and a.b)
function g(a,b,c,d,e)
if not (a >= b or c or d and e or nil) then
return 0
return 0x0
else
return 1
return 0x1
end
;
end
local function h
(a,b,c,d,e)
while (a >= b or c or (d and e) or nil) do
return 1
return 0x1
end
;
return 0
return 0x0
end
;
assert(f(2,1) == true and g(2,1) == 1 and h(2,1) == 1)
assert(f(1,2,"\u{61}") == "\u{61}" and g(1,2,"\u{61}") == 1 and h(1,2,"\u{61}") == 1)
assert(f(1,2,"\u{61}") ~= nil,"")
assert(f(1,2,"\u{61}") == "\u{61}" and g(1,2,"\u{61}") == 1 and h(1,2,"\u{61}") == 1)
assert(f(1,2,nil,1,"\u{78}") == "\u{78}" and g(1,2,nil,1,"\u{78}") == 1 and h(1,2,nil,1,"\u{78}") == 1)
assert(f(1,2,nil,nil,"\u{78}") == nil and g(1,2,nil,nil,"\u{78}") == 0 and h(1,2,nil,nil,"\u{78}") == 0)
assert(f(1,2,nil,1,nil) == nil and g(1,2,nil,1,nil) == 0 and h(1,2,nil,1,nil) == 0)
assert(1 and 2 < 3 == true and 2 < 3 and "\u{61}" < "\u{62}" == true)
x=2 < 3 and not 3
assert(f(0x2,0x1) == true and g(0x2,0x1) == 0x1 and h(0x2,0x1) == 0x1)
assert(f(0x1,0x2,"\u{61}") == "\u{61}" and g(0x1,0x2,"\u{61}") == 0x1 and h(0x1,0x2,"\u{61}") == 0x1)
assert(f(0x1,0x2,"\u{61}") ~= nil,"")
assert(f(0x1,0x2,"\u{61}") == "\u{61}" and g(0x1,0x2,"\u{61}") == 0x1 and h(0x1,0x2,"\u{61}") == 0x1)
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)
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)
assert(f(0x1,0x2,nil,0x1,nil) == nil and g(0x1,0x2,nil,0x1,nil) == 0x0 and h(0x1,0x2,nil,0x1,nil) == 0x0)
assert(0x1 and 0x2 < 0x3 == true and 0x2 < 0x3 and "\u{61}" < "\u{62}" == true)
x=0x2 < 0x3 and not 0x3
;
assert(x == false)
x=2 < 1 or (2 > 1 and "\u{61}")
x=0x2 < 0x1 or (0x2 > 0x1 and "\u{61}")
;
assert(x == "\u{61}")
do
local a
;
if nil then
a=1
a=0x1
;
else
a=2
a=0x2
;
end
;
assert(a == 2)
assert(a == 0x2)
end
local function F
(a)
assert(debug.getinfo(1,"\u{6e}").name == "\u{46}")
return a,2,3
assert(debug.getinfo(0x1,"\u{6e}").name == "\u{46}")
return a,0x2,0x3
end
a,b=F(1) ~= nil
a,b=F(0x1) ~= nil
;
assert(a == true and b == nil)
;
a,b=F(nil) == nil
;
assert(a == true and b == nil)
_ENV.GLOB1=math.random(0,1)
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}",10},{"\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}",0 == _ENV.GLOB1}}
_ENV.GLOB1=math.random(0x0,0x1)
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}}
local prog
if _ENV.GLOB1 == 0 then
basiccases[2][1]="\u{46}"
if _ENV.GLOB1 == 0x0 then
basiccases[0x2][0x1]="\u{46}"
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}"
else
basiccases[4][1]="\u{6b}\u{31}\u{30}"
basiccases[0x4][0x1]="\u{6b}\u{31}\u{30}"
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}"
end
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}")
@ -423,7 +423,7 @@ local cases <const> = {}
local function createcases
(n)
local res = {}
for i = 1, n - 1
for i = 0x1, n - 0x1
do
for _,v1 in ipairs(cases[i])
do
@ -431,33 +431,33 @@ for _,v2 in ipairs(cases[n - i])
do
for _,op in ipairs(binops)
do
local t = {"\u{28}" .. v1[1] .. op[1] .. v2[1] .. "\u{29}",op[2](v1[2],v2[2])}
res[# res + 1]=t
res[# res + 1]={"\u{6e}\u{6f}\u{74}" .. t[1],not t[2]}
local t = {"\u{28}" .. v1[0x1] .. op[0x1] .. v2[0x1] .. "\u{29}",op[0x2](v1[0x2],v2[0x2])}
res[# res + 0x1]=t
res[# res + 0x1]={"\u{6e}\u{6f}\u{74}" .. t[0x1],not t[0x2]}
end
end
end
end
return res
end
local level = _soft and 3 or 4
cases[1]=basiccases
for i = 2, level
local level = _soft and 0x3 or 0x4
cases[0x1]=basiccases
for i = 0x2, level
do
cases[i]=createcases(i)
end
print("\u{2b}")
local i = 0
for n = 1, level
local i = 0x0
for n = 0x1, level
do
for _,v in pairs(cases[n])
do
local s = v[1]
local s = v[0x1]
local p = load(string.format(prog,s,s),"")
IX=false
assert(p() == v[2] and IX == not not v[2])
i=i + 1
if i % 60000 == 0 then
assert(p() == v[0x2] and IX == not not v[0x2])
i=i + 0x1
if i % 0xea60 == 0x0 then
print("\u{2b}")
end
end

File diff suppressed because it is too large Load Diff

View File

@ -7,11 +7,11 @@ assert(not s and string.find(err,msg))
end
do
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}")
local count = 0
local count = 0x0
local function loop
(x,y,z)
count=count + 1
return 1 + loop(x,y,z)
count=count + 0x1
return 0x1 + loop(x,y,z)
end
tracegc.stop()
local res,msg = xpcall(loop,loop)
@ -27,25 +27,25 @@ local s = string.rep("\u{61}",size)
local p = string.rep("\u{2e}\u{3f}",size)
return string.match(s,p)
end
local m = f(80)
assert(# m == 80)
checkerror("\u{74}\u{6f}\u{6f}\u{20}\u{63}\u{6f}\u{6d}\u{70}\u{6c}\u{65}\u{78}",f,2000)
local m = f(0x50)
assert(# m == 0x50)
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)
end
do
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}")
local count = 0
local count = 0x0
local function foo
()
count=count + 1
count=count + 0x1
string.gsub("\u{61}","\u{2e}",foo)
end
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)
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)
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}")
local count = 0
local count = 0x0
local t = setmetatable({},{["\u{5f}\u{5f}\u{69}\u{6e}\u{64}\u{65}\u{78}"] = foo})
foo=function ()
count=count + 1
count=count + 0x1
string.gsub("\u{61}","\u{2e}",t)
end
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)
@ -53,15 +53,15 @@ 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}\
end
do
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}")
local count = 0
local lim = 1000
local count = 0x0
local lim = 0x3e8
local function stack
(n)
if n > 0 then
return stack(n - 1) + 1
if n > 0x0 then
return stack(n - 0x1) + 0x1
else
coroutine.wrap(function ()
count=count + 1
count=count + 0x1
stack(lim)
end)()
end
@ -73,15 +73,15 @@ assert(not st and msg == "\u{6f}\u{6b}")
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)
end
do
local count = 0
local count = 0x0
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}")
local coro = false
for i = 1, 1000
for i = 0x1, 0x3e8
do
local previous = coro
coro=coroutine.create(function ()
local cc <close> = setmetatable({},{["\u{5f}\u{5f}\u{63}\u{6c}\u{6f}\u{73}\u{65}"] = function ()
count=count + 1
count=count + 0x1
if previous then
assert(coroutine.close(previous))
end
@ -96,14 +96,14 @@ 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}\
end
do
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}")
local count = 0
local count = 0x0
local function body
()
coroutine.yield()
local f = coroutine.wrap(body)
f()
;
count=count + 1
count=count + 0x1
f()
end
local f = coroutine.wrap(body)
@ -113,11 +113,11 @@ 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}\
end
do
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}")
local count = 0
local count = 0x0
local function foo
()
count=count + 1
pcall(1)
count=count + 0x1
pcall(0x1)
coroutine.wrap(foo)()
end
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)
@ -125,15 +125,15 @@ 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}\
end
if T then
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}")
local N = 0
local LIM = - 1
local N = 0x0
local LIM = - 0x1
local stack1
local dummy
local function err
(msg)
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}"))
local _,stacknow = T.stacklevel()
assert(stacknow == stack1 + 200)
assert(stacknow == stack1 + 0xc8)
end
local function f
()
@ -144,7 +144,7 @@ local _,stacknow = T.stacklevel()
assert(stacknow == stack1)
return
end
N=N + 1
N=N + 0x1
f()
end
local topB,sizeB
@ -154,10 +154,10 @@ tracegc.stop()
xpcall(f,err)
tracegc.start()
topA,sizeA=T.stacklevel()
assert(topA == topB and sizeA < sizeB * 2)
assert(topA == topB and sizeA < sizeB * 0x2)
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))
LIM=N
N=0
N=0x0
tracegc.stop()
f()
tracegc.start()

File diff suppressed because one or more lines are too long

View File

@ -23,7 +23,7 @@ local m = doit(prog)
if debug then
print(m,msg)
end
assert(string.find(m,msg,1,true))
assert(string.find(m,msg,0x1,true))
end
local function checksyntax
(prog,extra,token,line)
@ -34,7 +34,7 @@ end
token=string.gsub(token,"\u{28}\u{25}\u{70}\u{29}","\u{25}\u{25}\u{25}\u{31}")
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)
assert(string.find(msg,pt))
assert(string.find(msg,msg,1,true))
assert(string.find(msg,msg,0x1,true))
end
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}")
assert(doit("\u{65}\u{72}\u{72}\u{6f}\u{72}\u{28}\u{29}") == nil)
@ -49,35 +49,35 @@ assert(doit("\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{6e}\u{69}\u{6c}\u{29}"
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}"))
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}"))
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}"))
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}",3)
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)
do
local function checksyntax
(prog,msg,line)
local st,err = load(prog)
assert(string.find(err,"\u{6c}\u{69}\u{6e}\u{65}\u{20}" .. line))
assert(string.find(err,msg,1,true))
assert(string.find(err,msg,0x1,true))
end
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}",1)
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}",2)
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)
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)
end
if not T then
(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}")
else
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}")
local a = {}
for i = 1, 10000
for i = 0x1, 0x2710
do
a[i]=true
end
collectgarbage()
T.totalmem(T.totalmem() + 10000)
T.totalmem(T.totalmem() + 0x2710)
local st,msg = pcall(function ()
for i = 1, 100000
for i = 0x1, 0x186a0
do
a[i]=tostring(i)
end
end)
T.totalmem(0)
T.totalmem(0x0)
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}")
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}")
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}"))
@ -168,36 +168,36 @@ if T then
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}"})
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))
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)
assert(a == 10 and b == tostring(x))
assert(a == 0xa and b == tostring(x))
setmetatable(x,{["\u{5f}\u{5f}\u{74}\u{6f}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}"] = function (o)
assert(o == x)
return "\u{41}\u{42}\u{43}"
end})
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)
assert(a == x and b == 10 and c == "\u{41}\u{42}\u{43}")
assert(a == x and b == 0xa and c == "\u{41}\u{42}\u{43}")
end
end
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}")
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}")
do
local f = function (a)
return a + 1
return a + 0x1
end
f=assert(load(string.dump(f,true)))
assert(f(3) == 4)
assert(f(0x3) == 0x4)
checkerr("\u{5e}\u{25}\u{3f}\u{3a}\u{25}\u{2d}\u{31}\u{3a}",f,{})
f=function ()
local a
;
a={}
;
return a + 2
return a + 0x2
end
f=assert(load(string.dump(f,true)))
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)
end
local t = {}
for i = 1, 1000
for i = 0x1, 0x3e8
do
t[i]="\u{61}\u{61}\u{61}\u{20}\u{3d}\u{20}\u{78}" .. i
end
@ -236,20 +236,20 @@ end
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}"))
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}")
f=coroutine.wrap(function ()
table.sort({1,2,3},coroutine.yield)
table.sort({0x1,0x2,0x3},coroutine.yield)
end)
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)
local idsize = 60 - 1
local idsize = 0x3c - 0x1
local function checksize
(source)
local _,msg = load("\u{78}",source)
msg=string.match(msg,"\u{5e}\u{28}\u{5b}\u{5e}\u{3a}\u{5d}\u{2a}\u{29}\u{3a}")
assert(msg:len() <= idsize)
end
for i = 60 - 10, 60 + 10
for i = 0x3c - 0xa, 0x3c + 0xa
do
checksize("\u{40}" .. string.rep("\u{78}",i))
checksize(string.rep("\u{78}",i - 10))
checksize(string.rep("\u{78}",i - 0xa))
checksize("\u{3d}" .. string.rep("\u{78}",i))
end
local function lineerror
@ -258,46 +258,46 @@ local err,msg = pcall(load(s))
local line = tonumber(string.match(msg,"\u{3a}\u{28}\u{25}\u{64}\u{2b}\u{29}\u{3a}"))
assert(line == l or (not line and not l))
end
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}",2)
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}",3)
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}",4)
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}",1)
lineerror("\u{61}\u{20}\u{3d}\u{20}\u{a}\u{61}\u{a}\u{2b}\u{a}\u{7b}\u{7d}",3)
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}",6)
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}",3)
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}",3)
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}",2)
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}",5)
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}",6)
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)
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)
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)
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)
lineerror("\u{61}\u{20}\u{3d}\u{20}\u{a}\u{61}\u{a}\u{2b}\u{a}\u{7b}\u{7d}",0x3)
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)
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)
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)
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)
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)
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)
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}"
XX=3
XX=0x3
;
lineerror((p),3)
XX=0
lineerror((p),0x3)
XX=0x0
;
lineerror((p),false)
XX=1
XX=0x1
;
lineerror((p),2)
XX=2
lineerror((p),0x2)
XX=0x2
;
lineerror((p),1)
lineerror((p),0x1)
_G.XX,_G.g,_G.f=nil
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}",3)
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}",5)
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}",3)
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)
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)
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)
do
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}",300))
lineerror(s,301)
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))
lineerror(s,0x12d)
end
if not _soft then
collectgarbage()
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}")
local C = 0
local l = debug.getinfo(1,"\u{6c}").currentline + 1
local C = 0x0
local l = debug.getinfo(0x1,"\u{6c}").currentline + 0x1
local function auxy
()
C=C + 1
C=C + 0x1
;
auxy()
end
@ -309,7 +309,7 @@ end
local function checkstackmessage
(m)
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}")
C=0
C=0x0
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}"))
end
assert(checkstackmessage(doit("\u{59}\u{59}\u{28}\u{29}")))
@ -319,12 +319,12 @@ _G.YY=nil
local l1
local function g
(x)
l1=debug.getinfo(x,"\u{6c}").currentline + 2
l1=debug.getinfo(x,"\u{6c}").currentline + 0x2
collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
auxy()
collectgarbage("\u{72}\u{65}\u{73}\u{74}\u{61}\u{72}\u{74}")
end
local _,stackmsg = xpcall(g,debug.traceback,1)
local _,stackmsg = xpcall(g,debug.traceback,0x1)
print("\u{2b}")
local stack = {}
for line in string.gmatch(stackmsg,"\u{5b}\u{5e}\u{a}\u{5d}\u{2a}")
@ -334,43 +334,43 @@ if curr then
table.insert(stack,tonumber(curr))
end
end
local i = 1
local i = 0x1
while stack[i] ~= l1 do
assert(stack[i] == l)
i=i + 1
i=i + 0x1
end
assert(i > 15)
assert(i > 0xf)
local res,msg = xpcall(error,error)
assert(not res and type(msg) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}")
print("\u{2b}")
local function f
(x)
if x == 0 then
if x == 0x0 then
error("\u{61}\u{a}")
else
local aux = function ()
return f(x - 1)
return f(x - 0x1)
end
local a,b = xpcall(aux,aux)
return a,b
end
end
f(3)
f(0x3)
local function loop
(x,y,z)
return 1 + loop(x,y,z)
return 0x1 + loop(x,y,z)
end
local res,msg = xpcall(loop,function (m)
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}"))
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)
assert(math.sin(0) == 0)
return 15
assert(math.sin(0x0) == 0x0)
return 0xf
end)
assert(msg == 15)
assert(msg == 0xf)
local f = function ()
for i = 999900, 1000000, 1
for i = 0xf41dc, 0xf4240, 0x1
do
table.unpack({},1,i)
table.unpack({},0x1,i)
end
end
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)
@ -399,7 +399,7 @@ res,msg=pcall(function ()
assert(false)
end)
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}")
assert(tonumber(line) == debug.getinfo(1,"\u{6c}").currentline - 2)
assert(tonumber(line) == debug.getinfo(0x1,"\u{6c}").currentline - 0x2)
res,msg=pcall(assert,false,t)
assert(not res and msg == t)
res,msg=pcall(assert,nil,nil)
@ -408,81 +408,81 @@ res,msg=pcall(assert)
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}"))
end
local a,b,c = xpcall(string.find,error,"\u{61}\u{6c}\u{6f}","\u{61}\u{6c}")
assert(a and b == 1 and c == 2)
assert(a and b == 0x1 and c == 0x2)
a,b,c=xpcall(string.find,function (x)
return {}
end,true,"\u{61}\u{6c}")
assert(not a and type(b) == "\u{74}\u{61}\u{62}\u{6c}\u{65}" and c == nil)
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}")
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}",1)
checksyntax("\u{31}\u{2e}\u{30}\u{30}\u{30}","","\u{31}\u{2e}\u{30}\u{30}\u{30}",1)
checksyntax("\u{5b}\u{5b}\u{61}\u{5d}\u{5d}","","\u{5b}\u{5b}\u{61}\u{5d}\u{5d}",1)
checksyntax("\u{27}\u{61}\u{61}\u{27}","","\u{27}\u{61}\u{61}\u{27}",1)
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}",1)
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}",1)
checksyntax("\u{61}\u{1}\u{61}\u{20}\u{3d}\u{20}\u{31}","","\u{3c}\u{5c}\u{31}\u{3e}",1)
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}",1)
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)
checksyntax("\u{31}\u{2e}\u{30}\u{30}\u{30}","","\u{31}\u{2e}\u{30}\u{30}\u{30}",0x1)
checksyntax("\u{5b}\u{5b}\u{61}\u{5d}\u{5d}","","\u{5b}\u{5b}\u{61}\u{5d}\u{5d}",0x1)
checksyntax("\u{27}\u{61}\u{61}\u{27}","","\u{27}\u{61}\u{61}\u{27}",0x1)
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)
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)
checksyntax("\u{61}\u{1}\u{61}\u{20}\u{3d}\u{20}\u{31}","","\u{3c}\u{5c}\u{31}\u{3e}",0x1)
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)
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}")
assert(_G.aaa == 3 and not _G.I)
assert(_G.aaa == 0x3 and not _G.I)
_G.I,_G.aaa=nil
print("\u{2b}")
local lim = 1000
local lim = 0x3e8
if _soft then
lim=100
lim=0x64
end
for i = 1, lim
for i = 0x1, lim
do
doit("\u{61}\u{20}\u{3d}\u{20}")
doit("\u{61}\u{20}\u{3d}\u{20}\u{34}\u{2b}\u{6e}\u{69}\u{6c}")
end
local function testrep
(init,rep,close,repc,finalresult)
local s = init .. string.rep(rep,100) .. close .. string.rep(repc,100)
local s = init .. string.rep(rep,0x64) .. close .. string.rep(repc,0x64)
local res,msg = load(s)
assert(res)
if (finalresult) then
assert(res() == finalresult)
end
s=init .. string.rep(rep,500)
s=init .. string.rep(rep,0x1f4)
local res,msg = load(s)
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}")))
end
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}")
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}")
testrep("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}","\u{28}","\u{32}","\u{29}",2)
testrep("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}","\u{28}","\u{32}","\u{29}",0x2)
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)
testrep("","\u{64}\u{6f}\u{20}","","\u{20}\u{65}\u{6e}\u{64}")
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}")
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}")
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}")
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}")
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}","",1)
checkmessage("\u{61}\u{20}\u{3d}\u{20}\u{66}\u{28}\u{78}" .. string.rep("\u{2c}\u{78}",260) .. "\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}")
local lim = 127
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)
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}")
local lim = 0x7f
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}"
for j = 1, lim
for j = 0x1, lim
do
s=s .. "\u{61}" .. j .. "\u{2c}\u{20}"
end
s=s .. "\u{62}\u{2c}\u{63}\u{a}"
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}"
for j = 1, lim
for j = 0x1, lim
do
s=s .. "\u{62}" .. j .. "\u{2c}\u{20}"
end
s=s .. "\u{62}\u{a}"
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}"
local c = 1 + 2
for j = 1, lim
local c = 0x1 + 0x2
for j = 0x1, lim
do
s=s .. "\u{2b}\u{61}" .. j .. "\u{2b}\u{62}" .. j
c=c + 2
c=c + 0x2
end
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}"
local a,b = load(s)
assert(c > 255 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}"))
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}"))
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}"
for j = 1, 300
for j = 0x1, 0x12c
do
s=s .. "\u{61}" .. j .. "\u{2c}\u{20}"
end

View File

@ -1,18 +1,18 @@
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}")
local debug = require("\u{64}\u{65}\u{62}\u{75}\u{67}")
X=20
X=0x14
;
B=30
B=0x1e
_ENV=setmetatable({},{["\u{5f}\u{5f}\u{69}\u{6e}\u{64}\u{65}\u{78}"] = _G})
collectgarbage()
X=X + 10
assert(X == 30 and _G.X == 20)
X=X + 0xa
assert(X == 0x1e and _G.X == 0x14)
B=false
assert(B == false)
_ENV["\u{42}"]=undef
assert(B == 30)
assert(B == 0x1e)
assert(getmetatable({}) == nil)
assert(getmetatable(4) == nil)
assert(getmetatable(0x4) == nil)
assert(getmetatable(nil) == nil)
a={["\u{6e}\u{61}\u{6d}\u{65}"] = "\u{4e}\u{41}\u{4d}\u{45}"}
;
@ -24,7 +24,7 @@ assert(tostring(a) == "\u{4e}\u{41}\u{4d}\u{45}")
assert(pcall(setmetatable,a,{}) == false)
a.name="\u{67}\u{6f}\u{72}\u{6f}\u{72}\u{6f}\u{62}\u{61}"
assert(tostring(a) == "\u{67}\u{6f}\u{72}\u{6f}\u{72}\u{6f}\u{62}\u{61}")
local a,t = {10,20,30,["\u{78}"] = "\u{31}\u{30}",["\u{79}"] = "\u{32}\u{30}"},{}
local a,t = {0xa,0x14,0x1e,["\u{78}"] = "\u{31}\u{30}",["\u{79}"] = "\u{32}\u{30}"},{}
assert(setmetatable(a,t) == a)
assert(getmetatable(a) == t)
assert(setmetatable(a,nil) == a)
@ -33,71 +33,71 @@ assert(setmetatable(a,t) == a)
function f(t,i,e)
assert(not e)
local p = rawget(t,"\u{70}\u{61}\u{72}\u{65}\u{6e}\u{74}")
return (p and p[i] + 3),"\u{64}\u{75}\u{6d}\u{6d}\u{79}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}"
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}"
end
t.__index=f
a.parent={["\u{7a}"] = 25,["\u{78}"] = 12,[4] = 24}
assert(a[1] == 10 and a.z == 28 and a[4] == 27 and a.x == "\u{31}\u{30}")
a.parent={["\u{7a}"] = 0x19,["\u{78}"] = 0xc,[0x4] = 0x18}
assert(a[0x1] == 0xa and a.z == 0x1c and a[0x4] == 0x1b and a.x == "\u{31}\u{30}")
collectgarbage()
a=setmetatable({},t)
function f(t,i,v)
rawset(t,i,v - 3)
rawset(t,i,v - 0x3)
end
setmetatable(t,t)
t.__newindex=f
a[1]=30
a[0x1]=0x1e
;
a.x="\u{31}\u{30}\u{31}"
;
a[5]=200
assert(a[1] == 27 and a.x == 98 and a[5] == 197)
a[0x5]=0xc8
assert(a[0x1] == 0x1b and a.x == 0x62 and a[0x5] == 0xc5)
do
local mt = {}
mt.__newindex=mt
local t = setmetatable({},mt)
t[1]=10
assert(mt[1] == 10)
t[0x1]=0xa
assert(mt[0x1] == 0xa)
end
local c = {}
a=setmetatable({},t)
t.__newindex=c
t.__index=c
a[1]=10
a[0x1]=0xa
;
a[2]=20
a[0x2]=0x14
;
a[3]=90
a[0x3]=0x5a
;
for i = 4, 20
for i = 0x4, 0x14
do
a[i]=i * 10
a[i]=i * 0xa
end
assert(a[1] == 10 and a[2] == 20 and a[3] == 90)
for i = 4, 20
assert(a[0x1] == 0xa and a[0x2] == 0x14 and a[0x3] == 0x5a)
for i = 0x4, 0x14
do
assert(a[i] == i * 10)
assert(a[i] == i * 0xa)
end
assert(next(a) == nil)
do
local a
;
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)
return a[n - 3] + 4,"\u{6c}\u{69}\u{78}\u{6f}"
return a[n - 0x3] + 0x4,"\u{6c}\u{69}\u{78}\u{6f}"
end})})})
a[0]=20
for i = 0, 10
a[0x0]=0x14
for i = 0x0, 0xa
do
assert(a[i * 3] == 20 + i * 4)
assert(a[i * 0x3] == 0x14 + i * 0x4)
end
end
do
local foi
local a = {}
for i = 1, 10
for i = 0x1, 0xa
do
a[i]=0
a[i]=0x0
;
a["\u{61}" .. i]=0
a["\u{61}" .. i]=0x0
;
end
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)
@ -107,33 +107,33 @@ rawset(t,k,v)
end})
foi=false
;
a[1]=0
a[0x1]=0x0
;
assert(not foi)
foi=false
;
a["\u{61}\u{31}"]=0
a["\u{61}\u{31}"]=0x0
;
assert(not foi)
foi=false
;
a["\u{61}\u{31}\u{31}"]=0
a["\u{61}\u{31}\u{31}"]=0x0
;
assert(foi)
foi=false
;
a[11]=0
a[0xb]=0x0
;
assert(foi)
foi=false
;
a[1]=undef
a[0x1]=undef
;
assert(not foi)
a[1]=undef
a[0x1]=undef
foi=false
;
a[1]=nil
a[0x1]=nil
;
assert(foi)
end
@ -143,16 +143,16 @@ return t,{...}
end
t.__call=f
do
local x,y = a(table.unpack({"\u{61}",1}))
assert(x == a and y[1] == "\u{61}" and y[2] == 1 and y[3] == undef)
local x,y = a(table.unpack({"\u{61}",0x1}))
assert(x == a and y[0x1] == "\u{61}" and y[0x2] == 0x1 and y[0x3] == undef)
x,y=a()
assert(x == a and y[1] == undef)
assert(x == a and y[0x1] == undef)
end
local b = setmetatable({},t)
setmetatable(b,t)
function f(op)
return function (...)
cap={[0] = op,...}
cap={[0x0] = op,...}
;
return (...)
end
@ -176,54 +176,54 @@ t.__lt=f("\u{6c}\u{74}")
t.__le=f("\u{6c}\u{65}")
local function checkcap
(t)
assert(# cap + 1 == # t)
for i = 1, # t
assert(# cap + 0x1 == # t)
for i = 0x1, # t
do
assert(cap[i - 1] == t[i])
assert(math.type(cap[i - 1]) == math.type(t[i]))
assert(cap[i - 0x1] == t[i])
assert(math.type(cap[i - 0x1]) == math.type(t[i]))
end
end
assert(b + 5 == b)
assert(b + 0x5 == b)
;
checkcap({"\u{61}\u{64}\u{64}",b,5})
checkcap({"\u{61}\u{64}\u{64}",b,0x5})
assert(5.2 + b == 5.2)
;
checkcap({"\u{61}\u{64}\u{64}",5.2,b})
assert(b + "\u{35}" == b)
;
checkcap({"\u{61}\u{64}\u{64}",b,"\u{35}"})
assert(5 + b == 5)
assert(0x5 + b == 0x5)
;
checkcap({"\u{61}\u{64}\u{64}",5,b})
checkcap({"\u{61}\u{64}\u{64}",0x5,b})
assert("\u{35}" + b == "\u{35}")
;
checkcap({"\u{61}\u{64}\u{64}","\u{35}",b})
b=b - 3
b=b - 0x3
;
assert(getmetatable(b) == t)
;
checkcap({"\u{73}\u{75}\u{62}",b,3})
assert(5 - a == 5)
checkcap({"\u{73}\u{75}\u{62}",b,0x3})
assert(0x5 - a == 0x5)
;
checkcap({"\u{73}\u{75}\u{62}",5,a})
checkcap({"\u{73}\u{75}\u{62}",0x5,a})
assert("\u{35}" - a == "\u{35}")
;
checkcap({"\u{73}\u{75}\u{62}","\u{35}",a})
assert(a * a == a)
;
checkcap({"\u{6d}\u{75}\u{6c}",a,a})
assert(a / 0 == a)
assert(a / 0x0 == a)
;
checkcap({"\u{64}\u{69}\u{76}",a,0})
checkcap({"\u{64}\u{69}\u{76}",a,0x0})
assert(a / 0.0 == a)
;
checkcap({"\u{64}\u{69}\u{76}",a,0.0})
assert(a % 2 == a)
assert(a % 0x2 == a)
;
checkcap({"\u{6d}\u{6f}\u{64}",a,2})
assert(a // (1 / 0) == a)
checkcap({"\u{6d}\u{6f}\u{64}",a,0x2})
assert(a // (0x1 / 0x0) == a)
;
checkcap({"\u{69}\u{64}\u{69}\u{76}",a,1 / 0})
checkcap({"\u{69}\u{64}\u{69}\u{76}",a,0x1 / 0x0})
;
(function ()
assert(a & "\u{68}\u{69}" == a)
@ -232,16 +232,16 @@ end)()
checkcap({"\u{62}\u{61}\u{6e}\u{64}",a,"\u{68}\u{69}"})
;
(function ()
assert(10 & a == 10)
assert(0xa & a == 0xa)
end)()
;
checkcap({"\u{62}\u{61}\u{6e}\u{64}",10,a})
checkcap({"\u{62}\u{61}\u{6e}\u{64}",0xa,a})
;
(function ()
assert(a | 10 == a)
assert(a | 0xa == a)
end)()
;
checkcap({"\u{62}\u{6f}\u{72}",a,10})
checkcap({"\u{62}\u{6f}\u{72}",a,0xa})
assert(a | "\u{68}\u{69}" == a)
;
checkcap({"\u{62}\u{6f}\u{72}",a,"\u{68}\u{69}"})
@ -250,10 +250,10 @@ assert("\u{68}\u{69}" ~ a == "\u{68}\u{69}")
checkcap({"\u{62}\u{78}\u{6f}\u{72}","\u{68}\u{69}",a})
;
(function ()
assert(10 ~ a == 10)
assert(0xa ~ a == 0xa)
end)()
;
checkcap({"\u{62}\u{78}\u{6f}\u{72}",10,a})
checkcap({"\u{62}\u{78}\u{6f}\u{72}",0xa,a})
assert(- a == a)
;
checkcap({"\u{75}\u{6e}\u{6d}",a,a})
@ -263,9 +263,9 @@ checkcap({"\u{70}\u{6f}\u{77}",a,4.0})
assert(a ^ "\u{34}" == a)
;
checkcap({"\u{70}\u{6f}\u{77}",a,"\u{34}"})
assert(4 ^ a == 4)
assert(0x4 ^ a == 0x4)
;
checkcap({"\u{70}\u{6f}\u{77}",4,a})
checkcap({"\u{70}\u{6f}\u{77}",0x4,a})
assert("\u{34}" ^ a == "\u{34}")
;
checkcap({"\u{70}\u{6f}\u{77}","\u{34}",a})
@ -275,33 +275,33 @@ checkcap({"\u{6c}\u{65}\u{6e}",a,a})
assert(~ a == a)
;
checkcap({"\u{62}\u{6e}\u{6f}\u{74}",a,a})
assert(a << 3 == a)
assert(a << 0x3 == a)
;
checkcap({"\u{73}\u{68}\u{6c}",a,3})
checkcap({"\u{73}\u{68}\u{6c}",a,0x3})
assert(1.5 >> a == 1.5)
;
checkcap({"\u{73}\u{68}\u{72}",1.5,a})
assert(5.0 > a)
;
checkcap({"\u{6c}\u{74}",a,5.0})
assert(a >= 10)
assert(a >= 0xa)
;
checkcap({"\u{6c}\u{65}",10,a})
checkcap({"\u{6c}\u{65}",0xa,a})
assert(a <= - 10.0)
;
checkcap({"\u{6c}\u{65}",a,- 10.0})
assert(a < - 10)
assert(a < - 0xa)
;
checkcap({"\u{6c}\u{74}",a,- 10})
t=setmetatable({1,2,3},{["\u{5f}\u{5f}\u{6c}\u{65}\u{6e}"] = function ()
return 10
checkcap({"\u{6c}\u{74}",a,- 0xa})
t=setmetatable({0x1,0x2,0x3},{["\u{5f}\u{5f}\u{6c}\u{65}\u{6e}"] = function ()
return 0xa
end})
assert(# t == 10 and rawlen(t) == 3)
assert(rawlen("\u{61}\u{62}\u{63}") == 3)
assert(# t == 0xa and rawlen(t) == 0x3)
assert(rawlen("\u{61}\u{62}\u{63}") == 0x3)
assert(not pcall(rawlen,io.stdin))
assert(not pcall(rawlen,34))
assert(not pcall(rawlen,0x22))
assert(not pcall(rawlen))
assert(rawlen(string.rep("\u{61}",1000)) == 1000)
assert(rawlen(string.rep("\u{61}",0x3e8)) == 0x3e8)
t={}
t.__lt=function (a,b,c)
collectgarbage()
@ -339,30 +339,30 @@ return setmetatable({["\u{78}"] = x},t)
end
local function test
(a,b,c)
assert(not (Op(1) < Op(1)) and (Op(1) < Op(2)) and not (Op(2) < Op(1)))
assert(not (1 < Op(1)) and (Op(1) < 2) and not (2 < Op(1)))
assert(not (Op(0x1) < Op(0x1)) and (Op(0x1) < Op(0x2)) and not (Op(0x2) < Op(0x1)))
assert(not (0x1 < Op(0x1)) and (Op(0x1) < 0x2) and not (0x2 < Op(0x1)))
assert(not (Op("\u{61}") < Op("\u{61}")) and (Op("\u{61}") < Op("\u{62}")) and not (Op("\u{62}") < Op("\u{61}")))
assert(not ("\u{61}" < Op("\u{61}")) and (Op("\u{61}") < "\u{62}") and not (Op("\u{62}") < Op("\u{61}")))
assert((Op(1) <= Op(1)) and (Op(1) <= Op(2)) and not (Op(2) <= Op(1)))
assert((Op(0x1) <= Op(0x1)) and (Op(0x1) <= Op(0x2)) and not (Op(0x2) <= Op(0x1)))
assert((Op("\u{61}") <= Op("\u{61}")) and (Op("\u{61}") <= Op("\u{62}")) and not (Op("\u{62}") <= Op("\u{61}")))
assert(not (Op(1) > Op(1)) and not (Op(1) > Op(2)) and (Op(2) > Op(1)))
assert(not (Op(0x1) > Op(0x1)) and not (Op(0x1) > Op(0x2)) and (Op(0x2) > Op(0x1)))
assert(not (Op("\u{61}") > Op("\u{61}")) and not (Op("\u{61}") > Op("\u{62}")) and (Op("\u{62}") > Op("\u{61}")))
assert((Op(1) >= Op(1)) and not (Op(1) >= Op(2)) and (Op(2) >= Op(1)))
assert((1 >= Op(1)) and not (1 >= Op(2)) and (Op(2) >= 1))
assert((Op(0x1) >= Op(0x1)) and not (Op(0x1) >= Op(0x2)) and (Op(0x2) >= Op(0x1)))
assert((0x1 >= Op(0x1)) and not (0x1 >= Op(0x2)) and (Op(0x2) >= 0x1))
assert((Op("\u{61}") >= Op("\u{61}")) and not (Op("\u{61}") >= Op("\u{62}")) and (Op("\u{62}") >= Op("\u{61}")))
assert(("\u{61}" >= Op("\u{61}")) and not (Op("\u{61}") >= "\u{62}") and (Op("\u{62}") >= Op("\u{61}")))
assert(Op(1) == Op(1) and Op(1) ~= Op(2))
assert(Op(0x1) == Op(0x1) and Op(0x1) ~= Op(0x2))
assert(Op("\u{61}") == Op("\u{61}") and Op("\u{61}") ~= Op("\u{62}"))
assert(a == a and a ~= b)
assert(Op(3) == c)
assert(Op(0x3) == c)
end
test(Op(1),Op(2),Op(3))
test(Op(0x1),Op(0x2),Op(0x3))
local function rawSet
(x)
local y = {}
for _,k in pairs(x)
do
y[k]=1
y[k]=0x1
end
return y
end
@ -389,13 +389,13 @@ end
end
return true
end
assert(Set({1,2,3}) < Set({1,2,3,4}))
assert(not (Set({1,2,3,4}) < Set({1,2,3,4})))
assert((Set({1,2,3,4}) <= Set({1,2,3,4})))
assert((Set({1,2,3,4}) >= Set({1,2,3,4})))
assert(not (Set({1,3}) <= Set({3,5})))
assert(not (Set({1,3}) <= Set({3,5})))
assert(not (Set({1,3}) >= Set({3,5})))
assert(Set({0x1,0x2,0x3}) < Set({0x1,0x2,0x3,0x4}))
assert(not (Set({0x1,0x2,0x3,0x4}) < Set({0x1,0x2,0x3,0x4})))
assert((Set({0x1,0x2,0x3,0x4}) <= Set({0x1,0x2,0x3,0x4})))
assert((Set({0x1,0x2,0x3,0x4}) >= Set({0x1,0x2,0x3,0x4})))
assert(not (Set({0x1,0x3}) <= Set({0x3,0x5})))
assert(not (Set({0x1,0x3}) <= Set({0x3,0x5})))
assert(not (Set({0x1,0x3}) >= Set({0x3,0x5})))
t.__eq=function (a,b)
for k in pairs(a)
do
@ -406,38 +406,38 @@ b[k]=undef
end
return next(b) == nil
end
local s = Set({1,3,5})
assert(s == Set({3,5,1}))
assert(not rawequal(s,Set({3,5,1})))
local s = Set({0x1,0x3,0x5})
assert(s == Set({0x3,0x5,0x1}))
assert(not rawequal(s,Set({0x3,0x5,0x1})))
assert(rawequal(s,s))
assert(Set({1,3,5,1}) == rawSet({3,5,1}))
assert(rawSet({1,3,5,1}) == Set({3,5,1}))
assert(Set({1,3,5}) ~= Set({3,5,1,6}))
t[Set({1,3,5})]=1
assert(t[Set({1,3,5})] == undef)
assert(Set({0x1,0x3,0x5,0x1}) == rawSet({0x3,0x5,0x1}))
assert(rawSet({0x1,0x3,0x5,0x1}) == Set({0x3,0x5,0x1}))
assert(Set({0x1,0x3,0x5}) ~= Set({0x3,0x5,0x1,0x6}))
t[Set({0x1,0x3,0x5})]=0x1
assert(t[Set({0x1,0x3,0x5})] == undef)
do
local mt = {["\u{5f}\u{5f}\u{65}\u{71}"] = true}
local a = setmetatable({10},mt)
local b = setmetatable({10},mt)
local a = setmetatable({0xa},mt)
local b = setmetatable({0xa},mt)
mt.__eq=nil
assert(a ~= b)
mt.__eq=function (x,y)
return x[1] == y[1]
return x[0x1] == y[0x1]
end
assert(a == b)
end
if not T then
(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}")
else
local u1 = T.newuserdata(0,1)
local u2 = T.newuserdata(0,1)
local u3 = T.newuserdata(0,1)
local u1 = T.newuserdata(0x0,0x1)
local u2 = T.newuserdata(0x0,0x1)
local u3 = T.newuserdata(0x0,0x1)
assert(u1 ~= u2 and u1 ~= u3)
debug.setuservalue(u1,1)
debug.setuservalue(u1,0x1)
;
debug.setuservalue(u2,2)
debug.setuservalue(u2,0x2)
;
debug.setuservalue(u3,1)
debug.setuservalue(u3,0x1)
;
debug.setmetatable(u1,{["\u{5f}\u{5f}\u{65}\u{71}"] = function (a,b)
return debug.getuservalue(a) == debug.getuservalue(b)
@ -451,11 +451,11 @@ assert(u2 ~= {})
assert(rawequal(u1,u1) and not rawequal(u1,u3))
local mirror = {}
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})
for i = 1, 10
for i = 0x1, 0xa
do
u3[i]=i
end
for i = 1, 10
for i = 0x1, 0xa
do
assert(u3[i] == i)
end
@ -482,12 +482,12 @@ d={["\u{76}\u{61}\u{6c}"] = "\u{64}"}
setmetatable(d,t)
A=true
assert(c .. d == "\u{63}\u{64}")
assert(0 .. "\u{61}" .. "\u{62}" .. c .. d .. "\u{65}" .. "\u{66}" .. (5 + 3) .. "\u{67}" == "\u{30}\u{61}\u{62}\u{63}\u{64}\u{65}\u{66}\u{38}\u{67}")
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}")
A=false
assert((c .. d .. c .. d).val == "\u{63}\u{64}\u{63}\u{64}")
x=c .. d
assert(getmetatable(x) == t and x.val == "\u{63}\u{64}")
x=0 .. "\u{61}" .. "\u{62}" .. c .. d .. "\u{65}" .. "\u{66}" .. "\u{67}"
x=0x0 .. "\u{61}" .. "\u{62}" .. c .. d .. "\u{65}" .. "\u{66}" .. "\u{67}"
assert(x.val == "\u{30}\u{61}\u{62}\u{63}\u{64}\u{65}\u{66}\u{67}")
c={}
local x
@ -495,8 +495,8 @@ setmetatable(c,{["\u{5f}\u{5f}\u{63}\u{6f}\u{6e}\u{63}\u{61}\u{74}"] = function
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)
return c
end})
assert(c .. 5 == c and 5 .. c == c)
assert(4 .. c .. 5 == c and 4 .. 5 .. 6 .. 7 .. c == c)
assert(c .. 0x5 == c and 0x5 .. c == c)
assert(0x4 .. c .. 0x5 == c and 0x4 .. 0x5 .. 0x6 .. 0x7 .. c == c)
local t1,t2,c,d
t1={}
;
@ -522,7 +522,7 @@ setmetatable(d,t2)
assert(c == d and c < d and not (d <= c))
local i
local tt = {["\u{5f}\u{5f}\u{63}\u{61}\u{6c}\u{6c}"] = function (t, ...)
i=i + 1
i=i + 0x1
if t.f then
return t.f(...)
else
@ -532,10 +532,10 @@ end}
local a = setmetatable({},tt)
local b = setmetatable({["\u{66}"] = a},tt)
local c = setmetatable({["\u{66}"] = b},tt)
i=0
x=c(3,4,5)
assert(i == 3 and x[1] == 3 and x[3] == 5)
assert(_G.X == 20)
i=0x0
x=c(0x3,0x4,0x5)
assert(i == 0x3 and x[0x1] == 0x3 and x[0x3] == 0x5)
assert(_G.X == 0x14)
_G.X,_G.B=nil
print("\u{2b}")
local _g = _G
@ -543,21 +543,21 @@ _ENV=setmetatable({},{["\u{5f}\u{5f}\u{69}\u{6e}\u{64}\u{65}\u{78}"] = function
return _g[k]
end})
a={}
rawset(a,"\u{78}",1,2,3)
assert(a.x == 1 and rawget(a,"\u{78}",3) == 1)
rawset(a,"\u{78}",0x1,0x2,0x3)
assert(a.x == 0x1 and rawget(a,"\u{78}",0x3) == 0x1)
print("\u{2b}")
mt={["\u{5f}\u{5f}\u{69}\u{6e}\u{64}\u{65}\u{78}"] = function (a,b)
return a + b
end,["\u{5f}\u{5f}\u{6c}\u{65}\u{6e}"] = function (x)
return math.floor(x)
end}
debug.setmetatable(10,mt)
assert(getmetatable(- 2) == mt)
assert((10)[3] == 13)
assert((10)["\u{33}"] == 13)
assert(# 3.45 == 3)
debug.setmetatable(23,nil)
assert(getmetatable(- 2) == nil)
debug.setmetatable(0xa,mt)
assert(getmetatable(- 0x2) == mt)
assert((0xa)[0x3] == 0xd)
assert((0xa)["\u{33}"] == 0xd)
assert(# 3.45 == 0x3)
debug.setmetatable(0x17,nil)
assert(getmetatable(- 0x2) == nil)
debug.setmetatable(true,mt)
assert(getmetatable(false) == mt)
mt.__index=function (a,b)
@ -570,11 +570,11 @@ assert(getmetatable(true) == nil)
debug.setmetatable(nil,mt)
assert(getmetatable(nil) == mt)
mt.__add=function (a,b)
return (a or 1) + (b or 2)
return (a or 0x1) + (b or 0x2)
end
assert(10 + nil == 12)
assert(nil + 23 == 24)
assert(nil + nil == 3)
assert(0xa + nil == 0xc)
assert(nil + 0x17 == 0x18)
assert(nil + nil == 0x3)
debug.setmetatable(nil,nil)
assert(getmetatable(nil) == nil)
debug.setmetatable(nil,{})
@ -587,10 +587,10 @@ a.__index=a
a.__newindex=a
assert(not pcall(function (a,b)
return a[b]
end,a,10))
end,a,0xa))
assert(not pcall(function (a,b,c)
a[b]=c
end,a,10,true))
end,a,0xa,true))
T,K,V=nil
grandparent={}
grandparent.__newindex=function (t,k,v)
@ -604,7 +604,7 @@ parent={}
parent.__newindex=parent
setmetatable(parent,grandparent)
child=setmetatable({},parent)
child.foo=10
assert(T == parent and K == "\u{66}\u{6f}\u{6f}" and V == 10)
child.foo=0xa
assert(T == parent and K == "\u{66}\u{6f}\u{6f}" and V == 0xa)
print("\u{4f}\u{4b}")
return 12
return 0xc

View File

@ -7,7 +7,7 @@ assert(io.output(io.stdout) == io.stdout)
local function testerr
(msg,f, ...)
local stat,err = pcall(f,...)
return (not stat and string.find(err,msg,1,true))
return (not stat and string.find(err,msg,0x1,true))
end
local function checkerr
(msg,f, ...)
@ -17,7 +17,7 @@ assert(not io.close(io.stdin) and not io.stdout:close() and not io.stderr:close(
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)
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}")
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}")
assert(not io.type(8))
assert(not io.type(0x8))
local a = {}
;
setmetatable(a,{})
@ -56,15 +56,15 @@ assert(not io.open(file))
io.output(file)
assert(io.output() ~= io.stdout)
if not _port then
local status,msg,code = io.stdin:seek("\u{73}\u{65}\u{74}",1000)
local status,msg,code = io.stdin:seek("\u{73}\u{65}\u{74}",0x3e8)
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}")
end
assert(io.output():seek() == 0)
assert(io.output():seek() == 0x0)
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}"))
assert(io.output():seek("\u{63}\u{75}\u{72}",- 3) == string.len("\u{61}\u{6c}\u{6f}\u{20}\u{61}\u{6c}\u{6f}") - 3)
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)
assert(io.write("\u{6a}\u{6f}\u{61}\u{6f}"))
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}"))
assert(io.output():seek("\u{73}\u{65}\u{74}") == 0)
assert(io.output():seek("\u{73}\u{65}\u{74}") == 0x0)
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}"))
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}"))
io.output(io.stdout)
@ -72,9 +72,9 @@ collectgarbage()
assert(io.input() == io.stdin and rawequal(io.output(),io.stdout))
print("\u{2b}")
collectgarbage()
for i = 1, 120
for i = 0x1, 0x78
do
for i = 1, 5
for i = 0x1, 0x5
do
io.input(file)
assert(io.open(file,"\u{72}"))
@ -87,7 +87,7 @@ io.close()
assert(os.rename(file,otherfile))
assert(not os.rename(file,otherfile))
io.output(io.open(otherfile,"\u{61}\u{62}"))
assert(io.write("\u{a}\u{a}\u{9}\u{9}\u{20}\u{20}",3450,"\u{a}"))
assert(io.write("\u{a}\u{a}\u{9}\u{9}\u{20}\u{20}",0xd7a,"\u{a}"))
;
io.close()
do
@ -104,7 +104,7 @@ local f <close> = assert(io.open(file,"\u{77}"))
f:write(maxint,"\u{a}")
f:write(string.format("\u{30}\u{58}\u{25}\u{78}\u{a}",maxint))
f:write("\u{30}\u{78}\u{41}\u{42}\u{43}\u{70}\u{2d}\u{33}","\u{a}")
f:write(0,"\u{a}")
f:write(0x0,"\u{a}")
f:write(- maxint,"\u{a}")
f:write(string.format("\u{30}\u{78}\u{25}\u{58}\u{a}",- maxint))
f:write("\u{2d}\u{30}\u{78}\u{41}\u{42}\u{43}\u{70}\u{2d}\u{33}","\u{a}")
@ -113,7 +113,7 @@ local f <close> = assert(io.open(file,"\u{72}"))
assert(f:read("\u{6e}") == maxint)
assert(f:read("\u{6e}") == maxint)
assert(f:read("\u{6e}") == 343.5)
assert(f:read("\u{6e}") == 0)
assert(f:read("\u{6e}") == 0x0)
assert(f:read("\u{2a}\u{6e}") == - maxint)
assert(f:read("\u{6e}") == - maxint)
assert(f:read("\u{2a}\u{6e}") == - 343.5)
@ -126,11 +126,11 @@ local l1,l2,l3,l4,n1,n2,c,dummy
assert(f:close())
local f <close> = assert(io.open(file,"\u{72}"))
l1,l2,n1,n2,dummy=f:read("\u{6c}","\u{4c}","\u{6e}","\u{6e}")
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 == 1234 and n2 == 3.45 and dummy == nil)
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)
assert(f:close())
local f <close> = assert(io.open(file,"\u{72}"))
l1,l2,n1,n2,c,l3,l4,dummy=f:read(7,"\u{6c}","\u{6e}","\u{6e}",1,"\u{6c}","\u{6c}")
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 == 1234 and n2 == 3.45 and l3 == "\u{6f}\u{6e}\u{65}" and l4 == "\u{74}\u{77}\u{6f}" and dummy == nil)
l1,l2,n1,n2,c,l3,l4,dummy=f:read(0x7,"\u{6c}","\u{6e}","\u{6e}",0x1,"\u{6c}","\u{6c}")
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)
assert(f:close())
local f <close> = assert(io.open(file,"\u{72}"))
l1,n1,n2,dummy=f:read("\u{6c}","\u{6e}","\u{6e}","\u{6c}")
@ -141,15 +141,15 @@ f=assert(io.open(file,"\u{77}"))
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}")
assert(f:close())
f=coroutine.wrap(dofile)
assert(f(file) == 10)
assert(f(100,101) == 20)
assert(f(200) == 100 + 200 * 101)
assert(f(file) == 0xa)
assert(f(0x64,0x65) == 0x14)
assert(f(0xc8) == 0x64 + 0xc8 * 0x65)
assert(os.remove(file))
f=assert(io.open(file,"\u{77}"))
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}")
f:write("\u{31}\u{32}\u{33}\u{34}")
;
for i = 1, 1000
for i = 0x1, 0x3e8
do
f:write("\u{30}")
end
@ -160,25 +160,25 @@ assert(f:close())
f=assert(io.open(file,"\u{72}"))
assert(f:read("\u{6e}") == - 12.3)
;
assert(f:read(1) == "\u{2d}")
assert(f:read("\u{6e}") == - 65535)
assert(f:read(0x1) == "\u{2d}")
assert(f:read("\u{6e}") == - 0xffff)
;
assert(f:read(2) == "\u{2b}\u{20}")
assert(f:read(0x2) == "\u{2b}\u{20}")
assert(f:read("\u{6e}") == 0.3)
;
assert(f:read(1) == "\u{7c}")
assert(f:read(0x1) == "\u{7c}")
assert(f:read("\u{6e}") == 5e-3)
;
assert(f:read(1) == "\u{58}")
assert(f:read(0x1) == "\u{58}")
assert(f:read("\u{6e}") == 2.34e15)
;
assert(f:read(1) == "\u{45}")
assert(f:read("\u{6e}") == 16045690984833335023)
assert(f:read(0x1) == "\u{45}")
assert(f:read("\u{6e}") == 0xdeadbeefdeadbeef)
;
assert(f:read(2) == "\u{78}\u{a}")
assert(f:read(0x2) == "\u{78}\u{a}")
assert(f:read("\u{6e}") == 8.61328125)
;
assert(f:read(1) == "\u{65}")
assert(f:read(0x1) == "\u{65}")
do
assert(not f:read("\u{6e}"))
local s = f:read("\u{4c}")
@ -186,91 +186,91 @@ assert(string.find(s,"\u{5e}\u{30}\u{30}\u{2a}\u{a}\u{24}"))
end
assert(not f:read("\u{6e}"))
;
assert(f:read(2) == "\u{65}\u{2b}")
assert(f:read(0x2) == "\u{65}\u{2b}")
assert(not f:read("\u{6e}"))
;
assert(f:read(1) == "\u{3b}")
assert(f:read(0x1) == "\u{3b}")
assert(not f:read("\u{6e}"))
;
assert(f:read(2) == "\u{2d}\u{3b}")
assert(f:read(0x2) == "\u{2d}\u{3b}")
assert(not f:read("\u{6e}"))
;
assert(f:read(1) == "\u{58}")
assert(f:read(0x1) == "\u{58}")
assert(not f:read("\u{6e}"))
;
assert(f:read(1) == "\u{3b}")
assert(f:read(0x1) == "\u{3b}")
assert(not f:read("\u{6e}"))
;
assert(not f:read(0))
assert(not f:read(0x0))
assert(f:close())
assert(os.remove(file))
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}"))
assert(os.rename(otherfile,file))
io.output(otherfile)
local n = 0
local n = 0x0
local f = io.lines(file)
while f() do
n=n + 1
n=n + 0x1
end
;
assert(n == 6)
assert(n == 0x6)
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)
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)
n=0
n=0x0
for l in io.lines(file)
do
io.write(l,"\u{a}")
;
n=n + 1
n=n + 0x1
end
io.close()
assert(n == 6)
assert(n == 0x6)
local f = assert(io.open(otherfile))
assert(io.type(f) == "\u{66}\u{69}\u{6c}\u{65}")
io.output(file)
assert(not io.output():read())
n=0
n=0x0
for l in f:lines()
do
io.write(l,"\u{a}")
;
n=n + 1
n=n + 0x1
end
assert(tostring(f):sub(1,5) == "\u{66}\u{69}\u{6c}\u{65}\u{20}")
assert(tostring(f):sub(0x1,0x5) == "\u{66}\u{69}\u{6c}\u{65}\u{20}")
assert(f:close())
;
io.close()
assert(n == 6)
assert(n == 0x6)
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)
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}")
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}")
io.input(file)
f=io.open(otherfile):lines()
n=0
n=0x0
for l in io.lines()
do
assert(l == f())
;
n=n + 1
n=n + 0x1
end
f=nil
;
collectgarbage()
assert(n == 6)
assert(n == 0x6)
assert(os.remove(otherfile))
do
io.output(otherfile)
io.write(string.rep("\u{61}",300),"\u{a}")
io.write(string.rep("\u{61}",0x12c),"\u{a}")
io.close()
local t = {}
;
for i = 1, 250
for i = 0x1, 0xfa
do
t[i]=1
t[i]=0x1
end
t={io.lines(otherfile,table.unpack(t))()}
assert(# t == 250 and t[1] == "\u{61}" and t[# t] == "\u{61}")
t[# t + 1]=1
assert(# t == 0xfa and t[0x1] == "\u{61}" and t[# t] == "\u{61}")
t[# t + 0x1]=0x1
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))
collectgarbage()
assert(os.remove(otherfile))
@ -281,29 +281,29 @@ local a,b,c = io.input():write("\u{78}\u{75}\u{78}\u{75}")
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}")
end
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}")
assert(io.read(0) == "")
assert(io.read(5,"\u{6c}") == "\u{22}\u{61}\u{6c}\u{6f}\u{22}")
assert(io.read(0) == "")
assert(io.read(0x0) == "")
assert(io.read(0x5,"\u{6c}") == "\u{22}\u{61}\u{6c}\u{6f}\u{22}")
assert(io.read(0x0) == "")
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}")
local x = io.input():seek()
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}")
assert(io.input():seek("\u{73}\u{65}\u{74}",x))
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}")
assert(io.read(1) == "\u{58}")
assert(io.read(0x1) == "\u{58}")
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}")
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}")))
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}")
assert(io.read() == "")
assert(io.read("\u{6e}") == 3450)
assert(io.read(1) == "\u{a}")
assert(not io.read(0))
assert(not io.read(1))
assert(not io.read(30000))
assert(({io.read(1)})[2] == undef)
assert(io.read("\u{6e}") == 0xd7a)
assert(io.read(0x1) == "\u{a}")
assert(not io.read(0x0))
assert(not io.read(0x1))
assert(not io.read(0x7530))
assert(({io.read(0x1)})[0x2] == undef)
assert(not io.read())
assert(({io.read()})[2] == undef)
assert(({io.read()})[0x2] == undef)
assert(not io.read("\u{6e}"))
assert(({io.read("\u{6e}")})[2] == undef)
assert(({io.read("\u{6e}")})[0x2] == undef)
assert(io.read("\u{61}") == "")
assert(io.read("\u{61}") == "")
collectgarbage()
@ -312,12 +312,12 @@ io.close(io.input())
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)
assert(os.remove(file))
local t = "\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}"
for i = 1, 10
for i = 0x1, 0xa
do
t=t .. t
;
end
assert(string.len(t) == 10 * 2 ^ 10)
assert(string.len(t) == 0xa * 0x2 ^ 0xa)
io.output(file)
io.write("\u{61}\u{6c}\u{6f}"):write("\u{a}")
io.close()
@ -334,12 +334,12 @@ f:close()
print("\u{2b}")
io.input(file)
assert(io.read() == "\u{61}\u{6c}\u{6f}")
assert(io.read(1) == "\u{20}")
assert(io.read(0x1) == "\u{20}")
assert(io.read(string.len(t)) == t)
assert(io.read(1) == "\u{20}")
assert(io.read(0))
assert(io.read(0x1) == "\u{20}")
assert(io.read(0x0))
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}")
assert(not io.read(0))
assert(not io.read(0x0))
assert(io.close(io.input()))
do
local function ismsg
@ -403,18 +403,18 @@ io.output(file)
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()
local t = {}
assert(load(io.lines(file,"\u{4c}"),nil,nil,t))()
assert(t.a == - ((10 + 34) * 2))
assert(t.a == - ((0xa + 0x22) * 0x2))
do
local function gettoclose
(lv)
lv=lv + 1
local stvar = 0
for i = 1, 1000
lv=lv + 0x1
local stvar = 0x0
for i = 0x1, 0x3e8
do
local n,v = debug.getlocal(lv,i)
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
stvar=stvar + 1
if stvar == 4 then
stvar=stvar + 0x1
if stvar == 0x4 then
return v
end
end
@ -423,7 +423,7 @@ end
local f
for l in io.lines(file)
do
f=gettoclose(1)
f=gettoclose(0x1)
assert(io.type(f) == "\u{66}\u{69}\u{6c}\u{65}")
break
end
@ -433,7 +433,7 @@ local function foo
(name)
for l in io.lines(name)
do
f=gettoclose(1)
f=gettoclose(0x1)
assert(io.type(f) == "\u{66}\u{69}\u{6c}\u{65}")
error(f)
end
@ -444,19 +444,19 @@ end
io.output(file)
;
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()
for a,b in io.lines(file,1,1)
for a,b in io.lines(file,0x1,0x1)
do
if a == "\u{a}" then
assert(not b)
else
assert(tonumber(a) == tonumber(b) - 1)
assert(tonumber(a) == tonumber(b) - 0x1)
end
end
for a,b,c in io.lines(file,1,2,"\u{61}")
for a,b,c in io.lines(file,0x1,0x2,"\u{61}")
do
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}")
end
for a,b,c in io.lines(file,"\u{61}",0,1)
for a,b,c in io.lines(file,"\u{61}",0x0,0x1)
do
if a == "" then
break
@ -469,24 +469,24 @@ io.output(file)
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()
for a,b in io.lines(file,"\u{6e}","\u{6e}")
do
if a == 40 then
if a == 0x28 then
assert(not b)
else
assert(a == b - 10)
assert(a == b - 0xa)
end
end
io.output(file)
;
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()
_G.X=1
_G.X=0x1
assert(not load((io.lines(file))))
collectgarbage()
load((io.lines(file,"\u{4c}")))()
assert(_G.X == 2)
load((io.lines(file,1)))()
assert(_G.X == 4)
load((io.lines(file,3)))()
assert(_G.X == 8)
assert(_G.X == 0x2)
load((io.lines(file,0x1)))()
assert(_G.X == 0x4)
load((io.lines(file,0x3)))()
assert(_G.X == 0x8)
_G.X=nil
print("\u{2b}")
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}"
@ -513,44 +513,44 @@ assert(res == expres)
end
testloadfile(nil,nil)
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)
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}",234)
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}",239)
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)
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)
testloadfile("\u{ef}\u{bb}\u{bf}",nil)
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}",2)
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)
io.output(io.open(file,"\u{77}\u{62}"))
assert(io.write(string.dump(function ()
return 10,"\u{0}\u{61}\u{6c}\u{6f}\u{ff}","\u{68}\u{69}"
return 0xa,"\u{0}\u{61}\u{6c}\u{6f}\u{ff}","\u{68}\u{69}"
end)))
io.close()
a,b,c=assert(loadfile(file))()
assert(a == 10 and b == "\u{0}\u{61}\u{6c}\u{6f}\u{ff}" and c == "\u{68}\u{69}")
assert(a == 0xa and b == "\u{0}\u{61}\u{6c}\u{6f}\u{ff}" and c == "\u{68}\u{69}")
assert(os.remove(file))
do
io.output(io.open(file,"\u{77}\u{62}"))
assert(io.write(string.dump(function ()
return 1
return 0x1
end)))
io.close()
f=assert(loadfile(file,"\u{62}",{}))
assert(type(f) == "\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}" and f() == 1)
assert(type(f) == "\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}" and f() == 0x1)
assert(os.remove(file))
end
io.output(io.open(file,"\u{77}\u{62}"))
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 ()
return 20,"\u{0}\u{0}\u{0}"
return 0x14,"\u{0}\u{0}\u{0}"
end)))
io.close()
a,b,c=assert(loadfile(file))()
assert(a == 20 and b == "\u{0}\u{0}\u{0}" and c == nil)
assert(a == 0x14 and b == "\u{0}\u{0}\u{0}" and c == nil)
assert(os.remove(file))
do
local f = io.open(file,"\u{77}")
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}")
f:close()
local t = {["\u{62}"] = 12,["\u{63}"] = "\u{78}\u{75}\u{78}\u{75}",["\u{64}"] = print}
local t = {["\u{62}"] = 0xc,["\u{63}"] = "\u{78}\u{75}\u{78}\u{75}",["\u{64}"] = print}
local f = assert(loadfile(file,"\u{74}",t))
local b,c,d = f(1)
assert(t.a == 15 and b == 12 and c == t.c and d == print)
local b,c,d = f(0x1)
assert(t.a == 0xf and b == 0xc and c == t.c and d == print)
assert(f() == t)
f=assert(loadfile(file,"\u{74}",nil))
assert(f() == nil)
@ -584,12 +584,12 @@ filehandle:close()
;
assert(type(filehandle) == "\u{75}\u{73}\u{65}\u{72}\u{64}\u{61}\u{74}\u{61}")
io.input(otherfilehandle)
assert(io.read(4) == "\u{0}\u{1}\u{3}\u{0}")
assert(io.read(3) == "\u{0}\u{0}\u{0}")
assert(io.read(0) == "")
assert(io.read(1) == "\u{ff}")
assert(io.read(0x4) == "\u{0}\u{1}\u{3}\u{0}")
assert(io.read(0x3) == "\u{0}\u{0}\u{0}")
assert(io.read(0x0) == "")
assert(io.read(0x1) == "\u{ff}")
assert(io.read("\u{61}") == "\u{0}")
assert(not io.read(0))
assert(not io.read(0x0))
assert(otherfilehandle == io.input())
otherfilehandle:close()
assert(os.remove(file))
@ -597,7 +597,7 @@ assert(os.remove(otherfile))
collectgarbage()
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()
io.input(file)
local _,a,b,c,d,e,h,__ = io.read(1,"\u{6e}","\u{6e}","\u{6c}","\u{6c}","\u{6c}","\u{61}",10)
local _,a,b,c,d,e,h,__ = io.read(0x1,"\u{6e}","\u{6e}","\u{6c}","\u{6c}","\u{6c}","\u{61}",0xa)
assert(io.close(io.input()))
assert(_ == "\u{20}" and not __)
assert(type(a) == "\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}" and a == 123.4 and b == - 0.56)
@ -608,7 +608,7 @@ collectgarbage()
do
local f = assert(io.open(file,"\u{77}"))
local fr = assert(io.open(file,"\u{72}"))
assert(f:setvbuf("\u{66}\u{75}\u{6c}\u{6c}",2000))
assert(f:setvbuf("\u{66}\u{75}\u{6c}\u{6c}",0x7d0))
f:write("\u{78}")
assert(fr:read("\u{61}\u{6c}\u{6c}") == "")
f:close()
@ -623,9 +623,9 @@ f:close()
f=assert(io.open(file,"\u{61}"))
assert(f:setvbuf("\u{6c}\u{69}\u{6e}\u{65}"))
f:write("\u{78}")
fr:seek("\u{73}\u{65}\u{74}",1)
fr:seek("\u{73}\u{65}\u{74}",0x1)
assert(fr:read("\u{61}\u{6c}\u{6c}") == "")
f:write("\u{61}\u{a}"):seek("\u{73}\u{65}\u{74}",1)
f:write("\u{61}\u{a}"):seek("\u{73}\u{65}\u{74}",0x1)
assert(fr:read("\u{61}\u{6c}\u{6c}") == "\u{78}\u{61}\u{a}")
f:close()
;
@ -635,17 +635,17 @@ end
if not _soft then
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}")
io.output(file)
for i = 1, 5001
for i = 0x1, 0x1389
do
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}")
end
io.write("\u{a}\u{31}\u{32}\u{33}\u{34}\u{36}"):close()
io.input(file)
local x = io.read("\u{61}")
io.input():seek("\u{73}\u{65}\u{74}",0)
local y = io.read(30001) .. io.read(1005) .. io.read(0) .. io.read(1) .. io.read(100003)
assert(x == y and string.len(x) == 5001 * 13 + 6)
io.input():seek("\u{73}\u{65}\u{74}",0)
io.input():seek("\u{73}\u{65}\u{74}",0x0)
local y = io.read(0x7531) .. io.read(0x3ed) .. io.read(0x0) .. io.read(0x1) .. io.read(0x186a3)
assert(x == y and string.len(x) == 0x1389 * 0xd + 0x6)
io.input():seek("\u{73}\u{65}\u{74}",0x0)
y=io.read()
assert(x == y .. "\u{a}" .. io.read())
assert(not io.read())
@ -659,11 +659,11 @@ if not _port then
local progname
do
local arg = arg or ARG
local i = 0
local i = 0x0
while arg[i] do
i=i - 1
i=i - 0x1
end
progname="\u{22}" .. arg[i + 1] .. "\u{22}"
progname="\u{22}" .. arg[i + 0x1] .. "\u{22}"
end
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}")
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}","")
@ -679,18 +679,18 @@ assert(f:read("\u{61}") == "\u{61}\u{20}\u{6c}\u{69}\u{6e}\u{65}")
assert(f:close())
assert(os.remove(file))
end
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}",3},{"\u{65}\u{78}\u{69}\u{74}\u{20}\u{31}\u{32}\u{39}","\u{65}\u{78}\u{69}\u{74}",129},{"\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}",1},{"\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}",9},{"\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}",20}}
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}}
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}")
for _,v in ipairs(tests)
do
local x,y,z = io.popen(v[1]):close()
local x1,y1,z1 = os.execute(v[1])
local x,y,z = io.popen(v[0x1]):close()
local x1,y1,z1 = os.execute(v[0x1])
assert(x == x1 and y == y1 and z == z1)
if v[2] == "\u{6f}\u{6b}" then
assert(x and y == "\u{65}\u{78}\u{69}\u{74}" and z == 0)
if v[0x2] == "\u{6f}\u{6b}" then
assert(x and y == "\u{65}\u{78}\u{69}\u{74}" and z == 0x0)
else
assert(not x and y == v[2])
assert((v[3] == nil and z > 0) or v[3] == z)
assert(not x and y == v[0x2])
assert((v[0x3] == nil and z > 0x0) or v[0x3] == z)
end
end
end
@ -706,12 +706,12 @@ assert(os.date("") == "")
assert(os.date("\u{21}") == "")
assert(os.date("\u{0}\u{0}") == "\u{0}\u{0}")
assert(os.date("\u{21}\u{0}\u{0}") == "\u{0}\u{0}")
local x = string.rep("\u{61}",10000)
local x = string.rep("\u{61}",0x2710)
assert(os.date(x) == x)
local t = os.time()
D=os.date("\u{2a}\u{74}",t)
assert(os.date(string.rep("\u{25}\u{64}",1000),t) == string.rep(os.date("\u{25}\u{64}",t),1000))
assert(os.date(string.rep("\u{25}",200)) == string.rep("\u{25}",100))
assert(os.date(string.rep("\u{25}\u{64}",0x3e8),t) == string.rep(os.date("\u{25}\u{64}",t),0x3e8))
assert(os.date(string.rep("\u{25}",0xc8)) == string.rep("\u{25}",0x64))
local function checkDateTable
(t)
_G.D=os.date("\u{2a}\u{74}",t)
@ -721,11 +721,11 @@ _G.D=nil
end
checkDateTable(os.time())
if not _port then
checkDateTable(0)
checkDateTable(1)
checkDateTable(1000)
checkDateTable(2147483647)
checkDateTable(2147483648)
checkDateTable(0x0)
checkDateTable(0x1)
checkDateTable(0x3e8)
checkDateTable(0x7fffffff)
checkDateTable(0x80000000)
end
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}")
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}")
@ -733,44 +733,44 @@ checkerr("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{63}\u{6f}\u{6e}\u{7
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}")
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}")
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}")
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}"] = 1000,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 1,["\u{64}\u{61}\u{79}"] = 1,["\u{68}\u{6f}\u{75}\u{72}"] = "\u{78}"})
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}"] = 1000,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 1,["\u{64}\u{61}\u{79}"] = 1,["\u{68}\u{6f}\u{75}\u{72}"] = 1.5})
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}"] = 12})
if string.packsize("\u{69}") == 4 then
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}"] = - (1 << 31) + 1899,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 1,["\u{64}\u{61}\u{79}"] = 1})
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}"] = - (1 << 31),["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 1,["\u{64}\u{61}\u{79}"] = 1})
if math.maxinteger > 2 ^ 31 then
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}"] = (1 << 31) + 1900,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 1,["\u{64}\u{61}\u{79}"] = 1})
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}"})
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})
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})
if string.packsize("\u{69}") == 0x4 then
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})
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})
if math.maxinteger > 0x2 ^ 0x1f then
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})
end
end
if not _port then
assert(type(os.date("\u{25}\u{45}\u{78}")) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}")
assert(type(os.date("\u{25}\u{4f}\u{79}")) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}")
local t0 = os.time({["\u{79}\u{65}\u{61}\u{72}"] = 1970,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 1,["\u{64}\u{61}\u{79}"] = 0})
local t1 = os.time({["\u{79}\u{65}\u{61}\u{72}"] = 1970,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 1,["\u{64}\u{61}\u{79}"] = 0,["\u{73}\u{65}\u{63}"] = (1 << 31) - 1})
assert(t1 - t0 == (1 << 31) - 1)
t0=os.time({["\u{79}\u{65}\u{61}\u{72}"] = 1970,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 1,["\u{64}\u{61}\u{79}"] = 1})
t1=os.time({["\u{79}\u{65}\u{61}\u{72}"] = 1970,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 1,["\u{64}\u{61}\u{79}"] = 1,["\u{73}\u{65}\u{63}"] = - (1 << 31)})
assert(t1 - t0 == - (1 << 31))
if maxint >= 2 ^ 62 then
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}"] = 1,["\u{64}\u{61}\u{79}"] = 1})
if string.packsize("\u{69}") == 4 then
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}",2 ^ 40) then
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})
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})
assert(t1 - t0 == (0x1 << 0x1f) - 0x1)
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})
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)})
assert(t1 - t0 == - (0x1 << 0x1f))
if maxint >= 0x2 ^ 0x3e then
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})
if string.packsize("\u{69}") == 0x4 then
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
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}")
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}"] = 4000,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 1,["\u{64}\u{61}\u{79}"] = 1})
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})
else
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}")
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}",2 ^ 60)
assert(tonumber(os.time({["\u{79}\u{65}\u{61}\u{72}"] = (1 << 31) + 1899,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 12,["\u{64}\u{61}\u{79}"] = 31,["\u{68}\u{6f}\u{75}\u{72}"] = 23,["\u{6d}\u{69}\u{6e}"] = 59,["\u{73}\u{65}\u{63}"] = 59})))
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}"] = (1 << 31) + 1899,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 12,["\u{64}\u{61}\u{79}"] = 31,["\u{68}\u{6f}\u{75}\u{72}"] = 23,["\u{6d}\u{69}\u{6e}"] = 59,["\u{73}\u{65}\u{63}"] = 60})
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)
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})))
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})
end
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}"] = 0,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 1,["\u{64}\u{61}\u{79}"] = 2 ^ 32})
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}"] = 0,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = - ((1 << 31) + 1),["\u{64}\u{61}\u{79}"] = 1})
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}"] = (1 << 31) + 1900,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 1,["\u{64}\u{61}\u{79}"] = 1})
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})
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})
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})
else
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}")
assert(tonumber(os.date("\u{25}\u{59}",2 ^ 60)))
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}"] = 2 ^ 60,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 1,["\u{64}\u{61}\u{79}"] = 1})
assert(tonumber(os.date("\u{25}\u{59}",0x2 ^ 0x3c)))
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})
end
end
end
@ -788,22 +788,22 @@ assert(t == t1)
end
local D = os.date("\u{2a}\u{74}")
t=os.time(D)
D.year=D.year - 1
D.year=D.year - 0x1
;
local t1 = os.time(D)
assert(math.abs(os.difftime(t,t1) / (24 * 3600) - 365) < 2)
assert(math.abs(os.difftime(t,t1) / (0x18 * 0xe10) - 0x16d) < 0x2)
t=os.time()
t1=os.time(os.date("\u{2a}\u{74}"))
local diff = os.difftime(t1,t)
assert(0 <= diff and diff <= 1)
assert(0x0 <= diff and diff <= 0x1)
diff=os.difftime(t,t1)
assert(- 1 <= diff and diff <= 0)
local t1 = os.time({["\u{79}\u{65}\u{61}\u{72}"] = 2000,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 10,["\u{64}\u{61}\u{79}"] = 1,["\u{68}\u{6f}\u{75}\u{72}"] = 23,["\u{6d}\u{69}\u{6e}"] = 12})
local t2 = os.time({["\u{79}\u{65}\u{61}\u{72}"] = 2000,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 10,["\u{64}\u{61}\u{79}"] = 1,["\u{68}\u{6f}\u{75}\u{72}"] = 23,["\u{6d}\u{69}\u{6e}"] = 10,["\u{73}\u{65}\u{63}"] = 19})
assert(os.difftime(t1,t2) == 60 * 2 - 19)
t1={["\u{79}\u{65}\u{61}\u{72}"] = 2005,["\u{6d}\u{6f}\u{6e}\u{74}\u{68}"] = 1,["\u{64}\u{61}\u{79}"] = 1,["\u{68}\u{6f}\u{75}\u{72}"] = 1,["\u{6d}\u{69}\u{6e}"] = 0,["\u{73}\u{65}\u{63}"] = - 3602}
assert(- 0x1 <= diff and diff <= 0x0)
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})
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})
assert(os.difftime(t1,t2) == 0x3c * 0x2 - 0x13)
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}
os.time(t1)
assert(t1.day == 31 and t1.month == 12 and t1.year == 2004 and t1.hour == 23 and t1.min == 59 and t1.sec == 58 and t1.yday == 366)
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)
io.output(io.stdout)
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}")
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}")

View File

@ -1,17 +1,17 @@
foosjis=nil
az=bar[nil]
baz=bar(1).foo
i=3
i,a[i]=i + 1,20 >> 9
baz=bar(0x1).foo
i=0x3
i,a[i]=i + 0x1,0x14 >> 0x9
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}"
x={[hello] = 8,["\u{68}\u{65}\u{6c}\u{6c}\u{6f}"] = 12}
x={[hello] = 0x8,["\u{68}\u{65}\u{6c}\u{6c}\u{6f}"] = 0xc}
;
test_cases={{2147483647,"\u{32}\u{31}\u{34}\u{37}\u{34}\u{38}\u{33}\u{36}\u{34}\u{37}"},{2147483647,"\u{32}\u{31}\u{34}\u{37}\u{34}\u{38}\u{33}\u{36}\u{34}\u{37}"},{4294967295,"\u{34}\u{32}\u{39}\u{34}\u{39}\u{36}\u{37}\u{32}\u{39}\u{35}"},{4294967295,"\u{34}\u{32}\u{39}\u{34}\u{39}\u{36}\u{37}\u{32}\u{39}\u{35}"},{9223372036854775807,"\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}"},{9223372036854775807,"\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}"},{18446744073709551615,"\u{31}\u{2e}\u{38}\u{34}\u{34}\u{36}\u{37}\u{34}\u{34}\u{30}\u{37}\u{33}\u{37}\u{31}\u{65}\u{2b}\u{31}\u{39}"},{18446744073709551615,"\u{31}\u{2e}\u{38}\u{34}\u{34}\u{36}\u{37}\u{34}\u{34}\u{30}\u{37}\u{33}\u{37}\u{31}\u{65}\u{2b}\u{31}\u{39}"},{4294967296,"\u{34}\u{32}\u{39}\u{34}\u{39}\u{36}\u{37}\u{32}\u{39}\u{36}"},{4294967296,"\u{34}\u{32}\u{39}\u{34}\u{39}\u{36}\u{37}\u{32}\u{39}\u{36}"},{17592186044416,"\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}"},{17592186044416,"\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}"},{2147483648,"\u{32}\u{31}\u{34}\u{37}\u{34}\u{38}\u{33}\u{36}\u{34}\u{38}"},{2147483648,"\u{32}\u{31}\u{34}\u{37}\u{34}\u{38}\u{33}\u{36}\u{34}\u{38}"},{140737488355328,"\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}"},{140737488355328,"\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}"}}
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}"}}
::helli::
foo={3.0,3.1416,3.1416,3.1416,340.0,0.1171875,162.1875,162.1875,3.141592653589793,1984.0}
do
foo=1
return 8,foo
foo=0x1
return 0x8,foo
end
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}")
print("\u{68}\u{65}\u{6c}\u{6c}\u{6f}")
@ -23,26 +23,26 @@ break
end
repeat
do
foo=9
foo=0x9
;
end
until true
if l == 3 then
a=a + 1
if l == 0x3 then
a=a + 0x1
;
assert(getlocal(2,1) == "\u{28}\u{74}\u{65}\u{6d}\u{70}\u{6f}\u{72}\u{61}\u{72}\u{79}\u{29}")
elseif l == 4 then
a=a + 1
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}")
elseif l == 0x4 then
a=a + 0x1
;
assert(getlocal(2,1) == "\u{41}")
assert(getlocal(0x2,0x1) == "\u{41}")
else
;
end
for i = 1, 100
for i = 0x1, 0x64
do
karlSum=karlSum + i
end
for j = 100, 1, 1
for j = 0x64, 0x1, 0x1
do
fredSum=fredSum + j
end
@ -69,7 +69,7 @@ return function (y)
return x + y
end
end
x=- 1 + 8
x=- 0x1 + 0x8
if _VERSION ~= version then
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}")
return

View File

@ -13,29 +13,29 @@ local function nop
end
local function gcinfo
()
return collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}") * 1024
return collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}") * 0x400
end
do
local a = collectgarbage("\u{73}\u{65}\u{74}\u{70}\u{61}\u{75}\u{73}\u{65}",200)
local b = collectgarbage("\u{73}\u{65}\u{74}\u{73}\u{74}\u{65}\u{70}\u{6d}\u{75}\u{6c}",200)
local t = {0,2,10,90,500,5000,30000,2147483646}
for i = 1, # t
local a = collectgarbage("\u{73}\u{65}\u{74}\u{70}\u{61}\u{75}\u{73}\u{65}",0xc8)
local b = collectgarbage("\u{73}\u{65}\u{74}\u{73}\u{74}\u{65}\u{70}\u{6d}\u{75}\u{6c}",0xc8)
local t = {0x0,0x2,0xa,0x5a,0x1f4,0x1388,0x7530,0x7ffffffe}
for i = 0x1, # t
do
local p = t[i]
for j = 1, # t
for j = 0x1, # t
do
local m = t[j]
collectgarbage("\u{73}\u{65}\u{74}\u{70}\u{61}\u{75}\u{73}\u{65}",p)
collectgarbage("\u{73}\u{65}\u{74}\u{73}\u{74}\u{65}\u{70}\u{6d}\u{75}\u{6c}",m)
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0)
collectgarbage("\u{73}\u{74}\u{65}\u{70}",10000)
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x2710)
end
end
collectgarbage("\u{73}\u{65}\u{74}\u{70}\u{61}\u{75}\u{73}\u{65}",a)
collectgarbage("\u{73}\u{65}\u{74}\u{73}\u{74}\u{65}\u{70}\u{6d}\u{75}\u{6c}",b)
collectgarbage()
end
_G["\u{77}\u{68}\u{69}\u{6c}\u{65}"]=234
_G["\u{77}\u{68}\u{69}\u{6c}\u{65}"]=0xea
local function GC1
()
local u
@ -44,23 +44,23 @@ local finish = false
u=setmetatable({},{["\u{5f}\u{5f}\u{67}\u{63}"] = function ()
finish=true
end})
b={34}
b={0x22}
repeat
u={}
until finish
assert(b[1] == 34)
assert(b[0x1] == 0x22)
finish=false
;
local i = 1
local i = 0x1
u=setmetatable({},{["\u{5f}\u{5f}\u{67}\u{63}"] = function ()
finish=true
end})
repeat
i=i + 1
i=i + 0x1
;
u=tostring(i) .. tostring(i)
until finish
assert(b[1] == 34)
assert(b[0x1] == 0x22)
finish=false
u=setmetatable({},{["\u{5f}\u{5f}\u{67}\u{63}"] = function ()
finish=true
@ -72,7 +72,7 @@ u=function ()
return i
end
until finish
assert(b[1] == 34)
assert(b[0x1] == 0x22)
end
local function GC2
()
@ -81,23 +81,23 @@ local finish = false
u={setmetatable({},{["\u{5f}\u{5f}\u{67}\u{63}"] = function ()
finish=true
end})}
local b = {34}
local b = {0x22}
repeat
u={{}}
until finish
assert(b[1] == 34)
assert(b[0x1] == 0x22)
finish=false
;
local i = 1
local i = 0x1
u={setmetatable({},{["\u{5f}\u{5f}\u{67}\u{63}"] = function ()
finish=true
end})}
repeat
i=i + 1
i=i + 0x1
;
u={tostring(i) .. tostring(i)}
until finish
assert(b[1] == 34)
assert(b[0x1] == 0x22)
finish=false
u={setmetatable({},{["\u{5f}\u{5f}\u{67}\u{63}"] = function ()
finish=true
@ -109,7 +109,7 @@ u={function ()
return i
end}
until finish
assert(b[1] == 34)
assert(b[0x1] == 0x22)
end
local function GC
()
@ -119,15 +119,15 @@ GC2()
end
do
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}")
local limit = 5000
for i = 1, limit
local limit = 0x1388
for i = 0x1, limit
do
local a = {}
;
a=nil
end
local a = "\u{61}"
for i = 1, limit
for i = 0x1, limit
do
a=i .. "\u{62}"
;
@ -136,7 +136,7 @@ a="\u{61}"
end
a={}
function a:test()
for i = 1, limit
for i = 0x1, limit
do
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),"")()
assert(temp() == string.format("\u{61}\u{25}\u{64}",i))
@ -153,11 +153,11 @@ end
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}")
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}"
do
local step = 1
local step = 0x1
if _soft then
step=13
step=0xd
end
for i = 1, string.len(prog), step
for i = 0x1, string.len(prog), step
do
for j = i, string.len(prog), step
do
@ -171,20 +171,20 @@ do
foo=nil
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}")
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}"
assert(string.len(x) == 80)
assert(string.len(x) == 0x50)
local s = ""
local k = math.min(300,(math.maxinteger // 80) // 2)
for n = 1, k
local k = math.min(0x12c,(math.maxinteger // 0x50) // 0x2)
for n = 0x1, k
do
s=s .. x
;
local j = tostring(n)
end
assert(string.len(s) == k * 80)
s=string.sub(s,1,10000)
assert(string.len(s) == k * 0x50)
s=string.sub(s,0x1,0x2710)
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}","")
assert(i == 10000 // 4)
assert(_G["\u{77}\u{68}\u{69}\u{6c}\u{65}"] == 234)
assert(i == 0x2710 // 0x4)
assert(_G["\u{77}\u{68}\u{69}\u{6c}\u{65}"] == 0xea)
_G["\u{77}\u{68}\u{69}\u{6c}\u{65}"]=nil
end
do
@ -194,27 +194,27 @@ local function dosteps
(siz)
collectgarbage()
local a = {}
for i = 1, 100
for i = 0x1, 0x64
do
a[i]={{}}
;
local b = {}
end
local x = gcinfo()
local i = 0
local i = 0x0
repeat
i=i + 1
i=i + 0x1
until collectgarbage("\u{73}\u{74}\u{65}\u{70}",siz)
assert(gcinfo() < x)
return i
end
collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
if not _port then
assert(dosteps(10) < dosteps(2))
assert(dosteps(0xa) < dosteps(0x2))
end
assert(dosteps(20000) == 1)
assert(collectgarbage("\u{73}\u{74}\u{65}\u{70}",20000) == true)
assert(collectgarbage("\u{73}\u{74}\u{65}\u{70}",20000) == true)
assert(dosteps(0x4e20) == 0x1)
assert(collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x4e20) == true)
assert(collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x4e20) == true)
assert(not collectgarbage("\u{69}\u{73}\u{72}\u{75}\u{6e}\u{6e}\u{69}\u{6e}\u{67}"))
collectgarbage("\u{72}\u{65}\u{73}\u{74}\u{61}\u{72}\u{74}")
assert(collectgarbage("\u{69}\u{73}\u{72}\u{75}\u{6e}\u{6e}\u{69}\u{6e}\u{67}"))
@ -227,17 +227,17 @@ local x = gcinfo()
collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
repeat
local a = {}
until gcinfo() > 3 * x
until gcinfo() > 0x3 * x
collectgarbage("\u{72}\u{65}\u{73}\u{74}\u{61}\u{72}\u{74}")
assert(collectgarbage("\u{69}\u{73}\u{72}\u{75}\u{6e}\u{6e}\u{69}\u{6e}\u{67}"))
repeat
local a = {}
until gcinfo() <= x * 2
until gcinfo() <= x * 0x2
end
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}")
local lim = 15
local lim = 0xf
local a = {}
for i = 1, lim
for i = 0x1, lim
do
a[{}]=i
end
@ -258,11 +258,11 @@ for n in pairs(a)
do
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}")
end
for i = 1, lim
for i = 0x1, lim
do
a[i]=i
end
for i = 1, lim
for i = 0x1, lim
do
assert(a[i] == i)
end
@ -271,80 +271,80 @@ a={}
;
setmetatable(a,{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{6b}"})
;
for i = 1, lim
for i = 0x1, lim
do
a[{}]=i
end
for i = 1, lim
for i = 0x1, lim
do
a[i]=i
end
for i = 1, lim
for i = 0x1, lim
do
local s = string.rep("\u{40}",i)
;
a[s]=s .. "\u{23}"
end
collectgarbage()
local i = 0
local i = 0x0
for k,v in pairs(a)
do
assert(k == v or k .. "\u{23}" == v)
;
i=i + 1
i=i + 0x1
end
assert(i == 2 * lim)
assert(i == 0x2 * lim)
a={}
;
setmetatable(a,{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{76}"})
;
a[1]=string.rep("\u{62}",21)
a[0x1]=string.rep("\u{62}",0x15)
collectgarbage()
assert(a[1])
a[1]=undef
for i = 1, lim
assert(a[0x1])
a[0x1]=undef
for i = 0x1, lim
do
a[i]={}
end
for i = 1, lim
for i = 0x1, lim
do
a[i .. "\u{78}"]={}
end
for i = 1, lim
for i = 0x1, lim
do
local t = {}
;
a[t]=t
end
for i = 1, lim
for i = 0x1, lim
do
a[i + lim]=i .. "\u{78}"
end
collectgarbage()
local i = 0
local i = 0x0
for k,v in pairs(a)
do
assert(k == v or k - lim .. "\u{78}" == v)
;
i=i + 1
i=i + 0x1
end
assert(i == 2 * lim)
assert(i == 0x2 * lim)
a={}
;
setmetatable(a,{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{6b}\u{76}"})
;
local x,y,z = {},{},{}
a[1],a[2],a[3]=x,y,z
a[string.rep("\u{24}",11)]=string.rep("\u{24}",11)
for i = 4, lim
a[0x1],a[0x2],a[0x3]=x,y,z
a[string.rep("\u{24}",0xb)]=string.rep("\u{24}",0xb)
for i = 0x4, lim
do
a[i]={}
end
for i = 1, lim
for i = 0x1, lim
do
a[{}]=i
end
for i = 1, lim
for i = 0x1, lim
do
local t = {}
;
@ -352,21 +352,21 @@ a[t]=t
end
collectgarbage()
assert(next(a) ~= nil)
local i = 0
local i = 0x0
for k,v in pairs(a)
do
assert((k == 1 and v == x) or (k == 2 and v == y) or (k == 3 and v == z) or k == v)
assert((k == 0x1 and v == x) or (k == 0x2 and v == y) or (k == 0x3 and v == z) or k == v)
;
i=i + 1
i=i + 0x1
end
assert(i == 4)
assert(i == 0x4)
x,y,z=nil
collectgarbage()
assert(next(a) == string.rep("\u{24}",11))
assert(next(a) == string.rep("\u{24}",0xb))
a={}
local t = {["\u{78}"] = 10}
local t = {["\u{78}"] = 0xa}
local C = setmetatable({["\u{6b}\u{65}\u{79}"] = t},{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{76}"})
local C1 = setmetatable({[t] = 1},{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{6b}"})
local C1 = setmetatable({[t] = 0x1},{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{6b}"})
a.x=t
setmetatable(a,{["\u{5f}\u{5f}\u{67}\u{63}"] = function (u)
assert(C.key == nil)
@ -378,11 +378,11 @@ collectgarbage()
assert(next(C) == nil and next(C1) == nil)
C,C1=nil
local mt = {["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{6b}"}
a={{10},{20},{30},{40}}
a={{0xa},{0x14},{0x1e},{0x28}}
;
setmetatable(a,mt)
x=nil
for i = 1, 100
for i = 0x1, 0x64
do
local n = {}
;
@ -392,37 +392,37 @@ x=n
end
GC()
local n = x
local i = 0
local i = 0x0
while n do
n=a[n].k[1]
n=a[n].k[0x1]
;
i=i + 1
i=i + 0x1
end
assert(i == 100)
assert(i == 0x64)
x=nil
GC()
for i = 1, 4
for i = 0x1, 0x4
do
assert(a[i][1] == i * 10)
assert(a[i][0x1] == i * 0xa)
;
a[i]=undef
end
assert(next(a) == nil)
local K = {}
a[K]={}
for i = 1, 10
for i = 0x1, 0xa
do
a[K][i]={}
;
a[a[K][i]]=setmetatable({},mt)
end
x=nil
local k = 1
for j = 1, 100
local k = 0x1
for j = 0x1, 0x64
do
local n = {}
;
local nk = k % 10 + 1
local nk = k % 0xa + 0x1
a[a[K][nk]][n]={x,["\u{6b}"] = k}
;
x=n
@ -431,17 +431,17 @@ k=nk
end
GC()
local n = x
local i = 0
local i = 0x0
while n do
local t = a[a[K][k]][n]
;
n=t[1]
n=t[0x1]
;
k=t.k
;
i=i + 1
i=i + 0x1
end
assert(i == 100)
assert(i == 0x64)
K=nil
GC()
if T then
@ -453,12 +453,12 @@ setmetatable(s,{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{6b}"})
setmetatable(u,{["\u{5f}\u{5f}\u{67}\u{63}"] = function (o)
local i = s[o]
s[i]=true
assert(not s[i - 1])
if i == 8 then
assert(not s[i - 0x1])
if i == 0x8 then
error("\u{40}\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}\u{40}")
end
end})
for i = 6, 10
for i = 0x6, 0xa
do
local n = setmetatable({},getmetatable(u))
s[n]=i
@ -471,17 +471,17 @@ assert(string.find(_WARN,"\u{65}\u{72}\u{72}\u{6f}\u{72}\u{20}\u{69}\u{6e}\u{20}
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}")
;
_WARN=false
for i = 8, 10
for i = 0x8, 0xa
do
assert(s[i])
end
for i = 1, 5
for i = 0x1, 0x5
do
local n = setmetatable({},getmetatable(u))
s[n]=i
end
collectgarbage()
for i = 1, 10
for i = 0x1, 0xa
do
assert(s[i])
end
@ -494,16 +494,16 @@ if T == nil then
else
local function newproxy
(u)
return debug.setmetatable(T.newuserdata(0),debug.getmetatable(u))
return debug.setmetatable(T.newuserdata(0x0),debug.getmetatable(u))
end
collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
local u = newproxy(nil)
debug.setmetatable(u,{["\u{5f}\u{5f}\u{67}\u{63}"] = true})
local s = 0
local a = {[u] = 0}
local s = 0x0
local a = {[u] = 0x0}
;
setmetatable(a,{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{76}\u{6b}"})
for i = 1, 10
for i = 0x1, 0xa
do
a[newproxy(u)]=i
end
@ -521,7 +521,7 @@ for k,v in pairs(a1)
do
a[v]=k
end
for i = 1, 10
for i = 0x1, 0xa
do
assert(a[i])
end
@ -530,62 +530,62 @@ getmetatable(u).u=u
do
local u = u
getmetatable(u).__gc=function (o)
assert(a[o] == 10 - s)
assert(a[10 - s] == undef)
assert(a[o] == 0xa - s)
assert(a[0xa - s] == undef)
assert(getmetatable(o) == getmetatable(u))
assert(getmetatable(o).a[o] == 10 - s)
s=s + 1
assert(getmetatable(o).a[o] == 0xa - s)
s=s + 0x1
end
end
a1,u=nil
assert(next(a) ~= nil)
collectgarbage()
assert(s == 11)
assert(s == 0xb)
collectgarbage()
assert(next(a) == nil)
end
local u = setmetatable({},{["\u{5f}\u{5f}\u{67}\u{63}"] = true})
setmetatable(getmetatable(u),{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{76}"})
getmetatable(u).__gc=function (o)
os.exit(1)
os.exit(0x1)
end
u=nil
collectgarbage()
local u = setmetatable({},{["\u{5f}\u{5f}\u{67}\u{63}"] = true})
local m = getmetatable(u)
m.x={[{0}] = 1,[0] = {1}}
m.x={[{0x0}] = 0x1,[0x0] = {0x1}}
;
setmetatable(m.x,{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{6b}\u{76}"})
;
m.__gc=function (o)
assert(next(getmetatable(o).x) == nil)
m=10
m=0xa
end
u,m=nil
collectgarbage()
assert(m == 10)
assert(m == 0xa)
do
collectgarbage()
;
collectgarbage()
local m = collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}")
local a = setmetatable({},{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{6b}\u{76}"})
a[string.rep("\u{61}",2 ^ 22)]=25
a[string.rep("\u{62}",2 ^ 22)]={}
a[{}]=14
assert(collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}") > m + 2 ^ 13)
a[string.rep("\u{61}",0x2 ^ 0x16)]=0x19
a[string.rep("\u{62}",0x2 ^ 0x16)]={}
a[{}]=0xe
assert(collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}") > m + 0x2 ^ 0xd)
collectgarbage()
assert(collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}") >= m + 2 ^ 12 and collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}") < m + 2 ^ 13)
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)
local k,v = next(a)
assert(k == string.rep("\u{61}",2 ^ 22) and v == 25)
assert(k == string.rep("\u{61}",0x2 ^ 0x16) and v == 0x19)
assert(next(a,k) == nil)
assert(a[string.rep("\u{62}",2 ^ 22)] == undef)
assert(a[string.rep("\u{62}",0x2 ^ 0x16)] == undef)
a[k]=undef
k=nil
collectgarbage()
assert(next(a) == nil)
assert(a[string.rep("\u{62}",100)] == undef)
assert(collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}") <= m + 1)
assert(a[string.rep("\u{62}",0x64)] == undef)
assert(collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}") <= m + 0x1)
end
if T then
warn("\u{40}\u{73}\u{74}\u{6f}\u{72}\u{65}")
@ -602,7 +602,7 @@ end
if not _soft then
print("\u{6c}\u{6f}\u{6e}\u{67}\u{20}\u{6c}\u{69}\u{73}\u{74}")
local a = {}
for i = 1, 200000
for i = 0x1, 0x30d40
do
a={["\u{6e}\u{65}\u{78}\u{74}"] = a}
end
@ -610,7 +610,7 @@ a=nil
collectgarbage()
end
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}")
local thread_id = 0
local thread_id = 0x0
local threads = {}
local function fn
(thread)
@ -620,10 +620,10 @@ thread=x
end
coroutine.yield()
end
while thread_id < 1000 do
while thread_id < 0x3e8 do
local thread = coroutine.create(fn)
coroutine.resume(thread,thread)
thread_id=thread_id + 1
thread_id=thread_id + 0x1
end
do
local collected = false
@ -640,7 +640,7 @@ param={param,f}
setmetatable(param,{["\u{5f}\u{5f}\u{67}\u{63}"] = function ()
collected=true
end})
coroutine.yield(100)
coroutine.yield(0x64)
end)()
end
local co = coroutine.create(f)
@ -653,28 +653,28 @@ end
do
collectgarbage()
collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0)
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
local x = gcinfo()
repeat
for i = 1, 1000
for i = 0x1, 0x3e8
do
_ENV.a={}
end
until gcinfo() > 2 * x
until gcinfo() > 0x2 * x
collectgarbage("\u{72}\u{65}\u{73}\u{74}\u{61}\u{72}\u{74}")
_ENV.a=nil
end
if T then
local function foo
()
local a = {["\u{78}"] = 20}
local a = {["\u{78}"] = 0x14}
coroutine.yield(function ()
return a.x
end)
assert(a.x == 20)
a={["\u{78}"] = 30}
assert(a.x == 0x14)
a={["\u{78}"] = 0x1e}
assert(T.gccolor(a) == "\u{77}\u{68}\u{69}\u{74}\u{65}")
coroutine.yield(100)
coroutine.yield(0x64)
end
local t = setmetatable({},{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{6b}\u{76}"})
collectgarbage()
@ -684,12 +684,12 @@ t.co=coroutine.wrap(foo)
local f = t.co()
T.gcstate("\u{61}\u{74}\u{6f}\u{6d}\u{69}\u{63}")
assert(T.gcstate() == "\u{61}\u{74}\u{6f}\u{6d}\u{69}\u{63}")
assert(t.co() == 100)
assert(t.co() == 0x64)
assert(T.gccolor(t.co) == "\u{77}\u{68}\u{69}\u{74}\u{65}")
T.gcstate("\u{70}\u{61}\u{75}\u{73}\u{65}")
assert(t.co == nil and f() == 30)
assert(t.co == nil and f() == 0x1e)
collectgarbage("\u{72}\u{65}\u{73}\u{74}\u{61}\u{72}\u{74}")
local u = T.newuserdata(0,1)
local u = T.newuserdata(0x0,0x1)
collectgarbage()
collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
local a = {}
@ -706,8 +706,8 @@ end
if T then
local debug = require("\u{64}\u{65}\u{62}\u{75}\u{67}")
collectgarbage("\u{73}\u{74}\u{6f}\u{70}")
local x = T.newuserdata(0)
local y = T.newuserdata(0)
local x = T.newuserdata(0x0)
local y = T.newuserdata(0x0)
debug.setmetatable(y,{["\u{5f}\u{5f}\u{67}\u{63}"] = nop})
debug.setmetatable(x,{["\u{5f}\u{5f}\u{67}\u{63}"] = nop})
assert(T.gccolor(y) == "\u{77}\u{68}\u{69}\u{74}\u{65}")
@ -718,33 +718,33 @@ if T then
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}")
collectgarbage()
collectgarbage()
T.totalmem(T.totalmem() + 200)
for i = 1, 200
T.totalmem(T.totalmem() + 0xc8)
for i = 0x1, 0xc8
do
local a = {}
end
T.totalmem(0)
T.totalmem(0x0)
collectgarbage()
local t = T.totalmem("\u{74}\u{61}\u{62}\u{6c}\u{65}")
local a = {{},{},{}}
assert(T.totalmem("\u{74}\u{61}\u{62}\u{6c}\u{65}") == t + 4)
assert(T.totalmem("\u{74}\u{61}\u{62}\u{6c}\u{65}") == t + 0x4)
t=T.totalmem("\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}")
a=function ()
end
assert(T.totalmem("\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}") == t + 1)
assert(T.totalmem("\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}") == t + 0x1)
t=T.totalmem("\u{74}\u{68}\u{72}\u{65}\u{61}\u{64}")
a=coroutine.create(function ()
end)
assert(T.totalmem("\u{74}\u{68}\u{72}\u{65}\u{61}\u{64}") == t + 1)
assert(T.totalmem("\u{74}\u{68}\u{72}\u{65}\u{61}\u{64}") == t + 0x1)
end
do
local setmetatable,assert,type,print,getmetatable = setmetatable,assert,type,print,getmetatable
local tt = {}
tt.__gc=function (o)
assert(getmetatable(o) == tt)
local a = "\u{78}\u{75}\u{78}\u{75}" .. (10 + 3) .. "\u{6a}\u{6f}\u{61}\u{6f}",{}
local a = "\u{78}\u{75}\u{78}\u{75}" .. (0xa + 0x3) .. "\u{6a}\u{6f}\u{61}\u{6f}",{}
___Glob=o
setmetatable({},tt)
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}")
@ -754,14 +754,14 @@ ___Glob={u}
end
if T then
local error,assert,find,warn = error,assert,string.find,warn
local n = 0
local n = 0x0
local lastmsg
local mt = {["\u{5f}\u{5f}\u{67}\u{63}"] = function (o)
n=n + 1
assert(n == o[1])
if n == 1 then
n=n + 0x1
assert(n == o[0x1])
if n == 0x1 then
_WARN=false
elseif n == 2 then
elseif n == 0x2 then
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}"))
lastmsg=_WARN
else
@ -772,7 +772,7 @@ warn("\u{40}\u{73}\u{74}\u{6f}\u{72}\u{65}")
_WARN=false
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}")
end}
for i = 10, 1, - 1
for i = 0xa, 0x1, - 0x1
do
table.insert(___Glob,setmetatable({i},mt))
end

View File

@ -7,83 +7,83 @@ do
local U = {}
collectgarbage()
assert(not T or T.gcage(U) == "\u{6f}\u{6c}\u{64}")
U[1]={["\u{78}"] = {234}}
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[1]) == "\u{6e}\u{65}\u{77}"))
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0)
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[1]) == "\u{73}\u{75}\u{72}\u{76}\u{69}\u{76}\u{61}\u{6c}"))
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0)
assert(not T or (T.gcage(U) == "\u{6f}\u{6c}\u{64}" and T.gcage(U[1]) == "\u{6f}\u{6c}\u{64}\u{31}"))
assert(U[1].x[1] == 234)
U[0x1]={["\u{78}"] = {0xea}}
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}"))
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
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}"))
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
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}"))
assert(U[0x1].x[0x1] == 0xea)
end
do
local function foo
()
end
local old = {10}
local old = {0xa}
collectgarbage()
assert(not T or T.gcage(old) == "\u{6f}\u{6c}\u{64}")
setmetatable(old,{})
assert(not T or T.gcage(getmetatable(old)) == "\u{6f}\u{6c}\u{64}\u{30}")
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0)
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
assert(not T or T.gcage(getmetatable(old)) == "\u{6f}\u{6c}\u{64}\u{31}")
setmetatable(getmetatable(old),{["\u{5f}\u{5f}\u{67}\u{63}"] = foo})
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0)
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
end
do
local A = {}
A[1]=false
A[0x1]=false
local function gcf
(obj)
A[1]=obj
A[0x1]=obj
assert(not T or T.gcage(obj) == "\u{6f}\u{6c}\u{64}\u{31}")
obj=nil
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0)
print(getmetatable(A[1]).x)
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
print(getmetatable(A[0x1]).x)
end
collectgarbage()
local obj = {}
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0)
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
assert(not T or T.gcage(obj) == "\u{73}\u{75}\u{72}\u{76}\u{69}\u{76}\u{61}\u{6c}")
setmetatable(obj,{["\u{5f}\u{5f}\u{67}\u{63}"] = gcf,["\u{78}"] = "\u{2b}"})
assert(not T or T.gcage(getmetatable(obj)) == "\u{6e}\u{65}\u{77}")
obj=nil
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0)
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
end
do
local old = {10}
local old = {0xa}
collectgarbage()
local co = coroutine.create(function ()
local x = nil
local f = function ()
return x[1]
return x[0x1]
end
x=coroutine.yield(f)
coroutine.yield()
end)
local _,f = coroutine.resume(co)
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0)
old[1]={"\u{68}\u{65}\u{6c}\u{6c}\u{6f}"}
coroutine.resume(co,{123})
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
old[0x1]={"\u{68}\u{65}\u{6c}\u{6c}\u{6f}"}
coroutine.resume(co,{0x7b})
co=nil
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0)
assert(f() == 123 and old[1][1] == "\u{68}\u{65}\u{6c}\u{6c}\u{6f}")
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0)
assert(f() == 123 and old[1][1] == "\u{68}\u{65}\u{6c}\u{6c}\u{6f}")
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
assert(f() == 0x7b and old[0x1][0x1] == "\u{68}\u{65}\u{6c}\u{6c}\u{6f}")
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
assert(f() == 0x7b and old[0x1][0x1] == "\u{68}\u{65}\u{6c}\u{6c}\u{6f}")
end
do
local t = setmetatable({},{["\u{5f}\u{5f}\u{6d}\u{6f}\u{64}\u{65}"] = "\u{6b}\u{76}"})
collectgarbage()
assert(not T or T.gcage(t) == "\u{6f}\u{6c}\u{64}")
t[1]={10}
t[0x1]={0xa}
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}"))
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0)
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
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}"))
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0)
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
assert(not T or T.gcage(t) == "\u{6f}\u{6c}\u{64}")
t[1]={10}
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0)
assert(t[1] == nil)
t[0x1]={0xa}
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
assert(t[0x1] == nil)
end
if T == nil then
(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}")
@ -91,16 +91,16 @@ print("\u{4f}\u{4b}")
return
end
do
local U = T.newuserdata(0,1)
local U = T.newuserdata(0x0,0x1)
collectgarbage()
assert(T.gcage(U) == "\u{6f}\u{6c}\u{64}")
debug.setuservalue(U,{["\u{78}"] = {234}})
debug.setuservalue(U,{["\u{78}"] = {0xea}})
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}")
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0)
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
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}")
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0)
collectgarbage("\u{73}\u{74}\u{65}\u{70}",0x0)
assert(T.gcage(U) == "\u{6f}\u{6c}\u{64}" and T.gcage(debug.getuservalue(U)) == "\u{6f}\u{6c}\u{64}\u{31}")
assert(debug.getuservalue(U).x[1] == 234)
assert(debug.getuservalue(U).x[0x1] == 0xea)
end
assert(collectgarbage("\u{69}\u{73}\u{72}\u{75}\u{6e}\u{6e}\u{69}\u{6e}\u{67}"))
assert(collectgarbage("\u{69}\u{73}\u{72}\u{75}\u{6e}\u{6e}\u{69}\u{6e}\u{67}"))

View File

@ -15,10 +15,10 @@ 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}
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}")
local x
do
local y = 12
local y = 0xc
goto l1
::l2::
x=x + 1
x=x + 0x1
;
goto l3
::l1::
@ -28,16 +28,16 @@ goto l2
end
::l3::
::l3_1::
assert(x == 13)
assert(x == 0xd)
do
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}"
local label = string.rep("\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",40)
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)
prog=string.format(prog,label,label,label,label)
assert(assert(load(prog))() == 31)
assert(assert(load(prog))() == 0x1f)
end
do
goto l1
local a = 23
local a = 0x17
x=a
::l1::
;
@ -46,14 +46,14 @@ while true do
goto l4
goto l1
goto l1
local x = 45
local x = 0x2d
::l1::
;
;
;
end
::l4::
assert(x == 13)
assert(x == 0xd)
if print then
goto l1
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}")
@ -72,35 +72,35 @@ local function foo
local a = {}
goto l3
::l1::
a[# a + 1]=1
a[# a + 0x1]=0x1
;
goto l2
;
::l2::
a[# a + 1]=2
a[# a + 0x1]=0x2
;
goto l5
;
::l3::
::l3a::
a[# a + 1]=3
a[# a + 0x1]=0x3
;
goto l1
;
::l4::
a[# a + 1]=4
a[# a + 0x1]=0x4
;
goto l6
;
::l5::
a[# a + 1]=5
a[# a + 0x1]=0x5
;
goto l4
;
::l6::
assert(a[1] == 3 and a[2] == 1 and a[3] == 2 and a[4] == 5 and a[5] == 4)
if not a[6] then
a[6]=true
assert(a[0x1] == 0x3 and a[0x2] == 0x1 and a[0x3] == 0x2 and a[0x4] == 0x5 and a[0x5] == 0x4)
if not a[0x6] then
a[0x6]=true
;
goto l3a
end
@ -114,12 +114,12 @@ local y
assert(y == nil)
y=true
if x == nil then
x=1
x=0x1
goto L1
else
x=x + 1
x=x + 0x1
end
assert(x == 2 and y == true)
assert(x == 0x2 and y == true)
end
do
local first = true
@ -151,27 +151,27 @@ local function foo
()
local t = {}
do
local i = 1
local i = 0x1
local a,b,c,d
t[1]=function ()
t[0x1]=function ()
return a,b,c,d
end
::l1::
local b
do
local c
t[# t + 1]=function ()
t[# t + 0x1]=function ()
return a,b,c,d
end
if i > 2 then
if i > 0x2 then
goto l2
end
do
local d
t[# t + 1]=function ()
t[# t + 0x1]=function ()
return a,b,c,d
end
i=i + 1
i=i + 0x1
local a
goto l1
end
@ -181,52 +181,52 @@ end
return t
end
local a = foo()
assert(# a == 6)
for i = 2, 6
assert(# a == 0x6)
for i = 0x2, 0x6
do
assert(debug.upvalueid(a[1],1) == debug.upvalueid(a[i],1))
assert(debug.upvalueid(a[0x1],0x1) == debug.upvalueid(a[i],0x1))
end
for i = 2, 6
for i = 0x2, 0x6
do
assert(debug.upvalueid(a[1],2) ~= debug.upvalueid(a[i],2))
assert(debug.upvalueid(a[1],3) ~= debug.upvalueid(a[i],3))
assert(debug.upvalueid(a[0x1],0x2) ~= debug.upvalueid(a[i],0x2))
assert(debug.upvalueid(a[0x1],0x3) ~= debug.upvalueid(a[i],0x3))
end
for i = 3, 5, 2
for i = 0x3, 0x5, 0x2
do
assert(debug.upvalueid(a[i],2) == debug.upvalueid(a[i - 1],2))
assert(debug.upvalueid(a[i],3) == debug.upvalueid(a[i - 1],3))
assert(debug.upvalueid(a[i],2) ~= debug.upvalueid(a[i + 1],2))
assert(debug.upvalueid(a[i],3) ~= debug.upvalueid(a[i + 1],3))
assert(debug.upvalueid(a[i],0x2) == debug.upvalueid(a[i - 0x1],0x2))
assert(debug.upvalueid(a[i],0x3) == debug.upvalueid(a[i - 0x1],0x3))
assert(debug.upvalueid(a[i],0x2) ~= debug.upvalueid(a[i + 0x1],0x2))
assert(debug.upvalueid(a[i],0x3) ~= debug.upvalueid(a[i + 0x1],0x3))
end
for i = 2, 6, 2
for i = 0x2, 0x6, 0x2
do
assert(debug.upvalueid(a[1],4) == debug.upvalueid(a[i],4))
assert(debug.upvalueid(a[0x1],0x4) == debug.upvalueid(a[i],0x4))
end
for i = 3, 5, 2
for i = 0x3, 0x5, 0x2
do
for j = 1, 6
for j = 0x1, 0x6
do
assert((debug.upvalueid(a[i],4) == debug.upvalueid(a[j],4)) == (i == j))
assert((debug.upvalueid(a[i],0x4) == debug.upvalueid(a[j],0x4)) == (i == j))
end
end
local function testG
(a)
if a == 1 then
if a == 0x1 then
goto l1
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}")
elseif a == 2 then
elseif a == 0x2 then
goto l2
elseif a == 3 then
elseif a == 0x3 then
goto l3
elseif a == 4 then
elseif a == 0x4 then
goto l1
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}")
::l1::
a=a + 1
a=a + 0x1
else
goto l4
::l4a::
a=a * 2
a=a * 0x2
;
goto l4b
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,11 +249,11 @@ end
::l1::
return "\u{31}"
end
assert(testG(1) == "\u{31}")
assert(testG(2) == "\u{32}")
assert(testG(3) == "\u{33}")
assert(testG(4) == 5)
assert(testG(5) == 10)
assert(testG(0x1) == "\u{31}")
assert(testG(0x2) == "\u{32}")
assert(testG(0x3) == "\u{33}")
assert(testG(0x4) == 0x5)
assert(testG(0x5) == 0xa)
do
local X
goto L1

View File

@ -10,37 +10,37 @@ print(string.format("\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{77}\u{69}\u{74
end
end)
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}")))
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 * 100)
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)
end
print("\u{2b}")
end
local function loadrep
(x,what)
local p = 1 << 20
local p = 0x1 << 0x14
local s = string.rep(x,p)
local count = 0
local count = 0x0
local function f
()
count=count + p
if count % (128 * p) == 0 then
io.stderr:write("\u{28}",count // 2 ^ 20,"\u{20}\u{4d}\u{29}")
if count % (0x80 * p) == 0x0 then
io.stderr:write("\u{28}",count // 0x2 ^ 0x14,"\u{20}\u{4d}\u{29}")
end
return s
end
local st,msg = load(f,"\u{3d}\u{62}\u{69}\u{67}")
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}") * 1024)
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)
msg=string.match(msg,"\u{5e}\u{5b}\u{5e}\u{a}\u{5d}\u{2b}")
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))
return st,msg
end
function controlstruct()
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}")
local lim = ((1 << 24) - 2) // 3
local lim = ((0x1 << 0x18) - 0x2) // 0x3
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)
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}"
assert(load(s))
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}")
lim=lim + 3
lim=lim + 0x3
s=string.rep("\u{61}\u{20}\u{3d}\u{20}\u{61}\u{20}\u{2b}\u{20}\u{31}\u{a}",lim)
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}"
local st,msg = load(s)
@ -66,59 +66,59 @@ print("\u{2b}")
end
local function loadrepfunc
(prefix,f)
local count = - 1
local count = - 0x1
local function aux
()
count=count + 1
if count == 0 then
count=count + 0x1
if count == 0x0 then
return prefix
else
if count % (1048576) == 0 then
io.stderr:write("\u{28}",count // 2 ^ 20,"\u{20}\u{4d}\u{29}")
if count % (0x100000) == 0x0 then
io.stderr:write("\u{28}",count // 0x2 ^ 0x14,"\u{20}\u{4d}\u{29}")
end
return f(count)
end
end
local st,msg = load(aux,"\u{6b}")
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}") * 1024)
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)
msg=string.match(msg,"\u{5e}\u{5b}\u{5e}\u{a}\u{5d}\u{2b}")
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)
end
function toomanyconst()
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}")
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)
return string.char(34,((n // 128 ^ 0) & 127) + 128,((n // 128 ^ 1) & 127) + 128,((n // 128 ^ 2) & 127) + 128,((n // 128 ^ 3) & 127) + 128,((n // 128 ^ 4) & 127) + 128,34,44)
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)
end)
end
function toomanystr()
local a = {}
local st,msg = pcall(function ()
for i = 1, math.huge
for i = 0x1, math.huge
do
if i % (1048576) == 0 then
io.stderr:write("\u{28}",i // 2 ^ 20,"\u{20}\u{4d}\u{29}")
if i % (0x100000) == 0x0 then
io.stderr:write("\u{28}",i // 0x2 ^ 0x14,"\u{20}\u{4d}\u{29}")
end
a[i]=string.pack("\u{49}",i)
end
end)
local size = # a
a=collectgarbage("\u{63}\u{6f}\u{75}\u{6e}\u{74}")
print("\u{a}\u{6d}\u{65}\u{6d}\u{6f}\u{72}\u{79}\u{3a}",a * 1024)
print("\u{a}\u{6d}\u{65}\u{6d}\u{6f}\u{72}\u{79}\u{3a}",a * 0x400)
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)
print("\u{73}\u{69}\u{7a}\u{65}\u{3a}",size)
end
function toomanyidx()
local a = {}
local st,msg = pcall(function ()
for i = 1, math.huge
for i = 0x1, math.huge
do
if i % (1048576) == 0 then
io.stderr:write("\u{28}",i // 2 ^ 20,"\u{20}\u{4d}\u{29}")
if i % (0x100000) == 0x0 then
io.stderr:write("\u{28}",i // 0x2 ^ 0x14,"\u{20}\u{4d}\u{29}")
end
a[i]=i
end
end)
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}") * 1024)
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)
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)
print("\u{73}\u{69}\u{7a}\u{65}\u{3a}",# a)
end

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -9,11 +9,11 @@ local otherprog = os.tmpname()
local out = os.tmpname()
local progname
do
local i = 0
local i = 0x0
while arg[i] do
i=i - 1
i=i - 0x1
end
progname=arg[i + 1]
progname=arg[i + 0x1]
end
print("\u{70}\u{72}\u{6f}\u{67}\u{6e}\u{61}\u{6d}\u{65}\u{3a}\u{20}" .. progname)
local prepfile = function (s,mod,p)
@ -33,11 +33,11 @@ return t
end
local function checkprogout
(s)
assert(string.sub(s,- 1) == "\u{a}")
assert(string.sub(s,- 0x1) == "\u{a}")
local t = getoutput()
for line in string.gmatch(s,"\u{2e}\u{2d}\u{a}")
do
assert(string.find(t,line,1,true))
assert(string.find(t,line,0x1,true))
end
end
local function checkout
@ -51,17 +51,17 @@ return t
end
local function RUN
(p, ...)
p=string.gsub(p,"\u{6c}\u{75}\u{61}","\u{22}" .. progname .. "\u{22}",1)
p=string.gsub(p,"\u{6c}\u{75}\u{61}","\u{22}" .. progname .. "\u{22}",0x1)
local s = string.format(p,...)
assert(os.execute(s))
end
local function NoRun
(msg,p, ...)
p=string.gsub(p,"\u{6c}\u{75}\u{61}","\u{22}" .. progname .. "\u{22}",1)
p=string.gsub(p,"\u{6c}\u{75}\u{61}","\u{22}" .. progname .. "\u{22}",0x1)
local s = string.format(p,...)
s=string.format("\u{25}\u{73}\u{20}\u{3e}\u{25}\u{73}\u{20}\u{32}\u{3e}\u{26}\u{31}",s,out)
assert(not os.execute(s))
assert(string.find(getoutput(),msg,1,true))
assert(string.find(getoutput(),msg,0x1,true))
end
RUN("\u{6c}\u{75}\u{61}\u{20}\u{2d}\u{76}")
print(string.format("\u{28}\u{74}\u{65}\u{6d}\u{70}\u{6f}\u{72}\u{61}\u{72}\u{79}\u{20}\u{70}\u{72}\u{6f}\u{67}\u{72}\u{61}\u{6d}\u{20}\u{66}\u{69}\u{6c}\u{65}\u{20}\u{75}\u{73}\u{65}\u{64}\u{20}\u{69}\u{6e}\u{20}\u{74}\u{68}\u{65}\u{73}\u{65}\u{20}\u{74}\u{65}\u{73}\u{74}\u{73}\u{3a}\u{20}\u{25}\u{73}\u{29}",prog))
@ -130,7 +130,7 @@ local function convert
prepfile("\u{70}\u{72}\u{69}\u{6e}\u{74}\u{28}\u{70}\u{61}\u{63}\u{6b}\u{61}\u{67}\u{65}\u{2e}\u{70}\u{61}\u{74}\u{68}\u{29}")
RUN("\u{65}\u{6e}\u{76}\u{20}\u{4c}\u{55}\u{41}\u{5f}\u{50}\u{41}\u{54}\u{48}\u{3d}\u{22}\u{25}\u{73}\u{22}\u{20}\u{6c}\u{75}\u{61}\u{20}\u{25}\u{73}\u{20}\u{3e}\u{20}\u{25}\u{73}",p,prog,out)
local expected = getoutput()
expected=string.sub(expected,1,- 2)
expected=string.sub(expected,0x1,- 0x2)
if string.find(p,"\u{3b}\u{3b}") then
p=string.gsub(p,"\u{3b}\u{3b}","\u{3b}" .. defaultpath .. "\u{3b}")
p=string.gsub(p,"\u{5e}\u{3b}","")
@ -180,7 +180,7 @@ prepfile("\u{2d}\u{2d}\u{20}\u{73}\u{68}\u{6f}\u{75}\u{6c}\u{64}\u{20}\u{62}\u{6
RUN("\u{6c}\u{75}\u{61}\u{20}\u{2d}\u{57}\u{20}\u{25}\u{73}\u{20}\u{3e}\u{20}\u{25}\u{73}",prog,out)
checkout("\u{63}\u{72}\u{65}\u{61}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{31}\u{a}\u{63}\u{72}\u{65}\u{61}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{32}\u{a}\u{32}\u{a}\u{63}\u{72}\u{65}\u{61}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{33}\u{a}\u{6e}\u{69}\u{6c}\u{a}\u{31}\u{a}")
prepfile("\u{70}\u{72}\u{69}\u{6e}\u{74}\u{28}\u{28}\u{7b}\u{2e}\u{2e}\u{2e}\u{7d}\u{29}\u{5b}\u{33}\u{30}\u{5d}\u{29}")
RUN("\u{6c}\u{75}\u{61}\u{20}\u{25}\u{73}\u{20}\u{25}\u{73}\u{20}\u{3e}\u{20}\u{25}\u{73}",prog,string.rep("\u{20}\u{61}",30),out)
RUN("\u{6c}\u{75}\u{61}\u{20}\u{25}\u{73}\u{20}\u{25}\u{73}\u{20}\u{3e}\u{20}\u{25}\u{73}",prog,string.rep("\u{20}\u{61}",0x1e),out)
checkout("\u{61}\u{a}")
RUN("\u{6c}\u{75}\u{61}\u{20}\u{22}\u{2d}\u{65}\u{70}\u{72}\u{69}\u{6e}\u{74}\u{28}\u{31}\u{29}\u{22}\u{20}\u{2d}\u{65}\u{61}\u{3d}\u{33}\u{20}\u{2d}\u{65}\u{20}\u{22}\u{70}\u{72}\u{69}\u{6e}\u{74}\u{28}\u{61}\u{29}\u{22}\u{20}\u{3e}\u{20}\u{25}\u{73}",out)
checkout("\u{31}\u{a}\u{33}\u{a}")
@ -204,7 +204,7 @@ prompt="\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{20}\u{43}\u{20}\u{3d}\u{20}\u{30}\u{3b}
prepfile("\u{20}\u{2d}\u{2d}\u{a}\u{61}\u{20}\u{3d}\u{20}\u{32}\u{a}")
RUN("\u{6c}\u{75}\u{61}\u{20}\u{2d}\u{65}\u{20}\u{22}\u{25}\u{73}\u{22}\u{20}\u{2d}\u{69}\u{20}\u{3c}\u{20}\u{25}\u{73}\u{20}\u{3e}\u{20}\u{25}\u{73}",prompt,prog,out)
local t = getoutput()
assert(string.find(t,"\u{31}\u{20}\u{2d}\u{2d}\u{a}\u{32}\u{61}\u{20}\u{3d}\u{20}\u{32}\u{a}\u{33}\u{a}",1,true))
assert(string.find(t,"\u{31}\u{20}\u{2d}\u{2d}\u{a}\u{32}\u{61}\u{20}\u{3d}\u{20}\u{32}\u{a}\u{33}\u{a}",0x1,true))
prepfile("\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{20}\u{22}\u{64}\u{65}\u{62}\u{75}\u{67}\u{22}\u{a}\u{6d}\u{20}\u{3d}\u{20}\u{7b}\u{78}\u{3d}\u{30}\u{7d}\u{a}\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{6d}\u{2c}\u{20}\u{7b}\u{5f}\u{5f}\u{74}\u{6f}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{20}\u{3d}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{28}\u{78}\u{29}\u{a}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{74}\u{6f}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\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{34}\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{2b}\u{20}\u{78}\u{2e}\u{78}\u{29}\u{a}\u{65}\u{6e}\u{64}\u{7d}\u{29}\u{a}\u{65}\u{72}\u{72}\u{6f}\u{72}\u{28}\u{6d}\u{29}\u{a}")
NoRun(progname .. "\u{3a}\u{20}\u{36}\u{a}","\u{6c}\u{75}\u{61}\u{20}\u{25}\u{73}",prog)
prepfile("\u{65}\u{72}\u{72}\u{6f}\u{72}\u{7b}\u{7d}")
@ -297,8 +297,8 @@ print("\u{64}\u{6f}\u{6e}\u{65}")
local f,pid = runback("\u{20}\u{20}\u{20}\u{20}\u{70}\u{72}\u{69}\u{6e}\u{74}\u{28}\u{31}\u{35}\u{29}\u{3b}\u{20}\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{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{31}\u{30}\u{30}\u{30}\u{30}\u{30}\u{29}\u{2c}\u{20}\u{27}\u{2e}\u{2a}\u{62}\u{27}\u{29}")
assert(f:read() == "\u{31}\u{35}")
assert(os.execute("\u{73}\u{6c}\u{65}\u{65}\u{70}\u{20}\u{31}"))
local n = 100
for i = 0, 100
local n = 0x64
for i = 0x0, 0x64
do
if not kill(pid) then
n=i
@ -306,7 +306,7 @@ break
end
end
assert(f:close())
assert(n >= 2)
assert(n >= 0x2)
print(string.format("\u{64}\u{6f}\u{6e}\u{65}\u{20}\u{28}\u{77}\u{69}\u{74}\u{68}\u{20}\u{25}\u{64}\u{20}\u{6b}\u{69}\u{6c}\u{6c}\u{73}\u{29}",n))
end
print("\u{4f}\u{4b}")

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -12,25 +12,25 @@ return string.sub(s,i,e)
end
end
local a,b = string.find("","")
assert(a == 1 and b == 0)
assert(a == 0x1 and b == 0x0)
;
a,b=string.find("\u{61}\u{6c}\u{6f}","")
assert(a == 1 and b == 0)
a,b=string.find("\u{61}\u{0}\u{6f}\u{20}\u{61}\u{0}\u{6f}\u{20}\u{61}\u{0}\u{6f}","\u{61}",1)
assert(a == 1 and b == 1)
a,b=string.find("\u{61}\u{0}\u{6f}\u{20}\u{61}\u{0}\u{6f}\u{20}\u{61}\u{0}\u{6f}","\u{61}\u{0}\u{6f}",2)
assert(a == 5 and b == 7)
a,b=string.find("\u{61}\u{0}\u{6f}\u{20}\u{61}\u{0}\u{6f}\u{20}\u{61}\u{0}\u{6f}","\u{61}\u{0}\u{6f}",9)
assert(a == 9 and b == 11)
a,b=string.find("\u{61}\u{0}\u{61}\u{0}\u{61}\u{0}\u{61}\u{0}\u{0}\u{61}\u{62}","\u{0}\u{61}\u{62}",2)
assert(a == 0x1 and b == 0x0)
a,b=string.find("\u{61}\u{0}\u{6f}\u{20}\u{61}\u{0}\u{6f}\u{20}\u{61}\u{0}\u{6f}","\u{61}",0x1)
assert(a == 0x1 and b == 0x1)
a,b=string.find("\u{61}\u{0}\u{6f}\u{20}\u{61}\u{0}\u{6f}\u{20}\u{61}\u{0}\u{6f}","\u{61}\u{0}\u{6f}",0x2)
assert(a == 0x5 and b == 0x7)
a,b=string.find("\u{61}\u{0}\u{6f}\u{20}\u{61}\u{0}\u{6f}\u{20}\u{61}\u{0}\u{6f}","\u{61}\u{0}\u{6f}",0x9)
assert(a == 0x9 and b == 0xb)
a,b=string.find("\u{61}\u{0}\u{61}\u{0}\u{61}\u{0}\u{61}\u{0}\u{0}\u{61}\u{62}","\u{0}\u{61}\u{62}",0x2)
;
assert(a == 9 and b == 11)
assert(a == 0x9 and b == 0xb)
;
a,b=string.find("\u{61}\u{0}\u{61}\u{0}\u{61}\u{0}\u{61}\u{0}\u{0}\u{61}\u{62}","\u{62}")
assert(a == 11 and b == 11)
assert(a == 0xb and b == 0xb)
assert(not string.find("\u{61}\u{0}\u{61}\u{0}\u{61}\u{0}\u{61}\u{0}\u{0}\u{61}\u{62}","\u{62}\u{0}"))
assert(not string.find("","\u{0}"))
assert(string.find("\u{61}\u{6c}\u{6f}\u{31}\u{32}\u{33}\u{61}\u{6c}\u{6f}","\u{31}\u{32}") == 4)
assert(string.find("\u{61}\u{6c}\u{6f}\u{31}\u{32}\u{33}\u{61}\u{6c}\u{6f}","\u{31}\u{32}") == 0x4)
assert(not string.find("\u{61}\u{6c}\u{6f}\u{31}\u{32}\u{33}\u{61}\u{6c}\u{6f}","\u{5e}\u{31}\u{32}"))
assert(string.match("\u{61}\u{61}\u{61}\u{62}","\u{2e}\u{2a}\u{62}") == "\u{61}\u{61}\u{61}\u{62}")
assert(string.match("\u{61}\u{61}\u{61}","\u{2e}\u{2a}\u{61}") == "\u{61}\u{61}\u{61}")
@ -94,12 +94,12 @@ print("\u{2b}")
local function f1
(s,p)
p=string.gsub(p,"\u{25}\u{25}\u{28}\u{5b}\u{30}\u{2d}\u{39}\u{5d}\u{29}",function (s)
return "\u{25}" .. (tonumber(s) + 1)
return "\u{25}" .. (tonumber(s) + 0x1)
end)
p=string.gsub(p,"\u{5e}\u{28}\u{5e}\u{3f}\u{29}","\u{25}\u{31}\u{28}\u{29}",1)
p=string.gsub(p,"\u{28}\u{24}\u{3f}\u{29}\u{24}","\u{28}\u{29}\u{25}\u{31}",1)
p=string.gsub(p,"\u{5e}\u{28}\u{5e}\u{3f}\u{29}","\u{25}\u{31}\u{28}\u{29}",0x1)
p=string.gsub(p,"\u{28}\u{24}\u{3f}\u{29}\u{24}","\u{28}\u{29}\u{25}\u{31}",0x1)
local t = {string.match(s,p)}
return string.sub(s,t[1],t[# t] - 1)
return string.sub(s,t[0x1],t[# t] - 0x1)
end
assert(f1("\u{61}\u{6c}\u{6f}\u{20}\u{61}\u{6c}\u{78}\u{20}\u{31}\u{32}\u{33}\u{20}\u{62}\u{0}\u{6f}\u{20}\u{62}\u{0}\u{6f}","\u{28}\u{2e}\u{2e}\u{2a}\u{29}\u{20}\u{25}\u{31}") == "\u{62}\u{0}\u{6f}\u{20}\u{62}\u{0}\u{6f}")
assert(f1("\u{61}\u{78}\u{7a}\u{31}\u{32}\u{33}\u{3d}\u{20}\u{34}\u{3d}\u{20}\u{34}\u{20}\u{33}\u{34}","\u{28}\u{2e}\u{2b}\u{29}\u{3d}\u{28}\u{2e}\u{2a}\u{29}\u{3d}\u{25}\u{32}\u{20}\u{25}\u{31}") == "\u{33}\u{3d}\u{20}\u{34}\u{3d}\u{20}\u{34}\u{20}\u{33}")
@ -108,12 +108,12 @@ assert(not string.match("\u{3d}\u{3d}\u{3d}\u{3d}\u{3d}\u{3d}\u{3d}\u{3d}\u{3d}\
local function range
(i,j)
if i <= j then
return i,range(i + 1,j)
return i,range(i + 0x1,j)
end
end
local abc = string.char(range(0,127)) .. string.char(range(128,255))
local abc = string.char(range(0x0,0x7f)) .. string.char(range(0x80,0xff))
;
assert(string.len(abc) == 256)
assert(string.len(abc) == 0x100)
local function strset
(p)
local res = {["\u{73}"] = ""}
@ -123,7 +123,7 @@ end)
return res.s
end
;
assert(string.len(strset("\u{5b}\u{c8}\u{2d}\u{d2}\u{5d}")) == 11)
assert(string.len(strset("\u{5b}\u{c8}\u{2d}\u{d2}\u{5d}")) == 0xb)
assert(strset("\u{5b}\u{61}\u{2d}\u{7a}\u{5d}") == "\u{61}\u{62}\u{63}\u{64}\u{65}\u{66}\u{67}\u{68}\u{69}\u{6a}\u{6b}\u{6c}\u{6d}\u{6e}\u{6f}\u{70}\u{71}\u{72}\u{73}\u{74}\u{75}\u{76}\u{77}\u{78}\u{79}\u{7a}")
assert(strset("\u{5b}\u{61}\u{2d}\u{7a}\u{25}\u{64}\u{5d}") == strset("\u{5b}\u{25}\u{64}\u{61}\u{2d}\u{75}\u{75}\u{2d}\u{7a}\u{5d}"))
assert(strset("\u{5b}\u{61}\u{2d}\u{5d}") == "\u{2d}\u{61}")
@ -139,11 +139,11 @@ assert(string.match("\u{61}\u{6c}\u{6f}\u{20}\u{78}\u{79}\u{7a}\u{4b}","\u{28}\u
assert(string.match("\u{32}\u{35}\u{34}\u{20}\u{4b}","\u{28}\u{25}\u{64}\u{2a}\u{29}\u{4b}") == "")
assert(string.match("\u{61}\u{6c}\u{6f}\u{20}","\u{28}\u{25}\u{77}\u{2a}\u{29}\u{24}") == "")
assert(not string.match("\u{61}\u{6c}\u{6f}\u{20}","\u{28}\u{25}\u{77}\u{2b}\u{29}\u{24}"))
assert(string.find("\u{28}\u{c3}\u{a1}\u{6c}\u{6f}\u{29}","\u{25}\u{28}\u{c3}\u{a1}") == 1)
assert(string.find("\u{28}\u{c3}\u{a1}\u{6c}\u{6f}\u{29}","\u{25}\u{28}\u{c3}\u{a1}") == 0x1)
local a,b,c,d,e = string.match("\u{c3}\u{a2}\u{6c}\u{6f}\u{20}\u{61}\u{6c}\u{6f}",PU("\u{5e}\u{28}\u{28}\u{28}\u{2e}\u{29}\u{2e}\u{29}\u{2e}\u{20}\u{28}\u{25}\u{77}\u{2a}\u{29}\u{29}\u{24}"))
assert(a == "\u{c3}\u{a2}\u{6c}\u{6f}\u{20}\u{61}\u{6c}\u{6f}" and b == "\u{c3}\u{a2}\u{6c}" and c == "\u{c3}\u{a2}" and d == "\u{61}\u{6c}\u{6f}" and e == nil)
a,b,c,d=string.match("\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}","\u{28}\u{2e}\u{2b}\u{28}\u{2e}\u{3f}\u{29}\u{28}\u{29}\u{29}")
assert(a == "\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}" and b == "" and c == 11 and d == nil)
assert(a == "\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}" and b == "" and c == 0xb and d == nil)
print("\u{2b}")
assert(string.gsub("\u{c3}\u{bc}\u{6c}\u{6f}\u{20}\u{c3}\u{bc}\u{6c}\u{6f}","\u{c3}\u{bc}","\u{78}") == "\u{78}\u{6c}\u{6f}\u{20}\u{78}\u{6c}\u{6f}")
assert(string.gsub("\u{61}\u{6c}\u{6f}\u{20}\u{c3}\u{ba}\u{6c}\u{6f}\u{20}\u{20}","\u{20}\u{2b}\u{24}","") == "\u{61}\u{6c}\u{6f}\u{20}\u{c3}\u{ba}\u{6c}\u{6f}")
@ -151,9 +151,9 @@ assert(string.gsub("\u{20}\u{20}\u{61}\u{6c}\u{6f}\u{20}\u{61}\u{6c}\u{6f}\u{20}
assert(string.gsub("\u{61}\u{6c}\u{6f}\u{20}\u{20}\u{61}\u{6c}\u{6f}\u{20}\u{20}\u{a}\u{20}\u{31}\u{32}\u{33}\u{a}\u{20}","\u{25}\u{73}\u{2b}","\u{20}") == "\u{61}\u{6c}\u{6f}\u{20}\u{61}\u{6c}\u{6f}\u{20}\u{31}\u{32}\u{33}\u{20}")
local t = "\u{61}\u{62}\u{c3}\u{a7}\u{20}\u{64}"
a,b=string.gsub(t,PU("\u{28}\u{2e}\u{29}"),"\u{25}\u{31}\u{40}")
assert(a == "\u{61}\u{40}\u{62}\u{40}\u{c3}\u{a7}\u{40}\u{20}\u{40}\u{64}\u{40}" and b == 5)
a,b=string.gsub("\u{61}\u{62}\u{c3}\u{a7}\u{64}",PU("\u{28}\u{2e}\u{29}"),"\u{25}\u{30}\u{40}",2)
assert(a == "\u{61}\u{40}\u{62}\u{40}\u{c3}\u{a7}\u{64}" and b == 2)
assert(a == "\u{61}\u{40}\u{62}\u{40}\u{c3}\u{a7}\u{40}\u{20}\u{40}\u{64}\u{40}" and b == 0x5)
a,b=string.gsub("\u{61}\u{62}\u{c3}\u{a7}\u{64}",PU("\u{28}\u{2e}\u{29}"),"\u{25}\u{30}\u{40}",0x2)
assert(a == "\u{61}\u{40}\u{62}\u{40}\u{c3}\u{a7}\u{64}" and b == 0x2)
assert(string.gsub("\u{61}\u{6c}\u{6f}\u{20}\u{61}\u{6c}\u{6f}","\u{28}\u{29}\u{5b}\u{61}\u{6c}\u{5d}","\u{25}\u{31}") == "\u{31}\u{32}\u{6f}\u{20}\u{35}\u{36}\u{6f}")
assert(string.gsub("\u{61}\u{62}\u{63}\u{3d}\u{78}\u{79}\u{7a}","\u{28}\u{25}\u{77}\u{2a}\u{29}\u{28}\u{25}\u{70}\u{29}\u{28}\u{25}\u{77}\u{2b}\u{29}","\u{25}\u{33}\u{25}\u{32}\u{25}\u{31}\u{2d}\u{25}\u{30}") == "\u{78}\u{79}\u{7a}\u{3d}\u{61}\u{62}\u{63}\u{2d}\u{61}\u{62}\u{63}\u{3d}\u{78}\u{79}\u{7a}")
assert(string.gsub("\u{61}\u{62}\u{63}","\u{25}\u{77}","\u{25}\u{31}\u{25}\u{30}") == "\u{61}\u{61}\u{62}\u{62}\u{63}\u{63}")
@ -166,10 +166,10 @@ do
assert(string.gsub("\u{61}\u{20}\u{62}\u{20}\u{63}\u{64}","\u{20}\u{2a}","\u{2d}") == "\u{2d}\u{61}\u{2d}\u{62}\u{2d}\u{63}\u{2d}\u{64}\u{2d}")
local res = ""
local sub = "\u{61}\u{20}\u{20}\u{a}\u{62}\u{63}\u{9}\u{9}\u{64}"
local i = 1
local i = 0x1
for p,e in string.gmatch(sub,"\u{28}\u{29}\u{25}\u{73}\u{2a}\u{28}\u{29}")
do
res=res .. string.sub(sub,i,p - 1) .. "\u{2d}"
res=res .. string.sub(sub,i,p - 0x1) .. "\u{2d}"
i=e
end
assert(res == "\u{2d}\u{61}\u{2d}\u{62}\u{2d}\u{63}\u{2d}\u{64}\u{2d}")
@ -206,7 +206,7 @@ assert(string.len(w) == b - a)
t[a]=b - a
;
end)
assert(s == r and t[1] == 1 and t[3] == 3 and t[7] == 4 and t[13] == 4)
assert(s == r and t[0x1] == 0x1 and t[0x3] == 0x3 and t[0x7] == 0x4 and t[0xd] == 0x4)
local function isbalanced
(s)
return not string.find(string.gsub(s,"\u{25}\u{62}\u{28}\u{29}",""),"\u{5b}\u{28}\u{29}\u{5d}")
@ -214,26 +214,26 @@ end
assert(isbalanced("\u{28}\u{39}\u{20}\u{28}\u{28}\u{38}\u{29}\u{29}\u{28}\u{0}\u{29}\u{20}\u{37}\u{29}\u{20}\u{0}\u{0}\u{20}\u{61}\u{20}\u{62}\u{20}\u{28}\u{29}\u{28}\u{63}\u{29}\u{28}\u{29}\u{20}\u{61}"))
assert(not isbalanced("\u{28}\u{39}\u{20}\u{28}\u{28}\u{38}\u{29}\u{20}\u{37}\u{29}\u{20}\u{61}\u{20}\u{62}\u{20}\u{28}\u{0}\u{20}\u{63}\u{29}\u{20}\u{61}"))
assert(string.gsub("\u{61}\u{6c}\u{6f}\u{20}\u{27}\u{6f}\u{69}\u{27}\u{20}\u{61}\u{6c}\u{6f}","\u{25}\u{62}\u{27}\u{27}","\u{22}") == "\u{61}\u{6c}\u{6f}\u{20}\u{22}\u{20}\u{61}\u{6c}\u{6f}")
local t = {"\u{61}\u{70}\u{70}\u{6c}\u{65}","\u{6f}\u{72}\u{61}\u{6e}\u{67}\u{65}","\u{6c}\u{69}\u{6d}\u{65}",["\u{6e}"] = 0}
local t = {"\u{61}\u{70}\u{70}\u{6c}\u{65}","\u{6f}\u{72}\u{61}\u{6e}\u{67}\u{65}","\u{6c}\u{69}\u{6d}\u{65}",["\u{6e}"] = 0x0}
assert(string.gsub("\u{78}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{78}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{78}","\u{78}",function ()
t.n=t.n + 1
t.n=t.n + 0x1
;
return t[t.n]
end) == "\u{61}\u{70}\u{70}\u{6c}\u{65}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{6f}\u{72}\u{61}\u{6e}\u{67}\u{65}\u{20}\u{61}\u{6e}\u{64}\u{20}\u{6c}\u{69}\u{6d}\u{65}")
t={["\u{6e}"] = 0}
t={["\u{6e}"] = 0x0}
string.gsub("\u{66}\u{69}\u{72}\u{73}\u{74}\u{20}\u{73}\u{65}\u{63}\u{6f}\u{6e}\u{64}\u{20}\u{77}\u{6f}\u{72}\u{64}","\u{25}\u{77}\u{25}\u{77}\u{2a}",function (w)
t.n=t.n + 1
t.n=t.n + 0x1
;
t[t.n]=w
end)
assert(t[1] == "\u{66}\u{69}\u{72}\u{73}\u{74}" and t[2] == "\u{73}\u{65}\u{63}\u{6f}\u{6e}\u{64}" and t[3] == "\u{77}\u{6f}\u{72}\u{64}" and t.n == 3)
t={["\u{6e}"] = 0}
assert(t[0x1] == "\u{66}\u{69}\u{72}\u{73}\u{74}" and t[0x2] == "\u{73}\u{65}\u{63}\u{6f}\u{6e}\u{64}" and t[0x3] == "\u{77}\u{6f}\u{72}\u{64}" and t.n == 0x3)
t={["\u{6e}"] = 0x0}
assert(string.gsub("\u{66}\u{69}\u{72}\u{73}\u{74}\u{20}\u{73}\u{65}\u{63}\u{6f}\u{6e}\u{64}\u{20}\u{77}\u{6f}\u{72}\u{64}","\u{25}\u{77}\u{2b}",function (w)
t.n=t.n + 1
t.n=t.n + 0x1
;
t[t.n]=w
end,2) == "\u{66}\u{69}\u{72}\u{73}\u{74}\u{20}\u{73}\u{65}\u{63}\u{6f}\u{6e}\u{64}\u{20}\u{77}\u{6f}\u{72}\u{64}")
assert(t[1] == "\u{66}\u{69}\u{72}\u{73}\u{74}" and t[2] == "\u{73}\u{65}\u{63}\u{6f}\u{6e}\u{64}" and t[3] == undef)
end,0x2) == "\u{66}\u{69}\u{72}\u{73}\u{74}\u{20}\u{73}\u{65}\u{63}\u{6f}\u{6e}\u{64}\u{20}\u{77}\u{6f}\u{72}\u{64}")
assert(t[0x1] == "\u{66}\u{69}\u{72}\u{73}\u{74}" and t[0x2] == "\u{73}\u{65}\u{63}\u{6f}\u{6e}\u{64}" and t[0x3] == undef)
checkerror("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{72}\u{65}\u{70}\u{6c}\u{61}\u{63}\u{65}\u{6d}\u{65}\u{6e}\u{74}\u{20}\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{25}\u{28}\u{61}\u{20}\u{74}\u{61}\u{62}\u{6c}\u{65}\u{25}\u{29}",string.gsub,"\u{61}\u{6c}\u{6f}","\u{2e}",{["\u{61}"] = {}})
checkerror("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{63}\u{61}\u{70}\u{74}\u{75}\u{72}\u{65}\u{20}\u{69}\u{6e}\u{64}\u{65}\u{78}\u{20}\u{25}\u{25}\u{32}",string.gsub,"\u{61}\u{6c}\u{6f}","\u{2e}","\u{25}\u{32}")
checkerror("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{63}\u{61}\u{70}\u{74}\u{75}\u{72}\u{65}\u{20}\u{69}\u{6e}\u{64}\u{65}\u{78}\u{20}\u{25}\u{25}\u{30}",string.gsub,"\u{61}\u{6c}\u{6f}","\u{28}\u{25}\u{30}\u{29}","\u{61}")
@ -241,11 +241,11 @@ checkerror("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{63}\u{61}\u{70}\u
checkerror("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{75}\u{73}\u{65}\u{20}\u{6f}\u{66}\u{20}\u{27}\u{25}\u{25}\u{27}",string.gsub,"\u{61}\u{6c}\u{6f}","\u{2e}","\u{25}\u{78}")
if not _soft then
print("\u{62}\u{69}\u{67}\u{20}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{73}")
local a = string.rep("\u{61}",300000)
local a = string.rep("\u{61}",0x493e0)
assert(string.find(a,"\u{5e}\u{61}\u{2a}\u{2e}\u{3f}\u{24}"))
assert(not string.find(a,"\u{5e}\u{61}\u{2a}\u{2e}\u{3f}\u{62}\u{24}"))
assert(string.find(a,"\u{5e}\u{61}\u{2d}\u{2e}\u{3f}\u{24}"))
a=string.rep("\u{61}",10000) .. string.rep("\u{62}",10000)
a=string.rep("\u{61}",0x2710) .. string.rep("\u{62}",0x2710)
assert(not pcall(string.gsub,a,"\u{62}"))
end
local function rev
@ -267,66 +267,66 @@ setmetatable(t,{["\u{5f}\u{5f}\u{69}\u{6e}\u{64}\u{65}\u{78}"] = function (t,s)
return string.upper(s)
end})
assert(string.gsub("\u{61}\u{20}\u{61}\u{6c}\u{6f}\u{20}\u{62}\u{20}\u{68}\u{69}","\u{25}\u{77}\u{25}\u{77}\u{2b}",t) == "\u{61}\u{20}\u{41}\u{4c}\u{4f}\u{20}\u{62}\u{20}\u{48}\u{49}")
local a = 0
local a = 0x0
for i in string.gmatch("\u{61}\u{62}\u{63}\u{64}\u{65}","\u{28}\u{29}")
do
assert(i == a + 1)
assert(i == a + 0x1)
;
a=i
end
assert(a == 6)
t={["\u{6e}"] = 0}
assert(a == 0x6)
t={["\u{6e}"] = 0x0}
for w in string.gmatch("\u{66}\u{69}\u{72}\u{73}\u{74}\u{20}\u{73}\u{65}\u{63}\u{6f}\u{6e}\u{64}\u{20}\u{77}\u{6f}\u{72}\u{64}","\u{25}\u{77}\u{2b}")
do
t.n=t.n + 1
t.n=t.n + 0x1
;
t[t.n]=w
end
assert(t[1] == "\u{66}\u{69}\u{72}\u{73}\u{74}" and t[2] == "\u{73}\u{65}\u{63}\u{6f}\u{6e}\u{64}" and t[3] == "\u{77}\u{6f}\u{72}\u{64}")
t={3,6,9}
assert(t[0x1] == "\u{66}\u{69}\u{72}\u{73}\u{74}" and t[0x2] == "\u{73}\u{65}\u{63}\u{6f}\u{6e}\u{64}" and t[0x3] == "\u{77}\u{6f}\u{72}\u{64}")
t={0x3,0x6,0x9}
for i in string.gmatch("\u{78}\u{75}\u{78}\u{78}\u{20}\u{75}\u{75}\u{20}\u{70}\u{70}\u{61}\u{72}\u{20}\u{72}","\u{28}\u{29}\u{28}\u{2e}\u{29}\u{25}\u{32}")
do
assert(i == table.remove(t,1))
assert(i == table.remove(t,0x1))
end
assert(# t == 0)
assert(# t == 0x0)
t={}
for i,j in string.gmatch("\u{31}\u{33}\u{20}\u{31}\u{34}\u{20}\u{31}\u{30}\u{20}\u{3d}\u{20}\u{31}\u{31}\u{2c}\u{20}\u{31}\u{35}\u{3d}\u{20}\u{31}\u{36}\u{2c}\u{20}\u{32}\u{32}\u{3d}\u{32}\u{33}","\u{28}\u{25}\u{64}\u{2b}\u{29}\u{25}\u{73}\u{2a}\u{3d}\u{25}\u{73}\u{2a}\u{28}\u{25}\u{64}\u{2b}\u{29}")
do
t[tonumber(i)]=tonumber(j)
end
a=0
a=0x0
for k,v in pairs(t)
do
assert(k + 1 == v + 0)
assert(k + 0x1 == v + 0x0)
;
a=a + 1
a=a + 0x1
end
assert(a == 3)
assert(a == 0x3)
do
local s = 0
for k in string.gmatch("\u{31}\u{30}\u{20}\u{32}\u{30}\u{20}\u{33}\u{30}","\u{25}\u{64}\u{2b}",3)
local s = 0x0
for k in string.gmatch("\u{31}\u{30}\u{20}\u{32}\u{30}\u{20}\u{33}\u{30}","\u{25}\u{64}\u{2b}",0x3)
do
s=s + tonumber(k)
end
assert(s == 50)
s=0
for k in string.gmatch("\u{31}\u{31}\u{20}\u{32}\u{31}\u{20}\u{33}\u{31}","\u{25}\u{64}\u{2b}",- 4)
assert(s == 0x32)
s=0x0
for k in string.gmatch("\u{31}\u{31}\u{20}\u{32}\u{31}\u{20}\u{33}\u{31}","\u{25}\u{64}\u{2b}",- 0x4)
do
s=s + tonumber(k)
end
assert(s == 32)
s=0
for k in string.gmatch("\u{31}\u{31}\u{20}\u{32}\u{31}\u{20}\u{33}\u{31}","\u{25}\u{77}\u{2a}",9)
assert(s == 0x20)
s=0x0
for k in string.gmatch("\u{31}\u{31}\u{20}\u{32}\u{31}\u{20}\u{33}\u{31}","\u{25}\u{77}\u{2a}",0x9)
do
s=s + 1
s=s + 0x1
end
assert(s == 1)
s=0
for k in string.gmatch("\u{31}\u{31}\u{20}\u{32}\u{31}\u{20}\u{33}\u{31}","\u{25}\u{77}\u{2a}",10)
assert(s == 0x1)
s=0x0
for k in string.gmatch("\u{31}\u{31}\u{20}\u{32}\u{31}\u{20}\u{33}\u{31}","\u{25}\u{77}\u{2a}",0xa)
do
s=s + 1
s=s + 0x1
end
assert(s == 0)
assert(s == 0x0)
end
assert(string.gsub("\u{61}\u{61}\u{61}\u{20}\u{61}\u{61}\u{20}\u{61}\u{20}\u{61}\u{61}\u{61}\u{20}\u{61}","\u{25}\u{66}\u{5b}\u{25}\u{77}\u{5d}\u{61}","\u{78}") == "\u{78}\u{61}\u{61}\u{20}\u{78}\u{61}\u{20}\u{78}\u{20}\u{78}\u{61}\u{61}\u{20}\u{78}")
assert(string.gsub("\u{5b}\u{5b}\u{5d}\u{5d}\u{20}\u{5b}\u{5d}\u{5b}\u{5d}\u{20}\u{5b}\u{5b}\u{5b}\u{5b}","\u{25}\u{66}\u{5b}\u{5b}\u{5d}\u{2e}","\u{78}") == "\u{78}\u{5b}\u{5d}\u{5d}\u{20}\u{78}\u{5d}\u{78}\u{5d}\u{20}\u{78}\u{5b}\u{5b}\u{5b}")
@ -334,23 +334,23 @@ assert(string.gsub("\u{30}\u{31}\u{61}\u{62}\u{63}\u{34}\u{35}\u{64}\u{65}\u{33}
assert(string.gsub("\u{30}\u{31}\u{61}\u{62}\u{63}\u{34}\u{35}\u{20}\u{64}\u{65}\u{33}\u{78}","\u{25}\u{66}\u{5b}\u{25}\u{44}\u{5d}\u{25}\u{77}","\u{2e}") == "\u{30}\u{31}\u{2e}\u{62}\u{63}\u{34}\u{35}\u{20}\u{64}\u{65}\u{33}\u{2e}")
assert(string.gsub("\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}","\u{25}\u{66}\u{5b}\u{1}\u{2d}\u{ff}\u{5d}\u{25}\u{77}","\u{2e}") == "\u{2e}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}")
assert(string.gsub("\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}","\u{25}\u{66}\u{5b}\u{5e}\u{1}\u{2d}\u{ff}\u{5d}","\u{2e}") == "\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{2e}")
assert(string.find("\u{61}","\u{25}\u{66}\u{5b}\u{61}\u{5d}") == 1)
assert(string.find("\u{61}","\u{25}\u{66}\u{5b}\u{5e}\u{25}\u{7a}\u{5d}") == 1)
assert(string.find("\u{61}","\u{25}\u{66}\u{5b}\u{5e}\u{25}\u{6c}\u{5d}") == 2)
assert(string.find("\u{61}\u{62}\u{61}","\u{25}\u{66}\u{5b}\u{61}\u{25}\u{7a}\u{5d}") == 3)
assert(string.find("\u{61}\u{62}\u{61}","\u{25}\u{66}\u{5b}\u{25}\u{7a}\u{5d}") == 4)
assert(string.find("\u{61}","\u{25}\u{66}\u{5b}\u{61}\u{5d}") == 0x1)
assert(string.find("\u{61}","\u{25}\u{66}\u{5b}\u{5e}\u{25}\u{7a}\u{5d}") == 0x1)
assert(string.find("\u{61}","\u{25}\u{66}\u{5b}\u{5e}\u{25}\u{6c}\u{5d}") == 0x2)
assert(string.find("\u{61}\u{62}\u{61}","\u{25}\u{66}\u{5b}\u{61}\u{25}\u{7a}\u{5d}") == 0x3)
assert(string.find("\u{61}\u{62}\u{61}","\u{25}\u{66}\u{5b}\u{25}\u{7a}\u{5d}") == 0x4)
assert(not string.find("\u{61}\u{62}\u{61}","\u{25}\u{66}\u{5b}\u{25}\u{6c}\u{25}\u{7a}\u{5d}"))
assert(not string.find("\u{61}\u{62}\u{61}","\u{25}\u{66}\u{5b}\u{5e}\u{25}\u{6c}\u{25}\u{7a}\u{5d}"))
local i,e = string.find("\u{20}\u{61}\u{6c}\u{6f}\u{20}\u{61}\u{61}\u{6c}\u{6f}\u{20}\u{61}\u{6c}\u{6c}\u{6f}","\u{25}\u{66}\u{5b}\u{25}\u{53}\u{5d}\u{2e}\u{2d}\u{25}\u{66}\u{5b}\u{25}\u{73}\u{5d}\u{2e}\u{2d}\u{25}\u{66}\u{5b}\u{25}\u{53}\u{5d}")
assert(i == 2 and e == 5)
assert(i == 0x2 and e == 0x5)
local k = string.match("\u{20}\u{61}\u{6c}\u{6f}\u{20}\u{61}\u{61}\u{6c}\u{6f}\u{20}\u{61}\u{6c}\u{6c}\u{6f}","\u{25}\u{66}\u{5b}\u{25}\u{53}\u{5d}\u{28}\u{2e}\u{2d}\u{25}\u{66}\u{5b}\u{25}\u{73}\u{5d}\u{2e}\u{2d}\u{25}\u{66}\u{5b}\u{25}\u{53}\u{5d}\u{29}")
assert(k == "\u{61}\u{6c}\u{6f}\u{20}")
local a = {1,5,9,14,17}
local a = {0x1,0x5,0x9,0xe,0x11}
for k in string.gmatch("\u{61}\u{6c}\u{6f}\u{20}\u{61}\u{6c}\u{6f}\u{20}\u{74}\u{68}\u{30}\u{32}\u{20}\u{69}\u{73}\u{20}\u{31}\u{68}\u{61}\u{74}","\u{28}\u{29}\u{25}\u{66}\u{5b}\u{25}\u{77}\u{25}\u{64}\u{5d}")
do
assert(table.remove(a,1) == k)
assert(table.remove(a,0x1) == k)
end
assert(# a == 0)
assert(# a == 0x0)
local function malform
(p,m)
m=m or "\u{6d}\u{61}\u{6c}\u{66}\u{6f}\u{72}\u{6d}\u{65}\u{64}"
@ -370,35 +370,35 @@ malform("\u{25}")
malform("\u{25}\u{66}","\u{6d}\u{69}\u{73}\u{73}\u{69}\u{6e}\u{67}")
assert(string.match("\u{61}\u{62}\u{0}\u{1}\u{2}\u{63}","\u{5b}\u{0}\u{2d}\u{2}\u{5d}\u{2b}") == "\u{0}\u{1}\u{2}")
assert(string.match("\u{61}\u{62}\u{0}\u{1}\u{2}\u{63}","\u{5b}\u{0}\u{2d}\u{0}\u{5d}\u{2b}") == "\u{0}")
assert(string.find("\u{62}\u{24}\u{61}","\u{24}\u{0}\u{3f}") == 2)
assert(string.find("\u{61}\u{62}\u{63}\u{0}\u{65}\u{66}\u{67}","\u{25}\u{0}") == 4)
assert(string.find("\u{62}\u{24}\u{61}","\u{24}\u{0}\u{3f}") == 0x2)
assert(string.find("\u{61}\u{62}\u{63}\u{0}\u{65}\u{66}\u{67}","\u{25}\u{0}") == 0x4)
assert(string.match("\u{61}\u{62}\u{63}\u{0}\u{65}\u{66}\u{67}\u{0}\u{1}\u{65}\u{1}\u{67}","\u{25}\u{62}\u{0}\u{1}") == "\u{0}\u{65}\u{66}\u{67}\u{0}\u{1}\u{65}\u{1}")
assert(string.match("\u{61}\u{62}\u{63}\u{0}\u{0}\u{0}","\u{25}\u{0}\u{2b}") == "\u{0}\u{0}\u{0}")
assert(string.match("\u{61}\u{62}\u{63}\u{0}\u{0}\u{0}","\u{25}\u{0}\u{25}\u{0}\u{3f}") == "\u{0}\u{0}")
assert(string.find("\u{61}\u{62}\u{63}\u{0}\u{0}","\u{0}\u{2e}") == 4)
assert(string.find("\u{61}\u{62}\u{63}\u{78}\u{0}\u{0}\u{61}\u{62}\u{63}\u{0}\u{61}\u{62}\u{63}","\u{78}\u{0}\u{0}\u{61}\u{62}\u{63}\u{0}\u{61}\u{2e}") == 4)
assert(string.find("\u{61}\u{62}\u{63}\u{0}\u{0}","\u{0}\u{2e}") == 0x4)
assert(string.find("\u{61}\u{62}\u{63}\u{78}\u{0}\u{0}\u{61}\u{62}\u{63}\u{0}\u{61}\u{62}\u{63}","\u{78}\u{0}\u{0}\u{61}\u{62}\u{63}\u{0}\u{61}\u{2e}") == 0x4)
do
local s = string.rep("\u{61}",100)
local s = string.rep("\u{61}",0x64)
local r = string.gsub(s,"\u{62}","\u{63}")
assert(string.format("\u{25}\u{70}",s) == string.format("\u{25}\u{70}",r))
r=string.gsub(s,"\u{2e}",{["\u{78}"] = "\u{79}"})
assert(string.format("\u{25}\u{70}",s) == string.format("\u{25}\u{70}",r))
local count = 0
local count = 0x0
r=string.gsub(s,"\u{2e}",function (x)
assert(x == "\u{61}")
count=count + 1
count=count + 0x1
return nil
end)
r=string.gsub(r,"\u{2e}",{["\u{62}"] = "\u{78}"})
assert(count == 100)
assert(count == 0x64)
assert(string.format("\u{25}\u{70}",s) == string.format("\u{25}\u{70}",r))
count=0
count=0x0
r=string.gsub(s,"\u{2e}",function (x)
assert(x == "\u{61}")
count=count + 1
count=count + 0x1
return x
end)
assert(count == 100)
assert(count == 0x64)
assert(r == s and string.format("\u{25}\u{70}",s) ~= string.format("\u{25}\u{70}",r))
end
print("\u{4f}\u{4b}")

View File

@ -8,70 +8,70 @@ local function checkerror
local s,err = pcall(f,...)
assert(not s and string.find(err,msg))
end
checkerror("\u{77}\u{72}\u{6f}\u{6e}\u{67}\u{20}\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}\u{20}\u{6f}\u{66}\u{20}\u{61}\u{72}\u{67}\u{75}\u{6d}\u{65}\u{6e}\u{74}\u{73}",table.insert,{},2,3,4)
checkerror("\u{77}\u{72}\u{6f}\u{6e}\u{67}\u{20}\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}\u{20}\u{6f}\u{66}\u{20}\u{61}\u{72}\u{67}\u{75}\u{6d}\u{65}\u{6e}\u{74}\u{73}",table.insert,{},0x2,0x3,0x4)
local x,y,z,a,n
a={}
;
local lim = _soft and 200 or 2000
for i = 1, lim
local lim = _soft and 0xc8 or 0x7d0
for i = 0x1, lim
do
a[i]=i
end
assert(select(lim,unpack(a)) == lim and select("\u{23}",unpack(a)) == lim)
x=unpack(a)
assert(x == 1)
assert(x == 0x1)
x={unpack(a)}
assert(# x == lim and x[1] == 1 and x[lim] == lim)
x={unpack(a,lim - 2)}
assert(# x == 3 and x[1] == lim - 2 and x[3] == lim)
x={unpack(a,10,6)}
assert(# x == lim and x[0x1] == 0x1 and x[lim] == lim)
x={unpack(a,lim - 0x2)}
assert(# x == 0x3 and x[0x1] == lim - 0x2 and x[0x3] == lim)
x={unpack(a,0xa,0x6)}
assert(next(x) == nil)
x={unpack(a,11,10)}
x={unpack(a,0xb,0xa)}
assert(next(x) == nil)
x,y=unpack(a,10,10)
assert(x == 10 and y == nil)
x,y,z=unpack(a,10,11)
assert(x == 10 and y == 11 and z == nil)
a,x=unpack({1})
assert(a == 1 and x == nil)
a,x=unpack({1,2},1,1)
assert(a == 1 and x == nil)
x,y=unpack(a,0xa,0xa)
assert(x == 0xa and y == nil)
x,y,z=unpack(a,0xa,0xb)
assert(x == 0xa and y == 0xb and z == nil)
a,x=unpack({0x1})
assert(a == 0x1 and x == nil)
a,x=unpack({0x1,0x2},0x1,0x1)
assert(a == 0x1 and x == nil)
do
local maxi = (1 << 31) - 1
local mini = - (1 << 31)
checkerror("\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}",unpack,{},0,maxi)
checkerror("\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}",unpack,{},1,maxi)
checkerror("\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}",unpack,{},0,maxI)
checkerror("\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}",unpack,{},1,maxI)
local maxi = (0x1 << 0x1f) - 0x1
local mini = - (0x1 << 0x1f)
checkerror("\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}",unpack,{},0x0,maxi)
checkerror("\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}",unpack,{},0x1,maxi)
checkerror("\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}",unpack,{},0x0,maxI)
checkerror("\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}",unpack,{},0x1,maxI)
checkerror("\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}",unpack,{},mini,maxi)
checkerror("\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}",unpack,{},- maxi,maxi)
checkerror("\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}",unpack,{},minI,maxI)
unpack({},maxi,0)
unpack({},maxi,1)
unpack({},maxi,0x0)
unpack({},maxi,0x1)
unpack({},maxI,minI)
pcall(unpack,{},1,maxi + 1)
local a,b = unpack({[maxi] = 20},maxi,maxi)
assert(a == 20 and b == nil)
a,b=unpack({[maxi] = 20},maxi - 1,maxi)
assert(a == nil and b == 20)
local t = {[maxI - 1] = 12,[maxI] = 23}
a,b=unpack(t,maxI - 1,maxI)
pcall(unpack,{},0x1,maxi + 0x1)
local a,b = unpack({[maxi] = 0x14},maxi,maxi)
assert(a == 0x14 and b == nil)
a,b=unpack({[maxi] = 0x14},maxi - 0x1,maxi)
assert(a == nil and b == 0x14)
local t = {[maxI - 0x1] = 0xc,[maxI] = 0x17}
a,b=unpack(t,maxI - 0x1,maxI)
;
assert(a == 12 and b == 23)
assert(a == 0xc and b == 0x17)
a,b=unpack(t,maxI,maxI)
;
assert(a == 23 and b == nil)
a,b=unpack(t,maxI,maxI - 1)
assert(a == 0x17 and b == nil)
a,b=unpack(t,maxI,maxI - 0x1)
;
assert(a == nil and b == nil)
t={[minI] = 12.3,[minI + 1] = 23.5}
a,b=unpack(t,minI,minI + 1)
t={[minI] = 12.3,[minI + 0x1] = 23.5}
a,b=unpack(t,minI,minI + 0x1)
;
assert(a == 12.3 and b == 23.5)
a,b=unpack(t,minI,minI)
;
assert(a == 12.3 and b == nil)
a,b=unpack(t,minI + 1,minI)
a,b=unpack(t,minI + 0x1,minI)
;
assert(a == nil and b == nil)
end
@ -80,17 +80,17 @@ local t = setmetatable({},{["\u{5f}\u{5f}\u{6c}\u{65}\u{6e}"] = function ()
return "\u{61}\u{62}\u{63}"
end})
assert(# t == "\u{61}\u{62}\u{63}")
checkerror("\u{6f}\u{62}\u{6a}\u{65}\u{63}\u{74}\u{20}\u{6c}\u{65}\u{6e}\u{67}\u{74}\u{68}\u{20}\u{69}\u{73}\u{20}\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}",table.insert,t,1)
checkerror("\u{6f}\u{62}\u{6a}\u{65}\u{63}\u{74}\u{20}\u{6c}\u{65}\u{6e}\u{67}\u{74}\u{68}\u{20}\u{69}\u{73}\u{20}\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}",table.insert,t,0x1)
end
print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{70}\u{61}\u{63}\u{6b}")
a=table.pack()
assert(a[1] == undef and a.n == 0)
assert(a[0x1] == undef and a.n == 0x0)
a=table.pack(table)
assert(a[1] == table and a.n == 1)
assert(a[0x1] == table and a.n == 0x1)
a=table.pack(nil,nil,nil,nil)
assert(a[1] == nil and a.n == 4)
assert(a[0x1] == nil and a.n == 0x4)
do
checkerror("\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}",table.move,1,2,3,4)
checkerror("\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}",table.move,0x1,0x2,0x3,0x4)
local function eqT
(a,b)
for k,v in pairs(a)
@ -102,45 +102,45 @@ do
assert(a[k] == v)
end
end
local a = table.move({10,20,30},1,3,2)
eqT(a,{10,10,20,30})
a=table.move({10,20,30},1,3,3)
eqT(a,{10,20,10,20,30})
a={10,20,30,40}
table.move(a,1,4,2,a)
eqT(a,{10,10,20,30,40})
a=table.move({10,20,30},2,3,1)
eqT(a,{20,30,30})
local a = table.move({0xa,0x14,0x1e},0x1,0x3,0x2)
eqT(a,{0xa,0xa,0x14,0x1e})
a=table.move({0xa,0x14,0x1e},0x1,0x3,0x3)
eqT(a,{0xa,0x14,0xa,0x14,0x1e})
a={0xa,0x14,0x1e,0x28}
table.move(a,0x1,0x4,0x2,a)
eqT(a,{0xa,0xa,0x14,0x1e,0x28})
a=table.move({0xa,0x14,0x1e},0x2,0x3,0x1)
eqT(a,{0x14,0x1e,0x1e})
a={}
assert(table.move({10,20,30},1,3,1,a) == a)
eqT(a,{10,20,30})
assert(table.move({0xa,0x14,0x1e},0x1,0x3,0x1,a) == a)
eqT(a,{0xa,0x14,0x1e})
a={}
assert(table.move({10,20,30},1,0,3,a) == a)
assert(table.move({0xa,0x14,0x1e},0x1,0x0,0x3,a) == a)
eqT(a,{})
a=table.move({10,20,30},1,10,1)
eqT(a,{10,20,30})
a=table.move({[maxI - 2] = 1,[maxI - 1] = 2,[maxI] = 3},maxI - 2,maxI,- 10,{})
eqT(a,{[- 10] = 1,[- 9] = 2,[- 8] = 3})
a=table.move({[minI] = 1,[minI + 1] = 2,[minI + 2] = 3},minI,minI + 2,- 10,{})
eqT(a,{[- 10] = 1,[- 9] = 2,[- 8] = 3})
a=table.move({45},1,1,maxI)
eqT(a,{45,[maxI] = 45})
a=table.move({[maxI] = 100},maxI,maxI,minI)
eqT(a,{[minI] = 100,[maxI] = 100})
a=table.move({[minI] = 100},minI,minI,maxI)
eqT(a,{[minI] = 100,[maxI] = 100})
a=table.move({0xa,0x14,0x1e},0x1,0xa,0x1)
eqT(a,{0xa,0x14,0x1e})
a=table.move({[maxI - 0x2] = 0x1,[maxI - 0x1] = 0x2,[maxI] = 0x3},maxI - 0x2,maxI,- 0xa,{})
eqT(a,{[- 0xa] = 0x1,[- 0x9] = 0x2,[- 0x8] = 0x3})
a=table.move({[minI] = 0x1,[minI + 0x1] = 0x2,[minI + 0x2] = 0x3},minI,minI + 0x2,- 0xa,{})
eqT(a,{[- 0xa] = 0x1,[- 0x9] = 0x2,[- 0x8] = 0x3})
a=table.move({0x2d},0x1,0x1,maxI)
eqT(a,{0x2d,[maxI] = 0x2d})
a=table.move({[maxI] = 0x64},maxI,maxI,minI)
eqT(a,{[minI] = 0x64,[maxI] = 0x64})
a=table.move({[minI] = 0x64},minI,minI,maxI)
eqT(a,{[minI] = 0x64,[maxI] = 0x64})
a=setmetatable({},{["\u{5f}\u{5f}\u{69}\u{6e}\u{64}\u{65}\u{78}"] = function (_,k)
return k * 10
return k * 0xa
end,["\u{5f}\u{5f}\u{6e}\u{65}\u{77}\u{69}\u{6e}\u{64}\u{65}\u{78}"] = error})
local b = table.move(a,1,10,3,{})
local b = table.move(a,0x1,0xa,0x3,{})
eqT(a,{})
eqT(b,{nil,nil,10,20,30,40,50,60,70,80,90,100})
eqT(b,{nil,nil,0xa,0x14,0x1e,0x28,0x32,0x3c,0x46,0x50,0x5a,0x64})
b=setmetatable({""},{["\u{5f}\u{5f}\u{69}\u{6e}\u{64}\u{65}\u{78}"] = error,["\u{5f}\u{5f}\u{6e}\u{65}\u{77}\u{69}\u{6e}\u{64}\u{65}\u{78}"] = function (t,k,v)
t[1]=string.format("\u{25}\u{73}\u{28}\u{25}\u{64}\u{2c}\u{25}\u{64}\u{29}",t[1],k,v)
t[0x1]=string.format("\u{25}\u{73}\u{28}\u{25}\u{64}\u{2c}\u{25}\u{64}\u{29}",t[0x1],k,v)
end})
table.move(a,10,13,3,b)
assert(b[1] == "\u{28}\u{33}\u{2c}\u{31}\u{30}\u{30}\u{29}\u{28}\u{34}\u{2c}\u{31}\u{31}\u{30}\u{29}\u{28}\u{35}\u{2c}\u{31}\u{32}\u{30}\u{29}\u{28}\u{36}\u{2c}\u{31}\u{33}\u{30}\u{29}")
local stat,msg = pcall(table.move,b,10,13,3,b)
table.move(a,0xa,0xd,0x3,b)
assert(b[0x1] == "\u{28}\u{33}\u{2c}\u{31}\u{30}\u{30}\u{29}\u{28}\u{34}\u{2c}\u{31}\u{31}\u{30}\u{29}\u{28}\u{35}\u{2c}\u{31}\u{32}\u{30}\u{29}\u{28}\u{36}\u{2c}\u{31}\u{33}\u{30}\u{29}")
local stat,msg = pcall(table.move,b,0xa,0xd,0x3,b)
assert(not stat and msg == b)
end
do
@ -157,25 +157,25 @@ end})
local st,msg = pcall(table.move,a,f,e,t)
assert(not st and not msg and pos1 == x and pos2 == y)
end
checkmove(1,maxI,0,1,0)
checkmove(0,maxI - 1,1,maxI - 1,maxI)
checkmove(minI,- 2,- 5,- 2,maxI - 6)
checkmove(minI + 1,- 1,- 2,- 1,maxI - 3)
checkmove(minI,- 2,0,minI,0)
checkmove(minI + 1,- 1,1,minI + 1,1)
checkmove(0x1,maxI,0x0,0x1,0x0)
checkmove(0x0,maxI - 0x1,0x1,maxI - 0x1,maxI)
checkmove(minI,- 0x2,- 0x5,- 0x2,maxI - 0x6)
checkmove(minI + 0x1,- 0x1,- 0x2,- 0x1,maxI - 0x3)
checkmove(minI,- 0x2,0x0,minI,0x0)
checkmove(minI + 0x1,- 0x1,0x1,minI + 0x1,0x1)
end
checkerror("\u{74}\u{6f}\u{6f}\u{20}\u{6d}\u{61}\u{6e}\u{79}",table.move,{},0,maxI,1)
checkerror("\u{74}\u{6f}\u{6f}\u{20}\u{6d}\u{61}\u{6e}\u{79}",table.move,{},- 1,maxI - 1,1)
checkerror("\u{74}\u{6f}\u{6f}\u{20}\u{6d}\u{61}\u{6e}\u{79}",table.move,{},minI,- 1,1)
checkerror("\u{74}\u{6f}\u{6f}\u{20}\u{6d}\u{61}\u{6e}\u{79}",table.move,{},minI,maxI,1)
checkerror("\u{77}\u{72}\u{61}\u{70}\u{20}\u{61}\u{72}\u{6f}\u{75}\u{6e}\u{64}",table.move,{},1,maxI,2)
checkerror("\u{77}\u{72}\u{61}\u{70}\u{20}\u{61}\u{72}\u{6f}\u{75}\u{6e}\u{64}",table.move,{},1,2,maxI)
checkerror("\u{77}\u{72}\u{61}\u{70}\u{20}\u{61}\u{72}\u{6f}\u{75}\u{6e}\u{64}",table.move,{},minI,- 2,2)
checkerror("\u{74}\u{6f}\u{6f}\u{20}\u{6d}\u{61}\u{6e}\u{79}",table.move,{},0x0,maxI,0x1)
checkerror("\u{74}\u{6f}\u{6f}\u{20}\u{6d}\u{61}\u{6e}\u{79}",table.move,{},- 0x1,maxI - 0x1,0x1)
checkerror("\u{74}\u{6f}\u{6f}\u{20}\u{6d}\u{61}\u{6e}\u{79}",table.move,{},minI,- 0x1,0x1)
checkerror("\u{74}\u{6f}\u{6f}\u{20}\u{6d}\u{61}\u{6e}\u{79}",table.move,{},minI,maxI,0x1)
checkerror("\u{77}\u{72}\u{61}\u{70}\u{20}\u{61}\u{72}\u{6f}\u{75}\u{6e}\u{64}",table.move,{},0x1,maxI,0x2)
checkerror("\u{77}\u{72}\u{61}\u{70}\u{20}\u{61}\u{72}\u{6f}\u{75}\u{6e}\u{64}",table.move,{},0x1,0x2,maxI)
checkerror("\u{77}\u{72}\u{61}\u{70}\u{20}\u{61}\u{72}\u{6f}\u{75}\u{6e}\u{64}",table.move,{},minI,- 0x2,0x2)
print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{73}\u{6f}\u{72}\u{74}")
local a = setmetatable({},{["\u{5f}\u{5f}\u{6c}\u{65}\u{6e}"] = function ()
return - 1
return - 0x1
end})
assert(# a == - 1)
assert(# a == - 0x1)
table.sort(a,error)
a=setmetatable({},{["\u{5f}\u{5f}\u{6c}\u{65}\u{6e}"] = function ()
return maxI
@ -191,17 +191,17 @@ return true
end
checkerror("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{6f}\u{72}\u{64}\u{65}\u{72}\u{20}\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}",table.sort,t,f)
end
check({1,2,3,4})
check({1,2,3,4,5})
check({1,2,3,4,5,6})
check({0x1,0x2,0x3,0x4})
check({0x1,0x2,0x3,0x4,0x5})
check({0x1,0x2,0x3,0x4,0x5,0x6})
function check(a,f)
f=f or function (x,y)
return x < y
end
;
for n = # a, 2, - 1
for n = # a, 0x2, - 0x1
do
assert(not f(a[n],a[n - 1]))
assert(not f(a[n],a[n - 0x1]))
end
end
a={"\u{4a}\u{61}\u{6e}","\u{46}\u{65}\u{62}","\u{4d}\u{61}\u{72}","\u{41}\u{70}\u{72}","\u{4d}\u{61}\u{79}","\u{4a}\u{75}\u{6e}","\u{4a}\u{75}\u{6c}","\u{41}\u{75}\u{67}","\u{53}\u{65}\u{70}","\u{4f}\u{63}\u{74}","\u{4e}\u{6f}\u{76}","\u{44}\u{65}\u{63}"}
@ -210,69 +210,69 @@ check(a)
local function perm
(s,n)
n=n or # s
if n == 1 then
if n == 0x1 then
local t = {unpack(s)}
table.sort(t)
check(t)
else
for i = 1, n
for i = 0x1, n
do
s[i],s[n]=s[n],s[i]
perm(s,n - 1)
perm(s,n - 0x1)
s[i],s[n]=s[n],s[i]
end
end
end
perm({})
perm({1})
perm({1,2})
perm({1,2,3})
perm({1,2,3,4})
perm({2,2,3,4})
perm({1,2,3,4,5})
perm({1,2,3,3,5})
perm({1,2,3,4,5,6})
perm({2,2,3,3,5,6})
perm({0x1})
perm({0x1,0x2})
perm({0x1,0x2,0x3})
perm({0x1,0x2,0x3,0x4})
perm({0x2,0x2,0x3,0x4})
perm({0x1,0x2,0x3,0x4,0x5})
perm({0x1,0x2,0x3,0x3,0x5})
perm({0x1,0x2,0x3,0x4,0x5,0x6})
perm({0x2,0x2,0x3,0x3,0x5,0x6})
local function timesort
(a,n,func,msg,pre)
local x = os.clock()
table.sort(a,func)
x=(os.clock() - x) * 1000
x=(os.clock() - x) * 0x3e8
pre=pre or ""
print(string.format("\u{25}\u{73}\u{73}\u{6f}\u{72}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{25}\u{64}\u{20}\u{25}\u{73}\u{20}\u{65}\u{6c}\u{65}\u{6d}\u{65}\u{6e}\u{74}\u{73}\u{20}\u{69}\u{6e}\u{20}\u{25}\u{2e}\u{32}\u{66}\u{20}\u{6d}\u{73}\u{65}\u{63}\u{2e}",pre,n,msg,x))
check(a,func)
end
local limit = 50000
local limit = 0xc350
if _soft then
limit=5000
limit=0x1388
end
a={}
for i = 1, limit
for i = 0x1, limit
do
a[i]=math.random()
end
timesort(a,limit,nil,"\u{72}\u{61}\u{6e}\u{64}\u{6f}\u{6d}")
timesort(a,limit,nil,"\u{73}\u{6f}\u{72}\u{74}\u{65}\u{64}","\u{72}\u{65}\u{2d}")
a={}
for i = 1, limit
for i = 0x1, limit
do
a[i]=math.random()
end
local x = os.clock()
;
local i = 0
local i = 0x0
table.sort(a,function (x,y)
i=i + 1
i=i + 0x1
;
return y < x
end)
x=(os.clock() - x) * 1000
x=(os.clock() - x) * 0x3e8
print(string.format("\u{49}\u{6e}\u{76}\u{65}\u{72}\u{74}\u{2d}\u{73}\u{6f}\u{72}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{6f}\u{74}\u{68}\u{65}\u{72}\u{20}\u{25}\u{64}\u{20}\u{65}\u{6c}\u{65}\u{6d}\u{65}\u{6e}\u{74}\u{73}\u{20}\u{69}\u{6e}\u{20}\u{25}\u{2e}\u{32}\u{66}\u{20}\u{6d}\u{73}\u{65}\u{63}\u{2e}\u{2c}\u{20}\u{77}\u{69}\u{74}\u{68}\u{20}\u{25}\u{69}\u{20}\u{63}\u{6f}\u{6d}\u{70}\u{61}\u{72}\u{69}\u{73}\u{6f}\u{6e}\u{73}",limit,x,i))
check(a,function (x,y)
return y < x
end)
table.sort({})
for i = 1, limit
for i = 0x1, limit
do
a[i]=false
end
@ -296,9 +296,9 @@ local tt = {["\u{5f}\u{5f}\u{6c}\u{74}"] = function (a,b)
return a.val < b.val
end}
a={}
for i = 1, 10
for i = 0x1, 0xa
do
a[i]={["\u{76}\u{61}\u{6c}"] = math.random(100)}
a[i]={["\u{76}\u{61}\u{6c}"] = math.random(0x64)}
;
setmetatable(a[i],tt)
;

View File

@ -23,116 +23,116 @@ assert(not ("\u{0}\u{0}\u{0}\u{0}" <= "\u{0}\u{0}\u{0}"))
assert("\u{0}\u{0}\u{0}" <= "\u{0}\u{0}\u{0}")
assert("\u{0}\u{0}\u{0}" >= "\u{0}\u{0}\u{0}")
assert(not ("\u{0}\u{0}\u{62}" < "\u{0}\u{0}\u{61}\u{0}"))
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",2,4) == "\u{32}\u{33}\u{34}")
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",7) == "\u{37}\u{38}\u{39}")
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",7,6) == "")
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",7,7) == "\u{37}")
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",0,0) == "")
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",- 10,10) == "\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}")
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",1,9) == "\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}")
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",- 10,- 20) == "")
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",- 1) == "\u{39}")
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",- 4) == "\u{36}\u{37}\u{38}\u{39}")
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",- 6,- 4) == "\u{34}\u{35}\u{36}")
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",mini,- 4) == "\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}")
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",0x2,0x4) == "\u{32}\u{33}\u{34}")
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",0x7) == "\u{37}\u{38}\u{39}")
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",0x7,0x6) == "")
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",0x7,0x7) == "\u{37}")
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",0x0,0x0) == "")
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",- 0xa,0xa) == "\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}")
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",0x1,0x9) == "\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}")
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",- 0xa,- 0x14) == "")
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",- 0x1) == "\u{39}")
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",- 0x4) == "\u{36}\u{37}\u{38}\u{39}")
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",- 0x6,- 0x4) == "\u{34}\u{35}\u{36}")
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",mini,- 0x4) == "\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}")
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",mini,maxi) == "\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}")
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",mini,mini) == "")
assert(string.sub("\u{0}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",3,5) == "\u{32}\u{33}\u{34}")
assert(("\u{0}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}"):sub(8) == "\u{37}\u{38}\u{39}")
assert(string.find("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}","\u{33}\u{34}\u{35}") == 3)
assert(string.sub("\u{0}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",0x3,0x5) == "\u{32}\u{33}\u{34}")
assert(("\u{0}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}"):sub(0x8) == "\u{37}\u{38}\u{39}")
assert(string.find("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}","\u{33}\u{34}\u{35}") == 0x3)
local a,b = string.find("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}","\u{33}\u{34}\u{35}")
assert(string.sub("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}",a,b) == "\u{33}\u{34}\u{35}")
assert(string.find("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}","\u{33}\u{34}\u{35}",3) == 3)
assert(string.find("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}","\u{33}\u{34}\u{35}",4) == 13)
assert(not string.find("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}","\u{33}\u{34}\u{36}",4))
assert(string.find("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}","\u{2e}\u{34}\u{35}",- 9) == 13)
assert(not string.find("\u{61}\u{62}\u{63}\u{64}\u{65}\u{66}\u{67}","\u{0}",5,1))
assert(string.find("","") == 1)
assert(string.find("","",1) == 1)
assert(not string.find("","",2))
assert(not string.find("","\u{61}\u{61}\u{61}",1))
assert(("\u{61}\u{6c}\u{6f}\u{28}\u{2e}\u{29}\u{61}\u{6c}\u{6f}"):find("\u{28}\u{2e}\u{29}",1,1) == 4)
assert(string.len("") == 0)
assert(string.len("\u{0}\u{0}\u{0}") == 3)
assert(string.len("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}") == 10)
assert(# "" == 0)
assert(# "\u{0}\u{0}\u{0}" == 3)
assert(# "\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}" == 10)
assert(string.byte("\u{61}") == 97)
assert(string.byte("\u{e4}") > 127)
assert(string.byte(string.char(255)) == 255)
assert(string.byte(string.char(0)) == 0)
assert(string.byte("\u{0}") == 0)
assert(string.byte("\u{0}\u{0}\u{61}\u{6c}\u{6f}\u{0}\u{78}",- 1) == string.byte("\u{78}"))
assert(string.byte("\u{62}\u{61}",2) == 97)
assert(string.byte("\u{a}\u{a}",2,- 1) == 10)
assert(string.byte("\u{a}\u{a}",2,2) == 10)
assert(string.find("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}","\u{33}\u{34}\u{35}",0x3) == 0x3)
assert(string.find("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}","\u{33}\u{34}\u{35}",0x4) == 0xd)
assert(not string.find("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}","\u{33}\u{34}\u{36}",0x4))
assert(string.find("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}","\u{2e}\u{34}\u{35}",- 0x9) == 0xd)
assert(not string.find("\u{61}\u{62}\u{63}\u{64}\u{65}\u{66}\u{67}","\u{0}",0x5,0x1))
assert(string.find("","") == 0x1)
assert(string.find("","",0x1) == 0x1)
assert(not string.find("","",0x2))
assert(not string.find("","\u{61}\u{61}\u{61}",0x1))
assert(("\u{61}\u{6c}\u{6f}\u{28}\u{2e}\u{29}\u{61}\u{6c}\u{6f}"):find("\u{28}\u{2e}\u{29}",0x1,0x1) == 0x4)
assert(string.len("") == 0x0)
assert(string.len("\u{0}\u{0}\u{0}") == 0x3)
assert(string.len("\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}") == 0xa)
assert(# "" == 0x0)
assert(# "\u{0}\u{0}\u{0}" == 0x3)
assert(# "\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}" == 0xa)
assert(string.byte("\u{61}") == 0x61)
assert(string.byte("\u{e4}") > 0x7f)
assert(string.byte(string.char(0xff)) == 0xff)
assert(string.byte(string.char(0x0)) == 0x0)
assert(string.byte("\u{0}") == 0x0)
assert(string.byte("\u{0}\u{0}\u{61}\u{6c}\u{6f}\u{0}\u{78}",- 0x1) == string.byte("\u{78}"))
assert(string.byte("\u{62}\u{61}",0x2) == 0x61)
assert(string.byte("\u{a}\u{a}",0x2,- 0x1) == 0xa)
assert(string.byte("\u{a}\u{a}",0x2,0x2) == 0xa)
assert(string.byte("") == nil)
assert(string.byte("\u{68}\u{69}",- 3) == nil)
assert(string.byte("\u{68}\u{69}",3) == nil)
assert(string.byte("\u{68}\u{69}",9,10) == nil)
assert(string.byte("\u{68}\u{69}",2,1) == nil)
assert(string.byte("\u{68}\u{69}",- 0x3) == nil)
assert(string.byte("\u{68}\u{69}",0x3) == nil)
assert(string.byte("\u{68}\u{69}",0x9,0xa) == nil)
assert(string.byte("\u{68}\u{69}",0x2,0x1) == nil)
assert(string.char() == "")
assert(string.char(0,255,0) == "\u{0}\u{ff}\u{0}")
assert(string.char(0,string.byte("\u{e4}"),0) == "\u{0}\u{e4}\u{0}")
assert(string.char(string.byte("\u{e4}\u{6c}\u{0}\u{f3}\u{75}",1,- 1)) == "\u{e4}\u{6c}\u{0}\u{f3}\u{75}")
assert(string.char(string.byte("\u{e4}\u{6c}\u{0}\u{f3}\u{75}",1,0)) == "")
assert(string.char(string.byte("\u{e4}\u{6c}\u{0}\u{f3}\u{75}",- 10,100)) == "\u{e4}\u{6c}\u{0}\u{f3}\u{75}")
checkerror("\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{72}\u{61}\u{6e}\u{67}\u{65}",string.char,256)
checkerror("\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{72}\u{61}\u{6e}\u{67}\u{65}",string.char,- 1)
assert(string.char(0x0,0xff,0x0) == "\u{0}\u{ff}\u{0}")
assert(string.char(0x0,string.byte("\u{e4}"),0x0) == "\u{0}\u{e4}\u{0}")
assert(string.char(string.byte("\u{e4}\u{6c}\u{0}\u{f3}\u{75}",0x1,- 0x1)) == "\u{e4}\u{6c}\u{0}\u{f3}\u{75}")
assert(string.char(string.byte("\u{e4}\u{6c}\u{0}\u{f3}\u{75}",0x1,0x0)) == "")
assert(string.char(string.byte("\u{e4}\u{6c}\u{0}\u{f3}\u{75}",- 0xa,0x64)) == "\u{e4}\u{6c}\u{0}\u{f3}\u{75}")
checkerror("\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{72}\u{61}\u{6e}\u{67}\u{65}",string.char,0x100)
checkerror("\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{72}\u{61}\u{6e}\u{67}\u{65}",string.char,- 0x1)
checkerror("\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{72}\u{61}\u{6e}\u{67}\u{65}",string.char,math.maxinteger)
checkerror("\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{72}\u{61}\u{6e}\u{67}\u{65}",string.char,math.mininteger)
assert(string.upper("\u{61}\u{62}\u{0}\u{63}") == "\u{41}\u{42}\u{0}\u{43}")
assert(string.lower("\u{0}\u{41}\u{42}\u{43}\u{63}\u{25}\u{24}") == "\u{0}\u{61}\u{62}\u{63}\u{63}\u{25}\u{24}")
assert(string.rep("\u{74}\u{65}\u{73}\u{74}\u{65}",0) == "")
assert(string.rep("\u{74}\u{e9}\u{73}\u{0}\u{74}\u{ea}",2) == "\u{74}\u{e9}\u{73}\u{0}\u{74}\u{ea}\u{74}\u{e9}\u{73}\u{0}\u{74}\u{ea}")
assert(string.rep("",10) == "")
if string.packsize("\u{69}") == 4 then
checkerror("\u{74}\u{6f}\u{6f}\u{20}\u{6c}\u{61}\u{72}\u{67}\u{65}",string.rep,"\u{61}\u{61}",(1 << 30))
checkerror("\u{74}\u{6f}\u{6f}\u{20}\u{6c}\u{61}\u{72}\u{67}\u{65}",string.rep,"\u{61}",(1 << 30),"\u{2c}")
assert(string.rep("\u{74}\u{65}\u{73}\u{74}\u{65}",0x0) == "")
assert(string.rep("\u{74}\u{e9}\u{73}\u{0}\u{74}\u{ea}",0x2) == "\u{74}\u{e9}\u{73}\u{0}\u{74}\u{ea}\u{74}\u{e9}\u{73}\u{0}\u{74}\u{ea}")
assert(string.rep("",0xa) == "")
if string.packsize("\u{69}") == 0x4 then
checkerror("\u{74}\u{6f}\u{6f}\u{20}\u{6c}\u{61}\u{72}\u{67}\u{65}",string.rep,"\u{61}\u{61}",(0x1 << 0x1e))
checkerror("\u{74}\u{6f}\u{6f}\u{20}\u{6c}\u{61}\u{72}\u{67}\u{65}",string.rep,"\u{61}",(0x1 << 0x1e),"\u{2c}")
end
assert(string.rep("\u{74}\u{65}\u{73}\u{74}\u{65}",0,"\u{78}\u{75}\u{78}\u{75}") == "")
assert(string.rep("\u{74}\u{65}\u{73}\u{74}\u{65}",1,"\u{78}\u{75}\u{78}\u{75}") == "\u{74}\u{65}\u{73}\u{74}\u{65}")
assert(string.rep("\u{1}\u{0}\u{1}",2,"\u{0}\u{0}") == "\u{1}\u{0}\u{1}\u{0}\u{0}\u{1}\u{0}\u{1}")
assert(string.rep("",10,"\u{2e}") == string.rep("\u{2e}",9))
assert(not pcall(string.rep,"\u{61}\u{61}",maxi // 2 + 10))
assert(not pcall(string.rep,"",maxi // 2 + 10,"\u{61}\u{61}"))
assert(string.rep("\u{74}\u{65}\u{73}\u{74}\u{65}",0x0,"\u{78}\u{75}\u{78}\u{75}") == "")
assert(string.rep("\u{74}\u{65}\u{73}\u{74}\u{65}",0x1,"\u{78}\u{75}\u{78}\u{75}") == "\u{74}\u{65}\u{73}\u{74}\u{65}")
assert(string.rep("\u{1}\u{0}\u{1}",0x2,"\u{0}\u{0}") == "\u{1}\u{0}\u{1}\u{0}\u{0}\u{1}\u{0}\u{1}")
assert(string.rep("",0xa,"\u{2e}") == string.rep("\u{2e}",0x9))
assert(not pcall(string.rep,"\u{61}\u{61}",maxi // 0x2 + 0xa))
assert(not pcall(string.rep,"",maxi // 0x2 + 0xa,"\u{61}\u{61}"))
assert(string.reverse("") == "")
assert(string.reverse("\u{0}\u{1}\u{2}\u{3}") == "\u{3}\u{2}\u{1}\u{0}")
assert(string.reverse("\u{0}\u{31}\u{32}\u{33}\u{34}") == "\u{34}\u{33}\u{32}\u{31}\u{0}")
for i = 0, 30
for i = 0x0, 0x1e
do
assert(string.len(string.rep("\u{61}",i)) == i)
end
assert(type(tostring(nil)) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}")
assert(type(tostring(12)) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}")
assert(type(tostring(0xc)) == "\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}")
assert(string.find(tostring({}),"\u{74}\u{61}\u{62}\u{6c}\u{65}\u{3a}"))
assert(string.find(tostring(print),"\u{66}\u{75}\u{6e}\u{63}\u{74}\u{69}\u{6f}\u{6e}\u{3a}"))
assert(# tostring("\u{0}") == 1)
assert(# tostring("\u{0}") == 0x1)
assert(tostring(true) == "\u{74}\u{72}\u{75}\u{65}")
assert(tostring(false) == "\u{66}\u{61}\u{6c}\u{73}\u{65}")
assert(tostring(- 1203) == "\u{2d}\u{31}\u{32}\u{30}\u{33}")
assert(tostring(- 0x4b3) == "\u{2d}\u{31}\u{32}\u{30}\u{33}")
assert(tostring(1203.125) == "\u{31}\u{32}\u{30}\u{33}\u{2e}\u{31}\u{32}\u{35}")
assert(tostring(- 0.5) == "\u{2d}\u{30}\u{2e}\u{35}")
assert(tostring(- 32767) == "\u{2d}\u{33}\u{32}\u{37}\u{36}\u{37}")
if math.tointeger(2147483647) then
assert(tostring(- 2147483647) == "\u{2d}\u{32}\u{31}\u{34}\u{37}\u{34}\u{38}\u{33}\u{36}\u{34}\u{37}")
assert(tostring(- 0x7fff) == "\u{2d}\u{33}\u{32}\u{37}\u{36}\u{37}")
if math.tointeger(0x7fffffff) then
assert(tostring(- 0x7fffffff) == "\u{2d}\u{32}\u{31}\u{34}\u{37}\u{34}\u{38}\u{33}\u{36}\u{34}\u{37}")
end
if math.tointeger(4611686018427387904) then
assert(tostring(4611686018427387904) == "\u{34}\u{36}\u{31}\u{31}\u{36}\u{38}\u{36}\u{30}\u{31}\u{38}\u{34}\u{32}\u{37}\u{33}\u{38}\u{37}\u{39}\u{30}\u{34}")
assert(tostring(- 4611686018427387904) == "\u{2d}\u{34}\u{36}\u{31}\u{31}\u{36}\u{38}\u{36}\u{30}\u{31}\u{38}\u{34}\u{32}\u{37}\u{33}\u{38}\u{37}\u{39}\u{30}\u{34}")
if math.tointeger(0x4000000000000000) then
assert(tostring(0x4000000000000000) == "\u{34}\u{36}\u{31}\u{31}\u{36}\u{38}\u{36}\u{30}\u{31}\u{38}\u{34}\u{32}\u{37}\u{33}\u{38}\u{37}\u{39}\u{30}\u{34}")
assert(tostring(- 0x4000000000000000) == "\u{2d}\u{34}\u{36}\u{31}\u{31}\u{36}\u{38}\u{36}\u{30}\u{31}\u{38}\u{34}\u{32}\u{37}\u{33}\u{38}\u{37}\u{39}\u{30}\u{34}")
end
if tostring(0.0) == "\u{30}\u{2e}\u{30}" then
assert("" .. 12 == "\u{31}\u{32}" and 12.0 .. "" == "\u{31}\u{32}\u{2e}\u{30}")
assert(tostring(- 1203 + 0.0) == "\u{2d}\u{31}\u{32}\u{30}\u{33}\u{2e}\u{30}")
assert("" .. 0xc == "\u{31}\u{32}" and 12.0 .. "" == "\u{31}\u{32}\u{2e}\u{30}")
assert(tostring(- 0x4b3 + 0.0) == "\u{2d}\u{31}\u{32}\u{30}\u{33}\u{2e}\u{30}")
else
assert(tostring(0.0) == "\u{30}")
assert("" .. 12 == "\u{31}\u{32}" and 12.0 .. "" == "\u{31}\u{32}")
assert(tostring(- 1203 + 0.0) == "\u{2d}\u{31}\u{32}\u{30}\u{33}")
assert("" .. 0xc == "\u{31}\u{32}" and 12.0 .. "" == "\u{31}\u{32}")
assert(tostring(- 0x4b3 + 0.0) == "\u{2d}\u{31}\u{32}\u{30}\u{33}")
end
do
local null = "\u{28}\u{6e}\u{75}\u{6c}\u{6c}\u{29}"
assert(string.format("\u{25}\u{70}",4) == null)
assert(string.format("\u{25}\u{70}",0x4) == null)
assert(string.format("\u{25}\u{70}",true) == null)
assert(string.format("\u{25}\u{70}",nil) == null)
assert(string.format("\u{25}\u{70}",{}) ~= null)
@ -142,10 +142,10 @@ assert(string.format("\u{25}\u{70}",io.stdin) ~= null)
assert(string.format("\u{25}\u{70}",io.stdin) == string.format("\u{25}\u{70}",io.stdin))
assert(string.format("\u{25}\u{70}",print) == string.format("\u{25}\u{70}",print))
assert(string.format("\u{25}\u{70}",print) ~= string.format("\u{25}\u{70}",assert))
assert(# string.format("\u{25}\u{39}\u{30}\u{70}",{}) == 90)
assert(# string.format("\u{25}\u{2d}\u{36}\u{30}\u{70}",{}) == 60)
assert(string.format("\u{25}\u{31}\u{30}\u{70}",false) == string.rep("\u{20}",10 - # null) .. null)
assert(string.format("\u{25}\u{2d}\u{31}\u{32}\u{70}",1.5) == null .. string.rep("\u{20}",12 - # null))
assert(# string.format("\u{25}\u{39}\u{30}\u{70}",{}) == 0x5a)
assert(# string.format("\u{25}\u{2d}\u{36}\u{30}\u{70}",{}) == 0x3c)
assert(string.format("\u{25}\u{31}\u{30}\u{70}",false) == string.rep("\u{20}",0xa - # null) .. null)
assert(string.format("\u{25}\u{2d}\u{31}\u{32}\u{70}",1.5) == null .. string.rep("\u{20}",0xc - # null))
do
local t1 = {}
;
@ -153,14 +153,14 @@ local t2 = {}
assert(string.format("\u{25}\u{70}",t1) ~= string.format("\u{25}\u{70}",t2))
end
do
local s1 = string.rep("\u{61}",10)
local s2 = string.rep("\u{61}\u{61}",5)
local s1 = string.rep("\u{61}",0xa)
local s2 = string.rep("\u{61}\u{61}",0x5)
assert(string.format("\u{25}\u{70}",s1) == string.format("\u{25}\u{70}",s2))
end
do
local s1 = string.rep("\u{61}",300)
local s1 = string.rep("\u{61}",0x12c)
;
local s2 = string.rep("\u{61}",300)
local s2 = string.rep("\u{61}",0x12c)
assert(string.format("\u{25}\u{70}",s1) ~= string.format("\u{25}\u{70}",s2))
end
end
@ -170,15 +170,15 @@ assert(string.format("\u{25}\u{71}","\u{0}") == "\u{22}\u{5c}\u{30}\u{22}")
assert(load(string.format("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{25}\u{71}",x))() == x)
x="\u{0}\u{1}\u{2}\u{33}\u{5}\u{0}\u{39}"
assert(load(string.format("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{25}\u{71}",x))() == x)
assert(string.format("\u{0}\u{25}\u{63}\u{0}\u{25}\u{63}\u{25}\u{78}\u{0}",string.byte("\u{e4}"),string.byte("\u{62}"),140) == "\u{0}\u{e4}\u{0}\u{62}\u{38}\u{63}\u{0}")
assert(string.format("\u{0}\u{25}\u{63}\u{0}\u{25}\u{63}\u{25}\u{78}\u{0}",string.byte("\u{e4}"),string.byte("\u{62}"),0x8c) == "\u{0}\u{e4}\u{0}\u{62}\u{38}\u{63}\u{0}")
assert(string.format("") == "")
assert(string.format("\u{25}\u{63}",34) .. string.format("\u{25}\u{63}",48) .. string.format("\u{25}\u{63}",90) .. string.format("\u{25}\u{63}",100) == string.format("\u{25}\u{31}\u{63}\u{25}\u{2d}\u{63}\u{25}\u{2d}\u{31}\u{63}\u{25}\u{63}",34,48,90,100))
assert(string.format("\u{25}\u{63}",0x22) .. string.format("\u{25}\u{63}",0x30) .. string.format("\u{25}\u{63}",0x5a) .. string.format("\u{25}\u{63}",0x64) == string.format("\u{25}\u{31}\u{63}\u{25}\u{2d}\u{63}\u{25}\u{2d}\u{31}\u{63}\u{25}\u{63}",0x22,0x30,0x5a,0x64))
assert(string.format("\u{25}\u{73}\u{0}\u{20}\u{69}\u{73}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{0}\u{25}\u{73}","\u{6e}\u{6f}\u{74}\u{20}\u{62}\u{65}","\u{62}\u{65}") == "\u{6e}\u{6f}\u{74}\u{20}\u{62}\u{65}\u{0}\u{20}\u{69}\u{73}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{0}\u{62}\u{65}")
assert(string.format("\u{25}\u{25}\u{25}\u{64}\u{20}\u{25}\u{30}\u{31}\u{30}\u{64}",10,23) == "\u{25}\u{31}\u{30}\u{20}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{32}\u{33}")
assert(string.format("\u{25}\u{25}\u{25}\u{64}\u{20}\u{25}\u{30}\u{31}\u{30}\u{64}",0xa,0x17) == "\u{25}\u{31}\u{30}\u{20}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{32}\u{33}")
assert(tonumber(string.format("\u{25}\u{66}",10.3)) == 10.3)
assert(string.format("\u{22}\u{25}\u{2d}\u{35}\u{30}\u{73}\u{22}","\u{61}") == "\u{22}\u{61}" .. string.rep("\u{20}",49) .. "\u{22}")
assert(string.format("\u{2d}\u{25}\u{2e}\u{32}\u{30}\u{73}\u{2e}\u{32}\u{30}\u{73}",string.rep("\u{25}",2000)) == "\u{2d}" .. string.rep("\u{25}",20) .. "\u{2e}\u{32}\u{30}\u{73}")
assert(string.format("\u{22}\u{2d}\u{25}\u{32}\u{30}\u{73}\u{2e}\u{32}\u{30}\u{73}\u{22}",string.rep("\u{25}",2000)) == string.format("\u{25}\u{71}","\u{2d}" .. string.rep("\u{25}",2000) .. "\u{2e}\u{32}\u{30}\u{73}"))
assert(string.format("\u{22}\u{25}\u{2d}\u{35}\u{30}\u{73}\u{22}","\u{61}") == "\u{22}\u{61}" .. string.rep("\u{20}",0x31) .. "\u{22}")
assert(string.format("\u{2d}\u{25}\u{2e}\u{32}\u{30}\u{73}\u{2e}\u{32}\u{30}\u{73}",string.rep("\u{25}",0x7d0)) == "\u{2d}" .. string.rep("\u{25}",0x14) .. "\u{2e}\u{32}\u{30}\u{73}")
assert(string.format("\u{22}\u{2d}\u{25}\u{32}\u{30}\u{73}\u{2e}\u{32}\u{30}\u{73}\u{22}",string.rep("\u{25}",0x7d0)) == string.format("\u{25}\u{71}","\u{2d}" .. string.rep("\u{25}",0x7d0) .. "\u{2e}\u{32}\u{30}\u{73}"))
do
local function checkQ
(v)
@ -196,7 +196,7 @@ checkQ(nil)
checkQ(false)
checkQ(math.huge)
checkQ(- math.huge)
assert(string.format("\u{25}\u{71}",0 / 0) == "\u{28}\u{30}\u{2f}\u{30}\u{29}")
assert(string.format("\u{25}\u{71}",0x0 / 0x0) == "\u{28}\u{30}\u{2f}\u{30}\u{29}")
checkerror("\u{6e}\u{6f}\u{20}\u{6c}\u{69}\u{74}\u{65}\u{72}\u{61}\u{6c}",string.format,"\u{25}\u{71}",{})
end
assert(string.format("\u{0}\u{25}\u{73}\u{0}","\u{0}\u{0}\u{1}") == "\u{0}\u{0}\u{0}\u{1}\u{0}")
@ -216,50 +216,50 @@ end
checkerror("\u{27}\u{5f}\u{5f}\u{74}\u{6f}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{27}\u{20}\u{6d}\u{75}\u{73}\u{74}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{61}\u{20}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}",tostring,m)
assert(string.format("\u{25}\u{78}",0.0) == "\u{30}")
assert(string.format("\u{25}\u{30}\u{32}\u{78}",0.0) == "\u{30}\u{30}")
assert(string.format("\u{25}\u{30}\u{38}\u{58}",4294967295) == "\u{46}\u{46}\u{46}\u{46}\u{46}\u{46}\u{46}\u{46}")
assert(string.format("\u{25}\u{2b}\u{30}\u{38}\u{64}",31501) == "\u{2b}\u{30}\u{30}\u{33}\u{31}\u{35}\u{30}\u{31}")
assert(string.format("\u{25}\u{2b}\u{30}\u{38}\u{64}",- 30927) == "\u{2d}\u{30}\u{30}\u{33}\u{30}\u{39}\u{32}\u{37}")
assert(string.format("\u{25}\u{30}\u{38}\u{58}",0xffffffff) == "\u{46}\u{46}\u{46}\u{46}\u{46}\u{46}\u{46}\u{46}")
assert(string.format("\u{25}\u{2b}\u{30}\u{38}\u{64}",0x7b0d) == "\u{2b}\u{30}\u{30}\u{33}\u{31}\u{35}\u{30}\u{31}")
assert(string.format("\u{25}\u{2b}\u{30}\u{38}\u{64}",- 0x78cf) == "\u{2d}\u{30}\u{30}\u{33}\u{30}\u{39}\u{32}\u{37}")
do
local i = 1
local j = 10000
while i + 1 < j do
local m = (i + j) // 2
if 10 ^ m < math.huge then
local i = 0x1
local j = 0x2710
while i + 0x1 < j do
local m = (i + j) // 0x2
if 0xa ^ m < math.huge then
i=m
else
j=m
end
end
assert(10 ^ i < math.huge and 10 ^ j == math.huge)
local s = string.format("\u{25}\u{2e}\u{39}\u{39}\u{66}",- (10 ^ i))
assert(string.len(s) >= i + 101)
assert(tonumber(s) == - (10 ^ i))
assert(10 ^ 38 < math.huge)
local s = string.format("\u{25}\u{2e}\u{39}\u{39}\u{66}",- (10 ^ 38))
assert(string.len(s) >= 38 + 101)
assert(tonumber(s) == - (10 ^ 38))
assert(0xa ^ i < math.huge and 0xa ^ j == math.huge)
local s = string.format("\u{25}\u{2e}\u{39}\u{39}\u{66}",- (0xa ^ i))
assert(string.len(s) >= i + 0x65)
assert(tonumber(s) == - (0xa ^ i))
assert(0xa ^ 0x26 < math.huge)
local s = string.format("\u{25}\u{2e}\u{39}\u{39}\u{66}",- (0xa ^ 0x26))
assert(string.len(s) >= 0x26 + 0x65)
assert(tonumber(s) == - (0xa ^ 0x26))
end
do
local max,min = 2147483647,- 2147483648
assert(string.sub(string.format("\u{25}\u{38}\u{78}",- 1),- 8) == "\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}")
local max,min = 0x7fffffff,- 0x80000000
assert(string.sub(string.format("\u{25}\u{38}\u{78}",- 0x1),- 0x8) == "\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}")
assert(string.format("\u{25}\u{78}",max) == "\u{37}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}\u{66}")
assert(string.sub(string.format("\u{25}\u{78}",min),- 8) == "\u{38}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}")
assert(string.sub(string.format("\u{25}\u{78}",min),- 0x8) == "\u{38}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}")
assert(string.format("\u{25}\u{64}",max) == "\u{32}\u{31}\u{34}\u{37}\u{34}\u{38}\u{33}\u{36}\u{34}\u{37}")
assert(string.format("\u{25}\u{64}",min) == "\u{2d}\u{32}\u{31}\u{34}\u{37}\u{34}\u{38}\u{33}\u{36}\u{34}\u{38}")
assert(string.format("\u{25}\u{75}",4294967295) == "\u{34}\u{32}\u{39}\u{34}\u{39}\u{36}\u{37}\u{32}\u{39}\u{35}")
assert(string.format("\u{25}\u{6f}",43981) == "\u{31}\u{32}\u{35}\u{37}\u{31}\u{35}")
max,min=9223372036854775807,- 9223372036854775808
if max > 2.0 ^ 53 then
assert(string.format("\u{25}\u{78}",(2 ^ 52 | 0) - 1) == "\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}")
assert(string.format("\u{30}\u{78}\u{25}\u{38}\u{58}",2399141891) == "\u{30}\u{78}\u{38}\u{46}\u{30}\u{30}\u{30}\u{30}\u{30}\u{33}")
assert(string.format("\u{25}\u{64}",2 ^ 53) == "\u{39}\u{30}\u{30}\u{37}\u{31}\u{39}\u{39}\u{32}\u{35}\u{34}\u{37}\u{34}\u{30}\u{39}\u{39}\u{32}")
assert(string.format("\u{25}\u{69}",- 2 ^ 53) == "\u{2d}\u{39}\u{30}\u{30}\u{37}\u{31}\u{39}\u{39}\u{32}\u{35}\u{34}\u{37}\u{34}\u{30}\u{39}\u{39}\u{32}")
assert(string.format("\u{25}\u{75}",0xffffffff) == "\u{34}\u{32}\u{39}\u{34}\u{39}\u{36}\u{37}\u{32}\u{39}\u{35}")
assert(string.format("\u{25}\u{6f}",0xabcd) == "\u{31}\u{32}\u{35}\u{37}\u{31}\u{35}")
max,min=0x7fffffffffffffff,- 0x8000000000000000
if max > 2.0 ^ 0x35 then
assert(string.format("\u{25}\u{78}",(0x2 ^ 0x34 | 0x0) - 0x1) == "\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}")
assert(string.format("\u{30}\u{78}\u{25}\u{38}\u{58}",0x8f000003) == "\u{30}\u{78}\u{38}\u{46}\u{30}\u{30}\u{30}\u{30}\u{30}\u{33}")
assert(string.format("\u{25}\u{64}",0x2 ^ 0x35) == "\u{39}\u{30}\u{30}\u{37}\u{31}\u{39}\u{39}\u{32}\u{35}\u{34}\u{37}\u{34}\u{30}\u{39}\u{39}\u{32}")
assert(string.format("\u{25}\u{69}",- 0x2 ^ 0x35) == "\u{2d}\u{39}\u{30}\u{30}\u{37}\u{31}\u{39}\u{39}\u{32}\u{35}\u{34}\u{37}\u{34}\u{30}\u{39}\u{39}\u{32}")
assert(string.format("\u{25}\u{78}",max) == "\u{37}\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}")
assert(string.format("\u{25}\u{78}",min) == "\u{38}\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}")
assert(string.format("\u{25}\u{64}",max) == "\u{39}\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{37}\u{37}\u{35}\u{38}\u{30}\u{37}")
assert(string.format("\u{25}\u{64}",min) == "\u{2d}\u{39}\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{37}\u{37}\u{35}\u{38}\u{30}\u{38}")
assert(string.format("\u{25}\u{75}",~ (- 1 << 64)) == "\u{31}\u{38}\u{34}\u{34}\u{36}\u{37}\u{34}\u{34}\u{30}\u{37}\u{33}\u{37}\u{30}\u{39}\u{35}\u{35}\u{31}\u{36}\u{31}\u{35}")
assert(tostring(1234567890123) == "\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}")
assert(string.format("\u{25}\u{75}",~ (- 0x1 << 0x40)) == "\u{31}\u{38}\u{34}\u{34}\u{36}\u{37}\u{34}\u{34}\u{30}\u{37}\u{33}\u{37}\u{30}\u{39}\u{35}\u{35}\u{31}\u{36}\u{31}\u{35}")
assert(tostring(0x11f71fb04cb) == "\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{30}\u{31}\u{32}\u{33}")
end
end
do
@ -273,43 +273,43 @@ s=string.format("\u{25}\u{41}",n)
assert(string.find(s,"\u{5e}\u{25}\u{2d}\u{3f}\u{30}\u{58}\u{5b}\u{31}\u{2d}\u{39}\u{41}\u{2d}\u{46}\u{5d}\u{25}\u{2e}\u{3f}\u{5b}\u{30}\u{2d}\u{39}\u{41}\u{2d}\u{46}\u{5d}\u{2a}\u{50}\u{5b}\u{2d}\u{2b}\u{5d}\u{3f}\u{25}\u{64}\u{2b}\u{24}"))
assert(tonumber(s) == n)
end
for _,n in ipairs({0.1,- 0.1,1 / 3,- 1 / 3,1e30,- 1e30,- 45 / 247,1,- 1,2,- 2,3e-20,- 3e-20})
for _,n in ipairs({0.1,- 0.1,0x1 / 0x3,- 0x1 / 0x3,1e30,- 1e30,- 0x2d / 0xf7,0x1,- 0x1,0x2,- 0x2,3e-20,- 3e-20})
do
matchhexa(n)
end
assert(string.find(string.format("\u{25}\u{41}",0.0),"\u{5e}\u{30}\u{58}\u{30}\u{25}\u{2e}\u{3f}\u{30}\u{2a}\u{50}\u{25}\u{2b}\u{3f}\u{30}\u{24}"))
assert(string.find(string.format("\u{25}\u{61}",- 0.0),"\u{5e}\u{25}\u{2d}\u{30}\u{78}\u{30}\u{25}\u{2e}\u{3f}\u{30}\u{2a}\u{70}\u{25}\u{2b}\u{3f}\u{30}\u{24}"))
if not _port then
assert(string.find(string.format("\u{25}\u{61}",1 / 0),"\u{5e}\u{69}\u{6e}\u{66}"))
assert(string.find(string.format("\u{25}\u{41}",- 1 / 0),"\u{5e}\u{25}\u{2d}\u{49}\u{4e}\u{46}"))
assert(string.find(string.format("\u{25}\u{61}",0 / 0),"\u{5e}\u{25}\u{2d}\u{3f}\u{6e}\u{61}\u{6e}"))
assert(string.find(string.format("\u{25}\u{61}",0x1 / 0x0),"\u{5e}\u{69}\u{6e}\u{66}"))
assert(string.find(string.format("\u{25}\u{41}",- 0x1 / 0x0),"\u{5e}\u{25}\u{2d}\u{49}\u{4e}\u{46}"))
assert(string.find(string.format("\u{25}\u{61}",0x0 / 0x0),"\u{5e}\u{25}\u{2d}\u{3f}\u{6e}\u{61}\u{6e}"))
assert(string.find(string.format("\u{25}\u{61}",- 0.0),"\u{5e}\u{25}\u{2d}\u{30}\u{78}\u{30}"))
end
if not pcall(string.format,"\u{25}\u{2e}\u{33}\u{61}",0) then
if not pcall(string.format,"\u{25}\u{2e}\u{33}\u{61}",0x0) then
(Message or print)("\u{a}\u{20}\u{3e}\u{3e}\u{3e}\u{20}\u{6d}\u{6f}\u{64}\u{69}\u{66}\u{69}\u{65}\u{72}\u{73}\u{20}\u{66}\u{6f}\u{72}\u{20}\u{66}\u{6f}\u{72}\u{6d}\u{61}\u{74}\u{20}\u{27}\u{25}\u{61}\u{27}\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{20}\u{3c}\u{3c}\u{3c}\u{a}")
else
assert(string.find(string.format("\u{25}\u{2b}\u{2e}\u{32}\u{41}",12),"\u{5e}\u{25}\u{2b}\u{30}\u{58}\u{25}\u{78}\u{25}\u{2e}\u{25}\u{78}\u{30}\u{50}\u{25}\u{2b}\u{3f}\u{25}\u{64}\u{24}"))
assert(string.find(string.format("\u{25}\u{2e}\u{34}\u{41}",- 12),"\u{5e}\u{25}\u{2d}\u{30}\u{58}\u{25}\u{78}\u{25}\u{2e}\u{25}\u{78}\u{30}\u{30}\u{30}\u{50}\u{25}\u{2b}\u{3f}\u{25}\u{64}\u{24}"))
assert(string.find(string.format("\u{25}\u{2b}\u{2e}\u{32}\u{41}",0xc),"\u{5e}\u{25}\u{2b}\u{30}\u{58}\u{25}\u{78}\u{25}\u{2e}\u{25}\u{78}\u{30}\u{50}\u{25}\u{2b}\u{3f}\u{25}\u{64}\u{24}"))
assert(string.find(string.format("\u{25}\u{2e}\u{34}\u{41}",- 0xc),"\u{5e}\u{25}\u{2d}\u{30}\u{58}\u{25}\u{78}\u{25}\u{2e}\u{25}\u{78}\u{30}\u{30}\u{30}\u{50}\u{25}\u{2b}\u{3f}\u{25}\u{64}\u{24}"))
end
end
assert(string.format("\u{25}\u{23}\u{31}\u{32}\u{6f}",10) == "\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{30}\u{31}\u{32}")
assert(string.format("\u{25}\u{23}\u{31}\u{30}\u{78}",100) == "\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{30}\u{78}\u{36}\u{34}")
assert(string.format("\u{25}\u{23}\u{2d}\u{31}\u{37}\u{58}",100) == "\u{30}\u{58}\u{36}\u{34}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}")
assert(string.format("\u{25}\u{30}\u{31}\u{33}\u{69}",- 100) == "\u{2d}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{31}\u{30}\u{30}")
assert(string.format("\u{25}\u{32}\u{2e}\u{35}\u{64}",- 100) == "\u{2d}\u{30}\u{30}\u{31}\u{30}\u{30}")
assert(string.format("\u{25}\u{2e}\u{75}",0) == "")
assert(string.format("\u{25}\u{2b}\u{23}\u{30}\u{31}\u{34}\u{2e}\u{30}\u{66}",100) == "\u{2b}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{31}\u{30}\u{30}\u{2e}")
assert(string.format("\u{25}\u{2d}\u{31}\u{36}\u{63}",97) == "\u{61}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}")
assert(string.format("\u{25}\u{23}\u{31}\u{32}\u{6f}",0xa) == "\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{30}\u{31}\u{32}")
assert(string.format("\u{25}\u{23}\u{31}\u{30}\u{78}",0x64) == "\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{30}\u{78}\u{36}\u{34}")
assert(string.format("\u{25}\u{23}\u{2d}\u{31}\u{37}\u{58}",0x64) == "\u{30}\u{58}\u{36}\u{34}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}")
assert(string.format("\u{25}\u{30}\u{31}\u{33}\u{69}",- 0x64) == "\u{2d}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{31}\u{30}\u{30}")
assert(string.format("\u{25}\u{32}\u{2e}\u{35}\u{64}",- 0x64) == "\u{2d}\u{30}\u{30}\u{31}\u{30}\u{30}")
assert(string.format("\u{25}\u{2e}\u{75}",0x0) == "")
assert(string.format("\u{25}\u{2b}\u{23}\u{30}\u{31}\u{34}\u{2e}\u{30}\u{66}",0x64) == "\u{2b}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{31}\u{30}\u{30}\u{2e}")
assert(string.format("\u{25}\u{2d}\u{31}\u{36}\u{63}",0x61) == "\u{61}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}\u{20}")
assert(string.format("\u{25}\u{2b}\u{2e}\u{33}\u{47}",1.5) == "\u{2b}\u{31}\u{2e}\u{35}")
assert(string.format("\u{25}\u{2e}\u{30}\u{73}","\u{61}\u{6c}\u{6f}") == "")
assert(string.format("\u{25}\u{2e}\u{73}","\u{61}\u{6c}\u{6f}") == "")
assert(string.match(string.format("\u{25}\u{20}\u{31}\u{2e}\u{30}\u{45}",100),"\u{5e}\u{20}\u{31}\u{45}\u{25}\u{2b}\u{30}\u{2b}\u{32}\u{24}"))
assert(string.match(string.format("\u{25}\u{20}\u{2e}\u{31}\u{67}",2 ^ 10),"\u{5e}\u{20}\u{31}\u{65}\u{25}\u{2b}\u{30}\u{2b}\u{33}\u{24}"))
assert(string.match(string.format("\u{25}\u{20}\u{31}\u{2e}\u{30}\u{45}",0x64),"\u{5e}\u{20}\u{31}\u{45}\u{25}\u{2b}\u{30}\u{2b}\u{32}\u{24}"))
assert(string.match(string.format("\u{25}\u{20}\u{2e}\u{31}\u{67}",0x2 ^ 0xa),"\u{5e}\u{20}\u{31}\u{65}\u{25}\u{2b}\u{30}\u{2b}\u{33}\u{24}"))
local function check
(fmt,msg)
checkerror(msg,string.format,fmt,10)
checkerror(msg,string.format,fmt,0xa)
end
local aux = string.rep("\u{30}",600)
local aux = string.rep("\u{30}",0x258)
check("\u{25}\u{31}\u{30}\u{30}\u{2e}\u{33}\u{64}","\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}")
check("\u{25}\u{31}" .. aux .. "\u{2e}\u{33}\u{64}","\u{74}\u{6f}\u{6f}\u{20}\u{6c}\u{6f}\u{6e}\u{67}")
check("\u{25}\u{31}\u{2e}\u{31}\u{30}\u{30}\u{64}","\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}")
@ -325,8 +325,8 @@ check("\u{25}\u{33}\u{2e}\u{31}\u{70}","\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{6
check("\u{25}\u{30}\u{2e}\u{73}","\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}")
check("\u{25}\u{31}\u{30}\u{71}","\u{63}\u{61}\u{6e}\u{6e}\u{6f}\u{74}\u{20}\u{68}\u{61}\u{76}\u{65}\u{20}\u{6d}\u{6f}\u{64}\u{69}\u{66}\u{69}\u{65}\u{72}\u{73}")
check("\u{25}\u{46}","\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}")
assert(load("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}\u{a}\u{2d}\u{2d}\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{4c}")() == 1)
checkerror("\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}",table.concat,3)
assert(load("\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{31}\u{a}\u{2d}\u{2d}\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{4c}")() == 0x1)
checkerror("\u{74}\u{61}\u{62}\u{6c}\u{65}\u{20}\u{65}\u{78}\u{70}\u{65}\u{63}\u{74}\u{65}\u{64}",table.concat,0x3)
checkerror("\u{61}\u{74}\u{20}\u{69}\u{6e}\u{64}\u{65}\u{78}\u{20}" .. maxi,table.concat,{},"\u{20}",maxi,maxi)
checkerror("\u{61}\u{74}\u{20}\u{69}\u{6e}\u{64}\u{65}\u{78}\u{20}\u{25}" .. mini,table.concat,{},"\u{20}",mini,mini)
assert(table.concat({}) == "")
@ -334,33 +334,33 @@ assert(table.concat({},"\u{78}") == "")
assert(table.concat({"\u{0}","\u{0}\u{1}","\u{0}\u{1}\u{2}"},"\u{2e}\u{0}\u{2e}") == "\u{0}\u{2e}\u{0}\u{2e}\u{0}\u{1}\u{2e}\u{0}\u{2e}\u{0}\u{1}\u{2}")
local a = {}
;
for i = 1, 300
for i = 0x1, 0x12c
do
a[i]="\u{78}\u{75}\u{78}\u{75}"
end
assert(table.concat(a,"\u{31}\u{32}\u{33}") .. "\u{31}\u{32}\u{33}" == string.rep("\u{78}\u{75}\u{78}\u{75}\u{31}\u{32}\u{33}",300))
assert(table.concat(a,"\u{62}",20,20) == "\u{78}\u{75}\u{78}\u{75}")
assert(table.concat(a,"",20,21) == "\u{78}\u{75}\u{78}\u{75}\u{78}\u{75}\u{78}\u{75}")
assert(table.concat(a,"\u{78}",22,21) == "")
assert(table.concat(a,"\u{33}",299) == "\u{78}\u{75}\u{78}\u{75}\u{33}\u{78}\u{75}\u{78}\u{75}")
assert(table.concat({},"\u{78}",maxi,maxi - 1) == "")
assert(table.concat({},"\u{78}",mini + 1,mini) == "")
assert(table.concat(a,"\u{31}\u{32}\u{33}") .. "\u{31}\u{32}\u{33}" == string.rep("\u{78}\u{75}\u{78}\u{75}\u{31}\u{32}\u{33}",0x12c))
assert(table.concat(a,"\u{62}",0x14,0x14) == "\u{78}\u{75}\u{78}\u{75}")
assert(table.concat(a,"",0x14,0x15) == "\u{78}\u{75}\u{78}\u{75}\u{78}\u{75}\u{78}\u{75}")
assert(table.concat(a,"\u{78}",0x16,0x15) == "")
assert(table.concat(a,"\u{33}",0x12b) == "\u{78}\u{75}\u{78}\u{75}\u{33}\u{78}\u{75}\u{78}\u{75}")
assert(table.concat({},"\u{78}",maxi,maxi - 0x1) == "")
assert(table.concat({},"\u{78}",mini + 0x1,mini) == "")
assert(table.concat({},"\u{78}",maxi,mini) == "")
assert(table.concat({[maxi] = "\u{61}\u{6c}\u{6f}"},"\u{78}",maxi,maxi) == "\u{61}\u{6c}\u{6f}")
assert(table.concat({[maxi] = "\u{61}\u{6c}\u{6f}",[maxi - 1] = "\u{79}"},"\u{2d}",maxi - 1,maxi) == "\u{79}\u{2d}\u{61}\u{6c}\u{6f}")
assert(table.concat({[maxi] = "\u{61}\u{6c}\u{6f}",[maxi - 0x1] = "\u{79}"},"\u{2d}",maxi - 0x1,maxi) == "\u{79}\u{2d}\u{61}\u{6c}\u{6f}")
assert(not pcall(table.concat,{"\u{61}","\u{62}",{}}))
a={"\u{61}","\u{62}","\u{63}"}
assert(table.concat(a,"\u{2c}",1,0) == "")
assert(table.concat(a,"\u{2c}",1,1) == "\u{61}")
assert(table.concat(a,"\u{2c}",1,2) == "\u{61}\u{2c}\u{62}")
assert(table.concat(a,"\u{2c}",2) == "\u{62}\u{2c}\u{63}")
assert(table.concat(a,"\u{2c}",3) == "\u{63}")
assert(table.concat(a,"\u{2c}",4) == "")
assert(table.concat(a,"\u{2c}",0x1,0x0) == "")
assert(table.concat(a,"\u{2c}",0x1,0x1) == "\u{61}")
assert(table.concat(a,"\u{2c}",0x1,0x2) == "\u{61}\u{2c}\u{62}")
assert(table.concat(a,"\u{2c}",0x2) == "\u{62}\u{2c}\u{63}")
assert(table.concat(a,"\u{2c}",0x3) == "\u{63}")
assert(table.concat(a,"\u{2c}",0x4) == "")
if not _port then
local locales = {"\u{70}\u{74}\u{62}","\u{70}\u{74}\u{5f}\u{42}\u{52}\u{2e}\u{69}\u{73}\u{6f}\u{38}\u{38}\u{35}\u{39}\u{31}","\u{49}\u{53}\u{4f}\u{2d}\u{38}\u{38}\u{35}\u{39}\u{2d}\u{31}"}
local function trylocale
(w)
for i = 1, # locales
for i = 0x1, # locales
do
if os.setlocale(locales[i],w) then
print(string.format("\u{27}\u{25}\u{73}\u{27}\u{20}\u{6c}\u{6f}\u{63}\u{61}\u{6c}\u{65}\u{20}\u{73}\u{65}\u{74}\u{20}\u{74}\u{6f}\u{20}\u{27}\u{25}\u{73}\u{27}",w,locales[i]))
@ -393,36 +393,36 @@ if T == nil then
(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{27}\u{70}\u{75}\u{73}\u{68}\u{66}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{27}\u{20}\u{74}\u{65}\u{73}\u{74}\u{73}\u{20}\u{3c}\u{3c}\u{3c}\u{a}")
else
print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{27}\u{70}\u{75}\u{73}\u{68}\u{66}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{27}")
local blen = 200
local blen = 0xc8
local function callpfs
(op,fmt,n)
local x = {T.testC("\u{70}\u{75}\u{73}\u{68}\u{66}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}" .. op .. "\u{3b}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{2a}",fmt,n)}
assert(# x == 4)
return x[4]
assert(# x == 0x4)
return x[0x4]
end
local function testpfs
(op,fmt,n)
assert(callpfs(op,fmt,n) == string.format(fmt,n))
end
testpfs("\u{49}","",0)
testpfs("\u{49}",string.rep("\u{61}",blen - 1),0)
testpfs("\u{49}",string.rep("\u{61}",blen),0)
testpfs("\u{49}",string.rep("\u{61}",blen + 1),0)
local str = string.rep("\u{61}\u{62}",blen) .. "\u{25}\u{64}" .. string.rep("\u{64}",blen / 2)
testpfs("\u{49}",str,2 ^ 14)
testpfs("\u{49}",str,- 2 ^ 15)
testpfs("\u{49}","",0x0)
testpfs("\u{49}",string.rep("\u{61}",blen - 0x1),0x0)
testpfs("\u{49}",string.rep("\u{61}",blen),0x0)
testpfs("\u{49}",string.rep("\u{61}",blen + 0x1),0x0)
local str = string.rep("\u{61}\u{62}",blen) .. "\u{25}\u{64}" .. string.rep("\u{64}",blen / 0x2)
testpfs("\u{49}",str,0x2 ^ 0xe)
testpfs("\u{49}",str,- 0x2 ^ 0xf)
str="\u{25}\u{64}" .. string.rep("\u{63}\u{64}",blen)
testpfs("\u{49}",str,2 ^ 14)
testpfs("\u{49}",str,- 2 ^ 15)
str=string.rep("\u{63}",blen - 2) .. "\u{25}\u{64}"
testpfs("\u{49}",str,2 ^ 14)
testpfs("\u{49}",str,- 2 ^ 15)
for l = 12, 14
testpfs("\u{49}",str,0x2 ^ 0xe)
testpfs("\u{49}",str,- 0x2 ^ 0xf)
str=string.rep("\u{63}",blen - 0x2) .. "\u{25}\u{64}"
testpfs("\u{49}",str,0x2 ^ 0xe)
testpfs("\u{49}",str,- 0x2 ^ 0xf)
for l = 0xc, 0xe
do
local str1 = string.rep("\u{61}",l)
for i = 0, 500, 13
for i = 0x0, 0x1f4, 0xd
do
for j = 0, 500, 13
for j = 0x0, 0x1f4, 0xd
do
str=string.rep("\u{61}",i) .. "\u{25}\u{73}" .. string.rep("\u{64}",j)
testpfs("\u{53}",str,str1)
@ -432,10 +432,10 @@ end
end
str="\u{61}\u{62}\u{63}\u{20}\u{25}\u{63}\u{20}\u{64}\u{65}\u{66}"
testpfs("\u{49}",str,string.byte("\u{41}"))
testpfs("\u{49}",str,255)
str=string.rep("\u{61}",blen - 1) .. "\u{25}\u{70}" .. string.rep("\u{63}\u{64}",blen)
testpfs("\u{49}",str,0xff)
str=string.rep("\u{61}",blen - 0x1) .. "\u{25}\u{70}" .. string.rep("\u{63}\u{64}",blen)
testpfs("\u{50}",str,{})
str=string.rep("\u{25}\u{25}",3 * blen) .. "\u{25}\u{70}" .. string.rep("\u{25}\u{25}",2 * blen)
str=string.rep("\u{25}\u{25}",0x3 * blen) .. "\u{25}\u{70}" .. string.rep("\u{25}\u{25}",0x2 * blen)
testpfs("\u{50}",str,{})
end
print("\u{4f}\u{4b}")

View File

@ -2,7 +2,7 @@ local pack = string.pack
local packsize = string.packsize
local unpack = string.unpack
print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{70}\u{61}\u{63}\u{6b}\u{2f}\u{75}\u{6e}\u{70}\u{61}\u{63}\u{6b}")
local NB = 16
local NB = 0x10
local sizeshort = packsize("\u{68}")
local sizeint = packsize("\u{69}")
local sizelong = packsize("\u{6c}")
@ -11,9 +11,9 @@ local sizeLI = packsize("\u{6a}")
local sizefloat = packsize("\u{66}")
local sizedouble = packsize("\u{64}")
local sizenumber = packsize("\u{6e}")
local little = (pack("\u{69}\u{32}",1) == "\u{1}\u{0}")
local little = (pack("\u{69}\u{32}",0x1) == "\u{1}\u{0}")
local align = packsize("\u{21}\u{78}\u{58}\u{69}\u{31}\u{36}")
assert(1 <= sizeshort and sizeshort <= sizeint and sizeint <= sizelong and sizefloat <= sizedouble)
assert(0x1 <= sizeshort and sizeshort <= sizeint and sizeint <= sizelong and sizefloat <= sizedouble)
print("\u{70}\u{6c}\u{61}\u{74}\u{66}\u{6f}\u{72}\u{6d}\u{3a}")
print(string.format("\u{9}\u{73}\u{68}\u{6f}\u{72}\u{74}\u{20}\u{25}\u{64}\u{2c}\u{20}\u{69}\u{6e}\u{74}\u{20}\u{25}\u{64}\u{2c}\u{20}\u{6c}\u{6f}\u{6e}\u{67}\u{20}\u{25}\u{64}\u{2c}\u{20}\u{73}\u{69}\u{7a}\u{65}\u{5f}\u{74}\u{20}\u{25}\u{64}\u{2c}\u{20}\u{66}\u{6c}\u{6f}\u{61}\u{74}\u{20}\u{25}\u{64}\u{2c}\u{20}\u{64}\u{6f}\u{75}\u{62}\u{6c}\u{65}\u{20}\u{25}\u{64}\u{2c}\u{a}\u{9}\u{6c}\u{75}\u{61}\u{20}\u{49}\u{6e}\u{74}\u{65}\u{67}\u{65}\u{72}\u{20}\u{25}\u{64}\u{2c}\u{20}\u{6c}\u{75}\u{61}\u{20}\u{4e}\u{75}\u{6d}\u{62}\u{65}\u{72}\u{20}\u{25}\u{64}",sizeshort,sizeint,sizelong,sizesize_t,sizefloat,sizedouble,sizeLI,sizenumber))
print("\u{9}" .. (little and "\u{6c}\u{69}\u{74}\u{74}\u{6c}\u{65}" or "\u{62}\u{69}\u{67}") .. "\u{20}\u{65}\u{6e}\u{64}\u{69}\u{61}\u{6e}")
@ -23,113 +23,113 @@ local function checkerror
local status,err = pcall(f,...)
assert(not status and string.find(err,msg))
end
assert(unpack("\u{42}",pack("\u{42}",255)) == 255)
assert(unpack("\u{62}",pack("\u{62}",127)) == 127)
assert(unpack("\u{62}",pack("\u{62}",- 128)) == - 128)
assert(unpack("\u{48}",pack("\u{48}",65535)) == 65535)
assert(unpack("\u{68}",pack("\u{68}",32767)) == 32767)
assert(unpack("\u{68}",pack("\u{68}",- 32768)) == - 32768)
assert(unpack("\u{4c}",pack("\u{4c}",4294967295)) == 4294967295)
assert(unpack("\u{6c}",pack("\u{6c}",2147483647)) == 2147483647)
assert(unpack("\u{6c}",pack("\u{6c}",- 2147483648)) == - 2147483648)
for i = 1, NB
assert(unpack("\u{42}",pack("\u{42}",0xff)) == 0xff)
assert(unpack("\u{62}",pack("\u{62}",0x7f)) == 0x7f)
assert(unpack("\u{62}",pack("\u{62}",- 0x80)) == - 0x80)
assert(unpack("\u{48}",pack("\u{48}",0xffff)) == 0xffff)
assert(unpack("\u{68}",pack("\u{68}",0x7fff)) == 0x7fff)
assert(unpack("\u{68}",pack("\u{68}",- 0x8000)) == - 0x8000)
assert(unpack("\u{4c}",pack("\u{4c}",0xffffffff)) == 0xffffffff)
assert(unpack("\u{6c}",pack("\u{6c}",0x7fffffff)) == 0x7fffffff)
assert(unpack("\u{6c}",pack("\u{6c}",- 0x80000000)) == - 0x80000000)
for i = 0x1, NB
do
local s = string.rep("\u{ff}",i)
assert(pack("\u{69}" .. i,- 1) == s)
assert(pack("\u{69}" .. i,- 0x1) == s)
assert(packsize("\u{69}" .. i) == # s)
assert(unpack("\u{69}" .. i,s) == - 1)
s="\u{aa}" .. string.rep("\u{0}",i - 1)
assert(pack("\u{3c}\u{49}" .. i,170) == s)
assert(unpack("\u{3c}\u{49}" .. i,s) == 170)
assert(pack("\u{3e}\u{49}" .. i,170) == s:reverse())
assert(unpack("\u{3e}\u{49}" .. i,s:reverse()) == 170)
assert(unpack("\u{69}" .. i,s) == - 0x1)
s="\u{aa}" .. string.rep("\u{0}",i - 0x1)
assert(pack("\u{3c}\u{49}" .. i,0xaa) == s)
assert(unpack("\u{3c}\u{49}" .. i,s) == 0xaa)
assert(pack("\u{3e}\u{49}" .. i,0xaa) == s:reverse())
assert(unpack("\u{3e}\u{49}" .. i,s:reverse()) == 0xaa)
end
do
local lnum = 1510926445411202934483812811265
local lnum = 0x807060504030201
local s = pack("\u{3c}\u{6a}",lnum)
assert(unpack("\u{3c}\u{6a}",s) == lnum)
assert(unpack("\u{3c}\u{69}" .. sizeLI + 1,s .. "\u{0}") == lnum)
assert(unpack("\u{3c}\u{69}" .. sizeLI + 1,s .. "\u{0}") == lnum)
for i = sizeLI + 1, NB
assert(unpack("\u{3c}\u{69}" .. sizeLI + 0x1,s .. "\u{0}") == lnum)
assert(unpack("\u{3c}\u{69}" .. sizeLI + 0x1,s .. "\u{0}") == lnum)
for i = sizeLI + 0x1, NB
do
local s = pack("\u{3c}\u{6a}",- lnum)
assert(unpack("\u{3c}\u{6a}",s) == - lnum)
assert(unpack("\u{3c}\u{69}" .. i,s .. ("\u{ff}"):rep(i - sizeLI)) == - lnum)
assert(unpack("\u{3e}\u{69}" .. i,("\u{ff}"):rep(i - sizeLI) .. s:reverse()) == - lnum)
assert(unpack("\u{3c}\u{49}" .. i,s .. ("\u{0}"):rep(i - sizeLI)) == - lnum)
checkerror("\u{64}\u{6f}\u{65}\u{73}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{66}\u{69}\u{74}",unpack,"\u{3c}\u{49}" .. i,("\u{0}"):rep(i - 1) .. "\u{1}")
checkerror("\u{64}\u{6f}\u{65}\u{73}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{66}\u{69}\u{74}",unpack,"\u{3e}\u{69}" .. i,"\u{1}" .. ("\u{0}"):rep(i - 1))
checkerror("\u{64}\u{6f}\u{65}\u{73}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{66}\u{69}\u{74}",unpack,"\u{3c}\u{49}" .. i,("\u{0}"):rep(i - 0x1) .. "\u{1}")
checkerror("\u{64}\u{6f}\u{65}\u{73}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{66}\u{69}\u{74}",unpack,"\u{3e}\u{69}" .. i,"\u{1}" .. ("\u{0}"):rep(i - 0x1))
end
end
for i = 1, sizeLI
for i = 0x1, sizeLI
do
local lstr = "\u{1}\u{2}\u{3}\u{4}\u{5}\u{6}\u{7}\u{8}\u{9}\u{a}\u{b}\u{c}\u{d}"
local lnum = 1510926445411202934483812811265
local n = lnum & (~ (- 1 << (i * 8)))
local s = string.sub(lstr,1,i)
local lnum = 0x807060504030201
local n = lnum & (~ (- 0x1 << (i * 0x8)))
local s = string.sub(lstr,0x1,i)
assert(pack("\u{3c}\u{69}" .. i,n) == s)
assert(pack("\u{3e}\u{69}" .. i,n) == s:reverse())
assert(unpack("\u{3e}\u{69}" .. i,s:reverse()) == n)
end
do
local u = 240
for i = 1, sizeLI - 1
local u = 0xf0
for i = 0x1, sizeLI - 0x1
do
assert(unpack("\u{3c}\u{69}" .. i,"\u{f0}" .. ("\u{ff}"):rep(i - 1)) == - 16)
assert(unpack("\u{3e}\u{49}" .. i,"\u{f0}" .. ("\u{ff}"):rep(i - 1)) == u)
u=u * 256 + 255
assert(unpack("\u{3c}\u{69}" .. i,"\u{f0}" .. ("\u{ff}"):rep(i - 0x1)) == - 0x10)
assert(unpack("\u{3e}\u{49}" .. i,"\u{f0}" .. ("\u{ff}"):rep(i - 0x1)) == u)
u=u * 0x100 + 0xff
end
end
do
assert(pack("\u{3e}\u{69}\u{32}\u{20}\u{3c}\u{69}\u{32}",10,20) == "\u{0}\u{a}\u{14}\u{0}")
assert(pack("\u{3e}\u{69}\u{32}\u{20}\u{3c}\u{69}\u{32}",0xa,0x14) == "\u{0}\u{a}\u{14}\u{0}")
local a,b = unpack("\u{3c}\u{69}\u{32}\u{20}\u{3e}\u{69}\u{32}","\u{a}\u{0}\u{0}\u{14}")
assert(a == 10 and b == 20)
assert(pack("\u{3d}\u{69}\u{34}",2001) == pack("\u{69}\u{34}",2001))
assert(a == 0xa and b == 0x14)
assert(pack("\u{3d}\u{69}\u{34}",0x7d1) == pack("\u{69}\u{34}",0x7d1))
end
print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\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}\u{73}")
checkerror("\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{6c}\u{69}\u{6d}\u{69}\u{74}\u{73}",pack,"\u{69}\u{30}",0)
checkerror("\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{6c}\u{69}\u{6d}\u{69}\u{74}\u{73}",pack,"\u{69}" .. NB + 1,0)
checkerror("\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{6c}\u{69}\u{6d}\u{69}\u{74}\u{73}",pack,"\u{21}" .. NB + 1,0)
checkerror("\u{25}\u{28}\u{31}\u{37}\u{25}\u{29}\u{20}\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{6c}\u{69}\u{6d}\u{69}\u{74}\u{73}\u{20}\u{25}\u{5b}\u{31}\u{2c}\u{31}\u{36}\u{25}\u{5d}",pack,"\u{58}\u{69}" .. NB + 1)
checkerror("\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}\u{20}\u{6f}\u{70}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{27}\u{72}\u{27}",pack,"\u{69}\u{33}\u{72}",0)
checkerror("\u{31}\u{36}\u{25}\u{2d}\u{62}\u{79}\u{74}\u{65}\u{20}\u{69}\u{6e}\u{74}\u{65}\u{67}\u{65}\u{72}",unpack,"\u{69}\u{31}\u{36}",string.rep("\u{3}",16))
checkerror("\u{6e}\u{6f}\u{74}\u{20}\u{70}\u{6f}\u{77}\u{65}\u{72}\u{20}\u{6f}\u{66}\u{20}\u{32}",pack,"\u{21}\u{34}\u{69}\u{33}",0)
checkerror("\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{6c}\u{69}\u{6d}\u{69}\u{74}\u{73}",pack,"\u{69}\u{30}",0x0)
checkerror("\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{6c}\u{69}\u{6d}\u{69}\u{74}\u{73}",pack,"\u{69}" .. NB + 0x1,0x0)
checkerror("\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{6c}\u{69}\u{6d}\u{69}\u{74}\u{73}",pack,"\u{21}" .. NB + 0x1,0x0)
checkerror("\u{25}\u{28}\u{31}\u{37}\u{25}\u{29}\u{20}\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{6c}\u{69}\u{6d}\u{69}\u{74}\u{73}\u{20}\u{25}\u{5b}\u{31}\u{2c}\u{31}\u{36}\u{25}\u{5d}",pack,"\u{58}\u{69}" .. NB + 0x1)
checkerror("\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}\u{20}\u{6f}\u{70}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{27}\u{72}\u{27}",pack,"\u{69}\u{33}\u{72}",0x0)
checkerror("\u{31}\u{36}\u{25}\u{2d}\u{62}\u{79}\u{74}\u{65}\u{20}\u{69}\u{6e}\u{74}\u{65}\u{67}\u{65}\u{72}",unpack,"\u{69}\u{31}\u{36}",string.rep("\u{3}",0x10))
checkerror("\u{6e}\u{6f}\u{74}\u{20}\u{70}\u{6f}\u{77}\u{65}\u{72}\u{20}\u{6f}\u{66}\u{20}\u{32}",pack,"\u{21}\u{34}\u{69}\u{33}",0x0)
;
checkerror("\u{6d}\u{69}\u{73}\u{73}\u{69}\u{6e}\u{67}\u{20}\u{73}\u{69}\u{7a}\u{65}",pack,"\u{63}","")
checkerror("\u{76}\u{61}\u{72}\u{69}\u{61}\u{62}\u{6c}\u{65}\u{25}\u{2d}\u{6c}\u{65}\u{6e}\u{67}\u{74}\u{68}\u{20}\u{66}\u{6f}\u{72}\u{6d}\u{61}\u{74}",packsize,"\u{73}")
checkerror("\u{76}\u{61}\u{72}\u{69}\u{61}\u{62}\u{6c}\u{65}\u{25}\u{2d}\u{6c}\u{65}\u{6e}\u{67}\u{74}\u{68}\u{20}\u{66}\u{6f}\u{72}\u{6d}\u{61}\u{74}",packsize,"\u{7a}")
checkerror("\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}",packsize,"\u{63}\u{31}" .. string.rep("\u{30}",40))
if packsize("\u{69}") == 4 then
local s = string.rep("\u{63}\u{32}\u{36}\u{38}\u{34}\u{33}\u{35}\u{34}\u{35}\u{36}",2 ^ 3)
checkerror("\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}",packsize,"\u{63}\u{31}" .. string.rep("\u{30}",0x28))
if packsize("\u{69}") == 0x4 then
local s = string.rep("\u{63}\u{32}\u{36}\u{38}\u{34}\u{33}\u{35}\u{34}\u{35}\u{36}",0x2 ^ 0x3)
checkerror("\u{74}\u{6f}\u{6f}\u{20}\u{6c}\u{61}\u{72}\u{67}\u{65}",packsize,s)
s=string.rep("\u{63}\u{32}\u{36}\u{38}\u{34}\u{33}\u{35}\u{34}\u{35}\u{36}",2 ^ 3 - 1) .. "\u{63}\u{32}\u{36}\u{38}\u{34}\u{33}\u{35}\u{34}\u{35}\u{35}"
assert(packsize(s) == 2147483647)
s=string.rep("\u{63}\u{32}\u{36}\u{38}\u{34}\u{33}\u{35}\u{34}\u{35}\u{36}",0x2 ^ 0x3 - 0x1) .. "\u{63}\u{32}\u{36}\u{38}\u{34}\u{33}\u{35}\u{34}\u{35}\u{35}"
assert(packsize(s) == 0x7fffffff)
end
for i = 1, sizeLI - 1
for i = 0x1, sizeLI - 0x1
do
local umax = (1 << (i * 8)) - 1
local max = umax >> 1
local umax = (0x1 << (i * 0x8)) - 0x1
local max = umax >> 0x1
local min = ~ max
checkerror("\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}",pack,"\u{3c}\u{49}" .. i,- 1)
checkerror("\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}",pack,"\u{3c}\u{49}" .. i,- 0x1)
checkerror("\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}",pack,"\u{3c}\u{49}" .. i,min)
checkerror("\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}",pack,"\u{3e}\u{49}" .. i,umax + 1)
checkerror("\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}",pack,"\u{3e}\u{49}" .. i,umax + 0x1)
checkerror("\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}",pack,"\u{3e}\u{69}" .. i,umax)
checkerror("\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}",pack,"\u{3e}\u{69}" .. i,max + 1)
checkerror("\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}",pack,"\u{3c}\u{69}" .. i,min - 1)
checkerror("\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}",pack,"\u{3e}\u{69}" .. i,max + 0x1)
checkerror("\u{6f}\u{76}\u{65}\u{72}\u{66}\u{6c}\u{6f}\u{77}",pack,"\u{3c}\u{69}" .. i,min - 0x1)
assert(unpack("\u{3e}\u{69}" .. i,pack("\u{3e}\u{69}" .. i,max)) == max)
assert(unpack("\u{3c}\u{69}" .. i,pack("\u{3c}\u{69}" .. i,min)) == min)
assert(unpack("\u{3e}\u{49}" .. i,pack("\u{3e}\u{49}" .. i,umax)) == umax)
end
assert(unpack("\u{3e}\u{6a}",pack("\u{3e}\u{6a}",math.maxinteger)) == math.maxinteger)
assert(unpack("\u{3c}\u{6a}",pack("\u{3c}\u{6a}",math.mininteger)) == math.mininteger)
assert(unpack("\u{3c}\u{4a}",pack("\u{3c}\u{6a}",- 1)) == - 1)
assert(unpack("\u{3c}\u{4a}",pack("\u{3c}\u{6a}",- 0x1)) == - 0x1)
if little then
assert(pack("\u{66}",24) == pack("\u{3c}\u{66}",24))
assert(pack("\u{66}",0x18) == pack("\u{3c}\u{66}",0x18))
else
assert(pack("\u{66}",24) == pack("\u{3e}\u{66}",24))
assert(pack("\u{66}",0x18) == pack("\u{3e}\u{66}",0x18))
end
print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{70}\u{61}\u{63}\u{6b}\u{2f}\u{75}\u{6e}\u{70}\u{61}\u{63}\u{6b}\u{20}\u{6f}\u{66}\u{20}\u{66}\u{6c}\u{6f}\u{61}\u{74}\u{69}\u{6e}\u{67}\u{2d}\u{70}\u{6f}\u{69}\u{6e}\u{74}\u{20}\u{6e}\u{75}\u{6d}\u{62}\u{65}\u{72}\u{73}")
for _,n in ipairs({0,- 1.1,1.9,1 / 0,- 1 / 0,1e20,- 1e20,0.1,2000.7})
for _,n in ipairs({0x0,- 1.1,1.9,0x1 / 0x0,- 0x1 / 0x0,1e20,- 1e20,0.1,2000.7})
do
assert(unpack("\u{6e}",pack("\u{6e}",n)) == n)
assert(unpack("\u{3c}\u{6e}",pack("\u{3c}\u{6e}",n)) == n)
@ -137,7 +137,7 @@ assert(unpack("\u{3e}\u{6e}",pack("\u{3e}\u{6e}",n)) == n)
assert(pack("\u{3c}\u{66}",n) == pack("\u{3e}\u{66}",n):reverse())
assert(pack("\u{3e}\u{64}",n) == pack("\u{3c}\u{64}",n):reverse())
end
for _,n in ipairs({0,- 1.5,1 / 0,- 1 / 0,1e10,- 1e9,0.5,2000.25})
for _,n in ipairs({0x0,- 1.5,0x1 / 0x0,- 0x1 / 0x0,1e10,- 1e9,0.5,2000.25})
do
assert(unpack("\u{3c}\u{66}",pack("\u{3c}\u{66}",n)) == n)
assert(unpack("\u{3e}\u{66}",pack("\u{3e}\u{66}",n)) == n)
@ -146,17 +146,17 @@ assert(unpack("\u{3e}\u{64}",pack("\u{3e}\u{64}",n)) == n)
end
print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{70}\u{61}\u{63}\u{6b}\u{2f}\u{75}\u{6e}\u{70}\u{61}\u{63}\u{6b}\u{20}\u{6f}\u{66}\u{20}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}\u{73}")
do
local s = string.rep("\u{61}\u{62}\u{63}",1000)
assert(pack("\u{7a}\u{42}",s,247) == s .. "\u{0}\u{f7}")
local s = string.rep("\u{61}\u{62}\u{63}",0x3e8)
assert(pack("\u{7a}\u{42}",s,0xf7) == s .. "\u{0}\u{f7}")
local s1,b = unpack("\u{7a}\u{42}",s .. "\u{0}\u{f9}")
assert(b == 249 and s1 == s)
assert(b == 0xf9 and s1 == s)
s1=pack("\u{73}",s)
assert(unpack("\u{73}",s1) == s)
checkerror("\u{64}\u{6f}\u{65}\u{73}\u{20}\u{6e}\u{6f}\u{74}\u{20}\u{66}\u{69}\u{74}",pack,"\u{73}\u{31}",s)
checkerror("\u{63}\u{6f}\u{6e}\u{74}\u{61}\u{69}\u{6e}\u{73}\u{20}\u{7a}\u{65}\u{72}\u{6f}\u{73}",pack,"\u{7a}","\u{61}\u{6c}\u{6f}\u{0}")
;
checkerror("\u{75}\u{6e}\u{66}\u{69}\u{6e}\u{69}\u{73}\u{68}\u{65}\u{64}\u{20}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}",unpack,"\u{7a}\u{63}\u{31}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}\u{30}","\u{61}\u{6c}\u{6f}")
for i = 2, NB
for i = 0x2, NB
do
local s1 = pack("\u{73}" .. i,s)
assert(unpack("\u{73}" .. i,s1) == s and # s1 == # s + i)
@ -164,96 +164,96 @@ end
end
do
local x = pack("\u{73}","\u{61}\u{6c}\u{6f}")
checkerror("\u{74}\u{6f}\u{6f}\u{20}\u{73}\u{68}\u{6f}\u{72}\u{74}",unpack,"\u{73}",x:sub(1,- 2))
checkerror("\u{74}\u{6f}\u{6f}\u{20}\u{73}\u{68}\u{6f}\u{72}\u{74}",unpack,"\u{73}",x:sub(0x1,- 0x2))
checkerror("\u{74}\u{6f}\u{6f}\u{20}\u{73}\u{68}\u{6f}\u{72}\u{74}",unpack,"\u{63}\u{35}","\u{61}\u{62}\u{63}\u{64}")
checkerror("\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{6c}\u{69}\u{6d}\u{69}\u{74}\u{73}",pack,"\u{73}\u{31}\u{30}\u{30}","\u{61}\u{6c}\u{6f}")
end
do
assert(pack("\u{63}\u{30}","") == "")
assert(packsize("\u{63}\u{30}") == 0)
assert(packsize("\u{63}\u{30}") == 0x0)
assert(unpack("\u{63}\u{30}","") == "")
assert(pack("\u{3c}\u{21}\u{20}\u{63}\u{33}","\u{61}\u{62}\u{63}") == "\u{61}\u{62}\u{63}")
assert(packsize("\u{3c}\u{21}\u{20}\u{63}\u{33}") == 3)
assert(packsize("\u{3c}\u{21}\u{20}\u{63}\u{33}") == 0x3)
assert(pack("\u{3e}\u{21}\u{34}\u{20}\u{63}\u{36}","\u{61}\u{62}\u{63}\u{64}\u{65}\u{66}") == "\u{61}\u{62}\u{63}\u{64}\u{65}\u{66}")
assert(pack("\u{63}\u{33}","\u{31}\u{32}\u{33}") == "\u{31}\u{32}\u{33}")
assert(pack("\u{63}\u{30}","") == "")
assert(pack("\u{63}\u{38}","\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}") == "\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{0}\u{0}")
assert(pack("\u{63}\u{38}\u{38}","") == string.rep("\u{0}",88))
assert(pack("\u{63}\u{31}\u{38}\u{38}","\u{61}\u{62}") == "\u{61}\u{62}" .. string.rep("\u{0}",188 - 2))
assert(pack("\u{63}\u{38}\u{38}","") == string.rep("\u{0}",0x58))
assert(pack("\u{63}\u{31}\u{38}\u{38}","\u{61}\u{62}") == "\u{61}\u{62}" .. string.rep("\u{0}",0xbc - 0x2))
local a,b,c = unpack("\u{21}\u{34}\u{20}\u{7a}\u{20}\u{63}\u{33}","\u{61}\u{62}\u{63}\u{64}\u{65}\u{66}\u{67}\u{68}\u{69}\u{0}\u{78}\u{79}\u{7a}")
assert(a == "\u{61}\u{62}\u{63}\u{64}\u{65}\u{66}\u{67}\u{68}\u{69}" and b == "\u{78}\u{79}\u{7a}" and c == 14)
assert(a == "\u{61}\u{62}\u{63}\u{64}\u{65}\u{66}\u{67}\u{68}\u{69}" and b == "\u{78}\u{79}\u{7a}" and c == 0xe)
checkerror("\u{6c}\u{6f}\u{6e}\u{67}\u{65}\u{72}\u{20}\u{74}\u{68}\u{61}\u{6e}",pack,"\u{63}\u{33}","\u{31}\u{32}\u{33}\u{34}")
end
do
local x = pack("\u{3c}\u{62}\u{20}\u{68}\u{20}\u{62}\u{20}\u{66}\u{20}\u{64}\u{20}\u{66}\u{20}\u{6e}\u{20}\u{69}",1,2,3,4,5,6,7,8)
local x = pack("\u{3c}\u{62}\u{20}\u{68}\u{20}\u{62}\u{20}\u{66}\u{20}\u{64}\u{20}\u{66}\u{20}\u{6e}\u{20}\u{69}",0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8)
assert(# x == packsize("\u{3c}\u{62}\u{20}\u{68}\u{20}\u{62}\u{20}\u{66}\u{20}\u{64}\u{20}\u{66}\u{20}\u{6e}\u{20}\u{69}"))
local a,b,c,d,e,f,g,h = unpack("\u{3c}\u{62}\u{20}\u{68}\u{20}\u{62}\u{20}\u{66}\u{20}\u{64}\u{20}\u{66}\u{20}\u{6e}\u{20}\u{69}",x)
assert(a == 1 and b == 2 and c == 3 and d == 4 and e == 5 and f == 6 and g == 7 and h == 8)
assert(a == 0x1 and b == 0x2 and c == 0x3 and d == 0x4 and e == 0x5 and f == 0x6 and g == 0x7 and h == 0x8)
end
print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{61}\u{6c}\u{69}\u{67}\u{6e}\u{6d}\u{65}\u{6e}\u{74}")
do
assert(pack("\u{20}\u{3c}\u{20}\u{69}\u{31}\u{20}\u{69}\u{32}\u{20}",2,3) == "\u{2}\u{3}\u{0}")
local x = pack("\u{3e}\u{21}\u{38}\u{20}\u{62}\u{20}\u{58}\u{68}\u{20}\u{69}\u{34}\u{20}\u{69}\u{38}\u{20}\u{63}\u{31}\u{20}\u{58}\u{69}\u{38}",- 12,100,200,"\u{ec}")
assert(pack("\u{20}\u{3c}\u{20}\u{69}\u{31}\u{20}\u{69}\u{32}\u{20}",0x2,0x3) == "\u{2}\u{3}\u{0}")
local x = pack("\u{3e}\u{21}\u{38}\u{20}\u{62}\u{20}\u{58}\u{68}\u{20}\u{69}\u{34}\u{20}\u{69}\u{38}\u{20}\u{63}\u{31}\u{20}\u{58}\u{69}\u{38}",- 0xc,0x64,0xc8,"\u{ec}")
assert(# x == packsize("\u{3e}\u{21}\u{38}\u{20}\u{62}\u{20}\u{58}\u{68}\u{20}\u{69}\u{34}\u{20}\u{69}\u{38}\u{20}\u{63}\u{31}\u{20}\u{58}\u{69}\u{38}"))
assert(x == "\u{f4}" .. "\u{0}\u{0}\u{0}" .. "\u{0}\u{0}\u{0}\u{64}" .. "\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{c8}" .. "\u{ec}" .. "\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}")
local a,b,c,d,pos = unpack("\u{3e}\u{21}\u{38}\u{20}\u{63}\u{31}\u{20}\u{58}\u{68}\u{20}\u{69}\u{34}\u{20}\u{69}\u{38}\u{20}\u{62}\u{20}\u{58}\u{69}\u{38}\u{20}\u{58}\u{49}\u{20}\u{58}\u{48}",x)
assert(a == "\u{f4}" and b == 100 and c == 200 and d == - 20 and (pos - 1) == # x)
x=pack("\u{3e}\u{21}\u{34}\u{20}\u{63}\u{33}\u{20}\u{63}\u{34}\u{20}\u{63}\u{32}\u{20}\u{7a}\u{20}\u{69}\u{34}\u{20}\u{63}\u{35}\u{20}\u{63}\u{32}\u{20}\u{58}\u{69}\u{34}","\u{61}\u{62}\u{63}","\u{61}\u{62}\u{63}\u{64}","\u{78}\u{7a}","\u{68}\u{65}\u{6c}\u{6c}\u{6f}",5,"\u{77}\u{6f}\u{72}\u{6c}\u{64}","\u{78}\u{79}")
assert(a == "\u{f4}" and b == 0x64 and c == 0xc8 and d == - 0x14 and (pos - 0x1) == # x)
x=pack("\u{3e}\u{21}\u{34}\u{20}\u{63}\u{33}\u{20}\u{63}\u{34}\u{20}\u{63}\u{32}\u{20}\u{7a}\u{20}\u{69}\u{34}\u{20}\u{63}\u{35}\u{20}\u{63}\u{32}\u{20}\u{58}\u{69}\u{34}","\u{61}\u{62}\u{63}","\u{61}\u{62}\u{63}\u{64}","\u{78}\u{7a}","\u{68}\u{65}\u{6c}\u{6c}\u{6f}",0x5,"\u{77}\u{6f}\u{72}\u{6c}\u{64}","\u{78}\u{79}")
assert(x == "\u{61}\u{62}\u{63}\u{61}\u{62}\u{63}\u{64}\u{78}\u{7a}\u{68}\u{65}\u{6c}\u{6c}\u{6f}\u{0}\u{0}\u{0}\u{0}\u{0}\u{5}\u{77}\u{6f}\u{72}\u{6c}\u{64}\u{78}\u{79}\u{0}")
local a,b,c,d,e,f,g,pos = unpack("\u{3e}\u{21}\u{34}\u{20}\u{63}\u{33}\u{20}\u{63}\u{34}\u{20}\u{63}\u{32}\u{20}\u{7a}\u{20}\u{69}\u{34}\u{20}\u{63}\u{35}\u{20}\u{63}\u{32}\u{20}\u{58}\u{68}\u{20}\u{58}\u{69}\u{34}",x)
assert(a == "\u{61}\u{62}\u{63}" and b == "\u{61}\u{62}\u{63}\u{64}" and c == "\u{78}\u{7a}" and d == "\u{68}\u{65}\u{6c}\u{6c}\u{6f}" and e == 5 and f == "\u{77}\u{6f}\u{72}\u{6c}\u{64}" and g == "\u{78}\u{79}" and (pos - 1) % 4 == 0)
x=pack("\u{20}\u{62}\u{20}\u{62}\u{20}\u{58}\u{64}\u{20}\u{62}\u{20}\u{58}\u{62}\u{20}\u{78}",1,2,3)
assert(packsize("\u{20}\u{62}\u{20}\u{62}\u{20}\u{58}\u{64}\u{20}\u{62}\u{20}\u{58}\u{62}\u{20}\u{78}") == 4)
assert(a == "\u{61}\u{62}\u{63}" and b == "\u{61}\u{62}\u{63}\u{64}" and c == "\u{78}\u{7a}" and d == "\u{68}\u{65}\u{6c}\u{6c}\u{6f}" and e == 0x5 and f == "\u{77}\u{6f}\u{72}\u{6c}\u{64}" and g == "\u{78}\u{79}" and (pos - 0x1) % 0x4 == 0x0)
x=pack("\u{20}\u{62}\u{20}\u{62}\u{20}\u{58}\u{64}\u{20}\u{62}\u{20}\u{58}\u{62}\u{20}\u{78}",0x1,0x2,0x3)
assert(packsize("\u{20}\u{62}\u{20}\u{62}\u{20}\u{58}\u{64}\u{20}\u{62}\u{20}\u{58}\u{62}\u{20}\u{78}") == 0x4)
assert(x == "\u{1}\u{2}\u{3}\u{0}")
a,b,c,pos=unpack("\u{62}\u{62}\u{58}\u{64}\u{62}",x)
assert(a == 1 and b == 2 and c == 3 and pos == # x)
assert(packsize("\u{21}\u{38}\u{20}\u{78}\u{58}\u{69}\u{38}") == 8)
assert(a == 0x1 and b == 0x2 and c == 0x3 and pos == # x)
assert(packsize("\u{21}\u{38}\u{20}\u{78}\u{58}\u{69}\u{38}") == 0x8)
local pos = unpack("\u{21}\u{38}\u{20}\u{78}\u{58}\u{69}\u{38}","\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}")
;
assert(pos == 9)
assert(packsize("\u{21}\u{38}\u{20}\u{78}\u{58}\u{69}\u{32}") == 2)
assert(pos == 0x9)
assert(packsize("\u{21}\u{38}\u{20}\u{78}\u{58}\u{69}\u{32}") == 0x2)
local pos = unpack("\u{21}\u{38}\u{20}\u{78}\u{58}\u{69}\u{32}","\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}")
;
assert(pos == 3)
assert(packsize("\u{21}\u{32}\u{20}\u{78}\u{58}\u{69}\u{32}") == 2)
assert(pos == 0x3)
assert(packsize("\u{21}\u{32}\u{20}\u{78}\u{58}\u{69}\u{32}") == 0x2)
local pos = unpack("\u{21}\u{32}\u{20}\u{78}\u{58}\u{69}\u{32}","\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}")
;
assert(pos == 3)
assert(packsize("\u{21}\u{32}\u{20}\u{78}\u{58}\u{69}\u{38}") == 2)
assert(pos == 0x3)
assert(packsize("\u{21}\u{32}\u{20}\u{78}\u{58}\u{69}\u{38}") == 0x2)
local pos = unpack("\u{21}\u{32}\u{20}\u{78}\u{58}\u{69}\u{38}","\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}")
;
assert(pos == 3)
assert(packsize("\u{21}\u{31}\u{36}\u{20}\u{78}\u{58}\u{69}\u{31}\u{36}") == 16)
assert(pos == 0x3)
assert(packsize("\u{21}\u{31}\u{36}\u{20}\u{78}\u{58}\u{69}\u{31}\u{36}") == 0x10)
local pos = unpack("\u{21}\u{31}\u{36}\u{20}\u{78}\u{58}\u{69}\u{31}\u{36}","\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{30}\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}")
;
assert(pos == 17)
assert(pos == 0x11)
checkerror("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{6e}\u{65}\u{78}\u{74}\u{20}\u{6f}\u{70}\u{74}\u{69}\u{6f}\u{6e}",pack,"\u{58}")
checkerror("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{6e}\u{65}\u{78}\u{74}\u{20}\u{6f}\u{70}\u{74}\u{69}\u{6f}\u{6e}",unpack,"\u{58}\u{58}\u{69}","")
checkerror("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{6e}\u{65}\u{78}\u{74}\u{20}\u{6f}\u{70}\u{74}\u{69}\u{6f}\u{6e}",unpack,"\u{58}\u{20}\u{69}","")
checkerror("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{6e}\u{65}\u{78}\u{74}\u{20}\u{6f}\u{70}\u{74}\u{69}\u{6f}\u{6e}",pack,"\u{58}\u{63}\u{31}")
end
do
local x = pack("\u{69}\u{34}\u{69}\u{34}\u{69}\u{34}\u{69}\u{34}",1,2,3,4)
for pos = 1, 16, 4
local x = pack("\u{69}\u{34}\u{69}\u{34}\u{69}\u{34}\u{69}\u{34}",0x1,0x2,0x3,0x4)
for pos = 0x1, 0x10, 0x4
do
local i,p = unpack("\u{69}\u{34}",x,pos)
assert(i == pos // 4 + 1 and p == pos + 4)
assert(i == pos // 0x4 + 0x1 and p == pos + 0x4)
end
for pos = 0, 12
for pos = 0x0, 0xc
do
local i,p = unpack("\u{21}\u{34}\u{20}\u{69}\u{34}",x,pos + 1)
assert(i == (pos + 3) // 4 + 1 and p == i * 4 + 1)
local i,p = unpack("\u{21}\u{34}\u{20}\u{69}\u{34}",x,pos + 0x1)
assert(i == (pos + 0x3) // 0x4 + 0x1 and p == i * 0x4 + 0x1)
end
local i,p = unpack("\u{21}\u{34}\u{20}\u{69}\u{34}",x,- 4)
assert(i == 4 and p == 17)
local i,p = unpack("\u{21}\u{34}\u{20}\u{69}\u{34}",x,- 7)
assert(i == 4 and p == 17)
local i,p = unpack("\u{21}\u{34}\u{20}\u{69}\u{34}",x,- 0x4)
assert(i == 0x4 and p == 0x11)
local i,p = unpack("\u{21}\u{34}\u{20}\u{69}\u{34}",x,- 0x7)
assert(i == 0x4 and p == 0x11)
local i,p = unpack("\u{21}\u{34}\u{20}\u{69}\u{34}",x,- # x)
assert(i == 1 and p == 5)
for i = 1, # x + 1
assert(i == 0x1 and p == 0x5)
for i = 0x1, # x + 0x1
do
assert(unpack("\u{63}\u{30}",x,i) == "")
end
checkerror("\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}",unpack,"\u{63}\u{30}",x,# x + 2)
checkerror("\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}",unpack,"\u{63}\u{30}",x,# x + 0x2)
end
print("\u{4f}\u{4b}")

View File

@ -13,69 +13,69 @@ local justone = "\u{5e}" .. utf8.charpattern .. "\u{24}"
local function checksyntax
(s,t)
local ts = {"\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{27}"}
for i = 1, # t
for i = 0x1, # t
do
ts[i + 1]=string.format("\u{5c}\u{75}\u{7b}\u{25}\u{78}\u{7d}",t[i])
ts[i + 0x1]=string.format("\u{5c}\u{75}\u{7b}\u{25}\u{78}\u{7d}",t[i])
end
ts[# t + 2]="\u{27}"
ts[# t + 0x2]="\u{27}"
ts=table.concat(ts)
assert(assert(load(ts))() == s)
end
assert(not utf8.offset("\u{61}\u{6c}\u{6f}",5))
assert(not utf8.offset("\u{61}\u{6c}\u{6f}",- 4))
assert(not utf8.offset("\u{61}\u{6c}\u{6f}",0x5))
assert(not utf8.offset("\u{61}\u{6c}\u{6f}",- 0x4))
local function check
(s,t,nonstrict)
local l = utf8.len(s,1,- 1,nonstrict)
local l = utf8.len(s,0x1,- 0x1,nonstrict)
assert(# t == l and len(s) == l)
assert(utf8.char(table.unpack(t)) == s)
assert(utf8.offset(s,0) == 1)
assert(utf8.offset(s,0x0) == 0x1)
checksyntax(s,t)
local t1 = {utf8.codepoint(s,1,- 1,nonstrict)}
local t1 = {utf8.codepoint(s,0x1,- 0x1,nonstrict)}
assert(# t == # t1)
for i = 1, # t
for i = 0x1, # t
do
assert(t[i] == t1[i])
end
for i = 1, l
for i = 0x1, l
do
local pi = utf8.offset(s,i)
local pi1 = utf8.offset(s,2,pi)
assert(string.find(string.sub(s,pi,pi1 - 1),justone))
assert(utf8.offset(s,- 1,pi1) == pi)
assert(utf8.offset(s,i - l - 1) == pi)
local pi1 = utf8.offset(s,0x2,pi)
assert(string.find(string.sub(s,pi,pi1 - 0x1),justone))
assert(utf8.offset(s,- 0x1,pi1) == pi)
assert(utf8.offset(s,i - l - 0x1) == pi)
assert(pi1 - pi == # utf8.char(utf8.codepoint(s,pi,pi,nonstrict)))
for j = pi, pi1 - 1
for j = pi, pi1 - 0x1
do
assert(utf8.offset(s,0,j) == pi)
assert(utf8.offset(s,0x0,j) == pi)
end
for j = pi + 1, pi1 - 1
for j = pi + 0x1, pi1 - 0x1
do
assert(not utf8.len(s,j))
end
assert(utf8.len(s,pi,pi,nonstrict) == 1)
assert(utf8.len(s,pi,pi1 - 1,nonstrict) == 1)
assert(utf8.len(s,pi,- 1,nonstrict) == l - i + 1)
assert(utf8.len(s,pi1,- 1,nonstrict) == l - i)
assert(utf8.len(s,1,pi,nonstrict) == i)
assert(utf8.len(s,pi,pi,nonstrict) == 0x1)
assert(utf8.len(s,pi,pi1 - 0x1,nonstrict) == 0x1)
assert(utf8.len(s,pi,- 0x1,nonstrict) == l - i + 0x1)
assert(utf8.len(s,pi1,- 0x1,nonstrict) == l - i)
assert(utf8.len(s,0x1,pi,nonstrict) == i)
end
local i = 0
local i = 0x0
for p,c in utf8.codes(s,nonstrict)
do
i=i + 1
i=i + 0x1
assert(c == t[i] and p == utf8.offset(s,i))
assert(utf8.codepoint(s,p,p,nonstrict) == c)
end
assert(i == # t)
i=0
i=0x0
for c in string.gmatch(s,utf8.charpattern)
do
i=i + 1
i=i + 0x1
assert(c == utf8.char(t[i]))
end
assert(i == # t)
for i = 1, l
for i = 0x1, l
do
assert(utf8.offset(s,i) == utf8.offset(s,i - l - 1,# s + 1))
assert(utf8.offset(s,i) == utf8.offset(s,i - l - 0x1,# s + 0x1))
end
end
do
@ -84,15 +84,15 @@ local function check
local a,b = utf8.len(s)
assert(not a and b == p)
end
check("\u{61}\u{62}\u{63}\u{e3}\u{64}\u{65}\u{66}",4)
check("\u{f4}\u{9f}\u{bf}",1)
check("\u{f4}\u{9f}\u{bf}\u{bf}",1)
check("\u{e6}\u{b1}\u{89}\u{e5}\u{ad}\u{97}\u{80}",# ("\u{e6}\u{b1}\u{89}\u{e5}\u{ad}\u{97}") + 1)
check("\u{80}\u{68}\u{65}\u{6c}\u{6c}\u{6f}",1)
check("\u{68}\u{65}\u{6c}\u{80}\u{6c}\u{6f}",4)
check("\u{e6}\u{b1}\u{89}\u{e5}\u{ad}\u{97}\u{bf}",# ("\u{e6}\u{b1}\u{89}\u{e5}\u{ad}\u{97}") + 1)
check("\u{bf}\u{68}\u{65}\u{6c}\u{6c}\u{6f}",1)
check("\u{68}\u{65}\u{6c}\u{bf}\u{6c}\u{6f}",4)
check("\u{61}\u{62}\u{63}\u{e3}\u{64}\u{65}\u{66}",0x4)
check("\u{f4}\u{9f}\u{bf}",0x1)
check("\u{f4}\u{9f}\u{bf}\u{bf}",0x1)
check("\u{e6}\u{b1}\u{89}\u{e5}\u{ad}\u{97}\u{80}",# ("\u{e6}\u{b1}\u{89}\u{e5}\u{ad}\u{97}") + 0x1)
check("\u{80}\u{68}\u{65}\u{6c}\u{6c}\u{6f}",0x1)
check("\u{68}\u{65}\u{6c}\u{80}\u{6c}\u{6f}",0x4)
check("\u{e6}\u{b1}\u{89}\u{e5}\u{ad}\u{97}\u{bf}",# ("\u{e6}\u{b1}\u{89}\u{e5}\u{ad}\u{97}") + 0x1)
check("\u{bf}\u{68}\u{65}\u{6c}\u{6c}\u{6f}",0x1)
check("\u{68}\u{65}\u{6c}\u{bf}\u{6c}\u{6f}",0x4)
end
do
local function errorcodes
@ -110,49 +110,49 @@ errorcodes("\u{69}\u{6e}\u{80}\u{76}\u{61}\u{6c}\u{69}\u{64}")
errorcodes("\u{bf}\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}")
errorcodes("\u{ce}\u{b1}\u{ce}\u{bb}\u{cf}\u{86}\u{bf}\u{ce}\u{b1}")
local f = utf8.codes("")
assert(f("",2) == nil)
assert(f("",- 1) == nil)
assert(f("",0x2) == nil)
assert(f("",- 0x1) == nil)
assert(f("",math.mininteger) == nil)
end
checkerror("\u{70}\u{6f}\u{73}\u{69}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{62}\u{6f}\u{75}\u{6e}\u{64}\u{73}",utf8.offset,"\u{61}\u{62}\u{63}",1,5)
checkerror("\u{70}\u{6f}\u{73}\u{69}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{62}\u{6f}\u{75}\u{6e}\u{64}\u{73}",utf8.offset,"\u{61}\u{62}\u{63}",1,- 4)
checkerror("\u{70}\u{6f}\u{73}\u{69}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{62}\u{6f}\u{75}\u{6e}\u{64}\u{73}",utf8.offset,"",1,2)
checkerror("\u{70}\u{6f}\u{73}\u{69}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{62}\u{6f}\u{75}\u{6e}\u{64}\u{73}",utf8.offset,"",1,- 1)
checkerror("\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{62}\u{79}\u{74}\u{65}",utf8.offset,"\u{f0}\u{a6}\u{a7}\u{ba}",1,2)
checkerror("\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{62}\u{79}\u{74}\u{65}",utf8.offset,"\u{f0}\u{a6}\u{a7}\u{ba}",1,2)
checkerror("\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{62}\u{79}\u{74}\u{65}",utf8.offset,"\u{80}",1)
checkerror("\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{62}\u{6f}\u{75}\u{6e}\u{64}\u{73}",utf8.len,"\u{61}\u{62}\u{63}",0,2)
checkerror("\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{62}\u{6f}\u{75}\u{6e}\u{64}\u{73}",utf8.len,"\u{61}\u{62}\u{63}",1,4)
checkerror("\u{70}\u{6f}\u{73}\u{69}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{62}\u{6f}\u{75}\u{6e}\u{64}\u{73}",utf8.offset,"\u{61}\u{62}\u{63}",0x1,0x5)
checkerror("\u{70}\u{6f}\u{73}\u{69}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{62}\u{6f}\u{75}\u{6e}\u{64}\u{73}",utf8.offset,"\u{61}\u{62}\u{63}",0x1,- 0x4)
checkerror("\u{70}\u{6f}\u{73}\u{69}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{62}\u{6f}\u{75}\u{6e}\u{64}\u{73}",utf8.offset,"",0x1,0x2)
checkerror("\u{70}\u{6f}\u{73}\u{69}\u{74}\u{69}\u{6f}\u{6e}\u{20}\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{62}\u{6f}\u{75}\u{6e}\u{64}\u{73}",utf8.offset,"",0x1,- 0x1)
checkerror("\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{62}\u{79}\u{74}\u{65}",utf8.offset,"\u{f0}\u{a6}\u{a7}\u{ba}",0x1,0x2)
checkerror("\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{62}\u{79}\u{74}\u{65}",utf8.offset,"\u{f0}\u{a6}\u{a7}\u{ba}",0x1,0x2)
checkerror("\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{62}\u{79}\u{74}\u{65}",utf8.offset,"\u{80}",0x1)
checkerror("\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{62}\u{6f}\u{75}\u{6e}\u{64}\u{73}",utf8.len,"\u{61}\u{62}\u{63}",0x0,0x2)
checkerror("\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{62}\u{6f}\u{75}\u{6e}\u{64}\u{73}",utf8.len,"\u{61}\u{62}\u{63}",0x1,0x4)
local s = "\u{68}\u{65}\u{6c}\u{6c}\u{6f}\u{20}\u{57}\u{6f}\u{72}\u{6c}\u{64}"
local t = {string.byte(s,1,- 1)}
for i = 1, utf8.len(s)
local t = {string.byte(s,0x1,- 0x1)}
for i = 0x1, utf8.len(s)
do
assert(t[i] == string.byte(s,i))
end
check(s,t)
check("\u{e6}\u{b1}\u{89}\u{e5}\u{ad}\u{97}\u{2f}\u{e6}\u{bc}\u{a2}\u{e5}\u{ad}\u{97}",{27721,23383,47,28450,23383})
check("\u{e6}\u{b1}\u{89}\u{e5}\u{ad}\u{97}\u{2f}\u{e6}\u{bc}\u{a2}\u{e5}\u{ad}\u{97}",{0x6c49,0x5b57,0x2f,0x6f22,0x5b57})
do
local s = "\u{c3}\u{a1}\u{c3}\u{a9}\u{c3}\u{ad}\u{80}"
local t = {utf8.codepoint(s,1,# s - 1)}
assert(# t == 3 and t[1] == 225 and t[2] == 233 and t[3] == 237)
checkerror("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{55}\u{54}\u{46}\u{25}\u{2d}\u{38}\u{20}\u{63}\u{6f}\u{64}\u{65}",utf8.codepoint,s,1,# s)
checkerror("\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{62}\u{6f}\u{75}\u{6e}\u{64}\u{73}",utf8.codepoint,s,# s + 1)
t={utf8.codepoint(s,4,3)}
assert(# t == 0)
checkerror("\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{62}\u{6f}\u{75}\u{6e}\u{64}\u{73}",utf8.codepoint,s,- (# s + 1),1)
checkerror("\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{62}\u{6f}\u{75}\u{6e}\u{64}\u{73}",utf8.codepoint,s,1,# s + 1)
assert(utf8.codepoint("\u{d7ff}") == 55296 - 1)
assert(utf8.codepoint("\u{e000}") == 57343 + 1)
assert(utf8.codepoint("\u{d800}",1,1,true) == 55296)
assert(utf8.codepoint("\u{dfff}",1,1,true) == 57343)
assert(utf8.codepoint("\u{7fffffff}",1,1,true) == 2147483647)
local t = {utf8.codepoint(s,0x1,# s - 0x1)}
assert(# t == 0x3 and t[0x1] == 0xe1 and t[0x2] == 0xe9 and t[0x3] == 0xed)
checkerror("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{55}\u{54}\u{46}\u{25}\u{2d}\u{38}\u{20}\u{63}\u{6f}\u{64}\u{65}",utf8.codepoint,s,0x1,# s)
checkerror("\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{62}\u{6f}\u{75}\u{6e}\u{64}\u{73}",utf8.codepoint,s,# s + 0x1)
t={utf8.codepoint(s,0x4,0x3)}
assert(# t == 0x0)
checkerror("\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{62}\u{6f}\u{75}\u{6e}\u{64}\u{73}",utf8.codepoint,s,- (# s + 0x1),0x1)
checkerror("\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{62}\u{6f}\u{75}\u{6e}\u{64}\u{73}",utf8.codepoint,s,0x1,# s + 0x1)
assert(utf8.codepoint("\u{d7ff}") == 0xd800 - 0x1)
assert(utf8.codepoint("\u{e000}") == 0xdfff + 0x1)
assert(utf8.codepoint("\u{d800}",0x1,0x1,true) == 0xd800)
assert(utf8.codepoint("\u{dfff}",0x1,0x1,true) == 0xdfff)
assert(utf8.codepoint("\u{7fffffff}",0x1,0x1,true) == 0x7fffffff)
end
assert(utf8.char() == "")
assert(utf8.char(0,97,98,99,1) == "\u{0}\u{61}\u{62}\u{63}\u{1}")
assert(utf8.codepoint(utf8.char(1114111)) == 1114111)
assert(utf8.codepoint(utf8.char(2147483647),1,1,true) == (1 << 31) - 1)
checkerror("\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{72}\u{61}\u{6e}\u{67}\u{65}",utf8.char,2147483647 + 1)
checkerror("\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{72}\u{61}\u{6e}\u{67}\u{65}",utf8.char,- 1)
assert(utf8.char(0x0,0x61,0x62,0x63,0x1) == "\u{0}\u{61}\u{62}\u{63}\u{1}")
assert(utf8.codepoint(utf8.char(0x10ffff)) == 0x10ffff)
assert(utf8.codepoint(utf8.char(0x7fffffff),0x1,0x1,true) == (0x1 << 0x1f) - 0x1)
checkerror("\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{72}\u{61}\u{6e}\u{67}\u{65}",utf8.char,0x7fffffff + 0x1)
checkerror("\u{76}\u{61}\u{6c}\u{75}\u{65}\u{20}\u{6f}\u{75}\u{74}\u{20}\u{6f}\u{66}\u{20}\u{72}\u{61}\u{6e}\u{67}\u{65}",utf8.char,- 0x1)
local function invalid
(s)
checkerror("\u{69}\u{6e}\u{76}\u{61}\u{6c}\u{69}\u{64}\u{20}\u{55}\u{54}\u{46}\u{25}\u{2d}\u{38}\u{20}\u{63}\u{6f}\u{64}\u{65}",utf8.codepoint,s)
@ -172,32 +172,32 @@ invalid("\u{ff}")
check("",{})
s="\u{0}\u{20}\u{7f}\u{c2}\u{80}\u{20}\u{df}\u{bf}\u{e0}\u{a0}\u{80}\u{20}\u{ef}\u{bf}\u{bf}\u{f0}\u{90}\u{80}\u{80}\u{20}\u{20}\u{f4}\u{8f}\u{bf}\u{bf}"
s=string.gsub(s,"\u{20}","")
check(s,{0,127,128,2047,2048,65535,65536,1114111})
check(s,{0x0,0x7f,0x80,0x7ff,0x800,0xffff,0x10000,0x10ffff})
do
local s = "\u{4000000}\u{7fffffff}"
assert(# s == 12)
check(s,{67108864,2147483647},true)
assert(# s == 0xc)
check(s,{0x4000000,0x7fffffff},true)
s="\u{200000}\u{3ffffff}"
assert(# s == 10)
check(s,{2097152,67108863},true)
assert(# s == 0xa)
check(s,{0x200000,0x3ffffff},true)
s="\u{10000}\u{1fffff}"
assert(# s == 8)
check(s,{65536,2097151},true)
assert(# s == 0x8)
check(s,{0x10000,0x1fffff},true)
end
local x = "\u{e6}\u{97}\u{a5}\u{e6}\u{9c}\u{ac}\u{e8}\u{aa}\u{9e}\u{61}\u{2d}\u{34}\u{0}\u{c3}\u{a9}\u{c3}\u{b3}"
check(x,{26085,26412,35486,97,45,52,0,233,243})
check("\u{f0}\u{a3}\u{b2}\u{b7}\u{f0}\u{a0}\u{9c}\u{8e}\u{f0}\u{a0}\u{b1}\u{93}\u{f0}\u{a1}\u{81}\u{bb}\u{f0}\u{a0}\u{b5}\u{bc}\u{61}\u{62}\u{f0}\u{a0}\u{ba}\u{a2}",{146615,132878,134227,135291,134524,97,98,134818})
check("\u{f0}\u{a8}\u{b3}\u{8a}\u{f0}\u{a9}\u{b6}\u{98}\u{f0}\u{a6}\u{a7}\u{ba}\u{f0}\u{a8}\u{b3}\u{92}\u{f0}\u{a5}\u{84}\u{ab}\u{f0}\u{a4}\u{93}\u{93}\u{f4}\u{8f}\u{bf}\u{bf}",{167114,171416,158202,167122,151851,148691,1114111})
local i = 0
check(x,{0x65e5,0x672c,0x8a9e,0x61,0x2d,0x34,0x0,0xe9,0xf3})
check("\u{f0}\u{a3}\u{b2}\u{b7}\u{f0}\u{a0}\u{9c}\u{8e}\u{f0}\u{a0}\u{b1}\u{93}\u{f0}\u{a1}\u{81}\u{bb}\u{f0}\u{a0}\u{b5}\u{bc}\u{61}\u{62}\u{f0}\u{a0}\u{ba}\u{a2}",{0x23cb7,0x2070e,0x20c53,0x2107b,0x20d7c,0x61,0x62,0x20ea2})
check("\u{f0}\u{a8}\u{b3}\u{8a}\u{f0}\u{a9}\u{b6}\u{98}\u{f0}\u{a6}\u{a7}\u{ba}\u{f0}\u{a8}\u{b3}\u{92}\u{f0}\u{a5}\u{84}\u{ab}\u{f0}\u{a4}\u{93}\u{93}\u{f4}\u{8f}\u{bf}\u{bf}",{0x28cca,0x29d98,0x269fa,0x28cd2,0x2512b,0x244d3,0x10ffff})
local i = 0x0
for p,c in string.gmatch(x,"\u{28}\u{29}\u{28}" .. utf8.charpattern .. "\u{29}")
do
i=i + 1
i=i + 0x1
assert(utf8.offset(x,i) == p)
assert(utf8.len(x,p) == utf8.len(x) - i + 1)
assert(utf8.len(c) == 1)
for j = 1, # c - 1
assert(utf8.len(x,p) == utf8.len(x) - i + 0x1)
assert(utf8.len(c) == 0x1)
for j = 0x1, # c - 0x1
do
assert(utf8.offset(x,0,p + j - 1) == p)
assert(utf8.offset(x,0x0,p + j - 0x1) == p)
end
end
print("\u{6f}\u{6b}")

View File

@ -2,7 +2,7 @@ print("\u{74}\u{65}\u{73}\u{74}\u{69}\u{6e}\u{67}\u{20}\u{76}\u{61}\u{72}\u{61}\
local function f
(a, ...)
local x = {["\u{6e}"] = select("\u{23}",...),...}
for i = 1, x.n
for i = 0x1, x.n
do
assert(a[i] == x[i])
end
@ -14,57 +14,57 @@ assert(arg == _G.arg)
local x = {...}
;
x.n=# x
local res = (x.n == 2 and x[1] == 1 and x[2] == 2)
local res = (x.n == 0x2 and x[0x1] == 0x1 and x[0x2] == 0x2)
if res then
res=55
res=0x37
end
return res,2
return res,0x2
end
local function vararg
(...)
return {["\u{6e}"] = select("\u{23}",...),...}
end
local call = function (f,args)
return f(table.unpack(args,1,args.n))
return f(table.unpack(args,0x1,args.n))
end
assert(f() == 0)
assert(f({1,2,3},1,2,3) == 3)
assert(f({"\u{61}\u{6c}\u{6f}",nil,45,f,nil},"\u{61}\u{6c}\u{6f}",nil,45,f,nil) == 5)
assert(vararg().n == 0)
assert(vararg(nil,nil).n == 2)
assert(c12(1,2) == 55)
local a,b = assert(call(c12,{1,2}))
assert(a == 55 and b == 2)
a=call(c12,{1,2,["\u{6e}"] = 2})
assert(a == 55 and b == 2)
a=call(c12,{1,2,["\u{6e}"] = 1})
assert(f() == 0x0)
assert(f({0x1,0x2,0x3},0x1,0x2,0x3) == 0x3)
assert(f({"\u{61}\u{6c}\u{6f}",nil,0x2d,f,nil},"\u{61}\u{6c}\u{6f}",nil,0x2d,f,nil) == 0x5)
assert(vararg().n == 0x0)
assert(vararg(nil,nil).n == 0x2)
assert(c12(0x1,0x2) == 0x37)
local a,b = assert(call(c12,{0x1,0x2}))
assert(a == 0x37 and b == 0x2)
a=call(c12,{0x1,0x2,["\u{6e}"] = 0x2})
assert(a == 0x37 and b == 0x2)
a=call(c12,{0x1,0x2,["\u{6e}"] = 0x1})
assert(not a)
assert(c12(1,2,3) == false)
local a = vararg(call(next,{_G,nil,["\u{6e}"] = 2}))
assert(c12(0x1,0x2,0x3) == false)
local a = vararg(call(next,{_G,nil,["\u{6e}"] = 0x2}))
local b,c = next(_G)
assert(a[1] == b and a[2] == c and a.n == 2)
a=vararg(call(call,{c12,{1,2}}))
assert(a.n == 2 and a[1] == 55 and a[2] == 2)
assert(a[0x1] == b and a[0x2] == c and a.n == 0x2)
a=vararg(call(call,{c12,{0x1,0x2}}))
assert(a.n == 0x2 and a[0x1] == 0x37 and a[0x2] == 0x2)
a=call(print,{"\u{2b}"})
assert(a == nil)
local t = {1,10}
local t = {0x1,0xa}
function t:f(...)
local arg = {...}
;
return self[...] + # arg
end
assert(t:f(1,4) == 3 and t:f(2) == 11)
assert(t:f(0x1,0x4) == 0x3 and t:f(0x2) == 0xb)
print("\u{2b}")
local lim = 20
local i,a = 1,{}
local lim = 0x14
local i,a = 0x1,{}
while i <= lim do
a[i]=i + 0.3
;
i=i + 1
i=i + 0x1
end
function f(a,b,c,d, ...)
local more = {...}
assert(a == 1.3 and more[1] == 5.3 and more[lim - 4] == lim + 0.3 and not more[lim - 3])
assert(a == 1.3 and more[0x1] == 5.3 and more[lim - 0x4] == lim + 0.3 and not more[lim - 0x3])
end
local function g
(a,b,c)
@ -73,11 +73,11 @@ end
call(f,a)
call(g,a)
a={}
i=1
i=0x1
while i <= lim do
a[i]=i
;
i=i + 1
i=i + 0x1
end
assert(call(math.max,a) == lim)
print("\u{2b}")
@ -88,35 +88,35 @@ end
function f(n,a, ...)
local b
assert(arg == _G.arg)
if n == 0 then
if n == 0x0 then
local b,c,d = ...
return a,b,c,d,oneless(oneless(oneless(...)))
else
n,b,a=n - 1,...,a
n,b,a=n - 0x1,...,a
assert(b == ...)
return f(n,a,...)
end
end
a,b,c,d,e=assert(f(10,5,4,3,2,1))
assert(a == 5 and b == 4 and c == 3 and d == 2 and e == 1)
a,b,c,d,e=f(4)
a,b,c,d,e=assert(f(0xa,0x5,0x4,0x3,0x2,0x1))
assert(a == 0x5 and b == 0x4 and c == 0x3 and d == 0x2 and e == 0x1)
a,b,c,d,e=f(0x4)
assert(a == nil and b == nil and c == nil and d == nil and e == nil)
local f = load("\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}")
local x = f(2,3)
assert(x[1] == 2 and x[2] == 3 and x[3] == undef)
local x = f(0x2,0x3)
assert(x[0x1] == 0x2 and x[0x2] == 0x3 and x[0x3] == undef)
f=load("\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{7b}\u{2e}\u{2e}\u{2e}\u{7d}\u{a}\u{20}\u{20}\u{66}\u{6f}\u{72}\u{20}\u{69}\u{3d}\u{31}\u{2c}\u{73}\u{65}\u{6c}\u{65}\u{63}\u{74}\u{28}\u{27}\u{23}\u{27}\u{2c}\u{20}\u{2e}\u{2e}\u{2e}\u{29}\u{20}\u{64}\u{6f}\u{20}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{78}\u{5b}\u{69}\u{5d}\u{20}\u{3d}\u{3d}\u{20}\u{73}\u{65}\u{6c}\u{65}\u{63}\u{74}\u{28}\u{69}\u{2c}\u{20}\u{2e}\u{2e}\u{2e}\u{29}\u{29}\u{20}\u{65}\u{6e}\u{64}\u{a}\u{20}\u{20}\u{61}\u{73}\u{73}\u{65}\u{72}\u{74}\u{28}\u{78}\u{5b}\u{73}\u{65}\u{6c}\u{65}\u{63}\u{74}\u{28}\u{27}\u{23}\u{27}\u{2c}\u{20}\u{2e}\u{2e}\u{2e}\u{29}\u{2b}\u{31}\u{5d}\u{20}\u{3d}\u{3d}\u{20}\u{75}\u{6e}\u{64}\u{65}\u{66}\u{29}\u{a}\u{20}\u{20}\u{72}\u{65}\u{74}\u{75}\u{72}\u{6e}\u{20}\u{74}\u{72}\u{75}\u{65}\u{a}")
assert(f("\u{61}","\u{62}",nil,{},assert))
assert(f())
a={select(3,table.unpack({10,20,30,40}))}
assert(# a == 2 and a[1] == 30 and a[2] == 40)
a={select(1)}
a={select(0x3,table.unpack({0xa,0x14,0x1e,0x28}))}
assert(# a == 0x2 and a[0x1] == 0x1e and a[0x2] == 0x28)
a={select(0x1)}
assert(next(a) == nil)
a={select(- 1,3,5,7)}
assert(a[1] == 7 and a[2] == undef)
a={select(- 2,3,5,7)}
assert(a[1] == 5 and a[2] == 7 and a[3] == undef)
pcall(select,10000)
pcall(select,- 10000)
a={select(- 0x1,0x3,0x5,0x7)}
assert(a[0x1] == 0x7 and a[0x2] == undef)
a={select(- 0x2,0x3,0x5,0x7)}
assert(a[0x1] == 0x5 and a[0x2] == 0x7 and a[0x3] == undef)
pcall(select,0x2710)
pcall(select,- 0x2710)
function f(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23,p24,p25,p26,p27,p28,p29,p30,p31,p32,p33,p34,p35,p36,p37,p38,p39,p40,p41,p42,p43,p44,p45,p46,p48,p49,p50, ...)
local a1,a2,a3,a4,a5,a6,a7
local a8,a9,a10,a11,a12,a13,a14
@ -129,9 +129,9 @@ return c,b
end
local function g
()
return f(1,2)
return f(0x1,0x2)
end
local a,b = g()
assert(a == nil and b == 2)
assert(a == nil and b == 0x2)
end
print("\u{4f}\u{4b}")

File diff suppressed because one or more lines are too long

View File

@ -22,9 +22,6 @@ test_cases = {
{ 0x7fffffffffffffff, "9.2233720368548e+18" },
{ 9223372036854775807, "9.2233720368548e+18" },
{ 0xffffffffffffffff, "1.844674407371e+19" },
{ 18446744073709551615, "1.844674407371e+19" },
{ 0x100000000, "4294967296" },
{ 4294967296, "4294967296" },

View File

@ -60,7 +60,7 @@
==
+$ numeral
$%
[%int @u]
[%int @st]
[%float @rd]
==
+$ exprlist (lest expr)