Source

GL Profile Suite / tests / codegen.lua

Diff from to

tests/codegen.lua

 
 codegen.init = codegen.initialize
 
+-----------------------------------------
+-- Miscellaneous functions
+function codegen.stmtfile(filename)
+	assert(codegen._curr, "Must have a current suite/test to call stmtfile.")
+	
+	local base_dir = codegen._curr._base_dir
+	return function(...)
+		local oldcwd = os.getcwd()
+		os.chdir(base_dir)
+		local hFile = io.open(path.getabsolute(filename), "r")
+		local str = hFile:read("*a");
+		hFile:close()
+		os.chdir(oldcwd)
+		return str
+	end
+end
+
+function codegen.stmtlua(filename)
+	assert(codegen._curr, "Must have a current suite/test to call stmtlua.")
+
+	local base_dir = codegen._curr._base_dir
+	return function(...)
+		local oldcwd = os.getcwd()
+		os.chdir(base_dir)
+		local func = loadfile(path.getabsolute(filename),
+			path.getname(filename))
+		local temp = func(...)
+		os.chdir(oldcwd)
+		return temp
+	end
+end
+
 
 --------------------------------
 -- Test specific functions.