mirror of
https://github.com/Dingo-Shenanigans/ReSkate.git
synced 2026-10-24 10:26:13 +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.
31 lines
1.1 KiB
Lua
31 lines
1.1 KiB
Lua
local h = require("harness")
|
|
local t = h.module("time")
|
|
|
|
t.check("now is a number that moves forward", function()
|
|
local a = reskate.time.now()
|
|
assert(type(a) == "number" and a > 0)
|
|
assert(reskate.time.now() >= a)
|
|
end)
|
|
t.later("after runs once", 2000, function(done)
|
|
local count = 0
|
|
reskate.time.after(50, function() count += 1 end)
|
|
reskate.time.after(400, function() done(count == 1, "it ran " .. count .. " times") end)
|
|
end)
|
|
t.later("every repeats, and cancel stops it", 2000, function(done)
|
|
local count = 0
|
|
local id = reskate.time.every(50, function() count += 1 end)
|
|
reskate.time.after(300, function()
|
|
reskate.time.cancel(id)
|
|
local at = count
|
|
reskate.time.after(200, function()
|
|
done(count >= 3 and count == at, "it counted " .. count .. ", and " .. at .. " when cancelled")
|
|
end)
|
|
end)
|
|
end)
|
|
t.check("negative, NaN and zero repeats are refused", function()
|
|
h.refused(reskate.time.after, -1, print)
|
|
h.refused(reskate.time.after, 0 / 0, print)
|
|
h.refused(reskate.time.every, 0, print)
|
|
h.refused(reskate.time.after, 10, "not a function")
|
|
end)
|