Skip to content

Commit

Permalink
Improve test coverage for shallowEqual
Browse files Browse the repository at this point in the history
  • Loading branch information
LPGhatguy committed May 15, 2018
1 parent d22dc52 commit e210f40
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions lib/shallowEqual.spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
return function()
local shallowEqual = require(script.Parent.shallowEqual)

it("should compare dictionaries", function()
local a = {
a = "a",
b = {},
c = 6,
}

local b = {
b = a.b,
c = a.c,
a = a.a,
}

local c = {
b = {},
a = a.a,
c = a.c,
}

local d = {
a = a.a,
b = a.b,
c = a.c,
d = "hello",
}

expect(shallowEqual(a, a)).to.equal(true)
expect(shallowEqual(a, b)).to.equal(true)
expect(shallowEqual(a, c)).to.equal(false)
expect(shallowEqual(b, c)).to.equal(false)
expect(shallowEqual(a, d)).to.equal(false)
expect(shallowEqual(b, d)).to.equal(false)
end)

it("should handle nil for either argument", function()
local a = {}

expect(shallowEqual(nil, nil)).to.equal(true)
expect(shallowEqual(a, nil)).to.equal(false)
expect(shallowEqual(nil, a)).to.equal(false)
end)
end

0 comments on commit e210f40

Please sign in to comment.