summary refs log blame commit diff stats
path: root/test/line-numbers.cratera
blob: 75bc09b929317b2c0d4945bae75350b2bffb1417 (plain) (tree)


























                                   


                          
















                                        


                                                                    
                               
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")