Skip to content

Commit

Permalink
Share more code in task lib test files
Browse files Browse the repository at this point in the history
  • Loading branch information
filiptibell committed Jan 24, 2023
1 parent 4609092 commit 3c0e270
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 39 deletions.
14 changes: 1 addition & 13 deletions src/tests/task/defer.luau
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...))
Expand Down
14 changes: 1 addition & 13 deletions src/tests/task/delay.luau
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...))
Expand Down
13 changes: 13 additions & 0 deletions src/tests/task/fcheck.luau
Original file line number Diff line number Diff line change
@@ -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
14 changes: 1 addition & 13 deletions src/tests/task/spawn.luau
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...))
Expand Down

0 comments on commit 3c0e270

Please sign in to comment.