From 6b567c3d37e67c39d9387d2524c3f4a1f64e8364 Mon Sep 17 00:00:00 2001 From: Michael Lenaghan Date: Fri, 28 Jul 2023 13:26:58 -0400 Subject: [PATCH] Convert five test files from ISO-8859-1 to UTF-8. I discovered that five test files were encoded with ISO-8859-1 rather than UTF-8: ``` $ iconv -f UTF-8 third_party/lua/test/*.lua >/dev/null iconv: third_party/lua/test/db.lua:299:33: cannot convert iconv: third_party/lua/test/files.lua:95:18: cannot convert iconv: third_party/lua/test/pm.lua:76:19: cannot convert iconv: third_party/lua/test/sort.lua:292:6: cannot convert iconv: third_party/lua/test/strings.lua:94:39: cannot convert $ file third_party/lua/test/db.lua third_party/lua/test/db.lua: ISO-8859 text $ file third_party/lua/test/files.lua third_party/lua/test/files.lua: ISO-8859 text $ file third_party/lua/test/pm.lua third_party/lua/test/pm.lua: ISO-8859 text $ file third_party/lua/test/sort.lua third_party/lua/test/sort.lua: ISO-8859 text $ file third_party/lua/test/strings.lua third_party/lua/test/strings.lua: ISO-8859 text ``` --- 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 e8e2a17cc..cf375ffd5 100644 --- a/third_party/lua/test/db.lua +++ b/third_party/lua/test/db.lua @@ -296,7 +296,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$")) @@ -324,9 +324,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", "mamão" 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 0ce636eb0..01159d9f9 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 7b38fd6ce..3d962f308 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 ') -t = "abç d" +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('abçd', '(.)', '%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('+') @@ -187,8 +187,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 7c8c484ef..c22c14bea 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 -A = {"álo", "\0first :-)", "alo", "then this one", "45", "and a new"} +A = {"álo", "\0first :-)", "alo", "then this one", "45", "and a new"} table.sort(A) check(A) diff --git a/third_party/lua/test/strings.lua b/third_party/lua/test/strings.lua index bb85ebcde..f2012143c 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\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") 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('tés\00tê', 2) == 'tés\0têtés\000tê') assert(string.rep('', 10) == '') if string.packsize("i") == 4 then @@ -192,8 +192,8 @@ do -- tests for '%p' format end end -x = '"ílo"\n\\' -assert(string.format('%q%s', x, x) == '"\\"ílo\\"\\\n\\\\""ílo"\n\\') +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" @@ -405,14 +405,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") == "xÃxÉ") + assert(string.gsub("áÃéÉ", "%u", "x") == "áxéx") + assert(string.upper"áÃé{xuxu}ção" == "ÃÃÉ{XUXU}ÇÃO") end os.setlocale("C")