mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 13:00:37 +00:00
Share more code in task lib test files
This commit is contained in:
parent
4609092ec4
commit
3c0e270279
4 changed files with 16 additions and 39 deletions
|
@ -41,19 +41,7 @@ assert(flag3 == 3, "Defer should run after spawned threads")
|
|||
|
||||
-- Varargs should get passed correctly
|
||||
|
||||
local function fcheck(index: number, type: string, value: any)
|
||||
if typeof(value) ~= type then
|
||||
console.error(
|
||||
string.format(
|
||||
"Expected argument #%d to be of type %s, got %s",
|
||||
index,
|
||||
type,
|
||||
console.format(value)
|
||||
)
|
||||
)
|
||||
process.exit(1)
|
||||
end
|
||||
end
|
||||
local fcheck = require("./fcheck")
|
||||
|
||||
local function f(...: any)
|
||||
fcheck(1, "string", select(1, ...))
|
||||
|
|
|
@ -28,19 +28,7 @@ assert(not flag2, "Delay should work with yielding (2)")
|
|||
|
||||
-- Varargs should get passed correctly
|
||||
|
||||
local function fcheck(index: number, type: string, value: any)
|
||||
if typeof(value) ~= type then
|
||||
console.error(
|
||||
string.format(
|
||||
"Expected argument #%d to be of type %s, got %s",
|
||||
index,
|
||||
type,
|
||||
console.format(value)
|
||||
)
|
||||
)
|
||||
process.exit(1)
|
||||
end
|
||||
end
|
||||
local fcheck = require("./fcheck")
|
||||
|
||||
local function f(...: any)
|
||||
fcheck(1, "string", select(1, ...))
|
||||
|
|
13
src/tests/task/fcheck.luau
Normal file
13
src/tests/task/fcheck.luau
Normal file
|
@ -0,0 +1,13 @@
|
|||
return function(index: number, type: string, value: any)
|
||||
if typeof(value) ~= type then
|
||||
console.error(
|
||||
string.format(
|
||||
"Expected argument #%d to be of type %s, got %s",
|
||||
index,
|
||||
type,
|
||||
console.format(value)
|
||||
)
|
||||
)
|
||||
process.exit(1)
|
||||
end
|
||||
end
|
|
@ -33,19 +33,7 @@ assert(flag3, "Spawn should run threads made from coroutine.create")
|
|||
|
||||
-- Varargs should get passed correctly
|
||||
|
||||
local function fcheck(index: number, type: string, value: any)
|
||||
if typeof(value) ~= type then
|
||||
console.error(
|
||||
string.format(
|
||||
"Expected argument #%d to be of type %s, got %s",
|
||||
index,
|
||||
type,
|
||||
console.format(value)
|
||||
)
|
||||
)
|
||||
process.exit(1)
|
||||
end
|
||||
end
|
||||
local fcheck = require("./fcheck")
|
||||
|
||||
local function f(...: any)
|
||||
fcheck(1, "string", select(1, ...))
|
||||
|
|
Loading…
Reference in a new issue