diff --git a/lua-5.2.2-tests/all.lua b/lua-5.2.2-tests/all.lua index 8216359..b86c001 100755 --- a/lua-5.2.2-tests/all.lua +++ b/lua-5.2.2-tests/all.lua @@ -1,11 +1,11 @@ -#!../lua +--#!../lua -local version = "Lua 5.2" -if _VERSION ~= version then - io.stderr:write("\nThis test suite is for ", version, ", not for ", _VERSION, - "\nExiting tests\n") +--local version = "Lua 5.2" +--if _VERSION ~= version then +-- io.stderr:write("\nThis test suite is for ", version, ", not for ", _VERSION, +-- "\nExiting tests\n") -- return -end +--end -- next variables control the execution of some tests @@ -153,21 +153,26 @@ end --local f = assert(loadfile('gc.lua')) --f() +-- FIXMELuaJIT --collectgarbage("generational") --dofile('db.lua') assert(dofile('calls.lua') == deep and deep) +-- FIXME LuaJIT --olddofile('strings.lua') --olddofile('literals.lua') assert(dofile('attrib.lua') == 27) +-- FIXME LuaJIT --collectgarbage("incremental") -- redo some tests in incremental mode --olddofile('strings.lua') --olddofile('literals.lua') dofile('constructs.lua') dofile('api.lua') +-- FIXME LuaJIT --collectgarbage("generational") -- back to generational mode collectgarbage("setpause", 200) +-- FIXME LuaJIT --collectgarbage("setmajorinc", 500) assert(dofile('locals.lua') == 5) dofile('constructs.lua') @@ -184,11 +189,13 @@ dofile('api.lua') assert(dofile('events.lua') == 12) dofile('vararg.lua') dofile('closure.lua') +-- FIXME LuaJIT --dofile('coroutine.lua') dofile('goto.lua') dofile('errors.lua') dofile('math.lua') dofile('sort.lua') +-- FIXME LuaJIT --dofile('bitwise.lua') assert(dofile('verybig.lua') == 10); collectgarbage() dofile('files.lua') @@ -255,6 +262,7 @@ if not usertests then -- check whether current test time differs more than 5% from last time local diff = (time - lasttime) / time local tolerance = 0.05 -- 5% + -- FIXME LuaJIT --assert(diff < tolerance and diff > -tolerance) assert(open(fname, "w")):write(time):close() end diff --git a/lua-5.2.2-tests/attrib.lua b/lua-5.2.2-tests/attrib.lua index 2739e5b..8cf287f 100644 --- a/lua-5.2.2-tests/attrib.lua +++ b/lua-5.2.2-tests/attrib.lua @@ -115,6 +115,7 @@ local try = function (p, n, r) end a = require"names" +-- FIXME LuaJIT --assert(a[1] == "names" and a[2] == D"names.lua") _G.a = nil @@ -166,15 +167,18 @@ createfiles(files, "_ENV = {}\n", "\nreturn _ENV\n") AA = 0 local m = assert(require"P1") +-- FIXME LuaJIT --assert(AA == 0 and m.AA == 10) assert(require"P1" == m) assert(require"P1" == m) assert(package.searchpath("P1.xuxu", package.path) == D"P1/xuxu.lua") m.xuxu = assert(require"P1.xuxu") +-- FIXME LuaJIT --assert(AA == 0 and m.xuxu.AA == 20) assert(require"P1.xuxu" == m.xuxu) assert(require"P1.xuxu" == m.xuxu) +-- FIXME LuaJIT --assert(require"P1" == m and m.AA == 10) @@ -218,6 +222,7 @@ local p = "" -- On Mac OS X, redefine this to "_" local st, err, when = package.loadlib(D"lib1.so", "*") if not st then local f, err, when = package.loadlib("donotexist", p.."xuxu") + -- FIXME LuaJIT --assert(not f and type(err) == "string" and when == "absent") ;(Message or print)('\a\n >>> cannot load dynamic library <<<\n\a') print(err, when) @@ -270,6 +275,7 @@ do local pl = require"pl" assert(require"pl" == pl) + -- FIXME LuaJIT --assert(pl.xuxu(10) == 30) assert(pl[1] == "pl" and pl[2] == nil) diff --git a/lua-5.2.2-tests/calls.lua b/lua-5.2.2-tests/calls.lua index 14d8fa5..8bf4e2c 100644 --- a/lua-5.2.2-tests/calls.lua +++ b/lua-5.2.2-tests/calls.lua @@ -218,6 +218,7 @@ a = assert(load(read1(x), "modname", "t", _G)) assert(a() == "\0" and _G.x == 33) assert(debug.getinfo(a).source == "modname") -- cannot read text in binary mode +-- FIXME LuaJIT --cannotload("attempt to load a text chunk", load(read1(x), "modname", "b", {})) --cannotload("attempt to load a text chunk", load(x, "modname", "b")) @@ -240,6 +241,7 @@ assert(type(f) == "function" and f() == 1) x = string.dump(load("x = 1; return x")) a = assert(load(read1(x), nil, "b")) assert(a() == 1 and _G.x == 1) +-- FIXME LuaJIT --cannotload("attempt to load a binary chunk", load(read1(x), nil, "t")) --cannotload("attempt to load a binary chunk", load(x, nil, "t")) @@ -250,6 +252,7 @@ cannotload("unexpected symbol", load("*a = 123")) cannotload("hhi", load(function () error("hhi") end)) -- any value is valid for _ENV +-- FIXME LuaJIT --assert(load("return _ENV", nil, nil, 123)() == 123) @@ -261,6 +264,7 @@ local function h () end local d = string.dump(h) x = load(d, "", "b") +-- FIXME LuaJIT --assert(debug.getupvalue(x, 2) == '_ENV') debug.setupvalue(x, 2, _G) assert(x() == 123) diff --git a/lua-5.2.2-tests/closure.lua b/lua-5.2.2-tests/closure.lua index b6b8b25..f7197bd 100644 --- a/lua-5.2.2-tests/closure.lua +++ b/lua-5.2.2-tests/closure.lua @@ -42,6 +42,7 @@ assert(B.g == 19) -- testing equality a = {} for i = 1, 5 do a[i] = function (x) return x + a + _ENV end end +-- FIXME LuaJIT --assert(a[3] == a[4] and a[4] == a[5]) for i = 1, 5 do a[i] = function (x) return i + a + _ENV end end @@ -50,6 +51,7 @@ assert(a[3] ~= a[4] and a[4] ~= a[5]) local function f() return function (x) return math.sin(_ENV[x]) end end +-- FIXME LuaJIT --assert(f() == f()) @@ -227,6 +229,7 @@ assert(debug.upvalueid(string.gmatch("x", "x"), 1) ~= nil) assert(foo1() == 3 + 5 and foo2() == 5 + 3) debug.upvaluejoin(foo1, 2, foo2, 2) +-- FIXME LuaJIT --assert(foo1() == 3 + 3 and foo2() == 5 + 3) assert(foo3() == 10 + 5) debug.upvaluejoin(foo3, 2, foo2, 1) diff --git a/lua-5.2.2-tests/errors.lua b/lua-5.2.2-tests/errors.lua index 9e69060..51dc79a 100644 --- a/lua-5.2.2-tests/errors.lua +++ b/lua-5.2.2-tests/errors.lua @@ -54,6 +54,7 @@ assert(doit("function a (... , ...) end")) assert(doit("function a (, ...) end")) assert(doit("local t={}; t = t[#t] + 1")) +-- FIXME LuaJIT --checksyntax([[ -- local a = {4 -- @@ -84,6 +85,7 @@ checkmessage("b=1; local aaa='a'; x=aaa+b", "local 'aaa'") checkmessage("aaa={}; x=3/aaa", "global 'aaa'") checkmessage("aaa='2'; b=nil;x=aaa*b", "global 'b'") checkmessage("aaa={}; x=-aaa", "global 'aaa'") +-- FIXME LuaJIT --assert(not string.find(doit"aaa={}; x=(aaa or aaa)+(aaa and aaa)", "'aaa'")) --assert(not string.find(doit"aaa={}; (aaa or aaa)()", "'aaa'")) @@ -93,6 +95,7 @@ checkmessage("print(print < print)", "two function") -- passing light userdata instead of full userdata _G.D = debug +-- FIXME LuaJIT --checkmessage([[ -- -- create light udata -- local x = D.upvalueid(function () return debug end, 1) @@ -114,6 +117,7 @@ local s = table.concat(t, "; ") t = nil checkmessage(s.."; a = bbb + 1", "global 'bbb'") checkmessage("local _ENV=_ENV;"..s.."; a = bbb + 1", "global 'bbb'") +-- FIXME LuaJIT --checkmessage(s.."; local t = {}; a = t.bbb + 1", "field 'bbb'") --checkmessage(s.."; local t = {}; t:bbb()", "method 'bbb'") @@ -142,6 +146,7 @@ while 1 do insert(prefix, a) end]], "global 'insert'") +-- FIXME LuaJIT --checkmessage([[ -- tail call -- return math.sin("a") --]], "'sin'") @@ -166,12 +171,15 @@ checkmessage("a:sub()", "bad self") checkmessage("string.sub('a', {})", "#2") checkmessage("('a'):sub{}", "#1") +-- FIXME LuaJIT --checkmessage("table.sort({1,2,3}, table.sort)", "'table.sort'") -- next message may be 'setmetatable' or '_G.setmetatable' +-- FIXME LuaJIT --checkmessage("string.gsub('s', 's', setmetatable)", "setmetatable'") -- tests for errors in coroutines +-- FIXME LuaJIT --function f (n) -- local c = coroutine.create(f) -- local a,b = coroutine.resume(c) @@ -179,6 +187,7 @@ checkmessage("('a'):sub{}", "#1") --end --assert(string.find(f(), "C stack overflow")) +-- FIXME LuaJIT --checkmessage("coroutine.yield()", "outside a coroutine") f1 = function () table.sort({1,2,3}, coroutine.yield) end @@ -216,18 +225,22 @@ lineerror("\n local a \n for k,v in 3 \n do \n print(k) \n end", 3) lineerror("\n\n for k,v in \n 3 \n do \n print(k) \n end", 4) lineerror("function a.x.y ()\na=a+1\nend", 1) +-- FIXME LuaJIT --lineerror("a = \na\n+\n{}", 3) --lineerror("a = \n3\n+\n(\n4\n/\nprint)", 6) --lineerror("a = \nprint\n+\n(\n4\n/\n7)", 3) +-- FIXME LuaJIT --lineerror("a\n=\n-\n\nprint\n;", 3) +-- FIXME LuaJIT --lineerror([[ --a --( --23) --]], 1) +-- FIXME LuaJIT --lineerror([[ --local a = {x = 13} --a @@ -321,6 +334,7 @@ if not _soft then assert(math.sin(0) == 0) return 15 end) + -- FIXME LuaJIT --assert(msg == 15) res, msg = pcall(function () @@ -349,6 +363,7 @@ checksyntax("[[a]]", "", "[[a]]", 1) checksyntax("'aa'", "", "'aa'", 1) -- test 255 as first char in a chunk +-- FIXME LuaJIT --checksyntax("\255a = 1", "", "char(255)", 1) doit('I = load("a=9+"); a=3') @@ -381,6 +396,7 @@ testrep("a=", "a^") local s = ("a,"):rep(200).."a=nil" local a,b = load(s) +-- FIXME LuaJIT --assert(not a and string.find(b, "levels")) @@ -405,6 +421,7 @@ for j = 1,lim do end s = s.."\nend end end" local a,b = load(s) +-- FIXME LuaJIT --assert(c > 255 and string.find(b, "too many upvalues") and -- string.find(b, "line 5")) diff --git a/lua-5.2.2-tests/events.lua b/lua-5.2.2-tests/events.lua index 7512e9b..de1cd48 100644 --- a/lua-5.2.2-tests/events.lua +++ b/lua-5.2.2-tests/events.lua @@ -7,10 +7,12 @@ _ENV = setmetatable({}, {__index=_G}) collectgarbage() X = X+10 +-- FIXME LuaJIT --assert(X == 30 and _G.X == 20) B = false assert(B == false) B = nil +-- FIXME LuaJIT --assert(B == 30) assert(getmetatable{} == nil) @@ -317,7 +319,7 @@ i = 0 x = c(3,4,5) assert(i == 3 and x[1] == 3 and x[3] == 5) - +-- FIXME LuaJIT -- assert(_G.X == 20) print'+' diff --git a/lua-5.2.2-tests/files.lua b/lua-5.2.2-tests/files.lua index 0c04fb3..0247fde 100644 --- a/lua-5.2.2-tests/files.lua +++ b/lua-5.2.2-tests/files.lua @@ -36,6 +36,7 @@ print('testing i/o') local otherfile = os.tmpname() +-- FIXME LuaJIT --assert(not pcall(io.open, file, "rw")) -- invalid mode --assert(not pcall(io.open, file, "rb+")) -- invalid mode --assert(not pcall(io.open, file, "r+bk")) -- invalid mode @@ -361,12 +362,14 @@ io.output(io.open(file, "wb")) assert(io.write("#this is a comment for a binary file\0\n", string.dump(function () return 20, '\0\0\0' end))) io.close() +-- FIXME LuaJIT --a, b, c = assert(loadfile(file))() --assert(a == 20 and b == "\0\0\0" and c == nil) --assert(os.remove(file)) -- 'loadfile' with 'env' +-- FIXME LuaJIT test disabled if false then do local f = io.open(file, 'w') @@ -391,6 +394,7 @@ end -- 'loadfile' x modes +-- FIXME LuaJIT test disabled if false then do io.open(file, 'w'):write("return 10"):close() @@ -526,8 +530,10 @@ if not _noposix then if v[2] == "ok" then assert(x == true and y == 'exit' and z == 0) else + -- FIXME LuaJIT -- assert(x == nil and y == v[2]) -- correct status and 'what' -- correct code if known (but always different from 0) + -- FIXME LuaJIT --assert((v[3] == nil and z > 0) or v[3] == z) end end @@ -562,6 +568,7 @@ load(os.date([[assert(D.year==%Y and D.month==%m and D.day==%d and D.hour==%H and D.min==%M and D.sec==%S and D.wday==%w+1 and D.yday==%j and type(D.isdst) == 'boolean')]], t))() +-- FIXME LuaJIT --assert(not pcall(os.date, "%9")) -- invalid conversion specifier --assert(not pcall(os.date, "%")) -- invalid conversion specifier --assert(not pcall(os.date, "%O")) -- invalid conversion specifier diff --git a/lua-5.2.2-tests/locals.lua b/lua-5.2.2-tests/locals.lua index 2957f4c..fcd1cf7 100644 --- a/lua-5.2.2-tests/locals.lua +++ b/lua-5.2.2-tests/locals.lua @@ -72,8 +72,10 @@ local function getenv (f) end -- test for global table of loaded chunks +-- FIXME LuaJIT --assert(getenv(load"a=3") == _G) local c = {}; local f = load("a = 3", nil, nil, c) +-- FIXME LuaJIT --assert(getenv(f) == c) assert(c.a == nil) f() @@ -136,16 +138,20 @@ do local _ENV = mt return function (x) return A .. x end end end +-- FIXME LuaJIT --assert(getenv(foo) == mt) --x = foo('hi'); assert(mt.A == 'hi' and A == 1000) --assert(x('*') == mt.A .. '*') do local _ENV = {assert=assert, A=10}; do local _ENV = {assert=assert, A=20}; + -- FIXME LuaJIT --assert(A==20);x=A end + -- FIXME LuaJIT --assert(A==10 and x==20) end +-- FIXME LuaJIT --assert(x==20) diff --git a/lua-5.2.2-tests/math.lua b/lua-5.2.2-tests/math.lua index df45f54..5417d52 100644 --- a/lua-5.2.2-tests/math.lua +++ b/lua-5.2.2-tests/math.lua @@ -64,16 +64,20 @@ assert(tonumber('0x0.' .. string.rep('0', 150).."1") == 2^(-4*151)) -- testing 'tonumber' with base assert(tonumber(' 001010 ', 2) == 10) assert(tonumber(' 001010 ', 10) == 001010) +-- FIXME LuaJIT --assert(tonumber(' -1010 ', 2) == -10) assert(tonumber('10', 36) == 36) +-- FIXME LuaJIT --assert(tonumber(' -10 ', 36) == -36) assert(tonumber(' +1Z ', 36) == 36 + 35) +-- FIXME LuaJIT --assert(tonumber(' -1z ', 36) == -36 + -35) --assert(tonumber('-fFfa', 16) == -(10+(16*(15+(16*(15+(16*15))))))) assert(tonumber(string.rep('1', 42), 2) + 1 == 2^42) assert(tonumber(string.rep('1', 34), 2) + 1 == 2^34) assert(tonumber('ffffFFFF', 16)+1 == 2^32) assert(tonumber('0ffffFFFF', 16)+1 == 2^32) +-- FIXME LuaJIT --assert(tonumber('-0ffffffFFFF', 16) - 1 == -2^40) for i = 2,36 do assert(tonumber('\t10000000000\t', i) == i^10) @@ -82,12 +86,15 @@ end -- testing 'tonumber' fo invalid formats assert(f(tonumber('fFfa', 15)) == nil) assert(f(tonumber('099', 8)) == nil) +-- FIXME LuaJIT --assert(f(tonumber('1\0', 2)) == nil) assert(f(tonumber('', 8)) == nil) assert(f(tonumber(' ', 9)) == nil) assert(f(tonumber(' ', 9)) == nil) +-- FIXME LuaJIT --assert(f(tonumber('0xf', 10)) == nil) +-- FIXME LuaJIT --assert(f(tonumber('inf')) == nil) --assert(f(tonumber(' INF ')) == nil) --assert(f(tonumber('Nan')) == nil) @@ -96,6 +103,7 @@ assert(f(tonumber(' ', 9)) == nil) assert(f(tonumber(' ')) == nil) assert(f(tonumber('')) == nil) assert(f(tonumber('1 a')) == nil) +-- FIXME LuaJIT --assert(f(tonumber('1\0')) == nil) --assert(f(tonumber('1 \0')) == nil) --assert(f(tonumber('1\0 ')) == nil) diff --git a/lua-5.2.2-tests/nextvar.lua b/lua-5.2.2-tests/nextvar.lua index d11d098..6f5550f 100644 --- a/lua-5.2.2-tests/nextvar.lua +++ b/lua-5.2.2-tests/nextvar.lua @@ -323,18 +323,22 @@ local function test (a) end a = {n=0, [-7] = "ban"} +-- FIXME LuaJIT --test(a) assert(a.n == 0 and a[-7] == "ban") a = {[-7] = "ban"}; +-- FIXME LuaJIT --test(a) assert(a.n == nil and #a == 0 and a[-7] == "ban") a = {[-1] = "ban"} +-- FIXME LuaJIT --test(a) assert(#a == 0 and table.remove(a) == nil and a[-1] == "ban") a = {[0] = "ban"} +-- FIXME LuaJIT --assert(#a == 0 and table.remove(a) == "ban" and a[0] == nil) table.insert(a, 1, 10); table.insert(a, 1, 20); table.insert(a, 1, -1) @@ -355,6 +359,7 @@ assert(#a == 0 and a.n == nil) a = {10,20,30,40} assert(table.remove(a, #a + 1) == nil) +-- FIXME LuaJIT --assert(not pcall(table.remove, a, 0)) assert(a[#a] == 40) assert(table.remove(a, #a) == 40) diff --git a/lua-5.2.2-tests/pm.lua b/lua-5.2.2-tests/pm.lua index fca0813..30bfaad 100644 --- a/lua-5.2.2-tests/pm.lua +++ b/lua-5.2.2-tests/pm.lua @@ -322,12 +322,14 @@ malform("[]") malform("[^]") malform("[a%]") malform("[a%") +-- FIXME LuaJIT --malform("%b") --malform("%ba") malform("%") malform("%f", "missing") -- \0 in patterns +-- FIXME LuaJIT --assert(string.match("ab\0\1\2c", "[\0-\2]+") == "\0\1\2") --assert(string.match("ab\0\1\2c", "[\0-\0]+") == "\0") --assert(string.find("b$a", "$\0?") == 2) @@ -337,6 +339,7 @@ malform("%f", "missing") --assert(string.match("abc\0\0\0", "%\0%\0?") == "\0\0") -- magic char after \0 +-- FIXME LuaJIT --assert(string.find("abc\0\0","\0.") == 4) --assert(string.find("abcx\0\0abc\0abc","x\0\0abc\0a.") == 4) diff --git a/lua-5.2.2-tests/sort.lua b/lua-5.2.2-tests/sort.lua index e376692..85b9cf4 100644 --- a/lua-5.2.2-tests/sort.lua +++ b/lua-5.2.2-tests/sort.lua @@ -1,5 +1,6 @@ print "testing (parts of) table library" +-- FIXME LuaJIT pack/unpack tests disabled if false then print "testing unpack"