diff --git a/src/tests/task/defer.luau b/src/tests/task/defer.luau index 83fcda4b..df953384 100644 --- a/src/tests/task/defer.luau +++ b/src/tests/task/defer.luau @@ -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, ...)) diff --git a/src/tests/task/delay.luau b/src/tests/task/delay.luau index abedffea..7d005460 100644 --- a/src/tests/task/delay.luau +++ b/src/tests/task/delay.luau @@ -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, ...)) diff --git a/src/tests/task/fcheck.luau b/src/tests/task/fcheck.luau new file mode 100644 index 00000000..04e00814 --- /dev/null +++ b/src/tests/task/fcheck.luau @@ -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 diff --git a/src/tests/task/spawn.luau b/src/tests/task/spawn.luau index 08f1ae80..7080d058 100644 --- a/src/tests/task/spawn.luau +++ b/src/tests/task/spawn.luau @@ -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, ...))