return function()local v=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local E=v.Packages local L=require(E.Llama)local C=L.List local p=C.findWhereLast it("\115\104\111\117\108\100 \118\097\108\105\100\097\116\101 \116\121\112\101\115",function()local v={{0},{{};0};{0,function() end}}for E=1,#v,1 do local L,C=pcall(function()p(unpack(v[E]))end);(expect(string.find(C,"\101\120\112\101\099\116\101\100\044 \103\111\116"))).to.be.ok()end end)it("\115\104\111\117\108\100 \114\101\116\117\114\110 \116\104\101 \099\111\114\114\101\099\116 \105\110\100\101\120",function()local v={1;5,10,7}local E=function(v)return v%2==0 end local L=function(v)return v%2==1 end;(expect(p(v,E))).to.equal(3);(expect(p(v,L))).to.equal(4)end)it("\115\104\111\117\108\100 \114\101\116\117\114\110 \110\105\108 \119\104\101\110 \116\104\101 \119\104\101\110 \110\111 \118\097\108\117\101 \115\097\116\105\115\102\105\101\115 \116\104\101 \112\114\101\100\105\099\097\116\101",function()local v={1;2,3}local E=function(v)return v==4 end;(expect(p(v,E))).never.to.be.ok()end)it("\115\104\111\117\108\100 \119\111\114\107 \119\105\116\104 \097\110 \101\109\112\116\121 \116\097\098\108\101",function()local v=function()return true end;(expect(p({},v))).never.to.be.ok()end)it("\115\104\111\117\108\100 \114\101\116\117\114\110 \116\104\101 \105\110\100\101\120 \111\102 \116\104\101 \108\097\115\116 \118\097\108\117\101 \102\111\114 \119\104\105\099\104 \116\104\101 \112\114\101\100\105\099\097\116\101 \105\115 \116\114\117\101",function()local v={1,1;1;2,2}local E=function(v)return v==2 end;(expect(p(v,E))).to.equal(5)end)it("\115\104\111\117\108\100 \114\101\116\117\114\110 \116\104\101 \105\110\100\101\120 \111\102 \116\104\101 \108\097\115\116 \118\097\108\117\101 \102\111\114 \119\104\105\099\104 \116\104\101 \112\114\101\100\105\099\097\116\101 \105\115 \116\114\117\101 \102\114\111\109 \115\116\097\114\116 \105\110\100\101\120",function()local v={1;1,1;2,2}local E=function(v)return v==2 end;(expect(p(v,E,4))).to.equal(4)end)it("\115\104\111\117\108\100 \097\099\099\101\112\116 \097 \048 \111\114 \110\101\103\097\116\105\118\101 \115\116\097\114\116 \105\110\100\101\120",function()local v={1,3;3;2;3;3,2}local E=function(v)return v==2 end;(expect(p(v,E,-1))).to.equal(4);(expect(p(v,E,0))).to.equal(7)end)it("\115\104\111\117\108\100 \097\108\108\111\119 \097\099\099\101\115\115 \116\111 \098\111\116\104 \118\097\108\117\101 \097\110\100 \105\110\100\101\120 \105\110 \116\104\101 \112\114\101\100\105\099\097\116\101 \102\117\110\099\116\105\111\110",function()local v={1;1;2;2;1}local E=function(v,E)return v+E==5 end;(expect(p(v,E))).to.equal(3)end)end
return function()
	local ReplicatedStorage = game:GetService("ReplicatedStorage")

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

	local List = Llama.List
	local findWhereLast = List.findWhereLast

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

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

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

	it("should return the correct index", function()
		local numbers = { 1, 5, 10, 7 }

		local isEven = function(value)
			return value % 2 == 0
		end

		local isOdd = function(value)
			return value % 2 == 1
		end

		expect(findWhereLast(numbers, isEven)).to.equal(3)
		expect(findWhereLast(numbers, isOdd)).to.equal(4)
	end)

	it("should return nil when the when no value satisfies the predicate", function()
		local numbers = { 1, 2, 3 }
		
		local isFour = function(value)
			return value == 4
		end

		expect(findWhereLast(numbers, isFour)).never.to.be.ok()
	end)

	it("should work with an empty table", function()
		local anything = function()
			return true
		end

		expect(findWhereLast({}, anything)).never.to.be.ok()
	end)

	it("should return the index of the last value for which the predicate is true", function()
		local a = { 1, 1, 1, 2, 2 }

		local isTwo = function(value)
			return value == 2
		end

		expect(findWhereLast(a, isTwo)).to.equal(5)
	end)

	it("should return the index of the last value for which the predicate is true from start index", function()
		local a = { 1, 1, 1, 2, 2 }

		local isTwo = function(value)
			return value == 2
		end

		expect(findWhereLast(a, isTwo, 4)).to.equal(4)
	end)

	it("should accept a 0 or negative start index", function()
		local a = { 1, 3, 3, 2, 3, 3, 2 }

		local isTwo = function(value)
			return value == 2
		end

		expect(findWhereLast(a, isTwo, -1)).to.equal(4)
		expect(findWhereLast(a, isTwo, 0)).to.equal(7)
	end)

	it("should allow access to both value and index in the predicate function", function()
		local a = { 1, 1, 2, 2, 1 }

		local sumValueAndIndexToFive = function(value, index)
			return value + index == 5
		end

		expect(findWhereLast(a, sumValueAndIndexToFive)).to.equal(3)
	end)
end