mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 13:00:37 +00:00
Fix require caching by using correct tuple ordering in resolve_paths (#171)
This commit is contained in:
parent
94ba331ed0
commit
a65ef2ae1b
5 changed files with 30 additions and 1 deletions
|
@ -70,7 +70,7 @@ impl RequireContext {
|
|||
CWD.join(&rel_path)
|
||||
};
|
||||
|
||||
Ok((rel_path, abs_path))
|
||||
Ok((abs_path, rel_path))
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -95,6 +95,7 @@ create_tests! {
|
|||
require_nested: "require/tests/nested",
|
||||
require_parents: "require/tests/parents",
|
||||
require_siblings: "require/tests/siblings",
|
||||
require_state: "require/tests/state",
|
||||
|
||||
global_g_table: "globals/_G",
|
||||
global_version: "globals/_VERSION",
|
||||
|
|
14
tests/require/tests/state.luau
Normal file
14
tests/require/tests/state.luau
Normal file
|
@ -0,0 +1,14 @@
|
|||
-- the idea of this test is that state_module stores some state in one of its local
|
||||
-- variable
|
||||
local state_module = require("./state_module")
|
||||
|
||||
-- we confirm that without anything happening, the initial value is what we expect
|
||||
assert(state_module.state == 10)
|
||||
|
||||
-- this second file also requires state_module and calls a function that changes the local
|
||||
-- state to 11
|
||||
require("./state_second")
|
||||
|
||||
-- with correct module caching, we should see the change done in state_secone reflected
|
||||
-- here
|
||||
assert(state_module.state == 11)
|
9
tests/require/tests/state_module.luau
Normal file
9
tests/require/tests/state_module.luau
Normal file
|
@ -0,0 +1,9 @@
|
|||
local M = {}
|
||||
|
||||
M.state = 10
|
||||
|
||||
function M.set_state(n: number)
|
||||
M.state = n
|
||||
end
|
||||
|
||||
return M
|
5
tests/require/tests/state_second.luau
Normal file
5
tests/require/tests/state_second.luau
Normal file
|
@ -0,0 +1,5 @@
|
|||
local state_module = require("./state_module")
|
||||
|
||||
state_module.set_state(11)
|
||||
|
||||
return {}
|
Loading…
Reference in a new issue