return function()local d=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local S=d.Packages local E=require(S.Llama)local P=E.List local V=P.reduce it("\115\104\111\117\108\100 \118\097\108\105\100\097\116\101 \116\121\112\101\115",function()local d={{0};{{};0};{0;function() end}}for S=1,#d,1 do local E,P=pcall(function()V(unpack(d[S]))end);(expect(string.find(P,"\101\120\112\101\099\116\101\100\044 \103\111\116"))).to.be.ok()end end)it("\115\104\111\117\108\100 \099\097\108\108 \116\104\101 \114\101\100\117\099\101\114",function()local d={1,2;3}local S=0 V(d,function()S=S+1 end,0);(expect(S)).to.equal(3)end)it("\115\104\111\117\108\100 \110\111\116 \099\097\108\108 \116\104\101 \114\101\100\117\099\101\114 \119\104\101\110 \116\104\101 \108\105\115\116 \105\115 \101\109\112\116\121",function()local d=false V({},function()d=true end);(expect(d)).to.equal(false)end)it("\115\104\111\117\108\100 \099\097\108\108 \116\104\101 \114\101\100\117\099\101\114 \102\111\114 \101\097\099\104 \101\108\101\109\101\110\116",function()local d={4;5;6}local S={}V(d,function(d,E,P)S[P]=E return d end,0);(expect(#S)).to.equal(#d)for d,E in pairs(d)do(expect(E)).to.equal(S[d])end end)it("\115\104\111\117\108\100 \112\097\115\115 \116\104\101 \115\097\109\101 \109\111\100\105\102\105\101\100 \105\110\105\116\105\097\108 \118\097\108\117\101 \116\111 \116\104\101 \114\101\100\117\099\101\114",function()local d={5,4,3}local S={}V(d,function(d)(expect(d)).to.equal(S)return d end,S)end)it("\115\104\111\117\108\100 \099\097\108\108 \116\104\101 \114\101\100\117\099\101\114 \105\110 \116\104\101 \099\111\114\114\101\099\116 \111\114\100\101\114",function()local d={5;4;3}local S=1 V(d,function(E,P)(expect(P)).to.equal(d[S])S=S+1 return E end,0)end)it("\115\104\111\117\108\100 \097\099\099\101\112\116 \097 \102\097\108\115\121 \105\110\105\116\105\097\108 \114\101\100\117\099\116\105\111\110",function()local d={1,2}local S=V(d,function(d)return d end,false);(expect(S)).to.equal(false)end)it("\115\104\111\117\108\100 \109\097\107\101 \116\104\101 \105\110\105\116\105\097\108 \114\101\100\117\099\116\105\111\110 \116\104\101 \102\105\114\115\116 \118\097\108\117\101 \111\102 \116\104\101 \108\105\115\116 \105\102 \110\111\116 \112\114\111\118\105\100\101\100",function()local d={1,2;3}local S=0 local E=V(d,function(d,E)S=S+1 return d+E end);(expect(S)).to.equal(2);(expect(E)).to.equal(6)end)end
return function()
	local ReplicatedStorage = game:GetService("ReplicatedStorage")

	local Packages = ReplicatedStorage.Packages
	local Llama = require(Packages.Llama)

	local List = Llama.List
	local reduce = List.reduce

	it("should validate types", function()
		local args = {
			{ 0 },
			{ {}, 0 },
			{ 0, function() end },
		}

		for i = 1, #args do
			local _, err = pcall(function()
				reduce(unpack(args[i]))
			end)

			expect(string.find(err, "expected, got")).to.be.ok()
		end
	end)

	it("should call the reducer", function()
		local a = { 1, 2, 3 }
		local called = 0

		reduce(a, function()
			called = called + 1
		end, 0)

		expect(called).to.equal(3)
	end)

	it("should not call the reducer when the list is empty", function()
		local called = false

		reduce({}, function()
			called = true
		end)

		expect(called).to.equal(false)
	end)

	it("should call the reducer for each element", function()
		local a = { 4, 5, 6 }
		local copy = {}

		reduce(a, function(accum, value, index)
			copy[index] = value
			return accum
		end, 0)

		expect(#copy).to.equal(#a)

		for key, value in pairs(a) do
			expect(value).to.equal(copy[key])
		end
	end)

	it("should pass the same modified initial value to the reducer", function()
		local a = { 5, 4, 3 }
		local initialValue = {}

		reduce(a, function(accum)
			expect(accum).to.equal(initialValue)
			return accum
		end, initialValue)
	end)

	it("should call the reducer in the correct order", function()
		local a = { 5, 4, 3 }
		local index = 1

		reduce(a, function(accum, value)
			expect(value).to.equal(a[index])
			index = index + 1

			return accum
		end, 0)
	end)

	it("should accept a falsy initial reduction", function()
		local a = { 1, 2 }
		local result = reduce(a, function(acc)
			return acc
		end, false)

		expect(result).to.equal(false)
	end)

	it("should make the initial reduction the first value of the list if not provided", function()
		local a = { 1, 2, 3 }
		local called = 0

		local sum = reduce(a, function(accum, value)
			called = called + 1
			return accum + value
		end)

		expect(called).to.equal(2)
		expect(sum).to.equal(6)
	end)
end