From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 553616EC56; Sat, 13 Mar 2021 22:04:10 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 553616EC56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1615662250; bh=2ZOW54q6qOMMbTnQ1sXlFxasc8MNnjZ6x2w/kq9mPY8=; h=In-Reply-To:Date:References:To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=LO7zWb6ZBAagzDLyXYlEkZ8KVMsuppuKdakuI4JVrhNrfmMs5skyD8nSU9P03CzL8 KAuqjF9qSpAGrDl2OsbImPgF0IKWruOEURKLHN9DLNxCHybTHWDMISXxPMqftBjLdl rW20dWmPrcjfo0w+1dPUZwB1NO2a7+XiLMoqK1E4= Received: from smtp32.i.mail.ru (smtp32.i.mail.ru [94.100.177.92]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 0A8D46EC56 for ; Sat, 13 Mar 2021 22:04:09 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0A8D46EC56 Received: by smtp32.i.mail.ru with esmtpa (envelope-from ) id 1lL9YW-0005HG-0J; Sat, 13 Mar 2021 22:04:08 +0300 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) In-Reply-To: Date: Sat, 13 Mar 2021 22:04:07 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: References: To: Sergey Kaplun X-Mailer: Apple Mail (2.3654.60.0.2.21) X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9D3134714A9BDB69BD7A9E0863F1CB58A8422FE5281FCC8C800894C459B0CD1B9B5A51238656799EA68AC0ED707448775D87364BE715B8F58AE7198D1B9DA4060 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7876E9C5582D2D91DEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637E8DF562B6063DE0A8638F802B75D45FF914D58D5BE9E6BC131B5C99E7648C95C7FF294EE7CC9FD509DD0B736C7F158CE3D3AD8C0CBAFBE0EA471835C12D1D9774AD6D5ED66289B5278DA827A17800CE71AE4D56B06699BBC9FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C3CA5A41EBD8A3A0199FA2833FD35BB23DF004C9065253843057739F23D657EF2B13377AFFFEAFD26923F8577A6DFFEA7CA35FE21102777C0993EC92FD9297F6715571747095F342E857739F23D657EF2BD5E8D9A59859A8B62819857A95C66D5F089D37D7C0E48F6C5571747095F342E857739F23D657EF2B6825BDBE14D8E702E4EE3A04994FF497E5BFE6E7EFDEDCD789D4C264860C145E X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2BBE337FB72E923155C0AF1600DCBC20B6B58427014E5D5331F6BA74F4366EE6B X-C1DE0DAB: 0D63561A33F958A5F969913599AD96D1E4DE726682E2722AD4D7FAEE76669D6CD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75F04B387B5D7535DE410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D346840168BCAD8054E61809169845B0B1C5B025109CBE4F0C83E0B34F6B382C9321B1ABB707032A8021D7E09C32AA3244CF997982881C6FB178B21264CB7CC58D5B4DF56057A86259FFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj510EsIhvqdkFQYwxjhU3qw== X-Mailru-Sender: 3B9A0136629DC912F4AABCEFC589C81EBA1B732243852DEB5DAD337F1EEFBFACE403479789132AD7AD07DD1419AC565FA614486B47F28B67C5E079CCF3B0523AED31B7EB2E253A9E112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 2/3] test: adapt PUC-Rio Lua 5.1 test suite for LuaJIT X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Ostanevich via Tarantool-patches Reply-To: Sergey Ostanevich Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi! Thanks for the patch! LGTM. Sergos. > On 12 Mar 2021, at 08:36, Sergey Kaplun wrote: >=20 > In some insignificant details LuaJIT's behaviour is not the same > as the behaviour of Lua 5.1. >=20 > Tests in the following files are disabled with corresponding comments: > * closure.lua > * constructs.lua > * db.lua > * errors.lua > * literals.lua > * main.lua > * math.lua > * nextvar.lua > * pm.lua > * strings.lua > * vararg.lua >=20 > See full list of disabled tests to adapt in > https://github.com/tarantool/tarantool/issues/5870. >=20 > jit.off() as prologue and jit.on() as epilogue is added to one test > chunk in gc.lua for stable (JIT unrelated) GC test results. >=20 > Part of tarantool/tarantool#5845 > Part of tarantool/tarantool#4473 > --- > test/PUC-Lua-5.1-tests/closure.lua | 12 ++++- > test/PUC-Lua-5.1-tests/constructs.lua | 7 +++ > test/PUC-Lua-5.1-tests/db.lua | 75 ++++++++++++++++++++------- > test/PUC-Lua-5.1-tests/errors.lua | 28 +++++++--- > test/PUC-Lua-5.1-tests/gc.lua | 5 ++ > test/PUC-Lua-5.1-tests/literals.lua | 5 ++ > test/PUC-Lua-5.1-tests/main.lua | 56 ++++++++++++++------ > test/PUC-Lua-5.1-tests/math.lua | 7 ++- > test/PUC-Lua-5.1-tests/nextvar.lua | 7 +++ > test/PUC-Lua-5.1-tests/pm.lua | 6 ++- > test/PUC-Lua-5.1-tests/strings.lua | 17 +++++- > test/PUC-Lua-5.1-tests/vararg.lua | 20 ++++--- > 12 files changed, 195 insertions(+), 50 deletions(-) >=20 > diff --git a/test/PUC-Lua-5.1-tests/closure.lua = b/test/PUC-Lua-5.1-tests/closure.lua > index 27ca0ad..e9bd564 100644 > --- a/test/PUC-Lua-5.1-tests/closure.lua > +++ b/test/PUC-Lua-5.1-tests/closure.lua > @@ -174,7 +174,10 @@ f =3D coroutine.wrap(foo) > local a =3D {} > assert(f(a) =3D=3D _G) > local a,b =3D pcall(f) > -assert(a and b =3D=3D _G) > +-- LuaJIT getfenv() behaviour is different in tail calls. > +-- See also https://github.com/tarantool/tarantool/issues/5713. > +-- Test is disabled for LuaJIT for now. > +-- assert(a and b =3D=3D _G) >=20 >=20 > -- tests for multiple yield/resume arguments > @@ -261,6 +264,12 @@ end >=20 > local x =3D gen(100) > local a =3D {} > +-- In Lua 5.1 math.mod() is renamed to math.fmod() if build > +-- Lua 5.1 without flag `-DLUA_COMPAT_MOD`. > +-- LuaJIT also has math.fmod() instead math.mod() builtin. > +-- See also https://github.com/tarantool/tarantool/issues/5711. > +-- Test is disabled. > +--[=3D[ > while 1 do > local n =3D x() > if n =3D=3D nil then break end > @@ -269,6 +278,7 @@ while 1 do > end >=20 > assert(table.getn(a) =3D=3D 25 and a[table.getn(a)] =3D=3D 97) > +--]=3D] >=20 >=20 > -- errors in coroutines > diff --git a/test/PUC-Lua-5.1-tests/constructs.lua = b/test/PUC-Lua-5.1-tests/constructs.lua > index 5fb3798..6776ee6 100644 > --- a/test/PUC-Lua-5.1-tests/constructs.lua > +++ b/test/PUC-Lua-5.1-tests/constructs.lua > @@ -200,6 +200,12 @@ a,b =3D F(nil)=3D=3Dnil; assert(a =3D=3D true and = b =3D=3D nil) >=20 > function ID(x) return x end >=20 > +-- In Lua 5.1 math.mod() is renamed to math.fmod() if build > +-- Lua 5.1 without flag `-DLUA_COMPAT_MOD`. > +-- LuaJIT also has math.fmod() instead math.mod() builtin. > +-- See also https://github.com/tarantool/tarantool/issues/5711. > +-- Test is disabled. > +--[=3D[ > function f(t, i) > local b =3D t.n > local res =3D math.mod(math.floor(i/c), b)+1 > @@ -236,5 +242,6 @@ repeat > if math.mod(i,4000) =3D=3D 0 then print('+') end > i =3D i+1 > until i=3D=3Dc > +--]=3D] >=20 > print'OK' > diff --git a/test/PUC-Lua-5.1-tests/db.lua = b/test/PUC-Lua-5.1-tests/db.lua > index 9d2c86f..591a006 100644 > --- a/test/PUC-Lua-5.1-tests/db.lua > +++ b/test/PUC-Lua-5.1-tests/db.lua > @@ -95,6 +95,10 @@ repeat > assert(g(f) =3D=3D 'a') > until 1 >=20 > +-- LuaJIT interprets a return from calling result of loadstring() > +-- with a new line number unlike Lua does. > +-- See also https://github.com/tarantool/tarantool/issues/5693. > +--[=3D[ > test([[if > math.sin(1) > then > @@ -149,7 +153,7 @@ end > ]], {1,2,1,2,1,3}) >=20 > test([[for i=3D1,4 do a=3D1 end]], {1,1,1,1,1}) > - > +--]=3D] >=20 >=20 > print'+' > @@ -178,8 +182,13 @@ function f(a,b) > local _, x =3D debug.getlocal(1, 1) > local _, y =3D debug.getlocal(1, 2) > assert(x =3D=3D a and y =3D=3D b) > - assert(debug.setlocal(2, 3, "pera") =3D=3D "AA".."AA") > - assert(debug.setlocal(2, 4, "ma=EF=BF=BD=EF=BF=BD") =3D=3D "B") > + -- f() function is called only from g(...) vararg function. > + -- Lua 5.1 interprets ... in the vararg functions like additional > + -- first argument unlike LuaJIT does. > + -- This extension is from Lua 5.2. > + -- See also https://github.com/tarantool/tarantool/issues/5694. > + -- assert(debug.setlocal(2, 3, "pera") =3D=3D "AA".."AA") > + -- assert(debug.setlocal(2, 4, "ma=EF=BF=BD=EF=BF=BD") =3D=3D "B") > x =3D debug.getinfo(2) > assert(x.func =3D=3D g and x.what =3D=3D "Lua" and x.name =3D=3D 'g' = and > x.nups =3D=3D 0 and string.find(x.source, "^@.*db%.lua")) > @@ -208,11 +217,13 @@ function g(...) > local feijao > local AAAA,B =3D "xuxu", "mam=EF=BF=BDo" > f(AAAA,B) > - assert(AAAA =3D=3D "pera" and B =3D=3D "ma=EF=BF=BD=EF=BF=BD") > + -- Test is disabled for LuaJIT for now. See comment in f(). > + -- assert(AAAA =3D=3D "pera" and B =3D=3D "ma=EF=BF=BD=EF=BF=BD") > do > local B =3D 13 > local x,y =3D debug.getlocal(1,5) > - assert(x =3D=3D 'B' and y =3D=3D 13) > + -- Test is disabled for LuaJIT for now. See comment in f(). > + -- assert(x =3D=3D 'B' and y =3D=3D 13) > end > end >=20 > @@ -276,7 +287,8 @@ debug.sethook(function (e) > end, "c") >=20 > a:f(1,2,3,4,5) > -assert(X.self =3D=3D a and X.a =3D=3D 1 and X.b =3D=3D 2 and = X.arg.n =3D=3D 3 and X.c =3D=3D nil) > +-- Test is disabled for LuaJIT for now. See comment in f(). > +-- assert(X.self =3D=3D a and X.a =3D=3D 1 and X.b =3D=3D 2 and = X.arg.n =3D=3D 3 and X.c =3D=3D nil) > assert(XX =3D=3D 12) > assert(debug.gethook() =3D=3D nil) >=20 > @@ -314,12 +326,20 @@ assert(debug.setupvalue(io.read, 1, 10) =3D=3D = nil) >=20 > -- testing count hooks > local a=3D0 > +-- LuaJIT does not check hooks at traces without defined > +-- -DLUAJIT_ENABLE_CHECKHOOK. > +-- For more information see or commit > +-- 6bce6b118eeb2bb7f36157de158e5cccf0ea68e5 (Add compile-time > +-- option LUAJIT_ENABLE_CHECKHOOK. Disabled by default.). > +-- See also https://github.com/tarantool/tarantool/issues/5701. > +--[[ > debug.sethook(function (e) a=3Da+1 end, "", 1) > a=3D0; for i=3D1,1000 do end; assert(1000 < a and a < 1012) > debug.sethook(function (e) a=3Da+1 end, "", 4) > a=3D0; for i=3D1,1000 do end; assert(250 < a and a < 255) > local f,m,c =3D debug.gethook() > assert(m =3D=3D "" and c =3D=3D 4) > +--]] > debug.sethook(function (e) a=3Da+1 end, "", 4000) > a=3D0; for i=3D1,1000 do end; assert(a =3D=3D 0) > debug.sethook(print, "", 2^24 - 1) -- count upperbound > @@ -352,18 +372,24 @@ function g1(x) g(x) end >=20 > local function h (x) local f=3Dg1; return f(x) end >=20 > -h(true) > +-- LuaJIT does not provide information about tail calls, > +-- unlike Lua does. getfenv() behaviour is also different here. > +-- Test is disabled for LuaJIT for now. > +-- See also https://github.com/tarantool/tarantool/issues/5702. > +-- h(true) >=20 > local b =3D {} > -debug.sethook(function (e) table.insert(b, e) end, "cr") > -h(false) > -debug.sethook() > +-- Behavior is different for LuaJIT. See the comment above. > +-- debug.sethook(function (e) table.insert(b, e) end, "cr") > +-- h(false) > +-- debug.sethook() > local res =3D {"return", -- first return (from sethook) > "call", "call", "call", "call", > "return", "tail return", "return", "tail return", > "call", -- last call (to sethook) > } > -for _, k in ipairs(res) do assert(k =3D=3D table.remove(b, 1)) end > +-- Behavior is different for LuaJIT. See the comment above. > +-- for _, k in ipairs(res) do assert(k =3D=3D table.remove(b, 1)) end >=20 >=20 > lim =3D 30000 > @@ -375,7 +401,8 @@ local function foo (x) > end > end >=20 > -foo(lim) > +-- Behavior is different for LuaJIT. See the comment above. > +-- foo(lim) >=20 >=20 > print"+" > @@ -411,7 +438,11 @@ end >=20 > local co =3D coroutine.create(f) > coroutine.resume(co, 3) > -checktraceback(co, {"yield", "db.lua", "tail", "tail", "tail"}) > +-- LuaJIT does not provide information about tail calls, > +-- unlike Lua does. > +-- See also https://github.com/tarantool/tarantool/issues/5703. > +-- Test is disabled for LuaJIT for now. > +-- checktraceback(co, {"yield", "db.lua", "tail", "tail", "tail"}) >=20 >=20 > co =3D coroutine.create(function (x) > @@ -429,8 +460,12 @@ local _, l =3D coroutine.resume(co, 10) > local x =3D debug.getinfo(co, 1, "lfLS") > assert(x.currentline =3D=3D l.currentline and = x.activelines[x.currentline]) > assert(type(x.func) =3D=3D "function") > +-- LuaJIT does not report line with single "end" statement as > +-- an active line in debug.getinfo(), unlike Lua does. > +-- See also https://github.com/tarantool/tarantool/issues/5708. > +-- Test is disabled for LuaJIT for now. > for i=3Dx.linedefined + 1, x.lastlinedefined do > - assert(x.activelines[i]) > + -- assert(x.activelines[i]) > x.activelines[i] =3D nil > end > assert(next(x.activelines) =3D=3D nil) -- no 'extra' elements > @@ -441,8 +476,10 @@ a,b =3D debug.getlocal(co, 1, 2) > assert(a =3D=3D "a" and b =3D=3D 1) > debug.setlocal(co, 1, 2, "hi") > assert(debug.gethook(co) =3D=3D foo) > -assert(table.getn(tr) =3D=3D 2 and > - tr[1] =3D=3D l.currentline-1 and tr[2] =3D=3D l.currentline) > +-- LuaJIT does not support per-coroutine hooks. > +-- Test is disabled for LuaJIT. > +-- assert(table.getn(tr) =3D=3D 2 and > +-- tr[1] =3D=3D l.currentline-1 and tr[2] =3D=3D = l.currentline) >=20 > a,b,c =3D pcall(coroutine.resume, co) > assert(a and b and c =3D=3D l.currentline+1) > @@ -450,9 +487,11 @@ checktraceback(co, {"yield", "in function <"}) >=20 > a,b =3D coroutine.resume(co) > assert(a and b =3D=3D "hi") > -assert(table.getn(tr) =3D=3D 4 and tr[4] =3D=3D l.currentline+2) > +-- Behavior is different for LuaJIT. See the comment above. > +-- assert(table.getn(tr) =3D=3D 4 and tr[4] =3D=3D l.currentline+2) > assert(debug.gethook(co) =3D=3D foo) > -assert(debug.gethook() =3D=3D nil) > +-- Behavior is different for LuaJIT. See the comment above. > +-- assert(debug.gethook() =3D=3D nil) > checktraceback(co, {}) >=20 >=20 > diff --git a/test/PUC-Lua-5.1-tests/errors.lua = b/test/PUC-Lua-5.1-tests/errors.lua > index e881211..3270033 100644 > --- a/test/PUC-Lua-5.1-tests/errors.lua > +++ b/test/PUC-Lua-5.1-tests/errors.lua > @@ -72,8 +72,12 @@ checkmessage("b=3D1; local aaa=3D'a'; x=3Daaa+b", = "local 'aaa'") > checkmessage("aaa=3D{}; x=3D3/aaa", "global 'aaa'") > checkmessage("aaa=3D'2'; b=3Dnil;x=3Daaa*b", "global 'b'") > checkmessage("aaa=3D{}; x=3D-aaa", "global 'aaa'") > -assert(not string.find(doit"aaa=3D{}; x=3D(aaa or aaa)+(aaa and = aaa)", "'aaa'")) > -assert(not string.find(doit"aaa=3D{}; (aaa or aaa)()", "'aaa'")) > +-- LuaJIT reports the error as the following here: > +-- "attempt to perform arithmetic on global 'aaa' (a table value)" > +-- Lua 5.1 doesn't report variable name here. > +-- Test is disabled for LuaJIT. > +-- assert(not string.find(doit"aaa=3D{}; x=3D(aaa or aaa)+(aaa and = aaa)", "'aaa'")) > +-- assert(not string.find(doit"aaa=3D{}; (aaa or aaa)()", "'aaa'")) >=20 > checkmessage([[aaa=3D9 > repeat until 3=3D=3D3 > @@ -100,9 +104,12 @@ while 1 do > insert(prefix, a) > end]], "global 'insert'") >=20 > -checkmessage([[ -- tail call > - return math.sin("a") > -]], "'sin'") > +-- Implementation of fast functions in LuaJIT does not provide > +-- enough info on failure. > +-- Test is disabled for LuaJIT. > +-- checkmessage([[ -- tail call > +-- return math.sin("a") > +-- ]], "'sin'") >=20 > checkmessage([[collectgarbage("nooption")]], "invalid option") >=20 > @@ -193,7 +200,11 @@ checksyntax("[[a]]", "", "[[a]]", 1) > checksyntax("'aa'", "", "'aa'", 1) >=20 > -- test 255 as first char in a chunk > -checksyntax("\255a =3D 1", "", "\255", 1) > +-- LuaJIT does not avoid to use non-alphabetic symbols > +-- as identifiers, unlike Lua does. > +-- For more details see and . > +-- Test is disabled for LuaJIT. > +-- checksyntax("\255a =3D 1", "", "\255", 1) >=20 > doit('I =3D loadstring("a=3D9+"); a=3D3') > assert(a=3D=3D3 and I =3D=3D nil) > @@ -215,7 +226,10 @@ local function testrep (init, rep) > end > testrep("a=3D", "{") > testrep("a=3D", "(") > -testrep("", "a(") > +-- When compiled with LUAJIT_ENABLE_GC64 LJ_MAX_SLOTS limit > +-- is reached and error is LJ_ERR_XSLOTS ("function or expression too > +-- complex"). Test is disabled for LuaJIT. > +-- testrep("", "a(") > testrep("", "do ") > testrep("", "while a do ") > testrep("", "if a then else ") > diff --git a/test/PUC-Lua-5.1-tests/gc.lua = b/test/PUC-Lua-5.1-tests/gc.lua > index 86a9f75..b767104 100644 > --- a/test/PUC-Lua-5.1-tests/gc.lua > +++ b/test/PUC-Lua-5.1-tests/gc.lua > @@ -108,11 +108,16 @@ local function dosteps (siz) > return i > end >=20 > +-- JIT compilation can unpredictable allocate or reference objects > +-- (or traces itself). Disable it for this chunk for stable > +-- GC results. > +jit.off() > assert(dosteps(0) > 10) > assert(dosteps(6) < dosteps(2)) > assert(dosteps(10000) =3D=3D 1) > assert(collectgarbage("step", 1000000) =3D=3D true) > assert(collectgarbage("step", 1000000)) > +jit.on() >=20 >=20 > do > diff --git a/test/PUC-Lua-5.1-tests/literals.lua = b/test/PUC-Lua-5.1-tests/literals.lua > index 01d84d5..ee16a3e 100644 > --- a/test/PUC-Lua-5.1-tests/literals.lua > +++ b/test/PUC-Lua-5.1-tests/literals.lua > @@ -158,6 +158,10 @@ end >=20 >=20 > -- testing decimal point locale > +-- LuaJIT doesn't use `strtod()` depended on the locale, unlike > +-- Lua does. See for more info. > +-- Tests are disabled for LuaJIT. > +--[[ > if os.setlocale("pt_BR") or os.setlocale("ptb") then > assert(tonumber("3,4") =3D=3D 3.4 and tonumber"3.4" =3D=3D nil) > assert(assert(loadstring("return 3.4"))() =3D=3D 3.4) > @@ -171,6 +175,7 @@ else > (Message or print)( > '\a\n >>> pt_BR locale not available: skipping decimal point tests = <<<\n\a') > end > +--]] >=20 >=20 > print('OK') > diff --git a/test/PUC-Lua-5.1-tests/main.lua = b/test/PUC-Lua-5.1-tests/main.lua > index f520896..12f3981 100644 > --- a/test/PUC-Lua-5.1-tests/main.lua > +++ b/test/PUC-Lua-5.1-tests/main.lua > @@ -65,9 +65,16 @@ a =3D string.format(a, progname) > prepfile(a) > RUN('lua "-e " -- %s a b c', prog) >=20 > -prepfile"assert(arg=3D=3Dnil)" > -prepfile("assert(arg)", otherprog) > -RUN("lua -l%s - < %s", prog, otherprog) > +-- test 'arg' availability in libraries > +-- LuaJIT v2.1.0-beta3 has extension from Lua 5.3: > +-- The argument table `arg` can be read (and modified) > +-- by `LUA_INIT` and `-e` chunks. > +-- See commit 92d9ff211ae864777a8580b5a7326d5f408161ce > +-- (Set arg table before evaluating LUA_INIT and -e chunks.). > +-- See also https://github.com/tarantool/tarantool/issues/5686. > +-- prepfile"assert(arg=3D=3Dnil)" > +-- prepfile("assert(arg)", otherprog) > +-- RUN("lua -l%s - < %s", prog, otherprog) >=20 > prepfile"" > RUN("lua - < %s > %s", prog, out) > @@ -89,26 +96,35 @@ prepfile[[ > RUN("lua - < %s > %s", prog, out) > checkout("1\tnil\n") >=20 > +-- Version and status are printed in stdout instead stderr since > +-- LuaJIT-2.0.0-beta11 (as it is not an error message). > +-- See commit 0bd1a66f2f055211ef55834ccebca3b82d03c735 > +-- (Print version and JIT status to stdout, not stderr.). > +-- This behavior is the same as in Lua 5.2. > +-- See also https://github.com/tarantool/tarantool/issues/5687. > prepfile[[ > =3D (6*2-6) -- =3D=3D=3D > a > =3D 10 > print(a) > =3D a]] > -RUN([[lua -e"_PROMPT=3D'' _PROMPT2=3D''" -i < %s > %s]], prog, out) > -checkout("6\n10\n10\n\n") > +-- Behavior is different for LuaJIT. See the comment above. > +-- RUN([[lua -e"_PROMPT=3D'' _PROMPT2=3D''" -i < %s > %s]], prog, = out) > +-- checkout("6\n10\n10\n\n") >=20 > prepfile("a =3D [[b\nc\nd\ne]]\n=3Da") > print(prog) > -RUN([[lua -e"_PROMPT=3D'' _PROMPT2=3D''" -i < %s > %s]], prog, out) > -checkout("b\nc\nd\ne\n\n") > +-- Behavior is different for LuaJIT. See the comment above. > +-- RUN([[lua -e"_PROMPT=3D'' _PROMPT2=3D''" -i < %s > %s]], prog, = out) > +-- checkout("b\nc\nd\ne\n\n") >=20 > prompt =3D "alo" > prepfile[[ -- > a =3D 2 > ]] > -RUN([[lua "-e_PROMPT=3D'%s'" -i < %s > %s]], prompt, prog, out) > -checkout(string.rep(prompt, 3).."\n") > +-- Behavior is different for LuaJIT. See the comment above. > +-- RUN([[lua "-e_PROMPT=3D'%s'" -i < %s > %s]], prompt, prog, out) > +-- checkout(string.rep(prompt, 3).."\n") >=20 > s =3D [=3D[ -- > function f ( x ) > @@ -126,19 +142,29 @@ assert( a =3D=3D b ) > =3Df( 11 ) ]=3D] > s =3D string.gsub(s, ' ', '\n\n') > prepfile(s) > -RUN([[lua -e"_PROMPT=3D'' _PROMPT2=3D''" -i < %s > %s]], prog, out) > -checkout("11\n1\t2\n\n") > +-- Behavior is different for LuaJIT. See the comment above. > +-- RUN([[lua -e"_PROMPT=3D'' _PROMPT2=3D''" -i < %s > %s]], prog, = out) > +-- checkout("11\n1\t2\n\n") >=20 > prepfile[[#comment in 1st line without \n at the end]] > RUN("lua %s", prog) >=20 > +-- test loading and running bytecode files. > +-- Loading bytecode with an extra header (BOM or "#") is disabled > +-- for security reasons since LuaJIT-2.0.0-beta10. > +-- For more information see comment for lj_lex_setup() > +-- in . > +-- Also see commit 53a285c0c3544ff5dea7c67b741c3c2d06d22b47 > +-- (Disable loading bytecode with an extra header (BOM or #!).). > +-- See also https://github.com/tarantool/tarantool/issues/5691. > prepfile("#comment with a binary = file\n"..string.dump(loadstring("print(1)"))) > -RUN("lua %s > %s", prog, out) > -checkout("1\n") > +-- RUN("lua %s > %s", prog, out) > +-- checkout("1\n") >=20 > prepfile("#comment with a binary = file\r\n"..string.dump(loadstring("print(1)"))) > -RUN("lua %s > %s", prog, out) > -checkout("1\n") > +-- Behavior is different for LuaJIT. See the comment above. > +-- RUN("lua %s > %s", prog, out) > +-- checkout("1\n") >=20 > -- close Lua with an open file > prepfile(string.format([[io.output(%q); io.write('alo')]], out)) > diff --git a/test/PUC-Lua-5.1-tests/math.lua = b/test/PUC-Lua-5.1-tests/math.lua > index 5076f38..b46a3f5 100644 > --- a/test/PUC-Lua-5.1-tests/math.lua > +++ b/test/PUC-Lua-5.1-tests/math.lua > @@ -100,7 +100,12 @@ assert(math.abs(-10) =3D=3D 10) > assert(eq(math.atan2(1,0), math.pi/2)) > assert(math.ceil(4.5) =3D=3D 5.0) > assert(math.floor(4.5) =3D=3D 4.0) > -assert(math.mod(10,3) =3D=3D 1) > +-- In Lua 5.1 math.mod() is renamed to math.fmod() if build > +-- Lua 5.1 without flag `-DLUA_COMPAT_MOD`. > +-- LuaJIT also has math.fmod() instead math.mod() builtin. > +-- See also https://github.com/tarantool/tarantool/issues/5711. > +-- Test is disabled. > +-- assert(math.mod(10,3) =3D=3D 1) > assert(eq(math.sqrt(10)^2, 10)) > assert(eq(math.log10(2), math.log(2)/math.log(10))) > assert(eq(math.exp(0), 1)) > diff --git a/test/PUC-Lua-5.1-tests/nextvar.lua = b/test/PUC-Lua-5.1-tests/nextvar.lua > index 7ceaa75..a63f97e 100644 > --- a/test/PUC-Lua-5.1-tests/nextvar.lua > +++ b/test/PUC-Lua-5.1-tests/nextvar.lua > @@ -199,6 +199,12 @@ _G["xxx"] =3D 1 > assert(xxx=3D=3Dfind("xxx")) > print('+') >=20 > +-- In Lua 5.1 math.mod() is renamed to math.fmod() if build > +-- Lua 5.1 without flag `-DLUA_COMPAT_MOD`. > +-- LuaJIT also has math.fmod() instead math.mod() builtin. > +-- See also https://github.com/tarantool/tarantool/issues/5711. > +-- Test is disabled. > +--[=3D[ > a =3D {} > for i=3D0,10000 do > if math.mod(i,10) ~=3D 0 then > @@ -213,6 +219,7 @@ for i,v in pairs(a) do > end > assert(n.n =3D=3D 9000) > a =3D nil > +--]=3D] >=20 > -- remove those 10000 new global variables > for i=3D1,10000 do _G[i] =3D nil end > diff --git a/test/PUC-Lua-5.1-tests/pm.lua = b/test/PUC-Lua-5.1-tests/pm.lua > index fa125dc..366a31c 100644 > --- a/test/PUC-Lua-5.1-tests/pm.lua > +++ b/test/PUC-Lua-5.1-tests/pm.lua > @@ -223,7 +223,11 @@ assert(string.gsub("a alo b hi", "%w%w+", t) =3D=3D= "a ALO b HI") >=20 >=20 > -- tests for gmatch > -assert(string.gfind =3D=3D string.gmatch) > +-- In Lua 5.1 function string.gfind was renamed to string.gmatch. > +-- You can use it if Lua 5.1 is built with compile-time option > +-- `-DLUA_COMPAT_GFIND`. > +-- This builtin is removed from LuaJIT. Test is disabled. > +-- assert(string.gfind =3D=3D string.gmatch) > local a =3D 0 > for i in string.gmatch('abcde', '()') do assert(i =3D=3D a+1); a=3Di = end > assert(a=3D=3D6) > diff --git a/test/PUC-Lua-5.1-tests/strings.lua = b/test/PUC-Lua-5.1-tests/strings.lua > index 237dbad..a97c888 100644 > --- a/test/PUC-Lua-5.1-tests/strings.lua > +++ b/test/PUC-Lua-5.1-tests/strings.lua > @@ -102,7 +102,18 @@ print('+') >=20 > x =3D '"=EF=BF=BDlo"\n\\' > assert(string.format('%q%s', x, x) =3D=3D = '"\\"=EF=BF=BDlo\\"\\\n\\\\""=EF=BF=BDlo"\n\\') > -assert(string.format('%q', "\0") =3D=3D [["\000"]]) > +-- LuaJIT since v2.0.0-beta6 has extension from Lua 5.2: > +-- string.format(): %q reversible. > +-- In Lua 5.1 string.format() does not accept string values > +-- containing embedded zeros, except as arguments to the q option. > +-- In Lua 5.2 '\0' is not handled differently from other > +-- control chars in string.format('%q', ...). > +-- See commit 7cc981c14067d4b0e774a6bfb0acfc2f5c911f0d > +-- (string.format("%q", str) is now fully reversible > +-- (from Lua 5.2).). > +-- See also https://github.com/tarantool/tarantool/issues/5710. > +-- Test is disabled for LuaJIT for now. > +-- assert(string.format('%q', "\0") =3D=3D [["\000"]]) > assert(string.format("\0%c\0%c%x\0", string.byte("=EF=BF=BD"), = string.byte("b"), 140) =3D=3D > "\0=EF=BF=BD\0b8c\0") > assert(string.format('') =3D=3D "") > @@ -152,6 +163,9 @@ local function trylocale (w) > return false > end >=20 > +-- LuaJIT doesn't compare strings by `strcoll`, like Lua 5.1 does. > +-- Tests are disabled for LuaJIT. > +--[[ > if not trylocale("collate") then > print("locale not supported") > else > @@ -166,6 +180,7 @@ else > assert(string.gsub("=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD", "%u", = "x") =3D=3D "=EF=BF=BDx=EF=BF=BDx") > assert(string.upper"=EF=BF=BD=EF=BF=BD=EF=BF=BD{xuxu}=EF=BF=BD=EF=BF=BD= o" =3D=3D "=EF=BF=BD=EF=BF=BD=EF=BF=BD{XUXU}=EF=BF=BD=EF=BF=BDO") > end > +--]] >=20 > os.setlocale("C") > assert(os.setlocale() =3D=3D 'C') > diff --git a/test/PUC-Lua-5.1-tests/vararg.lua = b/test/PUC-Lua-5.1-tests/vararg.lua > index ae068fa..e2de1ad 100644 > --- a/test/PUC-Lua-5.1-tests/vararg.lua > +++ b/test/PUC-Lua-5.1-tests/vararg.lua > @@ -21,9 +21,14 @@ function vararg (...) return arg end >=20 > local call =3D function (f, args) return f(unpack(args, 1, args.n)) = end >=20 > -assert(f() =3D=3D 0) > -assert(f({1,2,3}, 1, 2, 3) =3D=3D 3) > -assert(f({"alo", nil, 45, f, nil}, "alo", nil, 45, f, nil) =3D=3D 5) > +-- Lua 5.1 interprets ... in the vararg functions like additional > +-- first argument unlike LuaJIT does. All extra arguments is set > +-- into `arg` variable. This extension is from Lua 5.2. > +-- See also https://github.com/tarantool/tarantool/issues/5712. > +-- Test is disabled for LuaJIT. > +-- assert(f() =3D=3D 0) > +-- assert(f({1,2,3}, 1, 2, 3) =3D=3D 3) > +-- assert(f({"alo", nil, 45, f, nil}, "alo", nil, 45, f, nil) =3D=3D = 5) >=20 > assert(c12(1,2)=3D=3D55) > a,b =3D assert(call(c12, {1,2})) > @@ -35,15 +40,18 @@ assert(not a) > assert(c12(1,2,3) =3D=3D false) > local a =3D vararg(call(next, {_G,nil;n=3D2})) > local b,c =3D next(_G) > -assert(a[1] =3D=3D b and a[2] =3D=3D c and a.n =3D=3D 2) > +-- Test is disabled for LuaJIT for now. See the comment above. > +-- assert(a[1] =3D=3D b and a[2] =3D=3D c and a.n =3D=3D 2) > a =3D vararg(call(call, {c12, {1,2}})) > -assert(a.n =3D=3D 2 and a[1] =3D=3D 55 and a[2] =3D=3D 2) > +-- Test is disabled for LuaJIT for now. See the comment above. > +-- assert(a.n =3D=3D 2 and a[1] =3D=3D 55 and a[2] =3D=3D 2) > a =3D call(print, {'+'}) > assert(a =3D=3D nil) >=20 > local t =3D {1, 10} > function t:f (...) return self[arg[1]]+arg.n end > -assert(t:f(1,4) =3D=3D 3 and t:f(2) =3D=3D 11) > +-- Test is disabled for LuaJIT for now. See the comment above. > +-- assert(t:f(1,4) =3D=3D 3 and t:f(2) =3D=3D 11) > print('+') >=20 > lim =3D 20 > --=20 > 2.28.0 >=20