inside_async_env.lua 1017 B

1234567891011121314151617181920212223242526272829303132333435
  1. unittests = {}
  2. core.log("info", "Hello World")
  3. unittests.custom_metatable = {}
  4. core.register_portable_metatable("unittests:custom_metatable", unittests.custom_metatable)
  5. local function do_tests()
  6. assert(core == minetest)
  7. -- stuff that should not be here
  8. assert(not core.get_player_by_name)
  9. assert(not core.set_node)
  10. assert(not core.object_refs)
  11. -- stuff that should be here
  12. assert(ItemStack)
  13. local meta = ItemStack():get_meta()
  14. assert(type(meta) == "userdata")
  15. assert(type(meta.set_tool_capabilities) == "function")
  16. assert(core.registered_items[""])
  17. assert(next(core.registered_nodes) ~= nil)
  18. assert(core.registered_craftitems["unittests:stick"])
  19. -- alias handling
  20. assert(core.registered_items["unittests:steel_ingot_alias"].name ==
  21. "unittests:steel_ingot")
  22. -- fallback to item defaults
  23. assert(core.registered_items["unittests:description_test"].on_place == true)
  24. end
  25. function unittests.async_test()
  26. local ok, err = pcall(do_tests)
  27. if not ok then
  28. core.log("error", err)
  29. end
  30. return ok
  31. end