lunarmodules / luassert

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

Allow asserts to be passed to functions #137

Closed o-lim closed 8 years ago

o-lim commented 8 years ago

This allows assert functions to be passed as arguments and called multiple times using the same table instance.

For example:

describe('Test using asserts passed to function', function()
  local function check_values(check, value, t)
    for _,v in ipairs(t) do
      check(value, v)
    end
  end

  it('check values in table', function()
    check_values(assert.is_equal, 5, {5, 5, 5})
    check_values(assert.is_not_equal, 0, {1, 2, 3})
  end)
end)
ajacksified commented 8 years ago

Simple change, neat feature. 👍