mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-08 02:40:28 +00:00
Restore the ISO-8859-1 encoding of five test files.
Some tests — in `files.lua` and `pm.lua` — count bytes. Since the byte count of encoded characters changes from ISO-8859-1 to UTF-8, the tests fail.
This commit is contained in:
parent
289ded82b4
commit
0ece0405d6
5 changed files with 37 additions and 37 deletions
6
third_party/lua/test/db.lua
vendored
6
third_party/lua/test/db.lua
vendored
|
@ -345,7 +345,7 @@ function f(a,b)
|
||||||
local _, y = debug.getlocal(1, 2)
|
local _, y = debug.getlocal(1, 2)
|
||||||
assert(x == a and y == b)
|
assert(x == a and y == b)
|
||||||
assert(debug.setlocal(2, 3, "pera") == "AA".."AA")
|
assert(debug.setlocal(2, 3, "pera") == "AA".."AA")
|
||||||
assert(debug.setlocal(2, 4, "maçã") == "B")
|
assert(debug.setlocal(2, 4, "maçã") == "B")
|
||||||
x = debug.getinfo(2)
|
x = debug.getinfo(2)
|
||||||
assert(x.func == g and x.what == "Lua" and x.name == 'g' and
|
assert(x.func == g and x.what == "Lua" and x.name == 'g' and
|
||||||
x.nups == 2 and string.find(x.source, "^@.*db%.lua$"))
|
x.nups == 2 and string.find(x.source, "^@.*db%.lua$"))
|
||||||
|
@ -373,9 +373,9 @@ function g (...)
|
||||||
local arg = {...}
|
local arg = {...}
|
||||||
do local a,b,c; a=math.sin(40); end
|
do local a,b,c; a=math.sin(40); end
|
||||||
local feijao
|
local feijao
|
||||||
local AAAA,B = "xuxu", "mamão"
|
local AAAA,B = "xuxu", "mamão"
|
||||||
f(AAAA,B)
|
f(AAAA,B)
|
||||||
assert(AAAA == "pera" and B == "maçã")
|
assert(AAAA == "pera" and B == "maçã")
|
||||||
do
|
do
|
||||||
local B = 13
|
local B = 13
|
||||||
local x,y = debug.getlocal(1,5)
|
local x,y = debug.getlocal(1,5)
|
||||||
|
|
8
third_party/lua/test/files.lua
vendored
8
third_party/lua/test/files.lua
vendored
|
@ -92,8 +92,8 @@ assert(io.output():seek("end") == string.len("alo joao"))
|
||||||
|
|
||||||
assert(io.output():seek("set") == 0)
|
assert(io.output():seek("set") == 0)
|
||||||
|
|
||||||
assert(io.write('"álo"', "{a}\n", "second line\n", "third line \n"))
|
assert(io.write('"álo"', "{a}\n", "second line\n", "third line \n"))
|
||||||
assert(io.write('çfourth_line'))
|
assert(io.write('çfourth_line'))
|
||||||
io.output(io.stdout)
|
io.output(io.stdout)
|
||||||
collectgarbage() -- file should be closed by GC
|
collectgarbage() -- file should be closed by GC
|
||||||
assert(io.input() == io.stdin and rawequal(io.output(), io.stdout))
|
assert(io.input() == io.stdin and rawequal(io.output(), io.stdout))
|
||||||
|
@ -300,14 +300,14 @@ do -- test error returns
|
||||||
end
|
end
|
||||||
checkerr("invalid format", io.read, "x")
|
checkerr("invalid format", io.read, "x")
|
||||||
assert(io.read(0) == "") -- not eof
|
assert(io.read(0) == "") -- not eof
|
||||||
assert(io.read(5, 'l') == '"álo"')
|
assert(io.read(5, 'l') == '"álo"')
|
||||||
assert(io.read(0) == "")
|
assert(io.read(0) == "")
|
||||||
assert(io.read() == "second line")
|
assert(io.read() == "second line")
|
||||||
local x = io.input():seek()
|
local x = io.input():seek()
|
||||||
assert(io.read() == "third line ")
|
assert(io.read() == "third line ")
|
||||||
assert(io.input():seek("set", x))
|
assert(io.input():seek("set", x))
|
||||||
assert(io.read('L') == "third line \n")
|
assert(io.read('L') == "third line \n")
|
||||||
assert(io.read(1) == "ç")
|
assert(io.read(1) == "ç")
|
||||||
assert(io.read(string.len"fourth_line") == "fourth_line")
|
assert(io.read(string.len"fourth_line") == "fourth_line")
|
||||||
assert(io.input():seek("cur", -string.len"fourth_line"))
|
assert(io.input():seek("cur", -string.len"fourth_line"))
|
||||||
assert(io.read() == "fourth_line")
|
assert(io.read() == "fourth_line")
|
||||||
|
|
36
third_party/lua/test/pm.lua
vendored
36
third_party/lua/test/pm.lua
vendored
|
@ -73,16 +73,16 @@ assert(f('aaa', '^.-$') == 'aaa')
|
||||||
assert(f('aabaaabaaabaaaba', 'b.*b') == 'baaabaaabaaab')
|
assert(f('aabaaabaaabaaaba', 'b.*b') == 'baaabaaabaaab')
|
||||||
assert(f('aabaaabaaabaaaba', 'b.-b') == 'baaab')
|
assert(f('aabaaabaaabaaaba', 'b.-b') == 'baaab')
|
||||||
assert(f('alo xo', '.o$') == 'xo')
|
assert(f('alo xo', '.o$') == 'xo')
|
||||||
assert(f(' \n isto é assim', '%S%S*') == 'isto')
|
assert(f(' \n isto é assim', '%S%S*') == 'isto')
|
||||||
assert(f(' \n isto é assim', '%S*$') == 'assim')
|
assert(f(' \n isto é assim', '%S*$') == 'assim')
|
||||||
assert(f(' \n isto é assim', '[a-z]*$') == 'assim')
|
assert(f(' \n isto é assim', '[a-z]*$') == 'assim')
|
||||||
assert(f('um caracter ? extra', '[^%sa-z]') == '?')
|
assert(f('um caracter ? extra', '[^%sa-z]') == '?')
|
||||||
assert(f('', 'a?') == '')
|
assert(f('', 'a?') == '')
|
||||||
assert(f('á', 'á?') == 'á')
|
assert(f('á', 'á?') == 'á')
|
||||||
assert(f('ábl', 'á?b?l?') == 'ábl')
|
assert(f('ábl', 'á?b?l?') == 'ábl')
|
||||||
assert(f(' ábl', 'á?b?l?') == '')
|
assert(f(' ábl', 'á?b?l?') == '')
|
||||||
assert(f('aa', '^aa?a?a') == 'aa')
|
assert(f('aa', '^aa?a?a') == 'aa')
|
||||||
assert(f(']]]áb', '[^]]') == 'á')
|
assert(f(']]]áb', '[^]]') == 'á')
|
||||||
assert(f("0alo alo", "%x*") == "0a")
|
assert(f("0alo alo", "%x*") == "0a")
|
||||||
assert(f("alo alo", "%C+") == "alo alo")
|
assert(f("alo alo", "%C+") == "alo alo")
|
||||||
print('+')
|
print('+')
|
||||||
|
@ -136,28 +136,28 @@ assert(string.match("alo xyzK", "(%w+)K") == "xyz")
|
||||||
assert(string.match("254 K", "(%d*)K") == "")
|
assert(string.match("254 K", "(%d*)K") == "")
|
||||||
assert(string.match("alo ", "(%w*)$") == "")
|
assert(string.match("alo ", "(%w*)$") == "")
|
||||||
assert(not string.match("alo ", "(%w+)$"))
|
assert(not string.match("alo ", "(%w+)$"))
|
||||||
assert(string.find("(álo)", "%(á") == 1)
|
assert(string.find("(álo)", "%(á") == 1)
|
||||||
local a, b, c, d, e = string.match("âlo alo", "^(((.).).* (%w*))$")
|
local a, b, c, d, e = string.match("âlo alo", "^(((.).).* (%w*))$")
|
||||||
assert(a == 'âlo alo' and b == 'âl' and c == 'â' and d == 'alo' and e == nil)
|
assert(a == 'âlo alo' and b == 'âl' and c == 'â' and d == 'alo' and e == nil)
|
||||||
a, b, c, d = string.match('0123456789', '(.+(.?)())')
|
a, b, c, d = string.match('0123456789', '(.+(.?)())')
|
||||||
assert(a == '0123456789' and b == '' and c == 11 and d == nil)
|
assert(a == '0123456789' and b == '' and c == 11 and d == nil)
|
||||||
print('+')
|
print('+')
|
||||||
|
|
||||||
assert(string.gsub('ülo ülo', 'ü', 'x') == 'xlo xlo')
|
assert(string.gsub('ülo ülo', 'ü', 'x') == 'xlo xlo')
|
||||||
assert(string.gsub('alo úlo ', ' +$', '') == 'alo úlo') -- trim
|
assert(string.gsub('alo úlo ', ' +$', '') == 'alo úlo') -- trim
|
||||||
assert(string.gsub(' alo alo ', '^%s*(.-)%s*$', '%1') == 'alo alo') -- double trim
|
assert(string.gsub(' alo alo ', '^%s*(.-)%s*$', '%1') == 'alo alo') -- double trim
|
||||||
assert(string.gsub('alo alo \n 123\n ', '%s+', ' ') == 'alo alo 123 ')
|
assert(string.gsub('alo alo \n 123\n ', '%s+', ' ') == 'alo alo 123 ')
|
||||||
local t = "abç d"
|
local t = "abç d"
|
||||||
a, b = string.gsub(t, '(.)', '%1@')
|
a, b = string.gsub(t, '(.)', '%1@')
|
||||||
assert('@'..a == string.gsub(t, '', '@') and b == 5)
|
assert('@'..a == string.gsub(t, '', '@') and b == 5)
|
||||||
a, b = string.gsub('abçd', '(.)', '%0@', 2)
|
a, b = string.gsub('abçd', '(.)', '%0@', 2)
|
||||||
assert(a == 'a@b@çd' and b == 2)
|
assert(a == 'a@b@çd' and b == 2)
|
||||||
assert(string.gsub('alo alo', '()[al]', '%1') == '12o 56o')
|
assert(string.gsub('alo alo', '()[al]', '%1') == '12o 56o')
|
||||||
assert(string.gsub("abc=xyz", "(%w*)(%p)(%w+)", "%3%2%1-%0") ==
|
assert(string.gsub("abc=xyz", "(%w*)(%p)(%w+)", "%3%2%1-%0") ==
|
||||||
"xyz=abc-abc=xyz")
|
"xyz=abc-abc=xyz")
|
||||||
assert(string.gsub("abc", "%w", "%1%0") == "aabbcc")
|
assert(string.gsub("abc", "%w", "%1%0") == "aabbcc")
|
||||||
assert(string.gsub("abc", "%w+", "%0%1") == "abcabc")
|
assert(string.gsub("abc", "%w+", "%0%1") == "abcabc")
|
||||||
assert(string.gsub('áéí', '$', '\0óú') == 'áéí\0óú')
|
assert(string.gsub('áéí', '$', '\0óú') == 'áéí\0óú')
|
||||||
assert(string.gsub('', '^', 'r') == 'r')
|
assert(string.gsub('', '^', 'r') == 'r')
|
||||||
assert(string.gsub('', '$', 'r') == 'r')
|
assert(string.gsub('', '$', 'r') == 'r')
|
||||||
print('+')
|
print('+')
|
||||||
|
@ -188,8 +188,8 @@ do
|
||||||
end
|
end
|
||||||
|
|
||||||
function f(a,b) return string.gsub(a,'.',b) end
|
function f(a,b) return string.gsub(a,'.',b) end
|
||||||
assert(string.gsub("trocar tudo em |teste|b| é |beleza|al|", "|([^|]*)|([^|]*)|", f) ==
|
assert(string.gsub("trocar tudo em |teste|b| é |beleza|al|", "|([^|]*)|([^|]*)|", f) ==
|
||||||
"trocar tudo em bbbbb é alalalalalal")
|
"trocar tudo em bbbbb é alalalalalal")
|
||||||
|
|
||||||
local function dostring (s) return load(s, "")() or "" end
|
local function dostring (s) return load(s, "")() or "" end
|
||||||
assert(string.gsub("alo $a='x'$ novamente $return a$",
|
assert(string.gsub("alo $a='x'$ novamente $return a$",
|
||||||
|
|
2
third_party/lua/test/sort.lua
vendored
2
third_party/lua/test/sort.lua
vendored
|
@ -289,7 +289,7 @@ timesort(a, limit, function(x,y) return nil end, "equal")
|
||||||
|
|
||||||
for i,v in pairs(a) do assert(v == false) end
|
for i,v in pairs(a) do assert(v == false) end
|
||||||
|
|
||||||
AA = {"álo", "\0first :-)", "alo", "then this one", "45", "and a new"}
|
AA = {"álo", "\0first :-)", "alo", "then this one", "45", "and a new"}
|
||||||
table.sort(AA)
|
table.sort(AA)
|
||||||
check(AA)
|
check(AA)
|
||||||
|
|
||||||
|
|
22
third_party/lua/test/strings.lua
vendored
22
third_party/lua/test/strings.lua
vendored
|
@ -91,9 +91,9 @@ assert(string.byte("hi", 2, 1) == nil)
|
||||||
assert(string.char() == "")
|
assert(string.char() == "")
|
||||||
assert(string.char(0, 255, 0) == "\0\255\0")
|
assert(string.char(0, 255, 0) == "\0\255\0")
|
||||||
assert(string.char(0, string.byte("\xe4"), 0) == "\0\xe4\0")
|
assert(string.char(0, string.byte("\xe4"), 0) == "\0\xe4\0")
|
||||||
assert(string.char(string.byte("\xe4l\0óu", 1, -1)) == "\xe4l\0óu")
|
assert(string.char(string.byte("\xe4l\0óu", 1, -1)) == "\xe4l\0óu")
|
||||||
assert(string.char(string.byte("\xe4l\0óu", 1, 0)) == "")
|
assert(string.char(string.byte("\xe4l\0óu", 1, 0)) == "")
|
||||||
assert(string.char(string.byte("\xe4l\0óu", -10, 100)) == "\xe4l\0óu")
|
assert(string.char(string.byte("\xe4l\0óu", -10, 100)) == "\xe4l\0óu")
|
||||||
|
|
||||||
checkerror("out of range", string.char, 256)
|
checkerror("out of range", string.char, 256)
|
||||||
checkerror("out of range", string.char, -1)
|
checkerror("out of range", string.char, -1)
|
||||||
|
@ -103,7 +103,7 @@ checkerror("out of range", string.char, math.mininteger)
|
||||||
assert(string.upper("ab\0c") == "AB\0C")
|
assert(string.upper("ab\0c") == "AB\0C")
|
||||||
assert(string.lower("\0ABCc%$") == "\0abcc%$")
|
assert(string.lower("\0ABCc%$") == "\0abcc%$")
|
||||||
assert(string.rep('teste', 0) == '')
|
assert(string.rep('teste', 0) == '')
|
||||||
assert(string.rep('tés\00tê', 2) == 'tés\0têtés\000tê')
|
assert(string.rep('tés\00tê', 2) == 'tés\0têtés\000tê')
|
||||||
assert(string.rep('', 10) == '')
|
assert(string.rep('', 10) == '')
|
||||||
|
|
||||||
if string.packsize("i") == 4 then
|
if string.packsize("i") == 4 then
|
||||||
|
@ -192,8 +192,8 @@ do -- tests for '%p' format
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local x = '"ílo"\n\\'
|
local x = '"ílo"\n\\'
|
||||||
assert(string.format('%q%s', x, x) == '"\\"ílo\\"\\\n\\\\""ílo"\n\\')
|
assert(string.format('%q%s', x, x) == '"\\"ílo\\"\\\n\\\\""ílo"\n\\')
|
||||||
assert(string.format('%q', "\0") == [["\0"]])
|
assert(string.format('%q', "\0") == [["\0"]])
|
||||||
assert(load(string.format('return %q', x))() == x)
|
assert(load(string.format('return %q', x))() == x)
|
||||||
x = "\0\1\0023\5\0009"
|
x = "\0\1\0023\5\0009"
|
||||||
|
@ -430,14 +430,14 @@ if not _port then
|
||||||
end
|
end
|
||||||
|
|
||||||
if trylocale("collate") then
|
if trylocale("collate") then
|
||||||
assert("alo" < "álo" and "álo" < "amo")
|
assert("alo" < "álo" and "álo" < "amo")
|
||||||
end
|
end
|
||||||
|
|
||||||
if trylocale("ctype") then
|
if trylocale("ctype") then
|
||||||
assert(string.gsub("áéíóú", "%a", "x") == "xxxxx")
|
assert(string.gsub("áéíóú", "%a", "x") == "xxxxx")
|
||||||
assert(string.gsub("áÁéÉ", "%l", "x") == "xÁxÉ")
|
assert(string.gsub("áÁéÉ", "%l", "x") == "xÁxÉ")
|
||||||
assert(string.gsub("áÁéÉ", "%u", "x") == "áxéx")
|
assert(string.gsub("áÁéÉ", "%u", "x") == "áxéx")
|
||||||
assert(string.upper"áÁé{xuxu}ção" == "ÁÁÉ{XUXU}ÇÃO")
|
assert(string.upper"áÁé{xuxu}ção" == "ÁÁÉ{XUXU}ÇÃO")
|
||||||
end
|
end
|
||||||
|
|
||||||
os.setlocale("C")
|
os.setlocale("C")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue