From 68a93e19cbdd03152d2211c58a0871b6a92f249d Mon Sep 17 00:00:00 2001 From: Michael Lenaghan Date: Sat, 29 Jul 2023 15:34:32 -0400 Subject: [PATCH] Restore the ISO-8859-1 encoding of five test files. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- third_party/lua/test/db.lua | 6 +++--- third_party/lua/test/files.lua | 8 +++---- third_party/lua/test/pm.lua | 36 ++++++++++++++++---------------- third_party/lua/test/sort.lua | 2 +- third_party/lua/test/strings.lua | 22 +++++++++---------- 5 files changed, 37 insertions(+), 37 deletions(-) diff --git a/third_party/lua/test/db.lua b/third_party/lua/test/db.lua index ccda34c80..431525421 100644 --- a/third_party/lua/test/db.lua +++ b/third_party/lua/test/db.lua @@ -345,7 +345,7 @@ function f(a,b) local _, y = debug.getlocal(1, 2) assert(x == a and y == b) 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) assert(x.func == g and x.what == "Lua" and x.name == 'g' and x.nups == 2 and string.find(x.source, "^@.*db%.lua$")) @@ -373,9 +373,9 @@ function g (...) local arg = {...} do local a,b,c; a=math.sin(40); end local feijao - local AAAA,B = "xuxu", "mamão" + local AAAA,B = "xuxu", "mamo" f(AAAA,B) - assert(AAAA == "pera" and B == "maçã") + assert(AAAA == "pera" and B == "ma") do local B = 13 local x,y = debug.getlocal(1,5) diff --git a/third_party/lua/test/files.lua b/third_party/lua/test/files.lua index 1f6e53c87..ada31850f 100644 --- a/third_party/lua/test/files.lua +++ b/third_party/lua/test/files.lua @@ -92,8 +92,8 @@ assert(io.output():seek("end") == string.len("alo joao")) assert(io.output():seek("set") == 0) -assert(io.write('"álo"', "{a}\n", "second line\n", "third line \n")) -assert(io.write('çfourth_line')) +assert(io.write('"lo"', "{a}\n", "second line\n", "third line \n")) +assert(io.write('fourth_line')) io.output(io.stdout) collectgarbage() -- file should be closed by GC assert(io.input() == io.stdin and rawequal(io.output(), io.stdout)) @@ -300,14 +300,14 @@ do -- test error returns end checkerr("invalid format", io.read, "x") 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() == "second line") local x = io.input():seek() assert(io.read() == "third line ") assert(io.input():seek("set", x)) 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.input():seek("cur", -string.len"fourth_line")) assert(io.read() == "fourth_line") diff --git a/third_party/lua/test/pm.lua b/third_party/lua/test/pm.lua index ccc59fa17..ce3c0b3ff 100644 --- a/third_party/lua/test/pm.lua +++ b/third_party/lua/test/pm.lua @@ -73,16 +73,16 @@ assert(f('aaa', '^.-$') == 'aaa') assert(f('aabaaabaaabaaaba', 'b.*b') == 'baaabaaabaaab') assert(f('aabaaabaaabaaaba', 'b.-b') == 'baaab') assert(f('alo xo', '.o$') == 'xo') -assert(f(' \n isto é assim', '%S%S*') == 'isto') -assert(f(' \n isto é assim', '%S*$') == 'assim') -assert(f(' \n isto é assim', '[a-z]*$') == 'assim') +assert(f(' \n isto assim', '%S%S*') == 'isto') +assert(f(' \n isto assim', '%S*$') == 'assim') +assert(f(' \n isto assim', '[a-z]*$') == 'assim') assert(f('um caracter ? extra', '[^%sa-z]') == '?') assert(f('', 'a?') == '') -assert(f('á', 'á?') == 'á') -assert(f('ábl', 'á?b?l?') == 'ábl') -assert(f(' ábl', 'á?b?l?') == '') +assert(f('', '?') == '') +assert(f('bl', '?b?l?') == 'bl') +assert(f(' bl', '?b?l?') == '') assert(f('aa', '^aa?a?a') == 'aa') -assert(f(']]]áb', '[^]]') == 'á') +assert(f(']]]b', '[^]]') == '') assert(f("0alo alo", "%x*") == "0a") assert(f("alo alo", "%C+") == "alo alo") print('+') @@ -136,28 +136,28 @@ assert(string.match("alo xyzK", "(%w+)K") == "xyz") assert(string.match("254 K", "(%d*)K") == "") assert(string.match("alo ", "(%w*)$") == "") assert(not string.match("alo ", "(%w+)$")) -assert(string.find("(álo)", "%(á") == 1) -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(string.find("(lo)", "%(") == 1) +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) a, b, c, d = string.match('0123456789', '(.+(.?)())') assert(a == '0123456789' and b == '' and c == 11 and d == nil) print('+') -assert(string.gsub('ülo ülo', 'ü', 'x') == 'xlo xlo') -assert(string.gsub('alo úlo ', ' +$', '') == 'alo úlo') -- trim +assert(string.gsub('lo lo', '', 'x') == 'xlo xlo') +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 \n 123\n ', '%s+', ' ') == 'alo alo 123 ') -local t = "abç d" +local t = "ab d" a, b = string.gsub(t, '(.)', '%1@') assert('@'..a == string.gsub(t, '', '@') and b == 5) -a, b = string.gsub('abçd', '(.)', '%0@', 2) -assert(a == 'a@b@çd' and b == 2) +a, b = string.gsub('abd', '(.)', '%0@', 2) +assert(a == 'a@b@d' and b == 2) assert(string.gsub('alo alo', '()[al]', '%1') == '12o 56o') assert(string.gsub("abc=xyz", "(%w*)(%p)(%w+)", "%3%2%1-%0") == "xyz=abc-abc=xyz") assert(string.gsub("abc", "%w", "%1%0") == "aabbcc") 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') print('+') @@ -188,8 +188,8 @@ do end function f(a,b) return string.gsub(a,'.',b) end -assert(string.gsub("trocar tudo em |teste|b| é |beleza|al|", "|([^|]*)|([^|]*)|", f) == - "trocar tudo em bbbbb é alalalalalal") +assert(string.gsub("trocar tudo em |teste|b| |beleza|al|", "|([^|]*)|([^|]*)|", f) == + "trocar tudo em bbbbb alalalalalal") local function dostring (s) return load(s, "")() or "" end assert(string.gsub("alo $a='x'$ novamente $return a$", diff --git a/third_party/lua/test/sort.lua b/third_party/lua/test/sort.lua index 09a4c4098..02789bda3 100644 --- a/third_party/lua/test/sort.lua +++ b/third_party/lua/test/sort.lua @@ -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 -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) check(AA) diff --git a/third_party/lua/test/strings.lua b/third_party/lua/test/strings.lua index 434acad50..3af86efd0 100644 --- a/third_party/lua/test/strings.lua +++ b/third_party/lua/test/strings.lua @@ -91,9 +91,9 @@ assert(string.byte("hi", 2, 1) == nil) assert(string.char() == "") assert(string.char(0, 255, 0) == "\0\255\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, 0)) == "") -assert(string.char(string.byte("\xe4l\0óu", -10, 100)) == "\xe4l\0óu") +assert(string.char(string.byte("\xe4l\0u", 1, -1)) == "\xe4l\0u") +assert(string.char(string.byte("\xe4l\0u", 1, 0)) == "") +assert(string.char(string.byte("\xe4l\0u", -10, 100)) == "\xe4l\0u") checkerror("out of range", string.char, 256) 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.lower("\0ABCc%$") == "\0abcc%$") assert(string.rep('teste', 0) == '') -assert(string.rep('tés\00tê', 2) == 'tés\0têtés\000tê') +assert(string.rep('ts\00t', 2) == 'ts\0tts\000t') assert(string.rep('', 10) == '') if string.packsize("i") == 4 then @@ -192,8 +192,8 @@ do -- tests for '%p' format end end -local x = '"ílo"\n\\' -assert(string.format('%q%s', x, x) == '"\\"ílo\\"\\\n\\\\""ílo"\n\\') +local x = '"lo"\n\\' +assert(string.format('%q%s', x, x) == '"\\"lo\\"\\\n\\\\""lo"\n\\') assert(string.format('%q', "\0") == [["\0"]]) assert(load(string.format('return %q', x))() == x) x = "\0\1\0023\5\0009" @@ -430,14 +430,14 @@ if not _port then end if trylocale("collate") then - assert("alo" < "álo" and "álo" < "amo") + assert("alo" < "lo" and "lo" < "amo") end if trylocale("ctype") then - assert(string.gsub("áéíóú", "%a", "x") == "xxxxx") - assert(string.gsub("áÁéÉ", "%l", "x") == "xÁxÉ") - assert(string.gsub("áÁéÉ", "%u", "x") == "áxéx") - assert(string.upper"áÁé{xuxu}ção" == "ÁÁÉ{XUXU}ÇÃO") + assert(string.gsub("", "%a", "x") == "xxxxx") + assert(string.gsub("", "%l", "x") == "xx") + assert(string.gsub("", "%u", "x") == "xx") + assert(string.upper"{xuxu}o" == "{XUXU}O") end os.setlocale("C")