mirror of
https://github.com/Dingo-Shenanigans/ReSkate.git
synced 2026-10-24 12:26:20 +02:00
- contrib/plugins/reskate-test calls every plugin API and says what worked: ptest all, ptest <module>, ptest list. Its 45 checks cover the base set, timers, the level, package files, JSON, require, the console, storage and the sandbox. It is the example to copy for a plugin. - contrib/plugins/reskate-hostile attacks the sandbox, one attack per command (hostile list): loops, memory and buffer bombs, caught errors, error and log floods, timers, recursion, an unload that never ends, and 17 ways out. Each must end stopped or refused. - dingosdk_plugin_tests runs both from the repository: every reskate-test check passes, and every hostile attack is stopped or refused with nothing escaping. - Taken from Domination (PR 279) for the plugin API to use: the trick watch (when a trick starts, lands and what it scored, or a slam breaks it; Domination's spots left out) in Extension/Skater/trick_watch.h with its tests, the score HUD reader in score_hud.h, and teleport_local_skater_heading, whose hunks are the PR's own. Neither is wired to anything yet.
26 lines
1.2 KiB
Lua
26 lines
1.2 KiB
Lua
local h = require("harness")
|
|
local t = h.module("base")
|
|
|
|
local ticks, loaded, last_dt = 0, false, nil
|
|
reskate.on("load", function() loaded = true end)
|
|
reskate.on("tick", function(dt)
|
|
ticks += 1
|
|
last_dt = dt
|
|
end)
|
|
|
|
t.check("api_version is 1", function() assert(reskate.api_version == 1, "it is " .. tostring(reskate.api_version)) end)
|
|
t.check("id is the mod folder's name", function() assert(type(reskate.id) == "string" and #reskate.id > 0) end)
|
|
t.check("the load handler ran", function() assert(loaded) end)
|
|
t.check("tick handlers run, with the time since the last tick", function()
|
|
assert(ticks > 0, "no tick yet")
|
|
assert(type(last_dt) == "number" and last_dt >= 0, "dt is " .. tostring(last_dt))
|
|
end)
|
|
t.check("log takes info, warn and error", function()
|
|
reskate.log("ptest: an info line")
|
|
reskate.log("ptest: a warning line", "warn")
|
|
end)
|
|
t.check("print goes to the log", function() print("ptest: printed", 1, true) end)
|
|
t.check("a made-up log level is refused", function() h.refused(reskate.log, "x", "loud") end)
|
|
t.check("a made-up event is refused", function() h.refused(reskate.on, "made_up", function() end) end)
|
|
t.check("an event needs a function", function() h.refused(reskate.on, "tick", 5) end)
|