lunarmodules / luassert

Assertion library for Lua
MIT License
206 stars 77 forks source link

Allow numbers to match against error objects in has_error() #74

Closed o-lim closed 9 years ago

o-lim commented 9 years ago

This solves the use case of matching against errors throwing numbers instead of strings or tables. This case is unique because Lua automatically converts the number to a string, which then causes the string comparison to fail against the expected numeric value.

describe('Test has_error()', function()
  it('compares error with expected error number', function()
    assert.has_error(function() error(0) end, 0)
  end)
end)
ajacksified commented 9 years ago

Thanks!