mirror of
https://github.com/minetest/minetest.git
synced 2024-12-02 20:43:45 +01:00
39 lines
1.1 KiB
Lua
39 lines
1.1 KiB
Lua
local function test_random()
|
|
-- Try out PseudoRandom
|
|
local pseudo = PseudoRandom(13)
|
|
assert(pseudo:next() == 22290)
|
|
assert(pseudo:next() == 13854)
|
|
end
|
|
unittests.register("test_random", test_random)
|
|
|
|
local function test_dynamic_media(cb, player)
|
|
if core.get_player_information(player:get_player_name()).protocol_version < 40 then
|
|
core.log("warning", "test_dynamic_media: Client too old, skipping test.")
|
|
return cb()
|
|
end
|
|
|
|
-- Check that the client acknowledges media transfers
|
|
local path = core.get_worldpath() .. "/test_media.obj"
|
|
local f = io.open(path, "w")
|
|
f:write("# contents don't matter\n")
|
|
f:close()
|
|
|
|
local call_ok = false
|
|
local ok = core.dynamic_add_media({
|
|
filepath = path,
|
|
to_player = player:get_player_name(),
|
|
}, function(name)
|
|
if not call_ok then
|
|
cb("impossible condition")
|
|
end
|
|
cb()
|
|
end)
|
|
if not ok then
|
|
return cb("dynamic_add_media() returned error")
|
|
end
|
|
call_ok = true
|
|
|
|
-- if the callback isn't called this test will just hang :shrug:
|
|
end
|
|
unittests.register("test_dynamic_media", test_dynamic_media, {async=true, player=true})
|