return function()local U=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local s=U.Packages local H=require(s.Llama)local X=H.List local Y=X.filter it("\115\104\111\117\108\100 \118\097\108\105\100\097\116\101 \116\121\112\101\115",function()local U={{0},{{},0},{0;function() end}}for s=1,#U,1 do local H,X=pcall(function()Y(unpack(U[s]))end);(expect(string.find(X,"\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 \097 \110\101\119 \116\097\098\108\101",function()local U={};(expect(Y(U,function() end))).never.to.equal(U)end)it("\115\104\111\117\108\100 \110\111\116 \109\117\116\097\116\101 \112\097\115\115\101\100 \105\110 \116\097\098\108\101\115",function()local U={"\102\111\111";"\098\097\114"}local s=0 setmetatable(U,{__newindex=function()s=s+1 end})Y(U,function() end);(expect(s)).to.equal(0)end)it("\115\104\111\117\108\100 \099\097\108\108 \116\104\101 \099\097\108\108\098\097\099\107 \102\111\114 \101\097\099\104 \101\108\101\109\101\110\116",function()local U={"\102\111\111","\098\097\114","\098\097\122"}local s={}local function H(U,H)s[H]=U return true end Y(U,H)for U,H in pairs(U)do(expect(s[U])).to.equal(H)end for s,H in pairs(s)do(expect(H)).to.equal(U[s])end end)it("\115\104\111\117\108\100 \099\111\114\114\101\099\116\108\121 \117\115\101 \116\104\101 \102\105\108\116\101\114 \099\097\108\108\098\097\099\107",function()local U={1;2,3,4;5}local function s(U)return U%2==0 end local H=Y(U,s);(expect(#H)).to.equal(2);(expect(H[1])).to.equal(2);(expect(H[2])).to.equal(4)end)it("\115\104\111\117\108\100 \099\111\112\121 \116\104\101 \108\105\115\116 \099\111\114\114\101\099\116\108\121",function()local U={1;2;3}local function s()return true end local H=Y(U,s)for U,s in pairs(U)do(expect(H[U])).to.equal(s)end for s,H in pairs(H)do(expect(H)).to.equal(U[s])end 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 U=false local function s()U=true return true end local H=Y({},s);(expect(#H)).to.equal(0);(expect(U)).to.equal(false)end)it("\115\104\111\117\108\100 \114\101\109\111\118\101 \097\108\108 \101\108\101\109\101\110\116\115 \102\114\111\109 \097 \108\105\115\116 \119\104\101\110 \099\097\108\108\098\097\099\107 \114\101\116\117\114\110 \097\108\119\097\121\115 \102\097\108\115\101",function()local U={6,2;8;6,7}local function s()return false end local H=Y(U,s);(expect(#H)).to.equal(0)end)end
return function()
	local ReplicatedStorage = game:GetService("ReplicatedStorage")

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

	local List = Llama.List
	local filter = List.filter

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

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

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

	it("should return a new table", function()
		local a = {}

		expect(filter(a, function() end)).never.to.equal(a)
	end)

	it("should not mutate passed in tables", function()
		local a = { "foo", "bar" }
		local mutations = 0

		setmetatable(a, {
			__newindex = function()
				mutations = mutations + 1
			end,
		})

		filter(a, function() end)

		expect(mutations).to.equal(0)
	end)

	it("should call the callback for each element", function()
		local a = {
			"foo",
			"bar",
			"baz",
		}
		local copy = {}

		local function copyCallback(value, index)
			copy[index] = value
			return true
		end

		filter(a, copyCallback)

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

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

	it("should correctly use the filter callback", function()
		local a = { 1, 2, 3, 4, 5 }

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

		local b = filter(a, onlyEvens)

		expect(#b).to.equal(2)
		expect(b[1]).to.equal(2)
		expect(b[2]).to.equal(4)
	end)

	it("should copy the list correctly", function()
		local a = { 1, 2, 3 }

		local function keepAll()
			return true
		end

		local b = filter(a, keepAll)

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

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

	it("should work with an empty table", function()
		local called = false

		local function callback()
			called = true
			return true
		end

		local a = filter({}, callback)

		expect(#a).to.equal(0)
		expect(called).to.equal(false)
	end)

	it("should remove all elements from a list when callback return always false", function()
		local a = { 6, 2, 8, 6, 7 }

		local function removeAll()
			return false
		end

		local b = filter(a, removeAll)

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