return function()local z=require(script.Parent)local function p(z)local p=typeof(z)if p=="\116\097\098\108\101"then local K=getmetatable(z)if type(K)=="\116\097\098\108\101"then local z=K.__type or K.ClassName if z then return z else return p end else return p end else return p end end describe("\067\105\114\099\117\108\097\114\066\117\102\102\101\114\046\110\101\119",function()it("\115\104\111\117\108\100 \114\101\116\117\114\110 \097 \067\105\114\099\117\108\097\114\066\117\102\102\101\114",function()(expect(p(z.new(1)))).to.equal("\067\105\114\099\117\108\097\114\066\117\102\102\101\114")end)it("\115\104\111\117\108\100 \116\104\114\111\119 \105\102 \116\104\101 \077\097\120\067\097\112\097\099\105\116\121 \105\115\110\'\116 \097 \110\117\109\098\101\114",function()(expect(function()z.new("")end)).to.throw()end)it("\115\104\111\117\108\100 \116\104\114\111\119 \105\102 \116\104\101 \077\097\120\067\097\112\097\099\105\116\121 \105\115 \108\101\115\115 \116\104\097\110 \049",function()(expect(function()z.new(0)end)).to.throw()end)end)describe("\067\105\114\099\117\108\097\114\066\117\102\102\101\114\058\080\117\115\104",function()it("\115\104\111\117\108\100 \114\101\116\117\114\110 \116\104\101 \114\101\109\111\118\101\100 \118\097\108\117\101",function()local p=z.new(1)p:Push(1);(expect(p:Push(2))).to.equal(1)end)it("\115\104\111\117\108\100 \112\117\115\104 \116\111 \116\104\101 \115\116\097\114\116",function()local p=z.new(2)p:Push(1)p:Push(2);(expect(p:PeekAt())).to.equal(2)end)it("\115\104\111\117\108\100 \116\104\114\111\119 \105\102 \116\104\101 \100\097\116\097 \105\115 \110\105\108",function()(expect(function()(z.new(1)):Push(nil)end)).to.throw()end)end)describe("\067\105\114\099\117\108\097\114\066\117\102\102\101\114\058\082\101\112\108\097\099\101",function()it("\115\104\111\117\108\100 \114\101\116\117\114\110 \116\104\101 \114\101\109\111\118\101\100 \118\097\108\117\101",function()local p=z.new(2)p:Push(1)p:Push(2);(expect(p:Replace(1,3))).to.equal(2)end)it("\115\104\111\117\108\100 \116\104\114\111\119 \105\102 \116\104\101 \105\110\100\101\120 \105\115\110\'\116 \097 \110\117\109\098\101\114",function()(expect(function()(z.new(1)):Insert("",{})end)).to.throw()end)it("\115\104\111\117\108\100 \116\104\114\111\119 \105\102 \116\104\101 \118\097\108\117\101 \105\115 \110\105\108",function()(expect(function()local p=z.new(2)p:Push(1)p:Replace(1,nil)end)).to.throw()end)it("\115\104\111\117\108\100 \116\104\114\111\119 \105\102 \116\104\101 \105\110\100\101\120 \100\105\100\110\'\116 \101\120\105\115\116",function()(expect(function()(z.new(2)):Replace(1,true)end)).to.throw()end)end)describe("\067\105\114\099\117\108\097\114\066\117\102\102\101\114\058\073\110\115\101\114\116",function()it("\115\104\111\117\108\100 \114\101\116\117\114\110 \116\104\101 \114\101\112\108\097\099\101\100 \118\097\108\117\101",function()local p=z.new(2)p:Push(1)p:Push(2);(expect(p:Insert(1,3))).to.equal(1)end)it("\115\104\111\117\108\100 \116\104\114\111\119 \105\102 \116\104\101 \105\110\100\101\120 \105\115\110\'\116 \097 \110\117\109\098\101\114",function()(expect(function()(z.new(2)):Insert("",{})end)).to.throw()end)it("\115\104\111\117\108\100 \116\104\114\111\119 \105\102 \116\104\101 \118\097\108\117\101 \105\115 \110\105\108",function()(expect(function()(z.new(2)):Insert(1,nil)end)).to.throw()end)end)describe("\067\105\114\099\117\108\097\114\066\117\102\102\101\114\058\073\115\069\109\112\116\121",function()it("\115\104\111\117\108\100 \114\101\116\117\114\110 \097 \098\111\111\108\101\097\110",function()(expect((z.new(1)):IsEmpty())).to.be.a("\098\111\111\108\101\097\110")end)it("\115\104\111\117\108\100 \114\101\116\117\114\110 \116\104\101 \099\111\114\114\101\099\116 \118\097\108\117\101",function()local p=z.new(2);(expect(p:IsEmpty())).to.equal(true)p:Push(1);(expect(p:IsEmpty())).to.equal(false)end)end)describe("\067\105\114\099\117\108\097\114\066\117\102\102\101\114\058\073\115\070\117\108\108",function()it("\115\104\111\117\108\100 \114\101\116\117\114\110 \097 \098\111\111\108\101\097\110",function()(expect((z.new(1)):IsFull())).to.be.a("\098\111\111\108\101\097\110")end)it("\115\104\111\117\108\100 \114\101\116\117\114\110 \116\104\101 \099\111\114\114\101\099\116 \118\097\108\117\101",function()local p=z.new(1);(expect(p:IsFull())).to.equal(false)p:Push(1);(expect(p:IsFull())).to.equal(true)end)end)describe("\067\105\114\099\117\108\097\114\066\117\102\102\101\114\058\067\108\101\097\114",function()it("\115\104\111\117\108\100 \114\101\116\117\114\110 \097 \076\105\110\107\101\100\076\105\115\116",function()(expect(p((z.new(5)):Clear()))).to.equal("\067\105\114\099\117\108\097\114\066\117\102\102\101\114")end)it("\115\104\111\117\108\100 \114\101\109\111\118\101 \101\118\101\114\121\116\104\105\110\103",function()local p=z.new(2)p:Push(1)p:Clear();(expect(p:IsEmpty())).to.equal(true)end)end)end
return function()
	local CircularBuffer = require(script.Parent)

	local function TypeOf(Value)
		local ValueType = typeof(Value)
		if ValueType == "table" then
			local Metatable = getmetatable(Value)
			if type(Metatable) == "table" then
				local CustomType = Metatable.__type or Metatable.ClassName
				if CustomType then
					return CustomType
				else
					return ValueType
				end
			else
				return ValueType
			end
		else
			return ValueType
		end
	end

	describe("CircularBuffer.new", function()
		it("should return a CircularBuffer", function()
			expect(TypeOf(CircularBuffer.new(1))).to.equal("CircularBuffer")
		end)

		it("should throw if the MaxCapacity isn't a number", function()
			expect(function()
				CircularBuffer.new("")
			end).to.throw()
		end)

		it("should throw if the MaxCapacity is less than 1", function()
			expect(function()
				CircularBuffer.new(0)
			end).to.throw()
		end)
	end)

	describe("CircularBuffer:Push", function()
		it("should return the removed value", function()
			local Buffer = CircularBuffer.new(1)
			Buffer:Push(1)
			expect(Buffer:Push(2)).to.equal(1)
		end)

		it("should push to the start", function()
			local Buffer = CircularBuffer.new(2)
			Buffer:Push(1)
			Buffer:Push(2)
			expect(Buffer:PeekAt()).to.equal(2)
		end)

		it("should throw if the data is nil", function()
			expect(function()
				CircularBuffer.new(1):Push(nil)
			end).to.throw()
		end)
	end)

	describe("CircularBuffer:Replace", function()
		it("should return the removed value", function()
			local Buffer = CircularBuffer.new(2)
			Buffer:Push(1)
			Buffer:Push(2)
			expect(Buffer:Replace(1, 3)).to.equal(2)
		end)

		it("should throw if the index isn't a number", function()
			expect(function()
				CircularBuffer.new(1):Insert("", {})
			end).to.throw()
		end)

		it("should throw if the value is nil", function()
			expect(function()
				local Buffer = CircularBuffer.new(2)
				Buffer:Push(1)
				Buffer:Replace(1, nil)
			end).to.throw()
		end)

		it("should throw if the index didn't exist", function()
			expect(function()
				CircularBuffer.new(2):Replace(1, true)
			end).to.throw()
		end)
	end)

	describe("CircularBuffer:Insert", function()
		it("should return the replaced value", function()
			local Buffer = CircularBuffer.new(2)
			Buffer:Push(1)
			Buffer:Push(2)
			expect(Buffer:Insert(1, 3)).to.equal(1)
		end)

		it("should throw if the index isn't a number", function()
			expect(function()
				CircularBuffer.new(2):Insert("", {})
			end).to.throw()
		end)

		it("should throw if the value is nil", function()
			expect(function()
				CircularBuffer.new(2):Insert(1, nil)
			end).to.throw()
		end)
	end)

	describe("CircularBuffer:IsEmpty", function()
		it("should return a boolean", function()
			expect(CircularBuffer.new(1):IsEmpty()).to.be.a("boolean")
		end)

		it("should return the correct value", function()
			local Buffer = CircularBuffer.new(2)
			expect(Buffer:IsEmpty()).to.equal(true)
			Buffer:Push(1)
			expect(Buffer:IsEmpty()).to.equal(false)
		end)
	end)

	describe("CircularBuffer:IsFull", function()
		it("should return a boolean", function()
			expect(CircularBuffer.new(1):IsFull()).to.be.a("boolean")
		end)

		it("should return the correct value", function()
			local Buffer = CircularBuffer.new(1)
			expect(Buffer:IsFull()).to.equal(false)
			Buffer:Push(1)
			expect(Buffer:IsFull()).to.equal(true)
		end)
	end)

	describe("CircularBuffer:Clear", function()
		it("should return a LinkedList", function()
			expect(TypeOf(CircularBuffer.new(5):Clear())).to.equal("CircularBuffer")
		end)

		it("should remove everything", function()
			local Buffer = CircularBuffer.new(2)
			Buffer:Push(1)
			Buffer:Clear()
			expect(Buffer:IsEmpty()).to.equal(true)
		end)
	end)
end
