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

Use correct tuple ordering in resolve_paths #171

Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion src/lune/globals/require/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl RequireContext {
CWD.join(&rel_path)
};

Ok((rel_path, abs_path))
Ok((abs_path, rel_path))
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 14 additions & 0 deletions tests/require/tests/state.luau
Original file line number Diff line number Diff line change
@@ -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 ecpect
kennethloeffler marked this conversation as resolved.
Show resolved Hide resolved
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 changes: 9 additions & 0 deletions tests/require/tests/state_module.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
local M = {}

M.state = 10

function M.set_state(n: number)
M.state = n
end

return M
5 changes: 5 additions & 0 deletions tests/require/tests/state_second.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
local state_module = require("./state_module")

state_module.set_state(11)

return {}
Loading