forked from premake/premake-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_lua.lua
More file actions
37 lines (28 loc) · 691 Bytes
/
Copy pathtest_lua.lua
File metadata and controls
37 lines (28 loc) · 691 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
--
-- tests/test_lua.lua
-- Automated test suite for Lua base functions.
-- Copyright (c) 2008 Jason Perkins and the Premake project
--
local suite = test.declare("lua")
--
-- loadfile
--
function suite.loadfile()
local file = path.join(_SCRIPT_DIR, "test_lua_loaded_noenv.lua")
local fn = assert(loadfile(file, nil))
local ret, value = pcall(fn)
test.isequal(10, value)
end
--
-- loadfile with custom env
--
function suite.loadfile_with_env()
local file = path.join(_SCRIPT_DIR, "test_lua_loaded.lua")
local value = 0
local env = {
["foobar"] = function(n) value = n end
}
local fn = assert(loadfile(file, nil, env))
pcall(fn)
test.isequal(10, value)
end