Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let Lua sort the package.loaded table #922

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions spec/lang/loader/loader_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,36 @@ describe("tl.loader", function()
@.]] .. util.os_sep .. [[file1.tl
]], output)
end)
it("works properly with the package.loaded table", function()
local dir_name = util.write_tmp_dir(finally, {
["module.lua"] = [[
package.loaded['module'] = { worked = 'it works' }

return nil
]],
["module.d.tl"] = [[
local record module
worked: string
end

return module
]],
["main.tl"] = [[
local m = require 'module'
print(type(m))
print(m.worked)
]]
})
local pd, output
util.do_in(dir_name, function()
pd = io.popen(util.tl_cmd("run", "main.tl"), "r")
output = pd:read("*a")
end)
util.assert_popen_close(0, pd:close())
util.assert_line_by_line([[
table
it works
]], output)
end)
end)
end)
1 change: 0 additions & 1 deletion tl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14165,7 +14165,6 @@ local function tl_package_loader(module_name)
loader_data = found_filename
end
local ret = chunk(modname, loader_data)
package.loaded[module_name] = ret
return ret
end, found_filename
else
Expand Down
1 change: 0 additions & 1 deletion tl.tl
Original file line number Diff line number Diff line change
Expand Up @@ -14165,7 +14165,6 @@ local function tl_package_loader(module_name: string): any, any
loader_data = found_filename
end
local ret = chunk(modname, loader_data)
package.loaded[module_name] = ret
return ret
end, found_filename
else
Expand Down
Loading