Skip to content

Commit

Permalink
Add tests for the isSimilar function
Browse files Browse the repository at this point in the history
  • Loading branch information
mskfox committed Feb 3, 2024
1 parent eb18b71 commit 39d92f9
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/Utility/isSimilar.spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
local Package = game:GetService("ReplicatedStorage").Fusion
local isSimilar = require(Package.Utility.isSimilar)

return function()
it("should return similar for identical values", function()
local value = 123

expect(isSimilar(value, value)).to.equal(true)
end)

it("should return non-similar for different values", function()
local value1 = 123
local value2 = 321

expect(isSimilar(value1, value2)).to.equal(false)
end)

it("should return similar for any NaN values", function()
local nan1 = 0 / 0
local nan2 = math.huge / math.huge

expect(isSimilar(nan1, nan1)).to.equal(true)
expect(isSimilar(nan1, nan2)).to.equal(true)
end)

it("should return non-similar for any tables", function()
local initialTable = { foo = 123, bar = "hello" }
local similarTable = { foo = 123, bar = "hello" }
local differentTable = { foo = 321, bar = "world" }

expect(isSimilar(initialTable, initialTable)).to.equal(false)
expect(isSimilar(initialTable, similarTable)).to.equal(false)
expect(isSimilar(initialTable, differentTable)).to.equal(false)
end)
end

1 comment on commit 39d92f9

@mskfox
Copy link
Contributor Author

@mskfox mskfox commented on 39d92f9 Feb 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In reference to #285

Please sign in to comment.