You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been trying to use TDD with busted to implement my own sandboxing behavior. However to my surprise the first test after ensuring the function gets called already failed due to some weird behavior with global variables. It tells me ACTUAL is still "GLOBAL_VAR"
My test:
test("When creating global variable inside sandbox.run() -> should not be in _G afterwards", function()
localsandbox=require"sandbox"sandbox.run(function()
ACTUAL="GLOBAL_VAR"end)
assert.is_nil(ACTUAL)
end)
In good TDD fashion I'm doing the simplest thing possible in sandbox.lua:
Turning off busted's sandbox doesn't change anything about it, nor should it. This is all within a single test function after all.
But in this case busted produces wrong results. I'm setting ACTUAL to nil, but it still shows up as GLOBAL_VAR. Maybe the function passed into run() is not being run in the same environment? There's nothing my code does with the environment, what I posted here is all I had written at that time.
I've been trying to use TDD with busted to implement my own sandboxing behavior. However to my surprise the first test after ensuring the function gets called already failed due to some weird behavior with global variables. It tells me
ACTUAL
is still "GLOBAL_VAR"My test:
In good TDD fashion I'm doing the simplest thing possible in
sandbox.lua
:As it turns out replacing
ACTUAL
with_G.ACTUAL
in both files fixes the bug. Every other combination seems to fail.The text was updated successfully, but these errors were encountered: