diff options
Diffstat (limited to 'testes')
-rw-r--r-- | testes/calls.lua | 14 | ||||
-rw-r--r-- | testes/db.lua | 8 | ||||
-rw-r--r-- | testes/errors.lua | 11 | ||||
-rw-r--r-- | testes/files.lua | 8 | ||||
-rw-r--r-- | testes/main.lua | 50 | ||||
-rw-r--r-- | testes/pm.lua | 56 | ||||
-rw-r--r-- | testes/sort.lua | 2 | ||||
-rw-r--r-- | testes/strings.lua | 3 | ||||
-rw-r--r-- | testes/utf8.lua | 2 |
9 files changed, 87 insertions, 67 deletions
diff --git a/testes/calls.lua b/testes/calls.lua index 2d562a24..a1938584 100644 --- a/testes/calls.lua +++ b/testes/calls.lua | |||
@@ -342,20 +342,6 @@ do -- another bug (in 5.4.0) | |||
342 | end | 342 | end |
343 | 343 | ||
344 | 344 | ||
345 | do -- another bug (since 5.2) | ||
346 | -- corrupted binary dump: list of upvalue names is larger than number | ||
347 | -- of upvalues, overflowing the array of upvalues. | ||
348 | local code = | ||
349 | "\x1b\x4c\x75\x61\x54\x00\x19\x93\x0d\x0a\x1a\x0a\x04\x08\x08\x78\x56\z | ||
350 | \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x28\x77\x40\x00\x86\x40\z | ||
351 | \x74\x65\x6d\x70\x81\x81\x01\x00\x02\x82\x48\x00\x02\x00\xc7\x00\x01\z | ||
352 | \x00\x80\x80\x80\x82\x00\x00\x80\x81\x82\x78\x80\x82\x81\x86\x40\x74\z | ||
353 | \x65\x6d\x70" | ||
354 | |||
355 | assert(load(code)) -- segfaults in previous versions | ||
356 | end | ||
357 | |||
358 | |||
359 | x = string.dump(load("x = 1; return x")) | 345 | x = string.dump(load("x = 1; return x")) |
360 | a = assert(load(read1(x), nil, "b")) | 346 | a = assert(load(read1(x), nil, "b")) |
361 | assert(a() == 1 and _G.x == 1) | 347 | assert(a() == 1 and _G.x == 1) |
diff --git a/testes/db.lua b/testes/db.lua index 02b96aca..d3758c41 100644 --- a/testes/db.lua +++ b/testes/db.lua | |||
@@ -345,7 +345,7 @@ function f(a,b) | |||
345 | local _, y = debug.getlocal(1, 2) | 345 | local _, y = debug.getlocal(1, 2) |
346 | assert(x == a and y == b) | 346 | assert(x == a and y == b) |
347 | assert(debug.setlocal(2, 3, "pera") == "AA".."AA") | 347 | assert(debug.setlocal(2, 3, "pera") == "AA".."AA") |
348 | assert(debug.setlocal(2, 4, "maçã") == "B") | 348 | assert(debug.setlocal(2, 4, "manga") == "B") |
349 | x = debug.getinfo(2) | 349 | x = debug.getinfo(2) |
350 | assert(x.func == g and x.what == "Lua" and x.name == 'g' and | 350 | assert(x.func == g and x.what == "Lua" and x.name == 'g' and |
351 | x.nups == 2 and string.find(x.source, "^@.*db%.lua$")) | 351 | x.nups == 2 and string.find(x.source, "^@.*db%.lua$")) |
@@ -373,9 +373,9 @@ function g (...) | |||
373 | local arg = {...} | 373 | local arg = {...} |
374 | do local a,b,c; a=math.sin(40); end | 374 | do local a,b,c; a=math.sin(40); end |
375 | local feijao | 375 | local feijao |
376 | local AAAA,B = "xuxu", "mamão" | 376 | local AAAA,B = "xuxu", "abacate" |
377 | f(AAAA,B) | 377 | f(AAAA,B) |
378 | assert(AAAA == "pera" and B == "maçã") | 378 | assert(AAAA == "pera" and B == "manga") |
379 | do | 379 | do |
380 | local B = 13 | 380 | local B = 13 |
381 | local x,y = debug.getlocal(1,5) | 381 | local x,y = debug.getlocal(1,5) |
@@ -928,7 +928,7 @@ do | |||
928 | local cl = countlines(rest) | 928 | local cl = countlines(rest) |
929 | -- at most 10 lines in first part, 11 in second, plus '...' | 929 | -- at most 10 lines in first part, 11 in second, plus '...' |
930 | assert(cl <= 10 + 11 + 1) | 930 | assert(cl <= 10 + 11 + 1) |
931 | local brk = string.find(rest, "%.%.%.") | 931 | local brk = string.find(rest, "%.%.%.\t%(skip") |
932 | if brk then -- does message have '...'? | 932 | if brk then -- does message have '...'? |
933 | local rest1 = string.sub(rest, 1, brk) | 933 | local rest1 = string.sub(rest, 1, brk) |
934 | local rest2 = string.sub(rest, brk, #rest) | 934 | local rest2 = string.sub(rest, brk, #rest) |
diff --git a/testes/errors.lua b/testes/errors.lua index bf6f389d..01cfe906 100644 --- a/testes/errors.lua +++ b/testes/errors.lua | |||
@@ -121,6 +121,9 @@ assert(not string.find(doit"aaa={13}; local bbbb=1; aaa[bbbb](3)", "'bbbb'")) | |||
121 | checkmessage("aaa={13}; local bbbb=1; aaa[bbbb](3)", "number") | 121 | checkmessage("aaa={13}; local bbbb=1; aaa[bbbb](3)", "number") |
122 | checkmessage("aaa=(1)..{}", "a table value") | 122 | checkmessage("aaa=(1)..{}", "a table value") |
123 | 123 | ||
124 | -- bug in 5.4.6 | ||
125 | checkmessage("a = {_ENV = {}}; print(a._ENV.x + 1)", "field 'x'") | ||
126 | |||
124 | _G.aaa, _G.bbbb = nil | 127 | _G.aaa, _G.bbbb = nil |
125 | 128 | ||
126 | -- calls | 129 | -- calls |
@@ -392,19 +395,19 @@ lineerror("a\n=\n-\n\nprint\n;", 3) | |||
392 | 395 | ||
393 | lineerror([[ | 396 | lineerror([[ |
394 | a | 397 | a |
395 | ( | 398 | ( -- << |
396 | 23) | 399 | 23) |
397 | ]], 1) | 400 | ]], 2) |
398 | 401 | ||
399 | lineerror([[ | 402 | lineerror([[ |
400 | local a = {x = 13} | 403 | local a = {x = 13} |
401 | a | 404 | a |
402 | . | 405 | . |
403 | x | 406 | x |
404 | ( | 407 | ( -- << |
405 | 23 | 408 | 23 |
406 | ) | 409 | ) |
407 | ]], 2) | 410 | ]], 5) |
408 | 411 | ||
409 | lineerror([[ | 412 | lineerror([[ |
410 | local a = {x = 13} | 413 | local a = {x = 13} |
diff --git a/testes/files.lua b/testes/files.lua index be00bf3f..1476006e 100644 --- a/testes/files.lua +++ b/testes/files.lua | |||
@@ -92,8 +92,8 @@ assert(io.output():seek("end") == string.len("alo joao")) | |||
92 | 92 | ||
93 | assert(io.output():seek("set") == 0) | 93 | assert(io.output():seek("set") == 0) |
94 | 94 | ||
95 | assert(io.write('"álo"', "{a}\n", "second line\n", "third line \n")) | 95 | assert(io.write('"alo"', "{a}\n", "second line\n", "third line \n")) |
96 | assert(io.write('çfourth_line')) | 96 | assert(io.write('Xfourth_line')) |
97 | io.output(io.stdout) | 97 | io.output(io.stdout) |
98 | collectgarbage() -- file should be closed by GC | 98 | collectgarbage() -- file should be closed by GC |
99 | assert(io.input() == io.stdin and rawequal(io.output(), io.stdout)) | 99 | assert(io.input() == io.stdin and rawequal(io.output(), io.stdout)) |
@@ -300,14 +300,14 @@ do -- test error returns | |||
300 | end | 300 | end |
301 | checkerr("invalid format", io.read, "x") | 301 | checkerr("invalid format", io.read, "x") |
302 | assert(io.read(0) == "") -- not eof | 302 | assert(io.read(0) == "") -- not eof |
303 | assert(io.read(5, 'l') == '"álo"') | 303 | assert(io.read(5, 'l') == '"alo"') |
304 | assert(io.read(0) == "") | 304 | assert(io.read(0) == "") |
305 | assert(io.read() == "second line") | 305 | assert(io.read() == "second line") |
306 | local x = io.input():seek() | 306 | local x = io.input():seek() |
307 | assert(io.read() == "third line ") | 307 | assert(io.read() == "third line ") |
308 | assert(io.input():seek("set", x)) | 308 | assert(io.input():seek("set", x)) |
309 | assert(io.read('L') == "third line \n") | 309 | assert(io.read('L') == "third line \n") |
310 | assert(io.read(1) == "ç") | 310 | assert(io.read(1) == "X") |
311 | assert(io.read(string.len"fourth_line") == "fourth_line") | 311 | assert(io.read(string.len"fourth_line") == "fourth_line") |
312 | assert(io.input():seek("cur", -string.len"fourth_line")) | 312 | assert(io.input():seek("cur", -string.len"fourth_line")) |
313 | assert(io.read() == "fourth_line") | 313 | assert(io.read() == "fourth_line") |
diff --git a/testes/main.lua b/testes/main.lua index f59badcf..11b14b44 100644 --- a/testes/main.lua +++ b/testes/main.lua | |||
@@ -27,17 +27,19 @@ do | |||
27 | end | 27 | end |
28 | print("progname: "..progname) | 28 | print("progname: "..progname) |
29 | 29 | ||
30 | local prepfile = function (s, p) | 30 | |
31 | p = p or prog | 31 | local prepfile = function (s, mod, p) |
32 | io.output(p) | 32 | mod = mod and "wb" or "w" -- mod true means binary files |
33 | io.write(s) | 33 | p = p or prog -- file to write the program |
34 | assert(io.close()) | 34 | local f = io.open(p, mod) |
35 | f:write(s) | ||
36 | assert(f:close()) | ||
35 | end | 37 | end |
36 | 38 | ||
37 | local function getoutput () | 39 | local function getoutput () |
38 | io.input(out) | 40 | local f = io.open(out) |
39 | local t = io.read("a") | 41 | local t = f:read("a") |
40 | io.input():close() | 42 | f:close() |
41 | assert(os.remove(out)) | 43 | assert(os.remove(out)) |
42 | return t | 44 | return t |
43 | end | 45 | end |
@@ -65,10 +67,11 @@ local function RUN (p, ...) | |||
65 | assert(os.execute(s)) | 67 | assert(os.execute(s)) |
66 | end | 68 | end |
67 | 69 | ||
70 | |||
68 | local function NoRun (msg, p, ...) | 71 | local function NoRun (msg, p, ...) |
69 | p = string.gsub(p, "lua", '"'..progname..'"', 1) | 72 | p = string.gsub(p, "lua", '"'..progname..'"', 1) |
70 | local s = string.format(p, ...) | 73 | local s = string.format(p, ...) |
71 | s = string.format("%s 2> %s", s, out) -- will send error to 'out' | 74 | s = string.format("%s >%s 2>&1", s, out) -- send output and error to 'out' |
72 | assert(not os.execute(s)) | 75 | assert(not os.execute(s)) |
73 | assert(string.find(getoutput(), msg, 1, true)) -- check error message | 76 | assert(string.find(getoutput(), msg, 1, true)) -- check error message |
74 | end | 77 | end |
@@ -108,17 +111,17 @@ RUN('lua %s > %s', prog, out) | |||
108 | checkout("3\n") | 111 | checkout("3\n") |
109 | 112 | ||
110 | -- bad BOMs | 113 | -- bad BOMs |
111 | prepfile("\xEF") | 114 | prepfile("\xEF", true) |
112 | NoRun("unexpected symbol", 'lua %s > %s', prog, out) | 115 | NoRun("unexpected symbol", 'lua %s', prog) |
113 | 116 | ||
114 | prepfile("\xEF\xBB") | 117 | prepfile("\xEF\xBB", true) |
115 | NoRun("unexpected symbol", 'lua %s > %s', prog, out) | 118 | NoRun("unexpected symbol", 'lua %s', prog) |
116 | 119 | ||
117 | prepfile("\xEFprint(3)") | 120 | prepfile("\xEFprint(3)", true) |
118 | NoRun("unexpected symbol", 'lua %s > %s', prog, out) | 121 | NoRun("unexpected symbol", 'lua %s', prog) |
119 | 122 | ||
120 | prepfile("\xEF\xBBprint(3)") | 123 | prepfile("\xEF\xBBprint(3)", true) |
121 | NoRun("unexpected symbol", 'lua %s > %s', prog, out) | 124 | NoRun("unexpected symbol", 'lua %s', prog) |
122 | 125 | ||
123 | 126 | ||
124 | -- test option '-' | 127 | -- test option '-' |
@@ -213,7 +216,7 @@ convert("a;b;;c") | |||
213 | 216 | ||
214 | -- test -l over multiple libraries | 217 | -- test -l over multiple libraries |
215 | prepfile("print(1); a=2; return {x=15}") | 218 | prepfile("print(1); a=2; return {x=15}") |
216 | prepfile(("print(a); print(_G['%s'].x)"):format(prog), otherprog) | 219 | prepfile(("print(a); print(_G['%s'].x)"):format(prog), false, otherprog) |
217 | RUN('env LUA_PATH="?;;" lua -l %s -l%s -lstring -l io %s > %s', prog, otherprog, otherprog, out) | 220 | RUN('env LUA_PATH="?;;" lua -l %s -l%s -lstring -l io %s > %s', prog, otherprog, otherprog, out) |
218 | checkout("1\n2\n15\n2\n15\n") | 221 | checkout("1\n2\n15\n2\n15\n") |
219 | 222 | ||
@@ -222,6 +225,13 @@ prepfile("print(str.upper'alo alo', m.max(10, 20))") | |||
222 | RUN("lua -l 'str=string' '-lm=math' -e 'print(m.sin(0))' %s > %s", prog, out) | 225 | RUN("lua -l 'str=string' '-lm=math' -e 'print(m.sin(0))' %s > %s", prog, out) |
223 | checkout("0.0\nALO ALO\t20\n") | 226 | checkout("0.0\nALO ALO\t20\n") |
224 | 227 | ||
228 | |||
229 | -- test module names with version sufix ("libs/lib2-v2") | ||
230 | RUN("env LUA_CPATH='./libs/?.so' lua -l lib2-v2 -e 'print(lib2.id())' > %s", | ||
231 | out) | ||
232 | checkout("true\n") | ||
233 | |||
234 | |||
225 | -- test 'arg' table | 235 | -- test 'arg' table |
226 | local a = [[ | 236 | local a = [[ |
227 | assert(#arg == 3 and arg[1] == 'a' and | 237 | assert(#arg == 3 and arg[1] == 'a' and |
@@ -237,7 +247,7 @@ RUN('lua "-e " -- %s a b c', prog) -- "-e " runs an empty command | |||
237 | 247 | ||
238 | -- test 'arg' availability in libraries | 248 | -- test 'arg' availability in libraries |
239 | prepfile"assert(arg)" | 249 | prepfile"assert(arg)" |
240 | prepfile("assert(arg)", otherprog) | 250 | prepfile("assert(arg)", false, otherprog) |
241 | RUN('env LUA_PATH="?;;" lua -l%s - < %s', prog, otherprog) | 251 | RUN('env LUA_PATH="?;;" lua -l%s - < %s', prog, otherprog) |
242 | 252 | ||
243 | -- test messing up the 'arg' table | 253 | -- test messing up the 'arg' table |
@@ -413,7 +423,7 @@ prepfile[[#comment in 1st line without \n at the end]] | |||
413 | RUN('lua %s', prog) | 423 | RUN('lua %s', prog) |
414 | 424 | ||
415 | -- first-line comment with binary file | 425 | -- first-line comment with binary file |
416 | prepfile("#comment\n" .. string.dump(load("print(3)"))) | 426 | prepfile("#comment\n" .. string.dump(load("print(3)")), true) |
417 | RUN('lua %s > %s', prog, out) | 427 | RUN('lua %s > %s', prog, out) |
418 | checkout('3\n') | 428 | checkout('3\n') |
419 | 429 | ||
diff --git a/testes/pm.lua b/testes/pm.lua index 795596d4..44454dff 100644 --- a/testes/pm.lua +++ b/testes/pm.lua | |||
@@ -1,6 +1,9 @@ | |||
1 | -- $Id: testes/pm.lua $ | 1 | -- $Id: testes/pm.lua $ |
2 | -- See Copyright Notice in file all.lua | 2 | -- See Copyright Notice in file all.lua |
3 | 3 | ||
4 | -- UTF-8 file | ||
5 | |||
6 | |||
4 | print('testing pattern matching') | 7 | print('testing pattern matching') |
5 | 8 | ||
6 | local function checkerror (msg, f, ...) | 9 | local function checkerror (msg, f, ...) |
@@ -50,6 +53,19 @@ assert(f('aLo_ALO', '%a*') == 'aLo') | |||
50 | 53 | ||
51 | assert(f(" \n\r*&\n\r xuxu \n\n", "%g%g%g+") == "xuxu") | 54 | assert(f(" \n\r*&\n\r xuxu \n\n", "%g%g%g+") == "xuxu") |
52 | 55 | ||
56 | |||
57 | -- Adapt a pattern to UTF-8 | ||
58 | local function PU (p) | ||
59 | -- break '?' into each individual byte of a character | ||
60 | p = string.gsub(p, "(" .. utf8.charpattern .. ")%?", function (c) | ||
61 | return string.gsub(c, ".", "%0?") | ||
62 | end) | ||
63 | -- change '.' to utf-8 character patterns | ||
64 | p = string.gsub(p, "%.", utf8.charpattern) | ||
65 | return p | ||
66 | end | ||
67 | |||
68 | |||
53 | assert(f('aaab', 'a*') == 'aaa'); | 69 | assert(f('aaab', 'a*') == 'aaa'); |
54 | assert(f('aaa', '^.*$') == 'aaa'); | 70 | assert(f('aaa', '^.*$') == 'aaa'); |
55 | assert(f('aaa', 'b*') == ''); | 71 | assert(f('aaa', 'b*') == ''); |
@@ -73,16 +89,16 @@ assert(f('aaa', '^.-$') == 'aaa') | |||
73 | assert(f('aabaaabaaabaaaba', 'b.*b') == 'baaabaaabaaab') | 89 | assert(f('aabaaabaaabaaaba', 'b.*b') == 'baaabaaabaaab') |
74 | assert(f('aabaaabaaabaaaba', 'b.-b') == 'baaab') | 90 | assert(f('aabaaabaaabaaaba', 'b.-b') == 'baaab') |
75 | assert(f('alo xo', '.o$') == 'xo') | 91 | assert(f('alo xo', '.o$') == 'xo') |
76 | assert(f(' \n isto é assim', '%S%S*') == 'isto') | 92 | assert(f(' \n isto é assim', '%S%S*') == 'isto') |
77 | assert(f(' \n isto é assim', '%S*$') == 'assim') | 93 | assert(f(' \n isto é assim', '%S*$') == 'assim') |
78 | assert(f(' \n isto é assim', '[a-z]*$') == 'assim') | 94 | assert(f(' \n isto é assim', '[a-z]*$') == 'assim') |
79 | assert(f('um caracter ? extra', '[^%sa-z]') == '?') | 95 | assert(f('um caracter ? extra', '[^%sa-z]') == '?') |
80 | assert(f('', 'a?') == '') | 96 | assert(f('', 'a?') == '') |
81 | assert(f('á', 'á?') == 'á') | 97 | assert(f('á', PU'á?') == 'á') |
82 | assert(f('ábl', 'á?b?l?') == 'ábl') | 98 | assert(f('ábl', PU'á?b?l?') == 'ábl') |
83 | assert(f(' ábl', 'á?b?l?') == '') | 99 | assert(f(' ábl', PU'á?b?l?') == '') |
84 | assert(f('aa', '^aa?a?a') == 'aa') | 100 | assert(f('aa', '^aa?a?a') == 'aa') |
85 | assert(f(']]]áb', '[^]]') == 'á') | 101 | assert(f(']]]áb', '[^]]+') == 'áb') |
86 | assert(f("0alo alo", "%x*") == "0a") | 102 | assert(f("0alo alo", "%x*") == "0a") |
87 | assert(f("alo alo", "%C+") == "alo alo") | 103 | assert(f("alo alo", "%C+") == "alo alo") |
88 | print('+') | 104 | print('+') |
@@ -136,28 +152,28 @@ assert(string.match("alo xyzK", "(%w+)K") == "xyz") | |||
136 | assert(string.match("254 K", "(%d*)K") == "") | 152 | assert(string.match("254 K", "(%d*)K") == "") |
137 | assert(string.match("alo ", "(%w*)$") == "") | 153 | assert(string.match("alo ", "(%w*)$") == "") |
138 | assert(not string.match("alo ", "(%w+)$")) | 154 | assert(not string.match("alo ", "(%w+)$")) |
139 | assert(string.find("(álo)", "%(á") == 1) | 155 | assert(string.find("(álo)", "%(á") == 1) |
140 | local a, b, c, d, e = string.match("âlo alo", "^(((.).).* (%w*))$") | 156 | local a, b, c, d, e = string.match("âlo alo", PU"^(((.).). (%w*))$") |
141 | assert(a == 'âlo alo' and b == 'âl' and c == 'â' and d == 'alo' and e == nil) | 157 | assert(a == 'âlo alo' and b == 'âl' and c == 'â' and d == 'alo' and e == nil) |
142 | a, b, c, d = string.match('0123456789', '(.+(.?)())') | 158 | a, b, c, d = string.match('0123456789', '(.+(.?)())') |
143 | assert(a == '0123456789' and b == '' and c == 11 and d == nil) | 159 | assert(a == '0123456789' and b == '' and c == 11 and d == nil) |
144 | print('+') | 160 | print('+') |
145 | 161 | ||
146 | assert(string.gsub('ülo ülo', 'ü', 'x') == 'xlo xlo') | 162 | assert(string.gsub('ülo ülo', 'ü', 'x') == 'xlo xlo') |
147 | assert(string.gsub('alo úlo ', ' +$', '') == 'alo úlo') -- trim | 163 | assert(string.gsub('alo úlo ', ' +$', '') == 'alo úlo') -- trim |
148 | assert(string.gsub(' alo alo ', '^%s*(.-)%s*$', '%1') == 'alo alo') -- double trim | 164 | assert(string.gsub(' alo alo ', '^%s*(.-)%s*$', '%1') == 'alo alo') -- double trim |
149 | assert(string.gsub('alo alo \n 123\n ', '%s+', ' ') == 'alo alo 123 ') | 165 | assert(string.gsub('alo alo \n 123\n ', '%s+', ' ') == 'alo alo 123 ') |
150 | local t = "abç d" | 166 | local t = "abç d" |
151 | a, b = string.gsub(t, '(.)', '%1@') | 167 | a, b = string.gsub(t, PU'(.)', '%1@') |
152 | assert('@'..a == string.gsub(t, '', '@') and b == 5) | 168 | assert(a == "a@b@ç@ @d@" and b == 5) |
153 | a, b = string.gsub('abçd', '(.)', '%0@', 2) | 169 | a, b = string.gsub('abçd', PU'(.)', '%0@', 2) |
154 | assert(a == 'a@b@çd' and b == 2) | 170 | assert(a == 'a@b@çd' and b == 2) |
155 | assert(string.gsub('alo alo', '()[al]', '%1') == '12o 56o') | 171 | assert(string.gsub('alo alo', '()[al]', '%1') == '12o 56o') |
156 | assert(string.gsub("abc=xyz", "(%w*)(%p)(%w+)", "%3%2%1-%0") == | 172 | assert(string.gsub("abc=xyz", "(%w*)(%p)(%w+)", "%3%2%1-%0") == |
157 | "xyz=abc-abc=xyz") | 173 | "xyz=abc-abc=xyz") |
158 | assert(string.gsub("abc", "%w", "%1%0") == "aabbcc") | 174 | assert(string.gsub("abc", "%w", "%1%0") == "aabbcc") |
159 | assert(string.gsub("abc", "%w+", "%0%1") == "abcabc") | 175 | assert(string.gsub("abc", "%w+", "%0%1") == "abcabc") |
160 | assert(string.gsub('áéí', '$', '\0óú') == 'áéí\0óú') | 176 | assert(string.gsub('áéÃ', '$', '\0óú') == 'áéÃ\0óú') |
161 | assert(string.gsub('', '^', 'r') == 'r') | 177 | assert(string.gsub('', '^', 'r') == 'r') |
162 | assert(string.gsub('', '$', 'r') == 'r') | 178 | assert(string.gsub('', '$', 'r') == 'r') |
163 | print('+') | 179 | print('+') |
@@ -188,8 +204,8 @@ do | |||
188 | end | 204 | end |
189 | 205 | ||
190 | function f(a,b) return string.gsub(a,'.',b) end | 206 | function f(a,b) return string.gsub(a,'.',b) end |
191 | assert(string.gsub("trocar tudo em |teste|b| é |beleza|al|", "|([^|]*)|([^|]*)|", f) == | 207 | assert(string.gsub("trocar tudo em |teste|b| é |beleza|al|", "|([^|]*)|([^|]*)|", f) == |
192 | "trocar tudo em bbbbb é alalalalalal") | 208 | "trocar tudo em bbbbb é alalalalalal") |
193 | 209 | ||
194 | local function dostring (s) return load(s, "")() or "" end | 210 | local function dostring (s) return load(s, "")() or "" end |
195 | assert(string.gsub("alo $a='x'$ novamente $return a$", | 211 | assert(string.gsub("alo $a='x'$ novamente $return a$", |
diff --git a/testes/sort.lua b/testes/sort.lua index 52919b8c..40bb2d8a 100644 --- a/testes/sort.lua +++ b/testes/sort.lua | |||
@@ -289,7 +289,7 @@ timesort(a, limit, function(x,y) return nil end, "equal") | |||
289 | 289 | ||
290 | for i,v in pairs(a) do assert(v == false) end | 290 | for i,v in pairs(a) do assert(v == false) end |
291 | 291 | ||
292 | AA = {"álo", "\0first :-)", "alo", "then this one", "45", "and a new"} | 292 | AA = {"\xE1lo", "\0first :-)", "alo", "then this one", "45", "and a new"} |
293 | table.sort(AA) | 293 | table.sort(AA) |
294 | check(AA) | 294 | check(AA) |
295 | 295 | ||
diff --git a/testes/strings.lua b/testes/strings.lua index b033c6ab..90983edd 100644 --- a/testes/strings.lua +++ b/testes/strings.lua | |||
@@ -1,6 +1,9 @@ | |||
1 | -- $Id: testes/strings.lua $ | 1 | -- $Id: testes/strings.lua $ |
2 | -- See Copyright Notice in file all.lua | 2 | -- See Copyright Notice in file all.lua |
3 | 3 | ||
4 | -- ISO Latin encoding | ||
5 | |||
6 | |||
4 | print('testing strings and string library') | 7 | print('testing strings and string library') |
5 | 8 | ||
6 | local maxi <const> = math.maxinteger | 9 | local maxi <const> = math.maxinteger |
diff --git a/testes/utf8.lua b/testes/utf8.lua index c5a9dd3f..efadbd5c 100644 --- a/testes/utf8.lua +++ b/testes/utf8.lua | |||
@@ -1,6 +1,8 @@ | |||
1 | -- $Id: testes/utf8.lua $ | 1 | -- $Id: testes/utf8.lua $ |
2 | -- See Copyright Notice in file all.lua | 2 | -- See Copyright Notice in file all.lua |
3 | 3 | ||
4 | -- UTF-8 file | ||
5 | |||
4 | print "testing UTF-8 library" | 6 | print "testing UTF-8 library" |
5 | 7 | ||
6 | local utf8 = require'utf8' | 8 | local utf8 = require'utf8' |