Share more code in task lib test files

This commit is contained in:
Filip Tibell 2023-01-24 12:52:41 -05:00
parent 4609092ec4
commit 3c0e270279
No known key found for this signature in database
4 changed files with 16 additions and 39 deletions

View file

@ -41,19 +41,7 @@ assert(flag3 == 3, "Defer should run after spawned threads")
-- Varargs should get passed correctly -- Varargs should get passed correctly
local function fcheck(index: number, type: string, value: any) local fcheck = require("./fcheck")
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 function f(...: any) local function f(...: any)
fcheck(1, "string", select(1, ...)) fcheck(1, "string", select(1, ...))

View file

@ -28,19 +28,7 @@ assert(not flag2, "Delay should work with yielding (2)")
-- Varargs should get passed correctly -- Varargs should get passed correctly
local function fcheck(index: number, type: string, value: any) local fcheck = require("./fcheck")
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 function f(...: any) local function f(...: any)
fcheck(1, "string", select(1, ...)) fcheck(1, "string", select(1, ...))

View 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

View file

@ -33,19 +33,7 @@ assert(flag3, "Spawn should run threads made from coroutine.create")
-- Varargs should get passed correctly -- Varargs should get passed correctly
local function fcheck(index: number, type: string, value: any) local fcheck = require("./fcheck")
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 function f(...: any) local function f(...: any)
fcheck(1, "string", select(1, ...)) fcheck(1, "string", select(1, ...))