1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
local function mkerror(key)
if key == "a" then
error("test failed")
elseif key == "b" then
-- hello
error("test failed")
elseif key == "c" then
error("test failed")
elseif key == "d" then
-- hmm...
error("test failed")
elseif key == "e" then
-- hmm...
error("test failed")
elseif key == "f" then
-- increasingly confused about this
-- hmm...
error("test failed")
elseif key == "g" then
local foo = [[
Test.
Test.
]]
error("test failed")
elseif key == "h" then
error [[
test failed]]
end
end
local ok, msg = pcall(mkerror,"a")
assert(not ok and msg:match(":3"), msg)
local ok, msg = pcall(mkerror,"b")
assert(not ok and msg:match(":6"), msg)
local ok, msg = pcall(mkerror,"c")
assert(not ok and msg:match(":10"), msg)
local ok, msg = pcall(mkerror,"d")
assert(not ok and msg:match(":13"), msg)
local ok, msg = pcall(mkerror,"e")
assert(not ok and msg:match(":17"), msg)
local ok, msg = pcall(mkerror,"f")
assert(not ok and msg:match(":21"), msg)
local ok, msg = pcall(mkerror,"g")
assert(not ok and msg:match(":27"), msg)
local ok, msg = pcall(mkerror,"h")
-- on lua 5.1, cratera line numbers align with the end of the string
assert(not ok and (msg:match(":29") or msg:match(":30")), msg)
print("line number tests pass")
|