| 123456789101112131415161718 |
- # tests/test_noop.py
- import lupa.luajit21 as lj
- def test_noop_table_safe_access():
- from apilot.stubs.noop import make_noop_table
- t = make_noop_table("cc")
- assert t["Sprite"] is not None # 任意键存在
- assert callable(t["Sprite"]["create"]) # 任意层级可调
- obj = t["Sprite"]["create"]()
- assert obj["getPosition"]() == (0, 0) # 调用返回 no-op 对象(继续安全)
- def test_install_noop_globals_in_lua():
- from apilot.stubs.noop import install_noop_globals
- rt = lj.LuaRuntime()
- install_noop_globals(rt)
- rt.execute("local s = cc.Sprite:create(); s:setPosition(1,2); s:addChild(cc.Node:create())")
- rt.execute("cc.Director:getInstance():getScheduler()")
- # 无异常即通过
|