mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-02 18:52:29 +00:00
Bring Lua to 5.4.6. (#1214)
This essentially re-does the work of #875 on top of master. This is what I did to check that Cosmo's Lua extensions still worked: ``` $ build/bootstrap/make MODE=aarch64 o/aarch64/third_party/lua/lua $ ape o/aarch64/third_party/lua/lua >: 10 10 >: 010 8 >: 0b10 2 >: string.byte("\e") 27 >: "Hello, %s" % {"world"} Hello, world >: "*" * 3 *** ``` `luaL_traceback2` was used to show the stack trace with parameter values; it's used in `LuaCallWithTrace`, which is used in Redbean to run Lua code. You should be able to see the extended stack trace by running something like this: `redbean -e "function a(b)c()end a(2)"` (with "params" indicating the extended stack trace): ``` stack traceback: [string "function a(b)c()end a(2)"]:1: in function 'a', params: b = 2; [string "function a(b)c()end a(2)"]:1: in main chunk ``` @pkulchenko confirmed that I get the expected result with the updated code. This is what I did to check that Lua itself still worked: ``` $ cd third_party/lua/test/ $ ape ../../../o/aarch64/third_party/lua/lua all.lua ``` There's one test failure, in `files.lua`: ``` ***** FILE 'files.lua'***** testing i/o ../../../o/aarch64/third_party/lua/lua: files.lua:84: assertion failed! stack traceback: [C]: in function 'assert' files.lua:84: in main chunk (...tail calls...) all.lua:195: in main chunk [C]: in ? .>>> closing state <<< ``` That isn't a result of these changes; the same test is failing in master. The failure is here: ```lua if not _port then -- invalid seek local status, msg, code = io.stdin:seek("set", 1000) assert(not status and type(msg) == "string" and type(code) == "number") end ``` The test expects a seek to offset 1,000 on stdin to fail — but it doesn't. `status` ends up being the new offset rather than `nil`. If I comment out that one test, the remaining tests succeed.
This commit is contained in:
parent
3a599bfbe1
commit
0dbf01bf1d
90 changed files with 2741 additions and 1376 deletions
23
third_party/lua/test/sort.lua
vendored
23
third_party/lua/test/sort.lua
vendored
|
@ -20,7 +20,7 @@ end
|
|||
checkerror("wrong number of arguments", table.insert, {}, 2, 3, 4)
|
||||
|
||||
local x,y,z,a,n
|
||||
a = {}; lim = _soft and 200 or 2000
|
||||
a = {}; local lim = _soft and 200 or 2000
|
||||
for i=1, lim do a[i]=i end
|
||||
assert(select(lim, unpack(a)) == lim and select('#', unpack(a)) == lim)
|
||||
x = unpack(a)
|
||||
|
@ -222,7 +222,7 @@ a = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
|
|||
table.sort(a)
|
||||
check(a)
|
||||
|
||||
function perm (s, n)
|
||||
local function perm (s, n)
|
||||
n = n or #s
|
||||
if n == 1 then
|
||||
local t = {unpack(s)}
|
||||
|
@ -248,7 +248,7 @@ perm{1,2,3,3,5}
|
|||
perm{1,2,3,4,5,6}
|
||||
perm{2,2,3,3,5,6}
|
||||
|
||||
function timesort (a, n, func, msg, pre)
|
||||
local function timesort (a, n, func, msg, pre)
|
||||
local x = os.clock()
|
||||
table.sort(a, func)
|
||||
x = (os.clock() - x) * 1000
|
||||
|
@ -257,7 +257,7 @@ function timesort (a, n, func, msg, pre)
|
|||
check(a, func)
|
||||
end
|
||||
|
||||
limit = 50000
|
||||
local limit = 50000
|
||||
if _soft then limit = 5000 end
|
||||
|
||||
a = {}
|
||||
|
@ -274,7 +274,7 @@ for i=1,limit do
|
|||
a[i] = math.random()
|
||||
end
|
||||
|
||||
x = os.clock(); i=0
|
||||
local x = os.clock(); local i = 0
|
||||
table.sort(a, function(x,y) i=i+1; return y<x end)
|
||||
x = (os.clock() - x) * 1000
|
||||
print(string.format("Invert-sorting other %d elements in %.2f msec., with %i comparisons",
|
||||
|
@ -289,18 +289,19 @@ timesort(a, limit, function(x,y) return nil end, "equal")
|
|||
|
||||
for i,v in pairs(a) do assert(v == false) end
|
||||
|
||||
A = {"álo", "\0first :-)", "alo", "then this one", "45", "and a new"}
|
||||
table.sort(A)
|
||||
check(A)
|
||||
AA = {"álo", "\0first :-)", "alo", "then this one", "45", "and a new"}
|
||||
table.sort(AA)
|
||||
check(AA)
|
||||
|
||||
table.sort(A, function (x, y)
|
||||
load(string.format("A[%q] = ''", x), "")()
|
||||
table.sort(AA, function (x, y)
|
||||
load(string.format("AA[%q] = ''", x), "")()
|
||||
collectgarbage()
|
||||
return x<y
|
||||
end)
|
||||
|
||||
_G.AA = nil
|
||||
|
||||
tt = {__lt = function (a,b) return a.val < b.val end}
|
||||
local tt = {__lt = function (a,b) return a.val < b.val end}
|
||||
a = {}
|
||||
for i=1,10 do a[i] = {val=math.random(100)}; setmetatable(a[i], tt); end
|
||||
table.sort(a)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue