function TestNode.expand(c)local e=getfenv(c.callback)local b=setmetatable({},{__index=e})for c,e in pairs(c.environment)do b[c]=e end b.script=e.script setfenv(c.callback,b)local W,i=xpcall(c.callback,function(c)return debug.traceback(tostring(c),2)end)if not W then c.loadError=i end end local c={}c.__index=c

function TestNode:expand()
	local originalEnv = getfenv(self.callback)
	local callbackEnv = setmetatable({}, { __index = originalEnv })
	for key, value in pairs(self.environment) do
		callbackEnv[key] = value
	end
	-- Copy 'script' directly to new env to make Studio debugger happy.
	-- Studio debugger does not look into __index, because of security reasons
	callbackEnv.script = originalEnv.script
	setfenv(self.callback, callbackEnv)

	local success, result = xpcall(self.callback, function(message)
		return debug.traceback(tostring(message), 2)
	end)

	if not success then
		self.loadError = result
	end
end

local TestPlan = {}
TestPlan.__index = TestPlan
