Skip to content

Commit b3418bc

Browse files
mkokryashkinigormunkin
authored andcommitted
test: update lua-Harness to c4451fe
This patch backports several small commits from the lua-Harness suite: - follow ravi 1.0-beta4[1] - refactor with near[2] - follow LuaJIT[3] - fix when no debug[4] - check if luac exists[5] - https[6] - more assert[7] [1]: https://framagit.org/fperrad/lua-Harness/-/commit/9455281b [2]: https://framagit.org/fperrad/lua-Harness/-/commit/70404580 [3]: https://framagit.org/fperrad/lua-Harness/-/commit/ac7671b6 [4]: https://framagit.org/fperrad/lua-Harness/-/commit/4db7e539 [5]: https://framagit.org/fperrad/lua-Harness/-/commit/97e9e4c1 [6]: https://framagit.org/fperrad/lua-Harness/-/commit/673c7869 [7]: https://framagit.org/fperrad/lua-Harness/-/commit/b7b1a9a2 Part of tarantool/tarantool#5970 Part of tarantool/tarantool#4473 Reviewed-by: Igor Munkin <[email protected]> Reviewed-by: Sergey Kaplun <[email protected]> Signed-off-by: Igor Munkin <[email protected]>
1 parent 8b87ad9 commit b3418bc

File tree

16 files changed

+63
-45
lines changed

16 files changed

+63
-45
lines changed

test/lua-Harness-tests/200-examples.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ equals(iter_factorial(7), 5040, "factorial (iter)")
7070
--[[
7171
7272
Knuth's "man or boy" test.
73-
See http://en.wikipedia.org/wiki/Man_or_boy_test
73+
See https://en.wikipedia.org/wiki/Man_or_boy_test
7474
7575
]]
7676

test/lua-Harness-tests/203-lexico.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
=head2 Description
2020
2121
See "Lua 5.3 Reference Manual", section 3.1 "Lexical Conventions",
22-
L<http://www.lua.org/manual/5.3/manual.html#3.1>.
22+
L<https://www.lua.org/manual/5.3/manual.html#3.1>.
2323
2424
See section "Lexical Conventions"
2525
L<https://www.lua.org/manual/5.1/manual.html#2.1>,

test/lua-Harness-tests/241-standalone.t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ end
4545

4646
local lua = _retrieve_progname()
4747
local luac = jit and lua or (lua .. 'c')
48+
local exists_luac = io.open(luac, 'r')
4849

4950
if not pcall(io.popen, lua .. [[ -e "a=1"]]) then
5051
skip_all "io.popen not supported"
@@ -78,7 +79,7 @@ else
7879
end
7980
f:close()
8081

81-
if has_bytecode then
82+
if has_bytecode and exists_luac then
8283
if jit then
8384
os.execute(lua .. " -b hello-241.lua hello-241.luac")
8485
else

test/lua-Harness-tests/242-luac.t

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ end
4141
local lua = _retrieve_progname()
4242
local luac = lua .. 'c'
4343

44+
if not io.open(luac, 'r') then
45+
skip_all "no luac"
46+
end
47+
4448
if not pcall(io.popen, lua .. [[ -e "a=1"]]) then
4549
skip_all "io.popen not supported"
4650
end

test/lua-Harness-tests/301-basic.t

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,15 @@ local lua = _retrieve_progname()
5353
plan'no_plan'
5454

5555
do -- assert
56-
local v, msg = assert('text', "assert string")
56+
local v, msg, extra = assert('text', "assert string", 'extra')
5757
equals(v, 'text', "function assert")
5858
equals(msg, "assert string")
59-
v, msg = assert({}, "assert table")
59+
equals(extra, 'extra')
60+
v, msg, extra = assert({}, "assert table", 'extra')
6061
equals(msg, "assert table")
62+
equals(extra, 'extra')
6163

62-
error_matches(function () assert(false, "ASSERTION TEST") end,
64+
error_matches(function () assert(false, "ASSERTION TEST", 'extra') end,
6365
"^[^:]+:%d+: ASSERTION TEST",
6466
"function assert(false, msg)")
6567

@@ -73,7 +75,7 @@ do -- assert
7375
else
7476
error_matches(function () assert(false, 42) end,
7577
"^[^:]+:%d+: 42",
76-
"function assert(false, 42)")
78+
"function assert(false, 42) --> invalid")
7779
end
7880

