local w=require(script.Parent.Comparators)local O=require(script.Parent.Parent.Constants)local T=require(script.Parent.Parent.Parent.Shared.Util)return function()describe("\067\111\109\112\097\114\097\116\111\114\115",function()it("\115\104\111\117\108\100 \099\111\109\112\097\114\101 \098\121 \114\101\102\101\114\101\110\099\101",function()(expect(w.reference(1,1))).to.equal(false);(expect(w.reference(1,2))).to.equal(true);(expect(w.reference({},{}))).to.equal(true)local O={};(expect(w.reference(O,O))).to.equal(false)end)it("\115\104\111\117\108\100 \099\111\109\112\097\114\101 \098\121 \118\097\108\117\101",function()(expect(w.value(1,1))).to.equal(false);(expect(w.value(1,2))).to.equal(true);(expect(w.value({},{}))).to.equal(false);(expect(w.value({1},{1}))).to.equal(false);(expect(w.value({1},{2}))).to.equal(true)local O={};(expect(w.value(O,O))).to.equal(false);(expect(w.value({key=1},{key=1}))).to.equal(false);(expect(w.value({key=1},{key=2}))).to.equal(true)local I={key=1;sub={subkey="\104\101\108\108\111"}}local q=T.deepCopy(I);(expect(w.value(I,q))).to.equal(false)end)it("\115\104\111\117\108\100 \099\111\109\112\097\114\101 \119\105\116\104\105\110 \097 \114\097\110\103\101",function()(expect((w.within(1))(1,5))).to.equal(true);(expect((w.within(1))(1,1.5))).to.equal(false);(expect(O.COMPARATOR_NEAR_DEFAULT>0)).to.equal(true);(expect(w.near(0,O.COMPARATOR_NEAR_DEFAULT/2))).to.equal(false);(expect(w.near(0,O.COMPARATOR_NEAR_DEFAULT*2))).to.equal(true)end)end)describe("\067\111\109\112\097\114\097\116\111\114 \117\116\105\108\105\116\105\101\115",function()it("\115\104\111\117\108\100 \099\111\109\112\097\114\101 \098\121 \112\114\111\112\101\114\116\121",function()local O=w.structure({reference=w.reference;value=w.value,near=w.near})local T={x=1};(expect(O({reference=T;value=T;near=0},{reference=T;value={x=1};near=.0001}))).to.equal(false);(expect(O({reference=T,new=5},{reference=T}))).to.equal(true)end)end)end
local Comparators = require(script.Parent.Comparators)
local Constants = require(script.Parent.Parent.Constants)
local Util = require(script.Parent.Parent.Parent.Shared.Util)

return function ()
	describe("Comparators", function()
		it("should compare by reference", function()
			expect(Comparators.reference(1, 1)).to.equal(false)
			expect(Comparators.reference(1, 2)).to.equal(true)
			expect(Comparators.reference({}, {})).to.equal(true)

			local a = {}
			expect(Comparators.reference(a, a)).to.equal(false)
		end)

		it("should compare by value", function()
			expect(Comparators.value(1, 1)).to.equal(false)
			expect(Comparators.value(1, 2)).to.equal(true)
			expect(Comparators.value({}, {})).to.equal(false)
			expect(Comparators.value({1}, {1})).to.equal(false)
			expect(Comparators.value({1}, {2})).to.equal(true)

			local a = {}
			expect(Comparators.value(a, a)).to.equal(false)

			expect(Comparators.value({key = 1}, {key = 1})).to.equal(false)
			expect(Comparators.value({key = 1}, {key = 2})).to.equal(true)

			local nested = {key = 1, sub = {subkey = "hello"}}
			local nestedCopy = Util.deepCopy(nested)
			expect(Comparators.value(nested, nestedCopy)).to.equal(false)
		end)

		it("should compare within a range", function()
			expect(Comparators.within(1)(1, 5)).to.equal(true)
			expect(Comparators.within(1)(1, 1.5)).to.equal(false)

			expect(Constants.COMPARATOR_NEAR_DEFAULT > 0).to.equal(true)
			expect(Comparators.near(0, Constants.COMPARATOR_NEAR_DEFAULT/2)).to.equal(false)
			expect(Comparators.near(0, Constants.COMPARATOR_NEAR_DEFAULT*2)).to.equal(true)
		end)
	end)

	describe("Comparator utilities", function()
		it("should compare by property", function()
			local compare = Comparators.structure({
				reference = Comparators.reference;
				value = Comparators.value;
				near = Comparators.near;
			})

			local t = { x = 1 }

			expect(compare({
				reference = t;
				value = t;
				near = 0;
			}, {
				reference = t;
				value = { x = 1 };
				near = 0.0001;
			})).to.equal(false)

			expect(compare({
				reference = t;
				new = 5;
			}, {
				reference = t;
			})).to.equal(true)
		end)
	end)
end
