tests/test.lua: Fix fake module() function to prevent _M from being _G (test.lua...
authorMatthew Wild <mwild1@gmail.com>
Wed, 6 Jan 2016 00:24:06 +0000 (00:24 +0000)
committerMatthew Wild <mwild1@gmail.com>
Wed, 6 Jan 2016 00:24:06 +0000 (00:24 +0000)
tests/test.lua

index de1e40fd8bb96166154cf78f16a6ccc08d2dac81..bb11ab267bd487584e8782b70d47f83af20728cd 100644 (file)
@@ -137,7 +137,10 @@ function dotest(unitname)
        end
        
        local oldmodule, old_M = _fakeG.module, _fakeG._M;
-       _fakeG.module = function () _M = _G end
+       _fakeG.module = function ()
+               setmetatable(unit, nil);
+               unit._M = unit;
+       end
        setfenv(chunk, unit);
        local success, err = pcall(chunk);
        _fakeG.module, _fakeG._M = oldmodule, old_M;