coronalabs / corona

Solar2D Game Engine main repository (ex Corona SDK)
https://solar2d.com/
MIT License
2.51k stars 270 forks source link

error() function is not working as intended #94

Closed Sledmine closed 4 years ago

Sledmine commented 4 years ago

Hi, I would like to see how Solar2D is related to the error function from Lua, I'm using the luaunit framework to add tests into my app but it looks like is having problems at running the error function from Lua and it just stops working without triggering any error, the library is not being able to catch something to throw.

local lu = require("luaunit")

test_Luaunit = {}

function test_Luaunit:test_NoErrorDetection()
    print("Testing no error triggering\n")

    lu.assertEquals(true, true)
end

-- Try to comment this function test to see how it is supposed to work
function test_Luaunit:test_ErrorDetection()
    print("Testing error function triggering\n")

    lu.assertEquals(true, false)
end

local runner = lu.LuaUnit.new()
runner:runSuite()

This is the same script running in a pure lua interpreter: image

And this is in the Corona Simulator: image

The library inside is running the "error()" function because the assert failed, after running the assert in the second test everything is just dead.

I think the error function is being used somehow by Solar2D and is messing with how it should work in pure Lua.

Is there a way to control how the error function works? Thanks in advance!

Sledmine commented 4 years ago

Lol, I just found the problem, I was loading another library that was replacing the error function and causing problems, closing the issue.