-
-
Notifications
You must be signed in to change notification settings - Fork 617
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix stack manipulation in Premake's
luaL_loadfilex
override.
An example of code that did not work: ```lua local env = { ["foo"] = function(n) print(n) end } assert(pcall(loadfile("foo.lua", nil, env)) ```
- Loading branch information
Showing
5 changed files
with
71 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
-- | ||
-- 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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
foobar(10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
return 10 |