This allows using on_call_with, called_with, and returned_with to match against object references.
it("Test called_with() using refs", function()
local match = require 'luassert.match'
local s = spy.new(function() end)
local t1 = { foo = { bar = { "test" } } }
local t2 = { foo = { bar = { "test" } } }
s(t1)
t1.foo.bar = "value"
assert.spy(s).was_not.called_with(t1) -- no match since t1 was modified
assert.spy(s).was.called_with(t2) -- matches since t2 was the same as t1 at call site
assert.spy(s).was_not.called_with(match.is_ref(t2)) -- does not match ref to t2
assert.spy(s).was.called_with(match.is_ref(t1)) -- matches ref to t1
end)
This allows using
on_call_with
,called_with
, andreturned_with
to match against object references.This should resolve issue #123.