Closed brandonsturgeon closed 1 year ago
I think being able to stub hook
functions is a gimmick, and I believe there are better ways to handle those tests, but this PR will still allow you to do that.
It also fixes some other minor issues I found while I was in there:
:Restore()
them - it's now properly a no-ophook.Add
ed, but cannot be retrieved directly from hook.GetTable()
(they're wrapped in an actual function, basically)I've been playing with this for awhile - it doesn't appear to break any existing functionality 👍
Currently, if you do:
This would fail, because the
stub
library is trying to stubRun
on the fakehook
library that we set in the test environment.The fix presented here would give the
hook
(and probablytimer
?) environment tables a metatable that would pass-through SET operations to the realhook
(andtimer
) tables, letting stubs actually stub the real functions.I didn't notice any side effects from doing this, but I'm going to play with it a bit more before merging.
e: One obvious issue here is that if you stub out any of the real hook methods, it'll fuck up anything in the entire lua environment that wants to use them... including GLuaTest.. If you put an expectation (or other kind of erroring code) in the stub, GLuaTest breaks because it can't find the debug info to report the error properly :/