local s=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local u=require(s.Packages.iter)return function()describe("\097\110\121",function()it("\115\104\111\117\108\100 \114\101\116\117\114\110 \116\114\117\101 \105\102 \097\110\121 \112\114\101\100\105\099\097\116\101 \105\115 \116\114\117\101",function()local s=(u.new({1,2,3})):any(function()return true end);(expect(s)).to.be.equal(true)end)it("\115\104\111\117\108\100 \114\101\116\117\114\110 \102\097\108\115\101 \105\102 \097\108\108 \112\114\101\100\105\099\097\116\101\115 \097\114\101 \102\097\108\115\101",function()local s=(u.new({1;2;3})):any(function()return false end);(expect(s)).to.be.equal(false)end)it("\115\104\111\117\108\100 \114\101\116\117\114\110 \102\097\108\115\101 \105\102 \116\104\101 \105\116\101\114\097\116\111\114 \105\115 \101\109\112\116\121",function()local s=(u.new({})):any(function()return true end);(expect(s)).to.be.equal(false)end)it("\115\104\111\117\108\100 \115\104\111\114\116 \099\105\114\099\117\105\116 \111\110 \116\104\101 \102\105\114\115\116 \116\114\117\101",function()local s={1;2,3}local c=u.new(s);(expect(c:any(function(s,u)return u==2 end))).to.be.equal(true);(expect(c:next())).to.be.equal(3)end)it("\115\104\111\117\108\100 \115\104\111\114\116 \099\105\114\099\117\105\116 \111\110 \116\104\101 \102\105\114\115\116 \116\114\117\101 \119\104\101\110 \097\112\112\101\110\100\101\100 \116\111 \111\116\104\101\114 \111\112\101\114\097\116\105\111\110\115",function()local s={1;2,3}local c=0 local E=0 local k=u.new(s);(expect(((k:map(function(s,u)c+=1;(expect(s)).to.be.a("\110\117\109\098\101\114");(expect(u)).to.be.a("\110\117\109\098\101\114")return-u end)):filter(function(s,u)E+=1;(expect(s)).to.be.a("\110\117\109\098\101\114");(expect(u)).to.be.a("\110\117\109\098\101\114")return true end)):all(function(s,u)(expect(s)).to.be.a("\110\117\109\098\101\114");(expect(u)).to.be.a("\110\117\109\098\101\114")return u~=-2 end))).to.be.equal(false);(expect(c)).to.be.equal(2);(expect(E)).to.be.equal(2);(expect(k:next())).to.be.equal(3)end)end)end
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local iter = require(ReplicatedStorage.Packages.iter)

return function()
	describe("any", function()
		it("should return true if any predicate is true", function()
			local result = iter.new({ 1, 2, 3 }):any(function()
				return true
			end)
			expect(result).to.be.equal(true)
		end)

		it("should return false if all predicates are false", function()
			local result = iter.new({ 1, 2, 3 }):any(function()
				return false
			end)
			expect(result).to.be.equal(false)
		end)

		it("should return false if the iterator is empty", function()
			local result = iter.new({}):any(function()
				return true
			end)
			expect(result).to.be.equal(false)
		end)

		it("should short circuit on the first true", function()
			local a = { 1, 2, 3 }

			local iterator = iter.new(a)

			expect(iterator:any(function(_, x)
				return x == 2
			end)).to.be.equal(true)

			-- we can still use `iter`, as there are more elements.
			expect(iterator:next()).to.be.equal(3)
		end)

		it("should short circuit on the first true when appended to other operations", function()
			local a = { 1, 2, 3 }
			local numCalledMap = 0
			local numCalledFilter = 0

			local iterator = iter.new(a)

			expect(iterator
				:map(function(i, x)
					numCalledMap += 1
					expect(i).to.be.a("number")
					expect(x).to.be.a("number")
					return -x
				end)
				:filter(function(i, x)
					numCalledFilter += 1
					expect(i).to.be.a("number")
					expect(x).to.be.a("number")
					return true
				end)
				:all(function(i, x)
					expect(i).to.be.a("number")
					expect(x).to.be.a("number")
					return x ~= -2
				end)).to.be.equal(false)

			expect(numCalledMap).to.be.equal(2)
			expect(numCalledFilter).to.be.equal(2)

			-- we can still use `iter`, as there are more elements.
			expect(iterator:next()).to.be.equal(3)
		end)
	end)
end
