local j=script.Parent.Parent.Parent local m=j.Parent local V=require(m.Dev.JestGlobals)local f=V.describe local y=V.expect local Y=V.it local c=require(m.LuauRegExp)local s=require(script.Parent.Parent.equal)f("\101\113\117\097\108",function()Y("\115\104\111\117\108\100 \114\101\116\117\114\110 \102\097\108\115\101 \105\102 \116\121\112\101\115 \100\111\110\'\116 \109\097\116\099\104",function()(y(s(1,"\049"))).toEqual(false);(y(s(1,true))).toEqual(false);(y(s({},"\116\097\098\108\101"))).toEqual(false);(y(s(1,nil))).toEqual(false)end)Y("\115\104\111\117\108\100 \114\101\116\117\114\110 \116\114\117\101 \119\104\101\110 \099\111\109\112\097\114\101\100 \116\111 \105\116\115\101\108\102",function()local j={"\102\111\111"}local m=1 local V=false local f={foo="\102\111\111",bar="\098\097\114"}local Y=f;(y(s(j,j))).toEqual(true);(y(s(m,m))).toEqual(true);(y(s(V,V))).toEqual(true);(y(s(f,f))).toEqual(true);(y(s(f,Y))).toEqual(true)end)Y("\115\104\111\117\108\100 \099\111\109\112\097\114\101 \110\101\115\116\101\100 \116\097\098\108\101\115",function()local j={foo="\102\111\111";bar="\098\097\114";baz={fizz="\102\105\122\122";fuzz="\102\117\122\122"}}local m={foo="\102\111\111";bar="\098\097\114",baz={fizz="\102\105\122\122";fuzz="\102\117\122\122"}}local V={foo="\102\111\111",bar="\098\097\114",baz={fizz="\102\105\122\122";fuzz="\102\097\105\108"}}local f={foo="\102\111\111";bar="\098\097\114";baz={fizz="\102\105\122\122";fail="\102\117\122\122"}}local Y={foo="\102\111\111",bar="\098\097\114";baz={fizz="\102\105\122\122"}};(y(s(j,m))).toEqual(true);(y(s(j,V))).toEqual(false);(y(s(j,f))).toEqual(false);(y(s(j,Y))).toEqual(false)end)Y("\115\104\111\117\108\100 \099\111\109\112\097\114\101 \097\114\114\097\121-\108\105\107\101 \116\097\098\108\101\115",function()local j={"\102\111\111","\098\097\114";"\098\097\122"}local m={"\102\111\111";"\098\097\114";"\098\097\122"}local V={"\098\097\114";"\102\111\111";"\098\097\122"};(y(s(j,m))).toEqual(true);(y(s(j,V))).toEqual(false)end)Y("\115\104\111\117\108\100 \099\111\109\112\097\114\101 \102\117\110\099\116\105\111\110\115",function()local function j() end local m=j local function V() end;(y(s(j,m))).toBe(true);(y(s(j,V))).toBe(false)end)Y("\115\104\111\117\108\100 \102\097\105\108 \105\102 \116\121\112\101 \105\115 \110\111\116 \115\117\112\112\111\114\116\101\100 \097\110\100 \117\115\105\110\103 \'\061\061\' \105\115 \110\111\116 \101\110\111\117\103\104",function()local j=newproxy(false)local m=j local V=newproxy();(y(s(j,m))).toEqual(true);(y(function()s(j,V)end)).toThrowError(c("\117\110\104\097\110\100\108\101\100 \101\113\117\097\108\105\116\121 \099\104\101\099\107"))end)Y("\115\104\111\117\108\100 \114\101\116\117\114\110 \102\097\108\115\101 \116\097\098\108\101 \105\116\101\109\115 \099\111\117\110\116 \100\105\102\102\101\114\115",function()local j={"\102\111\111","\098\097\114"}local m={"\102\111\111"}local V={foo="\102\111\111"}local f={foo="\102\111\111",bar="\098\097\114"}local Y={foo="\102\111\111";bar="\098\097\114";baz="\098\097\122"};(y(s(j,m))).toEqual(false);(y(s(V,f))).toEqual(false);(y(s(f,Y))).toEqual(false)end)end)return{}
--[[
 * Copyright (c) Roblox Corporation
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
]]
local srcWorkspace = script.Parent.Parent.Parent
local rootWorkspace = srcWorkspace.Parent

local JestGlobals = require(rootWorkspace.Dev.JestGlobals)
local describe = JestGlobals.describe
local expect = JestGlobals.expect
local it = JestGlobals.it

local RegExp = require(rootWorkspace.LuauRegExp)
local equal = require(script.Parent.Parent.equal)
describe("equal", function()
	it("should return false if types don't match", function()
		expect(equal(1, "1")).toEqual(false)
		expect(equal(1, true)).toEqual(false)
		expect(equal({}, "table")).toEqual(false)
		expect(equal(1, nil)).toEqual(false)
	end)

	it("should return true when compared to itself", function()
		local a = { "foo" }
		local b = 1
		local c = false
		local d = { foo = "foo", bar = "bar" }
		local e = d
		expect(equal(a, a)).toEqual(true)
		expect(equal(b, b)).toEqual(true)
		expect(equal(c, c)).toEqual(true)
		expect(equal(d, d)).toEqual(true)
		expect(equal(d, e)).toEqual(true)
	end)

	it("should compare nested tables", function()
		local a = { foo = "foo", bar = "bar", baz = { fizz = "fizz", fuzz = "fuzz" } }
		local b = { foo = "foo", bar = "bar", baz = { fizz = "fizz", fuzz = "fuzz" } }
		local c = { foo = "foo", bar = "bar", baz = { fizz = "fizz", fuzz = "fail" } }
		local d = { foo = "foo", bar = "bar", baz = { fizz = "fizz", fail = "fuzz" } }
		local e = { foo = "foo", bar = "bar", baz = { fizz = "fizz" } }
		expect(equal(a, b)).toEqual(true)
		expect(equal(a, c)).toEqual(false)
		expect(equal(a, d)).toEqual(false)
		expect(equal(a, e)).toEqual(false)
	end)

	it("should compare array-like tables", function()
		local a = { "foo", "bar", "baz" }
		local b = { "foo", "bar", "baz" }
		local c = { "bar", "foo", "baz" }
		expect(equal(a, b)).toEqual(true)
		expect(equal(a, c)).toEqual(false)
	end)

	it("should compare functions", function()
		local function a() end
		local b = a
		local function c() end
		expect(equal(a, b)).toBe(true)
		expect(equal(a, c)).toBe(false)
	end)

	it("should fail if type is not supported and using '==' is not enough", function()
		local a = newproxy(false)
		local b = a
		local c = newproxy()
		expect(equal(a, b)).toEqual(true)
		expect(function()
			equal(a, c)
		end).toThrowError(RegExp("unhandled equality check"))
	end)

	it("should return false table items count differs", function()
		local a = { "foo", "bar" }
		local b = { "foo" }
		local c = { foo = "foo" }
		local d = { foo = "foo", bar = "bar" }
		local e = { foo = "foo", bar = "bar", baz = "baz" }
		expect(equal(a, b)).toEqual(false)
		expect(equal(c, d)).toEqual(false)
		expect(equal(d, e)).toEqual(false)
	end)
end)

return {}
