diff options
| author | Shiffted <[email protected]> | 2026-06-14 01:48:07 +0200 |
|---|---|---|
| committer | Shiffted <[email protected]> | 2026-06-14 01:48:07 +0200 |
| commit | a63a03322c87be7978612a194995e767976f2bf9 (patch) | |
| tree | 07c569af202ec71d11bcb443acc6e9a0208b2413 /tests/projects/package/load_from_project/check.lua | |
| parent | 5b1633eb40616616458aca322802e268c3ab19a7 (diff) | |
add tests for package load_from_xxx
Diffstat (limited to 'tests/projects/package/load_from_project/check.lua')
| -rw-r--r-- | tests/projects/package/load_from_project/check.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/projects/package/load_from_project/check.lua b/tests/projects/package/load_from_project/check.lua new file mode 100644 index 000000000..d9a4edd49 --- /dev/null +++ b/tests/projects/package/load_from_project/check.lua @@ -0,0 +1,19 @@ +import("core.package.package") + +function main() + local foo1 = package.load_from_project("foo") + local foo2 = package.load_from_project("foo") + assert(foo1 and foo2, "load_from_project(foo) failed!") + + assert(table.contains(table.wrap(foo1:get("defines")), "FOO_BASE"), "foo1 missing FOO_BASE") + assert(table.contains(table.wrap(foo2:get("defines")), "FOO_BASE"), "foo2 missing FOO_BASE") + + -- mutating one instance should not leak into the other + foo1:add("defines", "FOO_LEAK") + assert(table.contains(table.wrap(foo1:get("defines")), "FOO_LEAK"), "foo1 missing FOO_LEAK") + assert(not table.contains(table.wrap(foo2:get("defines")), "FOO_LEAK"), "FOO_LEAK leaked into foo2") + + foo1:set("foo_leak", false) + assert(foo1:get("foo_leak") == false, "foo1 foo_leak not set") + assert(foo2:get("foo_leak") ~= false, "foo_leak leaked into foo2") +end |