7981
if has_error53 then
@@ -167,7 +169,7 @@ end
167169
f:close()
168170
dofile('lib-301.lua')
169171
local n = norm(3.4, 1.0)
170-
matches(twice(n), '^7%.088', "function dofile")
172+
near(twice(n), 7.088, 0.001, "function dofile")
171173

172174
os.remove('lib-301.lua') -- clean up
173175

test/lua-Harness-tests/304-string.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ do -- format
277277
equals(string.format("%s %d", r, r:len()), r .. " 200")
278278

279279
error_matches(function () string.format("%s %s", 1) end,
280-
"^[^:]+:%d+: bad argument #3 to 'format' %(.-no value%)",
280+
"^[^:]+:%d+: bad argument #3 to 'format' %(.-value.-%)",
281281
"function format (too few arg)")
282282

283283
error_matches(function () string.format('%d', 'toto') end,

test/lua-Harness-tests/307-math.t

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,20 @@ do -- abs
5656
end
5757

5858
do -- acos
59-
matches(math.acos(0.5), '^1%.047', "function acos")
59+
near(math.acos(0.5), 1.047, 0.001, "function acos")
6060
end
6161

6262
do -- asin
63-
matches(math.asin(0.5), '^0%.523', "function asin")
63+
near(math.asin(0.5), 0.523, 0.001, "function asin")
6464
end
6565

6666
do -- atan
67-
matches(math.atan(0.5), '^0%.463', "function atan")
67+
near(math.atan(0.5), 0.463, 0.001, "function atan")
6868
end
6969

7070
-- atan2
7171
if has_mathx then
72-
matches(math.atan2(1.0, 2.0), '^0%.463', "function atan2")
72+
near(math.atan2(1.0, 2.0), 0.463, 0.001, "function atan2")
7373
else
7474
is_nil(math.atan2, "function atan2 (removed)")
7575
end
@@ -84,12 +84,12 @@ do -- ceil
8484
end
8585

8686
do -- cos
87-
matches(math.cos(1.0), '^0%.540', "function cos")
87+
near(math.cos(1.0), 0.540, 0.001, "function cos")
8888
end
8989

9090
-- cosh
9191
if has_mathx then
92-
matches(math.cosh(1.0), '^1%.543', "function cosh")
92+
near(math.cosh(1.0), 1.543, 0.001, "function cosh")
9393
else
9494
is_nil(math.cosh, "function cosh (removed)")
9595
end
@@ -99,7 +99,7 @@ do -- deg
9999
end
100100

101101
do -- exp
102-
matches(math.exp(1.0), '^2%.718', "function exp")
102+
near(math.exp(1.0), 2.718, 0.001, "function exp")
103103
end
104104

105105
do -- floor
@@ -112,9 +112,9 @@ do -- floor
112112
end
113113

114114
do -- fmod
115-
matches(math.fmod(7.0001, 0.3), '^0%.100', "function fmod (float)")
116-
matches(math.fmod(-7.0001, 0.3), '^-0%.100')
117-
matches(math.fmod(-7.0001, -0.3), '^-0%.100')
115+
near(math.fmod(7.0001, 0.3), 0.100, 0.001, "function fmod (float)")
116+
near(math.fmod(-7.0001, 0.3), -0.100, 0.001)
117+
near(math.fmod(-7.0001, -0.3), -0.100, 0.001)
118118
if math.type then
119119
equals(math.type(math.fmod(7.0, 0.3)), 'float')
120120
end
@@ -155,17 +155,17 @@ else
155155
end
156156

157157
do -- log
158-
matches(math.log(47), '^3%.85', "function log")
158+
near(math.log(47), 3.85, 0.01, "function log")
159159
if has_log_with_base then
160-
matches(math.log(47, math.exp(1)), '^3%.85', "function log (base e)")
161-
matches(math.log(47, 2), '^5%.554', "function log (base 2)")
162-
matches(math.log(47, 10), '^1%.672', "function log (base 10)")
160+
near(math.log(47, math.exp(1)), 3.85, 0.01, "function log (base e)")
161+
near(math.log(47, 2), 5.554, 0.001, "function log (base 2)")
162+
near(math.log(47, 10), 1.672, 0.001, "function log (base 10)")
163163
end
164164
end
165165

166166
-- log10
167167
if has_log10 then
168-
matches(math.log10(47.0), '^1%.672', "function log10")
168+
near(math.log10(47.0), 1.672, 0.001, "function log10")
169169
else
170170
is_nil(math.log10, "function log10 (removed)")
171171
end
@@ -223,7 +223,7 @@ do -- modf
223223
end
224224

225225
do -- pi
226-
matches(tostring(math.pi), '^3%.14', "variable pi")
226+
near(math.pi, 3.14, 0.01, "variable pi")
227227
end
228228

229229
-- pow
@@ -234,7 +234,7 @@ else
234234
end
235235

236236
do -- rad
237-
matches(math.rad(180), '^3%.14', "function rad")
237+
near(math.rad(180), 3.14, 0.01, "function rad")
238238
end
239239

240240
do -- random
@@ -291,27 +291,27 @@ do -- randomseed
291291
end
292292

293293
do -- sin
294-
matches(math.sin(1.0), '^0%.841', "function sin")
294+
near(math.sin(1.0), 0.841, 0.001, "function sin")
295295
end
296296

297297
-- sinh
298298
if has_mathx then
299-
matches(math.sinh(1), '^1%.175', "function sinh")
299+
near(math.sinh(1), 1.175, 0.001, "function sinh")
300300
else
301301
is_nil(math.sinh, "function sinh (removed)")
302302
end
303303

304304
do -- sqrt
305-
matches(math.sqrt(2), '^1%.414', "function sqrt")
305+
near(math.sqrt(2), 1.414, 0.001, "function sqrt")
306306
end
307307

308308
do -- tan
309-
matches(math.tan(1.0), '^1%.557', "function tan")
309+
near(math.tan(1.0), 1.557, 0.001, "function tan")
310310
end
311311

312312
-- tanh
313313
if has_mathx then
314-
matches(math.tanh(1), '^0%.761', "function tanh")
314+
near(math.tanh(1), 0.761, 0.001, "function tanh")
315315
else
316316
is_nil(math.tanh, "function tanh (removed)")
317317
end

test/lua-Harness-tests/310-debug.t

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ local has_setmetatable52 = _VERSION >= 'Lua 5.2' or (profile.luajit_compat52 and
4242
local has_upvalueid = _VERSION >= 'Lua 5.2' or jit
4343
local has_upvaluejoin = _VERSION >= 'Lua 5.2' or jit
4444

45-
local debug = require 'debug'
46-
4745
if not debug then
4846
skip_all("no debug")
4947
end

test/lua-Harness-tests/320-stdin.t

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ if not pcall(io.popen, lua .. [[ -e "a=1"]]) then
3232
skip_all "io.popen not supported"
3333
end
3434

35-
plan(12)
35+
plan'no_plan'
3636

3737
do
3838
local f = io.open('lib-320.lua', 'w')
@@ -49,7 +49,7 @@ end
4949

5050
local cmd = lua .. [[ -e "dofile(); n = norm(3.4, 1.0); print(twice(n))" < lib-320.lua]]
5151
f = io.popen(cmd)
52-
matches(f:read'*l', '^7%.088', "function dofile (stdin)")
52+
near(f:read'*n', 7.088, 0.001, "function dofile (stdin)")
5353
f:close()
5454

5555
os.remove('lib-320.lua') -- clean up
@@ -102,14 +102,14 @@ do
102102

103103
local cmd = lua .. [[ -e "while true do local n1, n2, n3 = io.read('*number', '*number', '*number'); if not n1 then break end; print(math.max(n1, n2, n3)) end" < number-320.txt]]
104104
f = io.popen(cmd)
105-
matches(f:read'*l', '15000%.?', "function io:read *number")
106-
equals(f:read'*l', '1000001')
105+
equals(f:read'*n', 15000, "function io:read *number")
106+
equals(f:read'*n', 1000001)
107107
f:close()
108108

109109
os.remove('number-320.txt') -- clean up
110110
end
111111

112-
do
112+
if debug then
113113
local f = io.open('dbg-320.txt', 'w')
114114
f:write("print 'ok'\n")
115115
f:write("error 'dbg'\n")
@@ -123,8 +123,12 @@ do
123123
f:close()
124124

125125
os.remove('dbg-320.txt') -- clean up
126+
else
127+
diag("no debug")
126128
end
127129

130+
done_testing()
131+
128132
-- Local Variables:
129133
-- mode: lua
130134
-- lua-indent-level: 4

test/lua-Harness-tests/401-bitop.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
1919
=head2 Description
2020
21-
See L<http://bitop.luajit.org/>.
21+
See L<https://bitop.luajit.org/>.
2222
2323
=cut
2424

0 commit comments

Comments
 (0)