Skip to content

Commit

Permalink
Merge pull request #39 from osyrisrblx/rbxscriptsignal-and-rbxscriptc…
Browse files Browse the repository at this point in the history
…onnection

Add t.RBXScriptSignal, t.RBXScriptConnection
  • Loading branch information
osyrisrblx committed Sep 16, 2019
2 parents 00b91a7 + 08f2abd commit a2729b8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,24 @@ t.Enum = primitive("Enum")
**--]]
t.EnumItem = primitive("EnumItem")

--[[**
ensures Roblox RBXScriptSignal type
@param value The value to check against
@returns True iff the condition is satisfied, false otherwise
**--]]
t.RBXScriptSignal = primitive("RBXScriptSignal")

--[[**
ensures Roblox RBXScriptConnection type
@param value The value to check against
@returns True iff the condition is satisfied, false otherwise
**--]]
t.RBXScriptConnection = primitive("RBXScriptConnection")

--[[**
ensures value is a given literal value
Expand Down
14 changes: 14 additions & 0 deletions lib/init.spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,20 @@ return function()
assert(not (sortOrderEnumCheck()))
end)

it("should support Roblox RBXScriptSignal", function()
assert(t.RBXScriptSignal(game.ChildAdded))
assert(not (t.RBXScriptSignal(nil)))
assert(not (t.RBXScriptSignal(Vector3.new())))
end)

-- TODO: Add this back when Lemur supports it
-- it("should support Roblox RBXScriptConnection", function()
-- local conn = game.ChildAdded:Connect(function() end)
-- assert(t.RBXScriptConnection(conn))
-- assert(not (t.RBXScriptConnection(nil)))
-- assert(not (t.RBXScriptConnection(Vector3.new())))
-- end)

it("should support wrapping function types", function()
local checkFoo = t.tuple(t.string, t.number, t.optional(t.string))
local foo = t.wrap(function(a, b, c)
Expand Down
2 changes: 2 additions & 0 deletions lib/ts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ t.Vector3 = primitive("Vector3")
t.Vector3int16 = primitive("Vector3int16")
t.Enum = primitive("Enum")
t.EnumItem = primitive("EnumItem")
t.RBXScriptSignal = primitive("RBXScriptSignal")
t.RBXScriptConnection = primitive("RBXScriptConnection")

function t.literal(...)
local size = select("#", ...)
Expand Down

0 comments on commit a2729b8

Please sign in to comment.