return function()local p=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local s=p.Packages local P=require(s.Llama)local k=P.List local J=k.reduce it("\115\104\111\117\108\100 \118\097\108\105\100\097\116\101 \116\121\112\101\115",function()local p={{0},{{};0};{0,function() end}}for s=1,#p,1 do local P,k=pcall(function()J(unpack(p[s]))end);(expect(string.find(k,"\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 p={1;2,3}local s=0 J(p,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 p=false J({},function()p=true end);(expect(p)).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 p={4;5,6}local s={}J(p,function(p,P,k)s[k]=P return p end,0);(expect(#s)).to.equal(#p)for p,P in pairs(p)do(expect(P)).to.equal(s[p])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 p={5,4;3}local s={}J(p,function(p)(expect(p)).to.equal(s)return p 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 p={5;4,3}local s=1 J(p,function(P,k)(expect(k)).to.equal(p[s])s=s+1 return P 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 p={1;2}local s=J(p,function(p)return p 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 p={1,2;3}local s=0 local P=J(p,function(p,P)s=s+1 return p+P end);(expect(s)).to.equal(2);(expect(P)).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