return function()local C=require(script.Parent:FindFirstChild("\067\111\108\108\101\099\116"))describe("\099\104\105\108\100\114\101\110",function()it("\115\104\111\117\108\100 \109\097\116\099\104 \058\071\101\116\067\104\105\108\100\114\101\110\040\041",function()local f=C.children(workspace)local t=workspace:GetChildren();(expect(#f)).to.equal(#t)for C,f in f do(expect(f)).to.equal(t[C])end end)it("\115\104\111\117\108\100 \102\105\108\116\101\114 \105\116\115 \114\101\115\117\108\116\115 \098\121 \116\104\101 \112\114\101\100\105\099\097\116\101",function()local f=C.children(workspace,function(C)return C:IsA("\084\101\114\114\097\105\110")end);(expect(#f)).to.equal(1);(expect(f[1])).to.equal(workspace.Terrain)end)end)describe("\100\101\115\099\101\110\100\097\110\116\115\066\070\083",function()it("\115\104\111\117\108\100 \102\105\108\116\101\114 \105\116\115 \114\101\115\117\108\116\115 \098\121 \116\104\101 \112\114\101\100\105\099\097\116\101",function()local f=C.descendantsBFS(game,function(C)return C:IsA("\084\101\114\114\097\105\110")end);(expect(#f)).to.equal(1);(expect(f[1])).to.equal(workspace.Terrain)end)it("\115\104\111\117\108\100 \100\101\097\100-\101\110\100 \119\104\101\110 \097 \112\114\101\100\105\099\097\116\101 \114\101\115\117\108\116 \105\115 \110\105\108",function()local f=C.descendantsBFS(game,function(C)if C:IsA("\087\111\114\107\115\112\097\099\101")then return nil end return C:IsA("\084\101\114\114\097\105\110")end);(expect(#f)).to.equal(0)end)it("\115\104\111\117\108\100 \114\101\115\112\101\099\116 \100\101\112\116\104",function()local f=workspace:GetChildren()local t=C.descendantsBFS(workspace,function(C,f)return f==1 end);(expect(#t)).to.equal(#f)for C,t in t do(expect(t)).to.equal(f[C])end end)end)describe("\100\101\115\099\101\110\100\097\110\116\115\068\070\083",function()it("\115\104\111\117\108\100 \109\097\116\099\104 \058\071\101\116\068\101\115\099\101\110\100\097\110\116\115\040\041",function()local f=C.descendantsDFS(game)local t=game:GetDescendants();(expect(#f)).to.equal(#t)for C,f in f do(expect(f)).to.equal(t[C])end end)it("\115\104\111\117\108\100 \102\105\108\116\101\114 \105\116\115 \114\101\115\117\108\116\115 \098\121 \116\104\101 \112\114\101\100\105\099\097\116\101",function()local f=C.descendantsDFS(game,function(C)return C:IsA("\084\101\114\114\097\105\110")end);(expect(#f)).to.equal(1);(expect(f[1])).to.equal(workspace.Terrain)end)it("\115\104\111\117\108\100 \100\101\097\100-\101\110\100 \119\104\101\110 \097 \112\114\101\100\105\099\097\116\101 \114\101\115\117\108\116 \105\115 \110\105\108",function()local f=C.descendantsDFS(game,function(C)if C:IsA("\087\111\114\107\115\112\097\099\101")then return nil end return C:IsA("\084\101\114\114\097\105\110")end);(expect(#f)).to.equal(0)end)it("\115\104\111\117\108\100 \114\101\115\112\101\099\116 \100\101\112\116\104",function()local f=workspace:GetChildren()local t=C.descendantsDFS(workspace,function(C,f)return f==1 end);(expect(#t)).to.equal(#f)for C,t in t do(expect(t)).to.equal(f[C])end end)end)end
--!strict

return function()
	local Collect = require(script.Parent:FindFirstChild("Collect"))

	describe("children", function()
		it("should match :GetChildren()", function()
			local children = Collect.children(workspace)
			local childrenRaw = workspace:GetChildren()

			expect(#children).to.equal(#childrenRaw)
			for i, v in children do
				expect(v).to.equal(childrenRaw[i])
			end
		end)

		it("should filter its results by the predicate", function()
			local children = Collect.children(workspace, function(child)
				return child:IsA("Terrain")
			end)

			expect(#children).to.equal(1)
			expect(children[1]).to.equal(workspace.Terrain)
		end)
	end)

	describe("descendantsBFS", function()
		it("should filter its results by the predicate", function()
			local descendants = Collect.descendantsBFS(game, function(child)
				return child:IsA("Terrain")
			end)

			expect(#descendants).to.equal(1)
			expect(descendants[1]).to.equal(workspace.Terrain)
		end)

		it("should dead-end when a predicate result is nil", function()
			local descendants = Collect.descendantsBFS(game, function(child)
				if child:IsA("Workspace") then
					return nil
				end

				return child:IsA("Terrain")
			end)

			expect(#descendants).to.equal(0)
		end)

		it("should respect depth", function()
			local childrenRaw = workspace:GetChildren()
			local children = Collect.descendantsBFS(workspace, function(_, depth)
				return depth == 1
			end)

			expect(#children).to.equal(#childrenRaw)
			for i, v in children do
				expect(v).to.equal(childrenRaw[i])
			end
		end)
	end)

	describe("descendantsDFS", function()
		it("should match :GetDescendants()", function()
			local descendants = Collect.descendantsDFS(game)
			local descendantsRaw = game:GetDescendants()

			expect(#descendants).to.equal(#descendantsRaw)
			for i, v in descendants do
				expect(v).to.equal(descendantsRaw[i])
			end
		end)

		it("should filter its results by the predicate", function()
			local descendants = Collect.descendantsDFS(game, function(child)
				return child:IsA("Terrain")
			end)

			expect(#descendants).to.equal(1)
			expect(descendants[1]).to.equal(workspace.Terrain)
		end)

		it("should dead-end when a predicate result is nil", function()
			local descendants = Collect.descendantsDFS(game, function(child)
				if child:IsA("Workspace") then
					return nil
				end

				return child:IsA("Terrain")
			end)

			expect(#descendants).to.equal(0)
		end)

		it("should respect depth", function()
			local childrenRaw = workspace:GetChildren()
			local children = Collect.descendantsDFS(workspace, function(_, depth)
				return depth == 1
			end)

			expect(#children).to.equal(#childrenRaw)
			for i, v in children do
				expect(v).to.equal(childrenRaw[i])
			end
		end)
	end)
end
