From 9621add2918cc4943e6693b74ae85d51dd264fcf Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Mon, 21 Apr 2014 20:59:39 +1000 Subject: We don't need the testlua directory any more. --- .../testLua/yueliang-0.4.1/test_lua/5.0/bisect.lua | 27 - LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/cf.lua | 16 - LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/echo.lua | 5 - LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/env.lua | 7 - .../yueliang-0.4.1/test_lua/5.0/factorial.lua | 32 - LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/fib.lua | 40 -- .../testLua/yueliang-0.4.1/test_lua/5.0/fibfor.lua | 13 - .../yueliang-0.4.1/test_lua/5.0/globals.lua | 13 - .../testLua/yueliang-0.4.1/test_lua/5.0/hello.lua | 3 - LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/life.lua | 111 --- LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/luac.lua | 7 - .../testLua/yueliang-0.4.1/test_lua/5.0/printf.lua | 7 - .../yueliang-0.4.1/test_lua/5.0/readonly.lua | 12 - .../testLua/yueliang-0.4.1/test_lua/5.0/sieve.lua | 29 - LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/sort.lua | 66 -- .../testLua/yueliang-0.4.1/test_lua/5.0/table.lua | 12 - .../yueliang-0.4.1/test_lua/5.0/trace-calls.lua | 32 - .../yueliang-0.4.1/test_lua/5.0/trace-globals.lua | 38 - .../yueliang-0.4.1/test_lua/5.0/undefined.lua | 9 - LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/xd.lua | 14 - .../testLua/yueliang-0.4.1/test_lua/5.1/bisect.lua | 27 - LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/cf.lua | 16 - LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/echo.lua | 5 - LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/env.lua | 7 - .../yueliang-0.4.1/test_lua/5.1/factorial.lua | 32 - LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/fib.lua | 40 -- .../testLua/yueliang-0.4.1/test_lua/5.1/fibfor.lua | 13 - .../yueliang-0.4.1/test_lua/5.1/globals.lua | 13 - .../testLua/yueliang-0.4.1/test_lua/5.1/hello.lua | 3 - LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/life.lua | 111 --- LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/luac.lua | 7 - .../testLua/yueliang-0.4.1/test_lua/5.1/printf.lua | 7 - .../yueliang-0.4.1/test_lua/5.1/readonly.lua | 12 - .../testLua/yueliang-0.4.1/test_lua/5.1/sieve.lua | 29 - LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/sort.lua | 66 -- .../testLua/yueliang-0.4.1/test_lua/5.1/table.lua | 12 - .../yueliang-0.4.1/test_lua/5.1/trace-calls.lua | 32 - .../yueliang-0.4.1/test_lua/5.1/trace-globals.lua | 38 - LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/xd.lua | 14 - LuaSL/testLua/yueliang-0.4.1/test_lua/README | 65 -- .../yueliang-0.4.1/test_lua/files-lua-5.0.txt | 21 - .../yueliang-0.4.1/test_lua/files-lua-5.1.txt | 20 - .../yueliang-0.4.1/test_lua/files-other-5.0.txt | 21 - .../yueliang-0.4.1/test_lua/files-other-5.1.txt | 3 - .../yueliang-0.4.1/test_lua/files-yueliang-5.0.txt | 34 - .../yueliang-0.4.1/test_lua/files-yueliang-5.1.txt | 19 - .../yueliang-0.4.1/test_lua/test_parser-5.0.lua | 761 -------------------- .../yueliang-0.4.1/test_lua/test_parser-5.1.lua | 783 --------------------- .../yueliang-0.4.1/test_lua/test_scripts-5.0.lua | 158 ----- .../yueliang-0.4.1/test_lua/test_scripts-5.1.lua | 158 ----- 50 files changed, 3020 deletions(-) delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/bisect.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/cf.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/echo.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/env.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/factorial.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/fib.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/fibfor.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/globals.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/hello.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/life.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/luac.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/printf.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/readonly.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/sieve.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/sort.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/table.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/trace-calls.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/trace-globals.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/undefined.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/xd.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/bisect.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/cf.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/echo.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/env.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/factorial.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/fib.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/fibfor.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/globals.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/hello.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/life.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/luac.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/printf.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/readonly.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/sieve.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/sort.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/table.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/trace-calls.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/trace-globals.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/xd.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/README delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/files-lua-5.0.txt delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/files-lua-5.1.txt delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/files-other-5.0.txt delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/files-other-5.1.txt delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/files-yueliang-5.0.txt delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/files-yueliang-5.1.txt delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/test_parser-5.0.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/test_parser-5.1.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/test_scripts-5.0.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/test_lua/test_scripts-5.1.lua (limited to 'LuaSL/testLua/yueliang-0.4.1/test_lua') diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/bisect.lua b/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/bisect.lua deleted file mode 100644 index f91e69b..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/bisect.lua +++ /dev/null @@ -1,27 +0,0 @@ --- bisection method for solving non-linear equations - -delta=1e-6 -- tolerance - -function bisect(f,a,b,fa,fb) - local c=(a+b)/2 - io.write(n," c=",c," a=",a," b=",b,"\n") - if c==a or c==b or math.abs(a-b) posted to lua-l --- modified to use ANSI terminal escape sequences --- modified to use for instead of while - -local write=io.write - -ALIVE="¥" DEAD="þ" -ALIVE="O" DEAD="-" - -function delay() -- NOTE: SYSTEM-DEPENDENT, adjust as necessary - for i=1,10000 do end - -- local i=os.clock()+1 while(os.clock() 0 do - local xm1,x,xp1,xi=self.w-1,self.w,1,self.w - while xi > 0 do - local sum = self[ym1][xm1] + self[ym1][x] + self[ym1][xp1] + - self[y][xm1] + self[y][xp1] + - self[yp1][xm1] + self[yp1][x] + self[yp1][xp1] - next[y][x] = ((sum==2) and self[y][x]) or ((sum==3) and 1) or 0 - xm1,x,xp1,xi = x,xp1,xp1+1,xi-1 - end - ym1,y,yp1,yi = y,yp1,yp1+1,yi-1 - end -end - --- output the array to screen -function _CELLS:draw() - local out="" -- accumulate to reduce flicker - for y=1,self.h do - for x=1,self.w do - out=out..(((self[y][x]>0) and ALIVE) or DEAD) - end - out=out.."\n" - end - write(out) -end - --- constructor -function CELLS(w,h) - local c = ARRAY2D(w,h) - c.spawn = _CELLS.spawn - c.evolve = _CELLS.evolve - c.draw = _CELLS.draw - return c -end - --- --- shapes suitable for use with spawn() above --- -HEART = { 1,0,1,1,0,1,1,1,1; w=3,h=3 } -GLIDER = { 0,0,1,1,0,1,0,1,1; w=3,h=3 } -EXPLODE = { 0,1,0,1,1,1,1,0,1,0,1,0; w=3,h=4 } -FISH = { 0,1,1,1,1,1,0,0,0,1,0,0,0,0,1,1,0,0,1,0; w=5,h=4 } -BUTTERFLY = { 1,0,0,0,1,0,1,1,1,0,1,0,0,0,1,1,0,1,0,1,1,0,0,0,1; w=5,h=5 } - --- the main routine -function LIFE(w,h) - -- create two arrays - local thisgen = CELLS(w,h) - local nextgen = CELLS(w,h) - - -- create some life - -- about 1000 generations of fun, then a glider steady-state - thisgen:spawn(GLIDER,5,4) - thisgen:spawn(EXPLODE,25,10) - thisgen:spawn(FISH,4,12) - - -- run until break - local gen=1 - write("\027[2J") -- ANSI clear screen - while 1 do - thisgen:evolve(nextgen) - thisgen,nextgen = nextgen,thisgen - write("\027[H") -- ANSI home cursor - thisgen:draw() - write("Life - generation ",gen,"\n") - gen=gen+1 - if gen>2000 then break end - --delay() -- no delay - end -end - -LIFE(40,20) diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/luac.lua b/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/luac.lua deleted file mode 100644 index b009ae9..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/luac.lua +++ /dev/null @@ -1,7 +0,0 @@ --- bare-bones luac in Lua --- usage: lua luac.lua file.lua - -assert(arg[1]~=nil and arg[2]==nil,"usage: lua luac.lua file.lua") -f=assert(io.open("luac.out","wb")) -f:write(string.dump(assert(loadfile(arg[1])))) -io.close(f) diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/printf.lua b/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/printf.lua deleted file mode 100644 index 66dfda6..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/printf.lua +++ /dev/null @@ -1,7 +0,0 @@ --- an implementation of printf - -function printf(...) - io.write(string.format(unpack(arg))) -end - -printf("Hello %s from %s on %s\n",os.getenv"USER" or "there",_VERSION,os.date()) diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/readonly.lua b/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/readonly.lua deleted file mode 100644 index 85c0b4e..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/readonly.lua +++ /dev/null @@ -1,12 +0,0 @@ --- make global variables readonly - -local f=function (t,i) error("cannot redefine global variable `"..i.."'",2) end -local g={} -local G=getfenv() -setmetatable(g,{__index=G,__newindex=f}) -setfenv(1,g) - --- an example -rawset(g,"x",3) -x=2 -y=1 -- cannot redefine `y' diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/sieve.lua b/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/sieve.lua deleted file mode 100644 index 0871bb2..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/sieve.lua +++ /dev/null @@ -1,29 +0,0 @@ --- the sieve of of Eratosthenes programmed with coroutines --- typical usage: lua -e N=1000 sieve.lua | column - --- generate all the numbers from 2 to n -function gen (n) - return coroutine.wrap(function () - for i=2,n do coroutine.yield(i) end - end) -end - --- filter the numbers generated by `g', removing multiples of `p' -function filter (p, g) - return coroutine.wrap(function () - while 1 do - local n = g() - if n == nil then return end - if math.mod(n, p) ~= 0 then coroutine.yield(n) end - end - end) -end - -N=N or 1000 -- from command line -x = gen(N) -- generate primes up to N -while 1 do - local n = x() -- pick a number until done - if n == nil then break end - print(n) -- must be a prime number - x = filter(n, x) -- now remove its multiples -end diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/sort.lua b/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/sort.lua deleted file mode 100644 index 0bcb15f..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/sort.lua +++ /dev/null @@ -1,66 +0,0 @@ --- two implementations of a sort function --- this is an example only. Lua has now a built-in function "sort" - --- extracted from Programming Pearls, page 110 -function qsort(x,l,u,f) - if ly end) - show("after reverse selection sort",x) - qsort(x,1,n,function (x,y) return x>> ",string.rep(" ",level)) - if t~=nil and t.currentline>=0 then io.write(t.short_src,":",t.currentline," ") end - t=debug.getinfo(2) - if event=="call" then - level=level+1 - else - level=level-1 if level<0 then level=0 end - end - if t.what=="main" then - if event=="call" then - io.write("begin ",t.short_src) - else - io.write("end ",t.short_src) - end - elseif t.what=="Lua" then --- table.foreach(t,print) - io.write(event," ",t.name or "(Lua)"," <",t.linedefined,":",t.short_src,">") - else - io.write(event," ",t.name or "(C)"," [",t.what,"] ") - end - io.write("\n") -end - -debug.sethook(hook,"cr") -level=0 diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/trace-globals.lua b/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/trace-globals.lua deleted file mode 100644 index 295e670..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/trace-globals.lua +++ /dev/null @@ -1,38 +0,0 @@ --- trace assigments to global variables - -do - -- a tostring that quotes strings. note the use of the original tostring. - local _tostring=tostring - local tostring=function(a) - if type(a)=="string" then - return string.format("%q",a) - else - return _tostring(a) - end - end - - local log=function (name,old,new) - local t=debug.getinfo(3,"Sl") - local line=t.currentline - io.write(t.short_src) - if line>=0 then io.write(":",line) end - io.write(": ",name," is now ",tostring(new)," (was ",tostring(old),")","\n") - end - - local g={} - local set=function (t,name,value) - log(name,g[name],value) - g[name]=value - end - setmetatable(getfenv(),{__index=g,__newindex=set}) -end - --- an example - -a=1 -b=2 -a=10 -b=20 -b=nil -b=200 -print(a,b,c) diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/undefined.lua b/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/undefined.lua deleted file mode 100644 index efe5f24..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/undefined.lua +++ /dev/null @@ -1,9 +0,0 @@ --- catch "undefined" global variables - -local f=function (t,i) error("undefined global variable `"..i.."'",2) end -setmetatable(getfenv(),{__index=f}) - --- an example -a=1 -c=3 -print(a,b,c) -- `b' is undefined diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/xd.lua b/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/xd.lua deleted file mode 100644 index 32331dc..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.0/xd.lua +++ /dev/null @@ -1,14 +0,0 @@ --- hex dump --- usage: lua xd.lua < file - -local offset=0 - -while 1 do - local s=io.read(16) - if s==nil then return end - io.write(string.format("%08X ",offset)) - string.gsub(s,"(.)",function (c) io.write(string.format("%02X ",string.byte(c))) end) - io.write(string.rep(" ",3*(16-string.len(s)))) - io.write(" ",string.gsub(s,"%c","."),"\n") - offset=offset+16 -end diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/bisect.lua b/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/bisect.lua deleted file mode 100644 index f91e69b..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/bisect.lua +++ /dev/null @@ -1,27 +0,0 @@ --- bisection method for solving non-linear equations - -delta=1e-6 -- tolerance - -function bisect(f,a,b,fa,fb) - local c=(a+b)/2 - io.write(n," c=",c," a=",a," b=",b,"\n") - if c==a or c==b or math.abs(a-b) posted to lua-l --- modified to use ANSI terminal escape sequences --- modified to use for instead of while - -local write=io.write - -ALIVE="¥" DEAD="þ" -ALIVE="O" DEAD="-" - -function delay() -- NOTE: SYSTEM-DEPENDENT, adjust as necessary - for i=1,10000 do end - -- local i=os.clock()+1 while(os.clock() 0 do - local xm1,x,xp1,xi=self.w-1,self.w,1,self.w - while xi > 0 do - local sum = self[ym1][xm1] + self[ym1][x] + self[ym1][xp1] + - self[y][xm1] + self[y][xp1] + - self[yp1][xm1] + self[yp1][x] + self[yp1][xp1] - next[y][x] = ((sum==2) and self[y][x]) or ((sum==3) and 1) or 0 - xm1,x,xp1,xi = x,xp1,xp1+1,xi-1 - end - ym1,y,yp1,yi = y,yp1,yp1+1,yi-1 - end -end - --- output the array to screen -function _CELLS:draw() - local out="" -- accumulate to reduce flicker - for y=1,self.h do - for x=1,self.w do - out=out..(((self[y][x]>0) and ALIVE) or DEAD) - end - out=out.."\n" - end - write(out) -end - --- constructor -function CELLS(w,h) - local c = ARRAY2D(w,h) - c.spawn = _CELLS.spawn - c.evolve = _CELLS.evolve - c.draw = _CELLS.draw - return c -end - --- --- shapes suitable for use with spawn() above --- -HEART = { 1,0,1,1,0,1,1,1,1; w=3,h=3 } -GLIDER = { 0,0,1,1,0,1,0,1,1; w=3,h=3 } -EXPLODE = { 0,1,0,1,1,1,1,0,1,0,1,0; w=3,h=4 } -FISH = { 0,1,1,1,1,1,0,0,0,1,0,0,0,0,1,1,0,0,1,0; w=5,h=4 } -BUTTERFLY = { 1,0,0,0,1,0,1,1,1,0,1,0,0,0,1,1,0,1,0,1,1,0,0,0,1; w=5,h=5 } - --- the main routine -function LIFE(w,h) - -- create two arrays - local thisgen = CELLS(w,h) - local nextgen = CELLS(w,h) - - -- create some life - -- about 1000 generations of fun, then a glider steady-state - thisgen:spawn(GLIDER,5,4) - thisgen:spawn(EXPLODE,25,10) - thisgen:spawn(FISH,4,12) - - -- run until break - local gen=1 - write("\027[2J") -- ANSI clear screen - while 1 do - thisgen:evolve(nextgen) - thisgen,nextgen = nextgen,thisgen - write("\027[H") -- ANSI home cursor - thisgen:draw() - write("Life - generation ",gen,"\n") - gen=gen+1 - if gen>2000 then break end - --delay() -- no delay - end -end - -LIFE(40,20) diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/luac.lua b/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/luac.lua deleted file mode 100644 index 96a0a97..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/luac.lua +++ /dev/null @@ -1,7 +0,0 @@ --- bare-bones luac in Lua --- usage: lua luac.lua file.lua - -assert(arg[1]~=nil and arg[2]==nil,"usage: lua luac.lua file.lua") -f=assert(io.open("luac.out","wb")) -assert(f:write(string.dump(assert(loadfile(arg[1]))))) -assert(f:close()) diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/printf.lua b/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/printf.lua deleted file mode 100644 index 58c63ff..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/printf.lua +++ /dev/null @@ -1,7 +0,0 @@ --- an implementation of printf - -function printf(...) - io.write(string.format(...)) -end - -printf("Hello %s from %s on %s\n",os.getenv"USER" or "there",_VERSION,os.date()) diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/readonly.lua b/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/readonly.lua deleted file mode 100644 index 85c0b4e..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/readonly.lua +++ /dev/null @@ -1,12 +0,0 @@ --- make global variables readonly - -local f=function (t,i) error("cannot redefine global variable `"..i.."'",2) end -local g={} -local G=getfenv() -setmetatable(g,{__index=G,__newindex=f}) -setfenv(1,g) - --- an example -rawset(g,"x",3) -x=2 -y=1 -- cannot redefine `y' diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/sieve.lua b/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/sieve.lua deleted file mode 100644 index 0871bb2..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/sieve.lua +++ /dev/null @@ -1,29 +0,0 @@ --- the sieve of of Eratosthenes programmed with coroutines --- typical usage: lua -e N=1000 sieve.lua | column - --- generate all the numbers from 2 to n -function gen (n) - return coroutine.wrap(function () - for i=2,n do coroutine.yield(i) end - end) -end - --- filter the numbers generated by `g', removing multiples of `p' -function filter (p, g) - return coroutine.wrap(function () - while 1 do - local n = g() - if n == nil then return end - if math.mod(n, p) ~= 0 then coroutine.yield(n) end - end - end) -end - -N=N or 1000 -- from command line -x = gen(N) -- generate primes up to N -while 1 do - local n = x() -- pick a number until done - if n == nil then break end - print(n) -- must be a prime number - x = filter(n, x) -- now remove its multiples -end diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/sort.lua b/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/sort.lua deleted file mode 100644 index 0bcb15f..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/sort.lua +++ /dev/null @@ -1,66 +0,0 @@ --- two implementations of a sort function --- this is an example only. Lua has now a built-in function "sort" - --- extracted from Programming Pearls, page 110 -function qsort(x,l,u,f) - if ly end) - show("after reverse selection sort",x) - qsort(x,1,n,function (x,y) return x>> ",string.rep(" ",level)) - if t~=nil and t.currentline>=0 then io.write(t.short_src,":",t.currentline," ") end - t=debug.getinfo(2) - if event=="call" then - level=level+1 - else - level=level-1 if level<0 then level=0 end - end - if t.what=="main" then - if event=="call" then - io.write("begin ",t.short_src) - else - io.write("end ",t.short_src) - end - elseif t.what=="Lua" then --- table.foreach(t,print) - io.write(event," ",t.name or "(Lua)"," <",t.linedefined,":",t.short_src,">") - else - io.write(event," ",t.name or "(C)"," [",t.what,"] ") - end - io.write("\n") -end - -debug.sethook(hook,"cr") -level=0 diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/trace-globals.lua b/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/trace-globals.lua deleted file mode 100644 index 295e670..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/trace-globals.lua +++ /dev/null @@ -1,38 +0,0 @@ --- trace assigments to global variables - -do - -- a tostring that quotes strings. note the use of the original tostring. - local _tostring=tostring - local tostring=function(a) - if type(a)=="string" then - return string.format("%q",a) - else - return _tostring(a) - end - end - - local log=function (name,old,new) - local t=debug.getinfo(3,"Sl") - local line=t.currentline - io.write(t.short_src) - if line>=0 then io.write(":",line) end - io.write(": ",name," is now ",tostring(new)," (was ",tostring(old),")","\n") - end - - local g={} - local set=function (t,name,value) - log(name,g[name],value) - g[name]=value - end - setmetatable(getfenv(),{__index=g,__newindex=set}) -end - --- an example - -a=1 -b=2 -a=10 -b=20 -b=nil -b=200 -print(a,b,c) diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/xd.lua b/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/xd.lua deleted file mode 100644 index ebc3eff..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/5.1/xd.lua +++ /dev/null @@ -1,14 +0,0 @@ --- hex dump --- usage: lua xd.lua < file - -local offset=0 -while true do - local s=io.read(16) - if s==nil then return end - io.write(string.format("%08X ",offset)) - string.gsub(s,"(.)", - function (c) io.write(string.format("%02X ",string.byte(c))) end) - io.write(string.rep(" ",3*(16-string.len(s)))) - io.write(" ",string.gsub(s,"%c","."),"\n") - offset=offset+16 -end diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/README b/LuaSL/testLua/yueliang-0.4.1/test_lua/README deleted file mode 100644 index 07d9eb2..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/README +++ /dev/null @@ -1,65 +0,0 @@ -test_scripts-5.*.lua ----------------------- - -The scripts test_scripts*.lua are for exercising the frontends. Such -testing is non-exhaustive, but useful all the same. - -The files in the 5.0 directory are the sample scripts from the Lua 5.0.x -test directory. Ditto for the 5.1 directory. See the COPYRIGHT_Lua5 for -the copyright notice. - -For example, to run the 5.0.x script tester: - - >lua test_scripts-5.0.lua - -Or, if you have both Lua 5.0.x and Lua 5.1.x, you can prepare two -binaries and run them like this: - - >lua5.0 test_scripts-5.0.lua - >lua5.1 test_scripts-5.1.lua - -If the compilation result is exact, "CORRECT" is printed, otherwise both -binary chunks are written to the current directory as bc1.out and -bc2.out. You can use a disassembly tool like ChunkSpy to generate -listings for both files, then they can be compared with a visual diff -tool. ChunkSpy 0.9.8 supports 5.0.x and 5.1.x. - -For testing additional files, add the argument "ALL" like this: - - >lua test_scripts-5.0.lua ALL - -This will pull in additional personal script files for testing. But in -order to do so, you'd have to adjust the files files-other-*.txt. - -Current status: - -Frontend version File set Result ---------------------------------------------------------------------- -Yueliang 5.0.3 files-lua-5.0.txt ALL CORRECT - files-yueliang-5.0.txt ALL CORRECT -Yueliang 5.1.2 files-lua-5.1.txt ALL CORRECT - files-yueliang-5.1.txt ALL CORRECT ---------------------------------------------------------------------- - -test_parser-5.x.lua -------------------- - -The script files test_parser-5.0.lua and test_parser-5.1.lua contains -many test cases for both parsers. There are a lot of failure cases as -well as pass cases in order to exercise the parsers well, though the -test list is not exhaustive. - - test_parser-5.0.lua 503 test cases - test_parser-5.1.lua 524 test cases - -For the actual test scripts, see test_lparser2.lua in the respective -test directories of each front end. The 5.0.x front end of Yueliang -passed all the tests in test_parser-5.0.lua without any failures, while -testing of the 5.1.x front end using test_parser-5.1.lua led to one -bug found and fixed. - -For Lua 5.0.2, see Yueliang 0.1.3, which was the last release of Lua -5.0.2 material. - -For Lua 5.1.1, see Yueliang 0.2.1, which was the last release of Lua -5.1.1 material. diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/files-lua-5.0.txt b/LuaSL/testLua/yueliang-0.4.1/test_lua/files-lua-5.0.txt deleted file mode 100644 index d6b0c3c..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/files-lua-5.0.txt +++ /dev/null @@ -1,21 +0,0 @@ -# these are the sample scripts found in Lua 5.0.x -5.0/bisect.lua -5.0/cf.lua -5.0/echo.lua -5.0/env.lua -5.0/factorial.lua -5.0/fib.lua -5.0/fibfor.lua -5.0/globals.lua -5.0/hello.lua -5.0/life.lua -5.0/luac.lua -5.0/printf.lua -5.0/readonly.lua -5.0/sieve.lua -5.0/sort.lua -5.0/table.lua -5.0/trace-calls.lua -5.0/trace-globals.lua -5.0/undefined.lua -5.0/xd.lua diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/files-lua-5.1.txt b/LuaSL/testLua/yueliang-0.4.1/test_lua/files-lua-5.1.txt deleted file mode 100644 index a11d670..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/files-lua-5.1.txt +++ /dev/null @@ -1,20 +0,0 @@ -# these are the sample scripts found in Lua 5.1.x -5.1/bisect.lua -5.1/cf.lua -5.1/echo.lua -5.1/env.lua -5.1/factorial.lua -5.1/fib.lua -5.1/fibfor.lua -5.1/globals.lua -5.1/hello.lua -5.1/life.lua -5.1/luac.lua -5.1/printf.lua -5.1/readonly.lua -5.1/sieve.lua -5.1/sort.lua -5.1/table.lua -5.1/trace-calls.lua -5.1/trace-globals.lua -5.1/xd.lua diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/files-other-5.0.txt b/LuaSL/testLua/yueliang-0.4.1/test_lua/files-other-5.0.txt deleted file mode 100644 index a661bc5..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/files-other-5.0.txt +++ /dev/null @@ -1,21 +0,0 @@ -# these are other 5.0.x scripts found in my project directories -# WARNING currently out of date... - -../../SciTELuaExporters/SciTE_ExportBase.lua -../../SciTELuaExporters/SciTE_ExporterABW.lua -../../SciTELuaExporters/SciTE_ExporterHTML.lua -../../SciTELuaExporters/SciTE_ExporterHTMLPlus.lua -../../SciTELuaExporters/SciTE_ExporterODT.lua -../../SciTELuaExporters/SciTE_ExporterPDF.lua -../../SciTELuaExporters/SciTE_ExporterPDFPlus.lua -../../SciTELuaExporters/SciTE_ExporterRTF.lua -../../SciTELuaExporters/SciTE_ExporterSXW.lua -../../SciTELuaExporters/SciTE_ExporterTeX.lua -../../SciTELuaExporters/SciTE_ExporterTemplate.lua -../../SciTELuaExporters/SciTE_ExporterXML.lua -../../LuaSrcDiet/LuaSrcDiet.lua -../../LuaSrcDiet/LuaSrcDiet_.lua -../../ChunkBake/ChunkBake.lua -../../ChunkBake/misc/TestRig.lua -../../ChunkSpy/5.0.2/ChunkSpy.lua -../../ChunkSpy/5.1-work4/ChunkSpy.lua diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/files-other-5.1.txt b/LuaSL/testLua/yueliang-0.4.1/test_lua/files-other-5.1.txt deleted file mode 100644 index fa5827d..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/files-other-5.1.txt +++ /dev/null @@ -1,3 +0,0 @@ -# these are other 5.1.x scripts found in my project directories -# WARNING currently out of date... - diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/files-yueliang-5.0.txt b/LuaSL/testLua/yueliang-0.4.1/test_lua/files-yueliang-5.0.txt deleted file mode 100644 index 72e1da9..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/files-yueliang-5.0.txt +++ /dev/null @@ -1,34 +0,0 @@ -# these are yueliang files for 5.0.x - -test_scripts-5.0.lua - -../orig-5.0.3/lzio.lua -../orig-5.0.3/ldump.lua -../orig-5.0.3/lopcodes.lua -../orig-5.0.3/llex.lua -../orig-5.0.3/lparser.lua -../orig-5.0.3/lcode.lua -../orig-5.0.3/luac.lua - -../orig-5.0.3/test/test_lzio.lua -../orig-5.0.3/test/test_ldump.lua -../orig-5.0.3/test/test_llex.lua -../orig-5.0.3/test/test_lparser.lua -../orig-5.0.3/test/test_number.lua -../orig-5.0.3/test/bench_llex.lua -../orig-5.0.3/tools/call_graph.lua -../orig-5.0.3/tools/sample_expr.lua - -../nat-5.0.3/lzio_mk2.lua -../nat-5.0.3/lzio_mk4.lua -../nat-5.0.3/llex_mk2.lua -../nat-5.0.3/llex_mk3.lua -../nat-5.0.3/llex_mk4.lua - -../nat-5.0.3/test/test_lzio_mk2.lua -../nat-5.0.3/test/test_llex_mk2.lua -../nat-5.0.3/test/test_llex_mk3.lua -../nat-5.0.3/test/test_llex_mk4.lua -../nat-5.0.3/test/bench_llex_mk2.lua -../nat-5.0.3/test/bench_llex_mk3.lua -../nat-5.0.3/test/bench_llex_mk4.lua diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/files-yueliang-5.1.txt b/LuaSL/testLua/yueliang-0.4.1/test_lua/files-yueliang-5.1.txt deleted file mode 100644 index 6a112d9..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/files-yueliang-5.1.txt +++ /dev/null @@ -1,19 +0,0 @@ -# these are yueliang files for 5.1.x - -test_scripts-5.1.lua - -../orig-5.1.3/lzio.lua -../orig-5.1.3/ldump.lua -../orig-5.1.3/lopcodes.lua -../orig-5.1.3/llex.lua -../orig-5.1.3/lparser.lua -../orig-5.1.3/lcode.lua -../orig-5.1.3/luac.lua - -../orig-5.1.3/test/test_lzio.lua -../orig-5.1.3/test/test_ldump.lua -../orig-5.1.3/test/test_llex.lua -../orig-5.1.3/test/test_lparser.lua -../orig-5.1.3/test/test_number.lua -../orig-5.1.3/test/bench_llex.lua - diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/test_parser-5.0.lua b/LuaSL/testLua/yueliang-0.4.1/test_lua/test_parser-5.0.lua deleted file mode 100644 index b563ed3..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/test_parser-5.0.lua +++ /dev/null @@ -1,761 +0,0 @@ ---[[-------------------------------------------------------------------- - - test_parser-5.0.lua - Lua 5.0.x parser test cases - This file is part of Yueliang. - - Copyright (c) 2006 Kein-Hong Man - The COPYRIGHT file describes the conditions - under which this software may be distributed. - - See the ChangeLog for more information. - -----------------------------------------------------------------------]] - ---[[-------------------------------------------------------------------- --- Notes: --- * there is no intention of properly specifying a grammar; the notes --- are meant to reflect the structure of lparser so that it is easy --- to locate and modify lparser if so desired --- * some test may have invalid expressions but will compile, this --- is because the chunk hasn't been executed yet -----------------------------------------------------------------------]] - ---[[-------------------------------------------------------------------- --- lparser parsing structure, the Lua 5.0.x version... -----------------------------------------------------------------------]] - -------------------------------------------------------------------- - -- chunk -> { stat [';'] } - -------------------------------------------------------------------- - -- stat -> DO block END - -- block -> chunk - -------------------------------------------------------------------- - -- stat -> breakstat - -- breakstat -> BREAK - -- * must have a loop to break - -- * must be last statement in a block - -------------------------------------------------------------------- - -- stat -> retstat - -- retstat -> RETURN explist - -- * must be last statement in a block - -------------------------------------------------------------------- - -- stat -> exprstat - -- exprstat -> primaryexp - -- (-> func | assignment) - -- * if LHS is VCALL then func, otherwise assignment - -- * for func, LHS is VCALL if funcargs in expression - -------------------------------------------------------------------- - -- stat -> funcstat - -- funcstat -> FUNCTION funcname body - -- funcname -> NAME {'.' NAME} [':' NAME] - -------------------------------------------------------------------- - -- body -> '(' parlist ')' chunk END - -- parlist -> [ param { ',' param } ] - -- param -> NAME - -- * DOTS must be the last parameter in a parlist - -------------------------------------------------------------------- - -- stat -> LOCAL localstat - -- LOCAL localstat -> LOCAL NAME {',' NAME} ['=' explist1] - -- explist1 -> expr { ',' expr } - -------------------------------------------------------------------- - -- stat -> LOCAL FUNCTION localfunc - -- LOCAL FUNCTION localfunc -> LOCAL FUNCTION NAME body - -------------------------------------------------------------------- - -- stat -> ifstat - -- ifstat -> IF cond THEN block - -- {ELSEIF cond THEN block} - -- [ELSE block] END - -- block -> chunk - -- cond -> expr - -------------------------------------------------------------------- - -- stat -> forstat - -- forstat -> fornum | forlist - -- forlist -> NAME {,NAME} IN explist1 forbody END - -- fornum -> NAME = exp1,exp1[,exp1] forbody END - -- forbody -> DO block - -- block -> chunk - -------------------------------------------------------------------- - -- stat -> whilestat - -- whilestat -> WHILE cond DO block END - -- block -> chunk - -- cond -> expr - -------------------------------------------------------------------- - -- stat -> repeatstat - -- repeatstat -> REPEAT block UNTIL cond - -- block -> chunk - -- cond -> expr - -------------------------------------------------------------------- - -- assignment -> ',' primaryexp assignment - -- | '=' explist1 - -- explist1 -> expr { ',' expr } - -- * for assignment, LHS must be LOCAL, UPVAL, GLOBAL or INDEXED - -------------------------------------------------------------------- - -- primaryexp -> prefixexp { '.' NAME | '[' exp ']' | ':' NAME funcargs | funcargs } - -- prefixexp -> NAME | '(' expr ')' - -- funcargs -> '(' [ explist1 ] ')' | constructor | STRING - -- * funcargs turn an expr into a function call - -------------------------------------------------------------------- - -- expr -> subexpr - -- subexpr -> (UNOPR subexpr | simpleexp) { BINOPR subexpr } - -- simpleexp -> NUMBER | STRING | NIL | TRUE | FALSE - -- | constructor | FUNCTION body | primaryexp - -------------------------------------------------------------------- - -- constructor -> '{' [ field { fieldsep field } [ fieldsep ] ] '}' - -- fieldsep -> ',' | ';' - -- field -> recfield | listfield - -- recfield -> ( NAME | '[' exp1 ']' ) = exp1 - -- listfield -> expr - -------------------------------------------------------------------- - ---[[-------------------------------------------------------------------- --- parser test cases, Lua 5.0.x --- * uncomment string delimiter to enable syntax highlighting... --- * anything that matches "^%s*%-%-" is a comment --- * headings to display are "^%s*TESTS:%s*(.*)$" --- * FAIL test cases should match "%s*%-%-%s*FAIL%s*$" -----------------------------------------------------------------------]] -tests_source = [[ - -------------------------------------------------------------------- - TESTS: empty chunks - -------------------------------------------------------------------- - -- chunk -> { stat [';'] } - -------------------------------------------------------------------- - -; -- FAIL - -------------------------------------------------------------------- - TESTS: optional semicolon, simple local statements - -------------------------------------------------------------------- - -- stat -> LOCAL localstat - -- LOCAL localstat -> LOCAL NAME {',' NAME} ['=' explist1] - -- explist1 -> expr { ',' expr } - -------------------------------------------------------------------- -local -- FAIL -local; -- FAIL -local = -- FAIL -local end -- FAIL -local a -local a; -local a, b, c -local a; local b local c; -local a = 1 -local a local b = a -local a, b = 1, 2 -local a, b, c = 1, 2, 3 -local a, b, c = 1 -local a = 1, 2, 3 -local a, local -- FAIL -local 1 -- FAIL -local "foo" -- FAIL -local a = local -- FAIL -local a, b, = -- FAIL -local a, b = 1, local -- FAIL -local a, b = , local -- FAIL - -------------------------------------------------------------------- - TESTS: simple DO blocks - -------------------------------------------------------------------- - -- stat -> DO block END - -- block -> chunk - -------------------------------------------------------------------- -do -- FAIL -end -- FAIL -do end -do ; end -- FAIL -do 1 end -- FAIL -do "foo" end -- FAIL -do local a, b end -do local a local b end -do local a; local b; end -do local a = 1 end -do do end end -do do end; end -do do do end end end -do do do end; end; end -do do do return end end end -do end do -- FAIL -do end end -- FAIL -do return end -do return return end -- FAIL -do break end -- FAIL - -------------------------------------------------------------------- - TESTS: simple WHILE loops - -------------------------------------------------------------------- - -- stat -> whilestat - -- whilestat -> WHILE cond DO block END - -- block -> chunk - -- cond -> expr - -------------------------------------------------------------------- -while -- FAIL -while do -- FAIL -while = -- FAIL -while 1 do -- FAIL -while 1 do end -while 1 do local a end -while 1 do local a local b end -while 1 do local a; local b; end -while 1 do 2 end -- FAIL -while 1 do "foo" end -- FAIL -while true do end -while 1 do ; end -- FAIL -while 1 do while -- FAIL -while 1 end -- FAIL -while 1 2 do -- FAIL -while 1 = 2 do -- FAIL -while 1 do return end -while 1 do return return end -- FAIL -while 1 do do end end -while 1 do do return end end -while 1 do break end -while 1 do break break end -- FAIL -while 1 do do break end end - -------------------------------------------------------------------- - TESTS: simple REPEAT loops - -------------------------------------------------------------------- - -- stat -> repeatstat - -- repeatstat -> REPEAT block UNTIL cond - -- block -> chunk - -- cond -> expr - -------------------------------------------------------------------- -repeat -- FAIL -repeat until -- FAIL -repeat until 0 -repeat until false -repeat until local -- FAIL -repeat end -- FAIL -repeat 1 -- FAIL -repeat = -- FAIL -repeat local a until 1 -repeat local a local b until 0 -repeat local a; local b; until 0 -repeat ; until 1 -- FAIL -repeat 2 until 1 -- FAIL -repeat "foo" until 1 -- FAIL -repeat return until 0 -repeat return return until 0 -- FAIL -repeat break until 0 -repeat break break until 0 -- FAIL -repeat do end until 0 -repeat do return end until 0 -repeat do break end until 0 - -------------------------------------------------------------------- - TESTS: simple FOR loops - -------------------------------------------------------------------- - -- stat -> forstat - -- forstat -> fornum | forlist - -- forlist -> NAME {,NAME} IN explist1 forbody END - -- fornum -> NAME = exp1,exp1[,exp1] forbody END - -- forbody -> DO block - -- block -> chunk - -------------------------------------------------------------------- -for -- FAIL -for do -- FAIL -for end -- FAIL -for 1 -- FAIL -for a -- FAIL -for true -- FAIL -for a, in -- FAIL -for a in -- FAIL -for a do -- FAIL -for a in do -- FAIL -for a in b do -- FAIL -for a in b end -- FAIL -for a in b, do -- FAIL -for a in b do end -for a in b do local a local b end -for a in b do local a; local b; end -for a in b do 1 end -- FAIL -for a in b do "foo" end -- FAIL -for a b in -- FAIL -for a, b, c in p do end -for a, b, c in p, q, r do end -for a in 1 do end -for a in true do end -for a in "foo" do end -for a in b do break end -for a in b do break break end -- FAIL -for a in b do return end -for a in b do return return end -- FAIL -for a in b do do end end -for a in b do do break end end -for a in b do do return end end -for = -- FAIL -for a = -- FAIL -for a, b = -- FAIL -for a = do -- FAIL -for a = 1, do -- FAIL -for a = p, q, do -- FAIL -for a = p q do -- FAIL -for a = b do end -- FAIL -for a = 1, 2, 3, 4 do end -- FAIL -for a = p, q do end -for a = 1, 2 do end -for a = 1, 2 do local a local b end -for a = 1, 2 do local a; local b; end -for a = 1, 2 do 3 end -- FAIL -for a = 1, 2 do "foo" end -- FAIL -for a = p, q, r do end -for a = 1, 2, 3 do end -for a = p, q do break end -for a = p, q do break break end -- FAIL -for a = 1, 2 do return end -for a = 1, 2 do return return end -- FAIL -for a = p, q do do end end -for a = p, q do do break end end -for a = p, q do do return end end - -------------------------------------------------------------------- - TESTS: break statement - -------------------------------------------------------------------- - -- stat -> breakstat - -- breakstat -> BREAK - -- * must have a loop to break - -- * must be last statement in a block - -------------------------------------------------------------------- -break -- FAIL - -------------------------------------------------------------------- - TESTS: return statement - -------------------------------------------------------------------- - -- stat -> retstat - -- retstat -> RETURN explist - -- * must be last statement in a block - -------------------------------------------------------------------- -return -return; -return return -- FAIL -return 1 -return local -- FAIL -return "foo" -return 1, -- FAIL -return 1,2,3 -return a,b,c,d -return 1,2; - -------------------------------------------------------------------- - TESTS: conditional statements - -------------------------------------------------------------------- - -- stat -> ifstat - -- ifstat -> IF cond THEN block - -- {ELSEIF cond THEN block} - -- [ELSE block] END - -- block -> chunk - -- cond -> expr - -------------------------------------------------------------------- -if -- FAIL -elseif -- FAIL -else -- FAIL -then -- FAIL -if then -- FAIL -if 1 -- FAIL -if 1 then -- FAIL -if 1 else -- FAIL -if 1 then else -- FAIL -if 1 then elseif -- FAIL -if 1 then end -if 1 then local a end -if 1 then local a local b end -if 1 then local a; local b; end -if 1 then else end -if 1 then local a else local b end -if 1 then local a; else local b; end -if 1 then elseif 2 -- FAIL -if 1 then elseif 2 then -- FAIL -if 1 then elseif 2 then end -if 1 then local a elseif 2 then local b end -if 1 then local a; elseif 2 then local b; end -if 1 then elseif 2 then else end -if 1 then else if 2 then end end -if 1 then else if 2 then end -- FAIL -if 1 then break end -- FAIL -if 1 then return end -if 1 then return return end -- FAIL -if 1 then end; if 1 then end; - -------------------------------------------------------------------- - TESTS: function statements - -------------------------------------------------------------------- - -- stat -> funcstat - -- funcstat -> FUNCTION funcname body - -- funcname -> NAME {'.' NAME} [':' NAME] - -------------------------------------------------------------------- - -- body -> '(' parlist ')' chunk END - -- parlist -> [ param { ',' param } ] - -- param -> NAME - -- * DOTS must be the last parameter in a parlist - -------------------------------------------------------------------- -function -- FAIL -function 1 -- FAIL -function end -- FAIL -function a -- FAIL -function a end -- FAIL -function a( end -- FAIL -function a() end -function a(1 -- FAIL -function a("foo" -- FAIL -function a(p -- FAIL -function a(p,) -- FAIL -function a(p q -- FAIL -function a(p) end -function a(p,q,) end -- FAIL -function a(p,q,r) end -function a(p,q,1 -- FAIL -function a(p) do -- FAIL -function a(p) 1 end -- FAIL -function a(p) return end -function a(p) break end -- FAIL -function a(p) return return end -- FAIL -function a(p) do end end -function a.( -- FAIL -function a.1 -- FAIL -function a.b() end -function a.b, -- FAIL -function a.b.( -- FAIL -function a.b.c.d() end -function a: -- FAIL -function a:1 -- FAIL -function a:b() end -function a:b: -- FAIL -function a:b. -- FAIL -function a.b.c:d() end -function a(...) end -function a(..., -- FAIL -function a(p,...) end -function a(p,q,r,...) end -function a() local a local b end -function a() local a; local b; end -function a() end; function a() end; - -------------------------------------------------------------------- - TESTS: local function statements - -------------------------------------------------------------------- - -- stat -> LOCAL FUNCTION localfunc - -- LOCAL FUNCTION localfunc -> LOCAL FUNCTION NAME body - -------------------------------------------------------------------- -local function -- FAIL -local function 1 -- FAIL -local function end -- FAIL -local function a -- FAIL -local function a end -- FAIL -local function a( end -- FAIL -local function a() end -local function a(1 -- FAIL -local function a("foo" -- FAIL -local function a(p -- FAIL -local function a(p,) -- FAIL -local function a(p q -- FAIL -local function a(p) end -local function a(p,q,) end -- FAIL -local function a(p,q,r) end -local function a(p,q,1 -- FAIL -local function a(p) do -- FAIL -local function a(p) 1 end -- FAIL -local function a(p) return end -local function a(p) break end -- FAIL -local function a(p) return return end -- FAIL -local function a(p) do end end -local function a. -- FAIL -local function a: -- FAIL -local function a(...) end -local function a(..., -- FAIL -local function a(p,...) end -local function a(p,q,r,...) end -local function a() local a local b end -local function a() local a; local b; end -local function a() end; local function a() end; - -------------------------------------------------------------------- - -- stat -> exprstat - -- exprstat -> primaryexp - -- (-> func | assignment) - -- * if LHS is VCALL then func, otherwise assignment - -- * for func, LHS is VCALL if funcargs in expression - -------------------------------------------------------------------- - TESTS: assignments - -------------------------------------------------------------------- - -- assignment -> ',' primaryexp assignment - -- | '=' explist1 - -- explist1 -> expr { ',' expr } - -- * for assignment, LHS must be LOCAL, UPVAL, GLOBAL or INDEXED - -------------------------------------------------------------------- -a -- FAIL -a, -- FAIL -a,b,c -- FAIL -a,b = -- FAIL -a = 1 -a = 1,2,3 -a,b,c = 1 -a,b,c = 1,2,3 -a.b = 1 -a.b.c = 1 -a[b] = 1 -a[b][c] = 1 -a.b[c] = 1 -a[b].c = 1 -0 = -- FAIL -"foo" = -- FAIL -true = -- FAIL -(a) = -- FAIL -{} = -- FAIL -a:b() = -- FAIL -a() = -- FAIL -a.b:c() = -- FAIL -a[b]() = -- FAIL -a = a b -- FAIL -a = 1 2 -- FAIL -a = a = 1 -- FAIL - -------------------------------------------------------------------- - TESTS: function calls - -------------------------------------------------------------------- - -- primaryexp -> prefixexp { '.' NAME | '[' exp ']' | ':' NAME funcargs | funcargs } - -- prefixexp -> NAME | '(' expr ')' - -- funcargs -> '(' [ explist1 ] ')' | constructor | STRING - -- * funcargs turn an expr into a function call - -------------------------------------------------------------------- -a( -- FAIL -a() -a(1) -a(1,) -- FAIL -a(1,2,3) -1() -- FAIL -a()() -a.b() -a[b]() -a.1 -- FAIL -a.b -- FAIL -a[b] -- FAIL -a.b.( -- FAIL -a.b.c() -a[b][c]() -a[b].c() -a.b[c]() -a:b() -a:b -- FAIL -a:1 -- FAIL -a.b:c() -a[b]:c() -a:b: -- FAIL -a:b():c() -a:b().c[d]:e() -a:b()[c].d:e() -(a)() -()() -- FAIL -(1)() -("foo")() -(true)() -(a)()() -(a.b)() -(a[b])() -(a).b() -(a)[b]() -(a):b() -(a).b[c]:d() -(a)[b].c:d() -(a):b():c() -(a):b().c[d]:e() -(a):b()[c].d:e() - -------------------------------------------------------------------- - TESTS: more function calls - -------------------------------------------------------------------- -a"foo" -a[[foo]] -a.b"foo" -a[b]"foo" -a:b"foo" -a{} -a.b{} -a[b]{} -a:b{} -a()"foo" -a"foo"() -a"foo".b() -a"foo"[b]() -a"foo":c() -a"foo""bar" -a"foo"{} -(a):b"foo".c[d]:e"bar" -(a):b"foo"[c].d:e"bar" -a(){} -a{}() -a{}.b() -a{}[b]() -a{}:c() -a{}"foo" -a{}{} -(a):b{}.c[d]:e{} -(a):b{}[c].d:e{} - -------------------------------------------------------------------- - TESTS: simple expressions - -------------------------------------------------------------------- - -- simpleexp -> NUMBER | STRING | NIL | TRUE | FALSE - -- | constructor | FUNCTION body | primaryexp - -------------------------------------------------------------------- -a = -- FAIL -a = a -a = nil -a = false -a = 1 -a = "foo" -a = [[foo]] -a = {} -a = (a) -a = (nil) -a = (true) -a = (1) -a = ("foo") -a = ([[foo]]) -a = ({}) -a = a.b -a = a.b. -- FAIL -a = a.b.c -a = a:b -- FAIL -a = a[b] -a = a[1] -a = a["foo"] -a = a[b][c] -a = a.b[c] -a = a[b].c -a = (a)[b] -a = (a).c -a = () -- FAIL -a = a() -a = a.b() -a = a[b]() -a = a:b() -a = (a)() -a = (a).b() -a = (a)[b]() -a = (a):b() -a = a"foo" -a = a{} -a = function -- FAIL -a = function 1 -- FAIL -a = function a -- FAIL -a = function end -- FAIL -a = function( -- FAIL -a = function() end -a = function(1 -- FAIL -a = function(p) end -a = function(p,) -- FAIL -a = function(p q -- FAIL -a = function(p,q,r) end -a = function(p,q,1 -- FAIL -a = function(...) end -a = function(..., -- FAIL -a = function(p,...) end -a = function(p,q,r,...) end - -------------------------------------------------------------------- - TESTS: operators - -------------------------------------------------------------------- - -- expr -> subexpr - -- subexpr -> (UNOPR subexpr | simpleexp) { BINOPR subexpr } - -- simpleexp -> NUMBER | STRING | NIL | TRUE | FALSE - -- | constructor | FUNCTION body | primaryexp - -------------------------------------------------------------------- -a = -10 -a = -"foo" -a = -a -a = -nil -a = -true -a = -{} -a = -function() end -a = -a() -a = -(a) -a = - -- FAIL -a = not 10 -a = not "foo" -a = not a -a = not nil -a = not true -a = not {} -a = not function() end -a = not a() -a = not (a) -a = not -- FAIL -a = 1 + 2; a = 1 - 2 -a = 1 * 2; a = 1 / 2 -a = 1 ^ 2; a = 1 .. 2 -a = 1 + -- FAIL -a = 1 .. -- FAIL -a = 1 * / -- FAIL -a = 1 + -2; a = 1 - -2 -a = 1 * - -- FAIL -a = 1 * not 2; a = 1 / not 2 -a = 1 / not -- FAIL -a = 1 + 2 - 3 * 4 / 5 ^ 6 -a = ((1 + 2) - 3) * (4 / (5 ^ 6)) -a = (1 + (2 - (3 * (4 / (5 ^ ((6))))))) -a = ((1 -- FAIL -a = ((1 + 2) -- FAIL -a = 1) -- FAIL -a = a + b - c -a = "foo" + "bar" -a = "foo".."bar".."baz" -a = true + false - nil -a = {} * {} -a = function() end / function() end -a = a() ^ b() - -------------------------------------------------------------------- - TESTS: more operators - -------------------------------------------------------------------- -a = 1 == 2; a = 1 ~= 2 -a = 1 < 2; a = 1 <= 2 -a = 1 > 2; a = 1 >= 2 -a = 1 < 2 < 3 -a = 1 >= 2 >= 3 -a = 1 == -- FAIL -a = ~= 2 -- FAIL -a = "foo" == "bar" -a = "foo" > "bar" -a = a ~= b -a = true == false -a = 1 and 2; a = 1 or 2 -a = 1 and -- FAIL -a = or 1 -- FAIL -a = 1 and 2 and 3 -a = 1 or 2 or 3 -a = 1 and 2 or 3 -a = a and b or c -a = a() and (b)() or c.d -a = "foo" and "bar" -a = true or false -a = {} and {} or {} -a = (1) and ("foo") or (nil) -a = function() end == function() end -a = function() end or function() end - -------------------------------------------------------------------- - TESTS: constructors - -------------------------------------------------------------------- - -- constructor -> '{' [ field { fieldsep field } [ fieldsep ] ] '}' - -- fieldsep -> ',' | ';' - -- field -> recfield | listfield - -- recfield -> ( NAME | '[' exp1 ']' ) = exp1 - -- listfield -> expr - -------------------------------------------------------------------- -a = { -- FAIL -a = {} -a = {,} -- FAIL -a = {;} -a = {,,} -- FAIL -a = {;;} -- FAIL -a = {{ -- FAIL -a = {{{}}} -a = {{},{},{{}},} -a = { 1 } -a = { 1, } -a = { 1; } -a = { 1, 2 } -a = { a, b, c, } -a = { true; false, nil; } -a = { a.b, a[b]; a:c(), } -a = { 1 + 2, a > b, "a" or "b" } -a = { a=1, } -a = { a=1, b="foo", c=nil } -a = { a -- FAIL -a = { a= -- FAIL -a = { a=, -- FAIL -a = { a=; -- FAIL -a = { 1, a="foo" -- FAIL -a = { 1, a="foo"; b={}, d=true; } -a = { [ -- FAIL -a = { [1 -- FAIL -a = { [1] -- FAIL -a = { [a]= -- FAIL -a = { ["foo"]="bar" } -a = { [1]=a, [2]=b, } -a = { true, a=1; ["foo"]="bar", } -]] - --- end of script diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/test_parser-5.1.lua b/LuaSL/testLua/yueliang-0.4.1/test_lua/test_parser-5.1.lua deleted file mode 100644 index 0809652..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/test_parser-5.1.lua +++ /dev/null @@ -1,783 +0,0 @@ ---[[-------------------------------------------------------------------- - - test_parser-5.1.lua - Lua 5.1.x parser test cases - This file is part of Yueliang. - - Copyright (c) 2006 Kein-Hong Man - The COPYRIGHT file describes the conditions - under which this software may be distributed. - - See the ChangeLog for more information. - -----------------------------------------------------------------------]] - ---[[-------------------------------------------------------------------- --- Notes: --- * there is no intention of properly specifying a grammar; the notes --- are meant to reflect the structure of lparser so that it is easy --- to locate and modify lparser if so desired --- * some test may have invalid expressions but will compile, this --- is because the chunk hasn't been executed yet --- --- Changed in 5.1.x: --- * added ..., %, # cases -----------------------------------------------------------------------]] - ---[[-------------------------------------------------------------------- --- lparser parsing structure, the Lua 5.1.x version... -----------------------------------------------------------------------]] - -------------------------------------------------------------------- - -- chunk -> { stat [';'] } - -------------------------------------------------------------------- - -- stat -> DO block END - -- block -> chunk - -------------------------------------------------------------------- - -- stat -> breakstat - -- breakstat -> BREAK - -- * must have a loop to break - -- * must be last statement in a block - -------------------------------------------------------------------- - -- stat -> retstat - -- retstat -> RETURN explist - -- * must be last statement in a block - -------------------------------------------------------------------- - -- stat -> exprstat - -- exprstat -> primaryexp - -- (-> func | assignment) - -- * if LHS is VCALL then func, otherwise assignment - -- * for func, LHS is VCALL if funcargs in expression - -------------------------------------------------------------------- - -- stat -> funcstat - -- funcstat -> FUNCTION funcname body - -- funcname -> NAME {'.' NAME} [':' NAME] - -------------------------------------------------------------------- - -- body -> '(' parlist ')' chunk END - -- parlist -> [ param { ',' param } ] - -- param -> NAME - -- * DOTS must be the last parameter in a parlist - -------------------------------------------------------------------- - -- stat -> LOCAL localstat - -- LOCAL localstat -> LOCAL NAME {',' NAME} ['=' explist1] - -- explist1 -> expr { ',' expr } - -------------------------------------------------------------------- - -- stat -> LOCAL FUNCTION localfunc - -- LOCAL FUNCTION localfunc -> LOCAL FUNCTION NAME body - -------------------------------------------------------------------- - -- stat -> ifstat - -- ifstat -> IF cond THEN block - -- {ELSEIF cond THEN block} - -- [ELSE block] END - -- block -> chunk - -- cond -> expr - -------------------------------------------------------------------- - -- stat -> forstat - -- forstat -> fornum | forlist - -- forlist -> NAME {,NAME} IN explist1 forbody END - -- fornum -> NAME = exp1,exp1[,exp1] forbody END - -- forbody -> DO block - -- block -> chunk - -------------------------------------------------------------------- - -- stat -> whilestat - -- whilestat -> WHILE cond DO block END - -- block -> chunk - -- cond -> expr - -------------------------------------------------------------------- - -- stat -> repeatstat - -- repeatstat -> REPEAT chunk UNTIL cond - -- cond -> expr - -------------------------------------------------------------------- - -- assignment -> ',' primaryexp assignment - -- | '=' explist1 - -- explist1 -> expr { ',' expr } - -- * for assignment, LHS must be LOCAL, UPVAL, GLOBAL or INDEXED - -------------------------------------------------------------------- - -- primaryexp -> prefixexp { '.' NAME | '[' exp ']' | ':' NAME funcargs | funcargs } - -- prefixexp -> NAME | '(' expr ')' - -- funcargs -> '(' [ explist1 ] ')' | constructor | STRING - -- * funcargs turn an expr into a function call - -------------------------------------------------------------------- - -- expr -> subexpr - -- subexpr -> (UNOPR subexpr | simpleexp) { BINOPR subexpr } - -- simpleexp -> NUMBER | STRING | NIL | TRUE | FALSE | ... - -- | constructor | FUNCTION body | primaryexp - -------------------------------------------------------------------- - -- constructor -> '{' [ field { fieldsep field } [ fieldsep ] ] '}' - -- fieldsep -> ',' | ';' - -- field -> recfield | listfield - -- recfield -> ( NAME | '[' exp1 ']' ) = exp1 - -- listfield -> expr - -------------------------------------------------------------------- - ---[[-------------------------------------------------------------------- --- parser test cases, Lua 5.1.x --- * uncomment string delimiter to enable syntax highlighting... --- * anything that matches "^%s*%-%-" is a comment --- * headings to display are "^%s*TESTS:%s*(.*)$" --- * FAIL test cases should match "%s*%-%-%s*FAIL%s*$" -----------------------------------------------------------------------]] -tests_source = [=[ - -------------------------------------------------------------------- - TESTS: empty chunks - -------------------------------------------------------------------- - -- chunk -> { stat [';'] } - -------------------------------------------------------------------- - -; -- FAIL - -------------------------------------------------------------------- - TESTS: optional semicolon, simple local statements - -------------------------------------------------------------------- - -- stat -> LOCAL localstat - -- LOCAL localstat -> LOCAL NAME {',' NAME} ['=' explist1] - -- explist1 -> expr { ',' expr } - -------------------------------------------------------------------- -local -- FAIL -local; -- FAIL -local = -- FAIL -local end -- FAIL -local a -local a; -local a, b, c -local a; local b local c; -local a = 1 -local a local b = a -local a, b = 1, 2 -local a, b, c = 1, 2, 3 -local a, b, c = 1 -local a = 1, 2, 3 -local a, local -- FAIL -local 1 -- FAIL -local "foo" -- FAIL -local a = local -- FAIL -local a, b, = -- FAIL -local a, b = 1, local -- FAIL -local a, b = , local -- FAIL - -------------------------------------------------------------------- - TESTS: simple DO blocks - -------------------------------------------------------------------- - -- stat -> DO block END - -- block -> chunk - -------------------------------------------------------------------- -do -- FAIL -end -- FAIL -do end -do ; end -- FAIL -do 1 end -- FAIL -do "foo" end -- FAIL -do local a, b end -do local a local b end -do local a; local b; end -do local a = 1 end -do do end end -do do end; end -do do do end end end -do do do end; end; end -do do do return end end end -do end do -- FAIL -do end end -- FAIL -do return end -do return return end -- FAIL -do break end -- FAIL - -------------------------------------------------------------------- - TESTS: simple WHILE loops - -------------------------------------------------------------------- - -- stat -> whilestat - -- whilestat -> WHILE cond DO block END - -- block -> chunk - -- cond -> expr - -------------------------------------------------------------------- -while -- FAIL -while do -- FAIL -while = -- FAIL -while 1 do -- FAIL -while 1 do end -while 1 do local a end -while 1 do local a local b end -while 1 do local a; local b; end -while 1 do 2 end -- FAIL -while 1 do "foo" end -- FAIL -while true do end -while 1 do ; end -- FAIL -while 1 do while -- FAIL -while 1 end -- FAIL -while 1 2 do -- FAIL -while 1 = 2 do -- FAIL -while 1 do return end -while 1 do return return end -- FAIL -while 1 do do end end -while 1 do do return end end -while 1 do break end -while 1 do break break end -- FAIL -while 1 do do break end end - -------------------------------------------------------------------- - TESTS: simple REPEAT loops - -------------------------------------------------------------------- - -- stat -> repeatstat - -- repeatstat -> REPEAT chunk UNTIL cond - -- cond -> expr - -------------------------------------------------------------------- -repeat -- FAIL -repeat until -- FAIL -repeat until 0 -repeat until false -repeat until local -- FAIL -repeat end -- FAIL -repeat 1 -- FAIL -repeat = -- FAIL -repeat local a until 1 -repeat local a local b until 0 -repeat local a; local b; until 0 -repeat ; until 1 -- FAIL -repeat 2 until 1 -- FAIL -repeat "foo" until 1 -- FAIL -repeat return until 0 -repeat return return until 0 -- FAIL -repeat break until 0 -repeat break break until 0 -- FAIL -repeat do end until 0 -repeat do return end until 0 -repeat do break end until 0 - -------------------------------------------------------------------- - TESTS: simple FOR loops - -------------------------------------------------------------------- - -- stat -> forstat - -- forstat -> fornum | forlist - -- forlist -> NAME {,NAME} IN explist1 forbody END - -- fornum -> NAME = exp1,exp1[,exp1] forbody END - -- forbody -> DO block - -- block -> chunk - -------------------------------------------------------------------- -for -- FAIL -for do -- FAIL -for end -- FAIL -for 1 -- FAIL -for a -- FAIL -for true -- FAIL -for a, in -- FAIL -for a in -- FAIL -for a do -- FAIL -for a in do -- FAIL -for a in b do -- FAIL -for a in b end -- FAIL -for a in b, do -- FAIL -for a in b do end -for a in b do local a local b end -for a in b do local a; local b; end -for a in b do 1 end -- FAIL -for a in b do "foo" end -- FAIL -for a b in -- FAIL -for a, b, c in p do end -for a, b, c in p, q, r do end -for a in 1 do end -for a in true do end -for a in "foo" do end -for a in b do break end -for a in b do break break end -- FAIL -for a in b do return end -for a in b do return return end -- FAIL -for a in b do do end end -for a in b do do break end end -for a in b do do return end end -for = -- FAIL -for a = -- FAIL -for a, b = -- FAIL -for a = do -- FAIL -for a = 1, do -- FAIL -for a = p, q, do -- FAIL -for a = p q do -- FAIL -for a = b do end -- FAIL -for a = 1, 2, 3, 4 do end -- FAIL -for a = p, q do end -for a = 1, 2 do end -for a = 1, 2 do local a local b end -for a = 1, 2 do local a; local b; end -for a = 1, 2 do 3 end -- FAIL -for a = 1, 2 do "foo" end -- FAIL -for a = p, q, r do end -for a = 1, 2, 3 do end -for a = p, q do break end -for a = p, q do break break end -- FAIL -for a = 1, 2 do return end -for a = 1, 2 do return return end -- FAIL -for a = p, q do do end end -for a = p, q do do break end end -for a = p, q do do return end end - -------------------------------------------------------------------- - TESTS: break statement - -------------------------------------------------------------------- - -- stat -> breakstat - -- breakstat -> BREAK - -- * must have a loop to break - -- * must be last statement in a block - -------------------------------------------------------------------- -break -- FAIL - -------------------------------------------------------------------- - TESTS: return statement - -------------------------------------------------------------------- - -- stat -> retstat - -- retstat -> RETURN explist - -- * must be last statement in a block - -------------------------------------------------------------------- -return -return; -return return -- FAIL -return 1 -return local -- FAIL -return "foo" -return 1, -- FAIL -return 1,2,3 -return a,b,c,d -return 1,2; -return ... -return 1,a,... - -------------------------------------------------------------------- - TESTS: conditional statements - -------------------------------------------------------------------- - -- stat -> ifstat - -- ifstat -> IF cond THEN block - -- {ELSEIF cond THEN block} - -- [ELSE block] END - -- block -> chunk - -- cond -> expr - -------------------------------------------------------------------- -if -- FAIL -elseif -- FAIL -else -- FAIL -then -- FAIL -if then -- FAIL -if 1 -- FAIL -if 1 then -- FAIL -if 1 else -- FAIL -if 1 then else -- FAIL -if 1 then elseif -- FAIL -if 1 then end -if 1 then local a end -if 1 then local a local b end -if 1 then local a; local b; end -if 1 then else end -if 1 then local a else local b end -if 1 then local a; else local b; end -if 1 then elseif 2 -- FAIL -if 1 then elseif 2 then -- FAIL -if 1 then elseif 2 then end -if 1 then local a elseif 2 then local b end -if 1 then local a; elseif 2 then local b; end -if 1 then elseif 2 then else end -if 1 then else if 2 then end end -if 1 then else if 2 then end -- FAIL -if 1 then break end -- FAIL -if 1 then return end -if 1 then return return end -- FAIL -if 1 then end; if 1 then end; - -------------------------------------------------------------------- - TESTS: function statements - -------------------------------------------------------------------- - -- stat -> funcstat - -- funcstat -> FUNCTION funcname body - -- funcname -> NAME {'.' NAME} [':' NAME] - -------------------------------------------------------------------- - -- body -> '(' parlist ')' chunk END - -- parlist -> [ param { ',' param } ] - -- param -> NAME - -- * DOTS must be the last parameter in a parlist - -------------------------------------------------------------------- -function -- FAIL -function 1 -- FAIL -function end -- FAIL -function a -- FAIL -function a end -- FAIL -function a( end -- FAIL -function a() end -function a(1 -- FAIL -function a("foo" -- FAIL -function a(p -- FAIL -function a(p,) -- FAIL -function a(p q -- FAIL -function a(p) end -function a(p,q,) end -- FAIL -function a(p,q,r) end -function a(p,q,1 -- FAIL -function a(p) do -- FAIL -function a(p) 1 end -- FAIL -function a(p) return end -function a(p) break end -- FAIL -function a(p) return return end -- FAIL -function a(p) do end end -function a.( -- FAIL -function a.1 -- FAIL -function a.b() end -function a.b, -- FAIL -function a.b.( -- FAIL -function a.b.c.d() end -function a: -- FAIL -function a:1 -- FAIL -function a:b() end -function a:b: -- FAIL -function a:b. -- FAIL -function a.b.c:d() end -function a(...) end -function a(..., -- FAIL -function a(p,...) end -function a(p,q,r,...) end -function a() local a local b end -function a() local a; local b; end -function a() end; function a() end; - -------------------------------------------------------------------- - TESTS: local function statements - -------------------------------------------------------------------- - -- stat -> LOCAL FUNCTION localfunc - -- LOCAL FUNCTION localfunc -> LOCAL FUNCTION NAME body - -------------------------------------------------------------------- -local function -- FAIL -local function 1 -- FAIL -local function end -- FAIL -local function a -- FAIL -local function a end -- FAIL -local function a( end -- FAIL -local function a() end -local function a(1 -- FAIL -local function a("foo" -- FAIL -local function a(p -- FAIL -local function a(p,) -- FAIL -local function a(p q -- FAIL -local function a(p) end -local function a(p,q,) end -- FAIL -local function a(p,q,r) end -local function a(p,q,1 -- FAIL -local function a(p) do -- FAIL -local function a(p) 1 end -- FAIL -local function a(p) return end -local function a(p) break end -- FAIL -local function a(p) return return end -- FAIL -local function a(p) do end end -local function a. -- FAIL -local function a: -- FAIL -local function a(...) end -local function a(..., -- FAIL -local function a(p,...) end -local function a(p,q,r,...) end -local function a() local a local b end -local function a() local a; local b; end -local function a() end; local function a() end; - -------------------------------------------------------------------- - -- stat -> exprstat - -- exprstat -> primaryexp - -- (-> func | assignment) - -- * if LHS is VCALL then func, otherwise assignment - -- * for func, LHS is VCALL if funcargs in expression - -------------------------------------------------------------------- - TESTS: assignments - -------------------------------------------------------------------- - -- assignment -> ',' primaryexp assignment - -- | '=' explist1 - -- explist1 -> expr { ',' expr } - -- * for assignment, LHS must be LOCAL, UPVAL, GLOBAL or INDEXED - -------------------------------------------------------------------- -a -- FAIL -a, -- FAIL -a,b,c -- FAIL -a,b = -- FAIL -a = 1 -a = 1,2,3 -a,b,c = 1 -a,b,c = 1,2,3 -a.b = 1 -a.b.c = 1 -a[b] = 1 -a[b][c] = 1 -a.b[c] = 1 -a[b].c = 1 -0 = -- FAIL -"foo" = -- FAIL -true = -- FAIL -(a) = -- FAIL -{} = -- FAIL -a:b() = -- FAIL -a() = -- FAIL -a.b:c() = -- FAIL -a[b]() = -- FAIL -a = a b -- FAIL -a = 1 2 -- FAIL -a = a = 1 -- FAIL - -------------------------------------------------------------------- - TESTS: function calls - -------------------------------------------------------------------- - -- primaryexp -> prefixexp { '.' NAME | '[' exp ']' | ':' NAME funcargs | funcargs } - -- prefixexp -> NAME | '(' expr ')' - -- funcargs -> '(' [ explist1 ] ')' | constructor | STRING - -- * funcargs turn an expr into a function call - -------------------------------------------------------------------- -a( -- FAIL -a() -a(1) -a(1,) -- FAIL -a(1,2,3) -1() -- FAIL -a()() -a.b() -a[b]() -a.1 -- FAIL -a.b -- FAIL -a[b] -- FAIL -a.b.( -- FAIL -a.b.c() -a[b][c]() -a[b].c() -a.b[c]() -a:b() -a:b -- FAIL -a:1 -- FAIL -a.b:c() -a[b]:c() -a:b: -- FAIL -a:b():c() -a:b().c[d]:e() -a:b()[c].d:e() -(a)() -()() -- FAIL -(1)() -("foo")() -(true)() -(a)()() -(a.b)() -(a[b])() -(a).b() -(a)[b]() -(a):b() -(a).b[c]:d() -(a)[b].c:d() -(a):b():c() -(a):b().c[d]:e() -(a):b()[c].d:e() - -------------------------------------------------------------------- - TESTS: more function calls - -------------------------------------------------------------------- -a"foo" -a[[foo]] -a.b"foo" -a[b]"foo" -a:b"foo" -a{} -a.b{} -a[b]{} -a:b{} -a()"foo" -a"foo"() -a"foo".b() -a"foo"[b]() -a"foo":c() -a"foo""bar" -a"foo"{} -(a):b"foo".c[d]:e"bar" -(a):b"foo"[c].d:e"bar" -a(){} -a{}() -a{}.b() -a{}[b]() -a{}:c() -a{}"foo" -a{}{} -(a):b{}.c[d]:e{} -(a):b{}[c].d:e{} - -------------------------------------------------------------------- - TESTS: simple expressions - -------------------------------------------------------------------- - -- simpleexp -> NUMBER | STRING | NIL | TRUE | FALSE | ... - -- | constructor | FUNCTION body | primaryexp - -------------------------------------------------------------------- -a = -- FAIL -a = a -a = nil -a = false -a = 1 -a = "foo" -a = [[foo]] -a = {} -a = (a) -a = (nil) -a = (true) -a = (1) -a = ("foo") -a = ([[foo]]) -a = ({}) -a = a.b -a = a.b. -- FAIL -a = a.b.c -a = a:b -- FAIL -a = a[b] -a = a[1] -a = a["foo"] -a = a[b][c] -a = a.b[c] -a = a[b].c -a = (a)[b] -a = (a).c -a = () -- FAIL -a = a() -a = a.b() -a = a[b]() -a = a:b() -a = (a)() -a = (a).b() -a = (a)[b]() -a = (a):b() -a = a"foo" -a = a{} -a = function -- FAIL -a = function 1 -- FAIL -a = function a -- FAIL -a = function end -- FAIL -a = function( -- FAIL -a = function() end -a = function(1 -- FAIL -a = function(p) end -a = function(p,) -- FAIL -a = function(p q -- FAIL -a = function(p,q,r) end -a = function(p,q,1 -- FAIL -a = function(...) end -a = function(..., -- FAIL -a = function(p,...) end -a = function(p,q,r,...) end -a = ... -a = a, b, ... -a = (...) -a = ..., 1, 2 -a = function() return ... end -- FAIL - -------------------------------------------------------------------- - TESTS: operators - -------------------------------------------------------------------- - -- expr -> subexpr - -- subexpr -> (UNOPR subexpr | simpleexp) { BINOPR subexpr } - -- simpleexp -> NUMBER | STRING | NIL | TRUE | FALSE | ... - -- | constructor | FUNCTION body | primaryexp - -------------------------------------------------------------------- -a = -10 -a = -"foo" -a = -a -a = -nil -a = -true -a = -{} -a = -function() end -a = -a() -a = -(a) -a = - -- FAIL -a = not 10 -a = not "foo" -a = not a -a = not nil -a = not true -a = not {} -a = not function() end -a = not a() -a = not (a) -a = not -- FAIL -a = #10 -a = #"foo" -a = #a -a = #nil -a = #true -a = #{} -a = #function() end -a = #a() -a = #(a) -a = # -- FAIL -a = 1 + 2; a = 1 - 2 -a = 1 * 2; a = 1 / 2 -a = 1 ^ 2; a = 1 % 2 -a = 1 .. 2 -a = 1 + -- FAIL -a = 1 .. -- FAIL -a = 1 * / -- FAIL -a = 1 + -2; a = 1 - -2 -a = 1 * - -- FAIL -a = 1 * not 2; a = 1 / not 2 -a = 1 / not -- FAIL -a = 1 * #"foo"; a = 1 / #"foo" -a = 1 / # -- FAIL -a = 1 + 2 - 3 * 4 / 5 % 6 ^ 7 -a = ((1 + 2) - 3) * (4 / (5 % 6 ^ 7)) -a = (1 + (2 - (3 * (4 / (5 % 6 ^ ((7))))))) -a = ((1 -- FAIL -a = ((1 + 2) -- FAIL -a = 1) -- FAIL -a = a + b - c -a = "foo" + "bar" -a = "foo".."bar".."baz" -a = true + false - nil -a = {} * {} -a = function() end / function() end -a = a() ^ b() -a = ... % ... - -------------------------------------------------------------------- - TESTS: more operators - -------------------------------------------------------------------- -a = 1 == 2; a = 1 ~= 2 -a = 1 < 2; a = 1 <= 2 -a = 1 > 2; a = 1 >= 2 -a = 1 < 2 < 3 -a = 1 >= 2 >= 3 -a = 1 == -- FAIL -a = ~= 2 -- FAIL -a = "foo" == "bar" -a = "foo" > "bar" -a = a ~= b -a = true == false -a = 1 and 2; a = 1 or 2 -a = 1 and -- FAIL -a = or 1 -- FAIL -a = 1 and 2 and 3 -a = 1 or 2 or 3 -a = 1 and 2 or 3 -a = a and b or c -a = a() and (b)() or c.d -a = "foo" and "bar" -a = true or false -a = {} and {} or {} -a = (1) and ("foo") or (nil) -a = function() end == function() end -a = function() end or function() end - -------------------------------------------------------------------- - TESTS: constructors - -------------------------------------------------------------------- - -- constructor -> '{' [ field { fieldsep field } [ fieldsep ] ] '}' - -- fieldsep -> ',' | ';' - -- field -> recfield | listfield - -- recfield -> ( NAME | '[' exp1 ']' ) = exp1 - -- listfield -> expr - -------------------------------------------------------------------- -a = { -- FAIL -a = {} -a = {,} -- FAIL -a = {;} -- FAIL -a = {,,} -- FAIL -a = {;;} -- FAIL -a = {{ -- FAIL -a = {{{}}} -a = {{},{},{{}},} -a = { 1 } -a = { 1, } -a = { 1; } -a = { 1, 2 } -a = { a, b, c, } -a = { true; false, nil; } -a = { a.b, a[b]; a:c(), } -a = { 1 + 2, a > b, "a" or "b" } -a = { a=1, } -a = { a=1, b="foo", c=nil } -a = { a -- FAIL -a = { a= -- FAIL -a = { a=, -- FAIL -a = { a=; -- FAIL -a = { 1, a="foo" -- FAIL -a = { 1, a="foo"; b={}, d=true; } -a = { [ -- FAIL -a = { [1 -- FAIL -a = { [1] -- FAIL -a = { [a]= -- FAIL -a = { ["foo"]="bar" } -a = { [1]=a, [2]=b, } -a = { true, a=1; ["foo"]="bar", } -]=] - --- end of script diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/test_scripts-5.0.lua b/LuaSL/testLua/yueliang-0.4.1/test_lua/test_scripts-5.0.lua deleted file mode 100644 index 53a3ae3..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/test_scripts-5.0.lua +++ /dev/null @@ -1,158 +0,0 @@ ---[[-------------------------------------------------------------------- - - test_scripts-5.0.lua - Compile and compare Lua files - This file is part of Yueliang. - - Copyright (c) 2005-2007 Kein-Hong Man - The COPYRIGHT file describes the conditions - under which this software may be distributed. - - See the ChangeLog for more information. - -----------------------------------------------------------------------]] - ---[[-------------------------------------------------------------------- --- NOTE --- * use the argument ALL to pull in additional personal Lua scripts --- for testing, e.g. lua test_scripts.lua ALL -----------------------------------------------------------------------]] - ------------------------------------------------------------------------- --- reads in a list of files to crunch from a text file ------------------------------------------------------------------------- - -local function loadlist(fname, flist) - local inf = io.open(fname, "r") - if not inf then error("cannot open "..fname.." for reading") end - while true do - local d = inf:read("*l") - if not d then break end - if string.find(d, "^%s*$") or string.find(d, "^#") then - -- comments and empty lines are ignored - else - table.insert(flist, d) - end - end - inf:close() -end - ------------------------------------------------------------------------- --- read in list of files to test ------------------------------------------------------------------------- - -local files = {} - -loadlist("files-lua-5.0.txt", files) -loadlist("files-yueliang-5.0.txt", files) - --- pull in personal scripts to test if user specifies "ALL" -if arg[1] == "ALL" then - loadlist("files-other-5.0.txt", files) -end - --- if you want to specify files in this script itself (not recommended) --- you can add them using the following ---[[ -for v in string.gfind([[ -]], "[^%s]+") do - table.insert(files, v) -end ---]] - -total = 0 -- sum of sizes -fsize = 0 -- current file size - ------------------------------------------------------------------------- --- initialize ------------------------------------------------------------------------- - -require("../orig-5.0.3/lzio") -require("../orig-5.0.3/llex") -require("../orig-5.0.3/lopcodes") -require("../orig-5.0.3/ldump") -require("../orig-5.0.3/lcode") -require("../orig-5.0.3/lparser") - -function lua_assert(test) - if not test then error("assertion failed!") end -end - -luaX:init() - -io.stdout:write("\n\n") - ------------------------------------------------------------------------- --- * basic comparison for now; do it properly later ------------------------------------------------------------------------- - -local LuaState = {} - ------------------------------------------------------------------------- --- dump binary chunks to a file if something goes wrong ------------------------------------------------------------------------- -local function Dump(data, filename) - h = io.open(filename, "wb") - if not h then error("failed to open "..filename.." for writing") end - h:write(data) - h:close() -end - ------------------------------------------------------------------------- --- create custom chunk reader (sums up file sizes) ------------------------------------------------------------------------- -function make_getF(filename) - local h = io.open(filename, "r") - if not h then return nil end - fsize = h:seek("end") - h:seek("set") - total = total + fsize - return function() -- chunk reader anonymous function here - if not h then return nil end - local buff = h:read(512) - if not buff then h:close() end - return buff - end -end - ------------------------------------------------------------------------- --- attempt to compile Lua source files ------------------------------------------------------------------------- -for i, filename in ipairs(files) do - -- compile a source file - local zio = luaZ:init(make_getF(filename), nil, "@"..filename) - if not zio then - error("could not initialize zio stream for "..filename) - end - io.stdout:write(filename.."("..fsize.."): ") - local Func = luaY:parser(LuaState, zio, nil) - local Writer, Buff = luaU:make_setS() - luaU:dump(LuaState, Func, Writer, Buff) - local bc1 = Buff.data -- Yueliang's output - - local f = loadfile(filename) - local bc2 = string.dump(f) -- Lua's output - - -- compare outputs - if string.len(bc1) ~= string.len(bc2) then - Dump(bc1, "bc1.out") - Dump(bc2, "bc2.out") - error("binary chunk sizes different") - elseif bc1 ~= bc2 then - Dump(bc1, "bc1.out") - Dump(bc2, "bc2.out") - error("binary chunks different") - else - io.stdout:write("CORRECT\n") - end - local x, y = gcinfo() - -- memory usage isn't really a problem for the straight port - -- string handling in Lua that follows the original C closely is more - -- of a problem, but this will be fixed elsewhere, not in this tree - --io.stdout:write("gcinfo: "..x.." "..y.."\n") -end - --- summaries here -io.stdout:write("\nTotal file sizes: "..total.."\n") - --- end diff --git a/LuaSL/testLua/yueliang-0.4.1/test_lua/test_scripts-5.1.lua b/LuaSL/testLua/yueliang-0.4.1/test_lua/test_scripts-5.1.lua deleted file mode 100644 index 4d84055..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/test_lua/test_scripts-5.1.lua +++ /dev/null @@ -1,158 +0,0 @@ ---[[-------------------------------------------------------------------- - - test_scripts-5.1.lua - Compile and compare Lua files - This file is part of Yueliang. - - Copyright (c) 2005-2007 Kein-Hong Man - The COPYRIGHT file describes the conditions - under which this software may be distributed. - - See the ChangeLog for more information. - -----------------------------------------------------------------------]] - ---[[-------------------------------------------------------------------- --- NOTE --- * use the argument ALL to pull in additional personal Lua scripts --- for testing, e.g. lua test_scripts.lua ALL -----------------------------------------------------------------------]] - ------------------------------------------------------------------------- --- reads in a list of files to crunch from a text file ------------------------------------------------------------------------- - -local function loadlist(fname, flist) - local inf = io.open(fname, "r") - if not inf then error("cannot open "..fname.." for reading") end - while true do - local d = inf:read("*l") - if not d then break end - if string.match(d, "^%s*$") or string.match(d, "^#") then - -- comments and empty lines are ignored - else - flist[#flist+1] = d - end - end - inf:close() -end - ------------------------------------------------------------------------- --- read in list of files to test ------------------------------------------------------------------------- - -local files = {} - -loadlist("files-lua-5.1.txt", files) -loadlist("files-yueliang-5.1.txt", files) - --- pull in personal scripts to test if user specifies "ALL" -if arg[1] == "ALL" then - loadlist("files-other-5.1.txt", files) -end - --- if you want to specify files in this script itself (not recommended) --- you can add them using the following ---[=[ -for v in string.gmatch([[ -]], "[^%s]+") do - table.insert(files, v) -end ---]=] - -total = 0 -- sum of sizes -fsize = 0 -- current file size - ------------------------------------------------------------------------- --- initialize ------------------------------------------------------------------------- - -dofile("../orig-5.1.2/lzio.lua") -dofile("../orig-5.1.2/llex.lua") -dofile("../orig-5.1.2/lopcodes.lua") -dofile("../orig-5.1.2/ldump.lua") -dofile("../orig-5.1.2/lcode.lua") -dofile("../orig-5.1.2/lparser.lua") - -function lua_assert(test) - if not test then error("assertion failed!") end -end - -luaX:init() - -io.stdout:write("\n\n") - ------------------------------------------------------------------------- --- * basic comparison for now; do it properly later ------------------------------------------------------------------------- - -local LuaState = {} - ------------------------------------------------------------------------- --- dump binary chunks to a file if something goes wrong ------------------------------------------------------------------------- -local function Dump(data, filename) - h = io.open(filename, "wb") - if not h then error("failed to open "..filename.." for writing") end - h:write(data) - h:close() -end - ------------------------------------------------------------------------- --- create custom chunk reader (sums up file sizes) ------------------------------------------------------------------------- -function make_getF(filename) - local h = io.open(filename, "r") - if not h then return nil end - fsize = h:seek("end") - h:seek("set") - total = total + fsize - return function() -- chunk reader anonymous function here - if not h then return nil end - local buff = h:read(512) - if not buff then h:close() end - return buff - end -end - ------------------------------------------------------------------------- --- attempt to compile Lua source files ------------------------------------------------------------------------- -for i, filename in ipairs(files) do - -- compile a source file - local zio = luaZ:init(make_getF(filename), nil) - if not zio then - error("could not initialize zio stream for "..filename) - end - io.stdout:write(filename.."("..fsize.."): ") - local Func = luaY:parser(LuaState, zio, nil, "@"..filename) - local Writer, Buff = luaU:make_setS() - luaU:dump(LuaState, Func, Writer, Buff) - local bc1 = Buff.data -- Yueliang's output - - local f = loadfile(filename) - local bc2 = string.dump(f) -- Lua's output - - -- compare outputs - if #bc1 ~= #bc2 then - Dump(bc1, "bc1.out") - Dump(bc2, "bc2.out") - error("binary chunk sizes different") - elseif bc1 ~= bc2 then - Dump(bc1, "bc1.out") - Dump(bc2, "bc2.out") - error("binary chunks different") - else - io.stdout:write("CORRECT\n") - end - local x = collectgarbage("count") - -- memory usage isn't really a problem for the straight port - -- string handling in Lua that follows the original C closely is more - -- of a problem, but this will be fixed elsewhere, not in this tree - --io.stdout:write("collectgarbage: "..x.."\n") -end - --- summaries here -io.stdout:write("\nTotal file sizes: "..total.."\n") - --- end -- cgit v1.1