Skip to content

Commit

Permalink
Symbol test
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleitnick committed Dec 10, 2024
1 parent 70e6381 commit 2fb028f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 33 deletions.
33 changes: 0 additions & 33 deletions modules/symbol/init.spec.luau

This file was deleted.

37 changes: 37 additions & 0 deletions modules/symbol/init.test.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
local ServerScriptService = game:GetService("ServerScriptService")

local Test = require(ServerScriptService.TestRunner.Test)

return function(ctx: Test.TestContext)
local Symbol = require(script.Parent)

ctx:Describe("Constructor", function()
ctx:Test("should create a new symbol", function()
local symbol = Symbol("Test")
ctx:Expect(symbol):ToBeA("userdata")
ctx:Expect(symbol == symbol):ToBe(true)
ctx:Expect(tostring(symbol)):ToBe("Symbol(Test)")
end)

ctx:Test("should create a new symbol with no name", function()
local symbol = Symbol()
ctx:Expect(symbol):ToBeA("userdata")
ctx:Expect(symbol == symbol):ToBe(true)
ctx:Expect(tostring(symbol)):ToBe("Symbol()")
end)

ctx:Test("should be unique regardless of the name", function()
ctx:Expect(Symbol("Test") == Symbol("Test")):ToBe(false)
ctx:Expect(Symbol() == Symbol()):ToBe(false)
ctx:Expect(Symbol("Test") == Symbol()):ToBe(false)
ctx:Expect(Symbol("Test1") == Symbol("Test2")):ToBe(false)
end)

ctx:Test("should be useable as a table key", function()
local symbol = Symbol()
local t = {}
t[symbol] = 100
ctx:Expect(t[symbol]):ToBe(100)
end)
end)
end

0 comments on commit 2fb028f

Please sign in to comment.