From 2fb028fa1fa15eae9e90374bda893060b70f288f Mon Sep 17 00:00:00 2001 From: Stephen Leitnick Date: Tue, 10 Dec 2024 09:47:06 -0500 Subject: [PATCH] Symbol test --- modules/symbol/init.spec.luau | 33 ------------------------------- modules/symbol/init.test.luau | 37 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 33 deletions(-) delete mode 100644 modules/symbol/init.spec.luau create mode 100644 modules/symbol/init.test.luau diff --git a/modules/symbol/init.spec.luau b/modules/symbol/init.spec.luau deleted file mode 100644 index a8b4f580..00000000 --- a/modules/symbol/init.spec.luau +++ /dev/null @@ -1,33 +0,0 @@ -return function() - local Symbol = require(script.Parent) - - describe("Constructor", function() - it("should create a new symbol", function() - local symbol = Symbol("Test") - expect(symbol).to.be.a("userdata") - expect(symbol == symbol).to.equal(true) - expect(tostring(symbol)).to.equal("Symbol(Test)") - end) - - it("should create a new symbol with no name", function() - local symbol = Symbol() - expect(symbol).to.be.a("userdata") - expect(symbol == symbol).to.equal(true) - expect(tostring(symbol)).to.equal("Symbol()") - end) - - it("should be unique regardless of the name", function() - expect(Symbol("Test") == Symbol("Test")).to.equal(false) - expect(Symbol() == Symbol()).to.equal(false) - expect(Symbol("Test") == Symbol()).to.equal(false) - expect(Symbol("Test1") == Symbol("Test2")).to.equal(false) - end) - - it("should be useable as a table key", function() - local symbol = Symbol() - local t = {} - t[symbol] = 100 - expect(t[symbol]).to.equal(100) - end) - end) -end diff --git a/modules/symbol/init.test.luau b/modules/symbol/init.test.luau new file mode 100644 index 00000000..09fb9326 --- /dev/null +++ b/modules/symbol/init.test.luau @@ -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