| 1234567891011121314151617181920212223242526272829 |
- import pytest
- from cq2_sdk.lua_bridge.runtime import LuaRuntime, get_runtime, DEFAULT_LUA_PATH
- def test_lua_eval_arithmetic():
- rt = LuaRuntime()
- assert rt.eval("1 + 2") == 3
- def test_lua_call_global_function():
- rt = LuaRuntime()
- rt.execute("function double(x) return x * 2 end")
- assert rt.call("double", 21) == 42
- def test_get_runtime_returns_singleton():
- a = get_runtime()
- b = get_runtime()
- assert a is b
- def test_default_path_from_env(monkeypatch):
- monkeypatch.setenv("CQ2_LUA_PATH", "/custom/path")
- rt = LuaRuntime()
- assert rt.lua_path == "/custom/path"
- def test_default_path_constant():
- assert DEFAULT_LUA_PATH == r"D:\ProgramFiles\996box\GameBoxDownload\1\cq\assets"
|