return function()local v=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local h=v.Packages local B=require(h.Llama)local k=B.List local c=k.filter 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 h=1,#v,1 do local B,k=pcall(function()c(unpack(v[h]))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 \114\101\116\117\114\110 \097 \110\101\119 \116\097\098\108\101",function()local v={};(expect(c(v,function() end))).never.to.equal(v)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 v={"\102\111\111","\098\097\114"}local h=0 setmetatable(v,{__newindex=function()h=h+1 end})c(v,function() end);(expect(h)).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 v={"\102\111\111";"\098\097\114";"\098\097\122"}local h={}local function B(v,B)h[B]=v return true end c(v,B)for v,B in pairs(v)do(expect(h[v])).to.equal(B)end for h,B in pairs(h)do(expect(B)).to.equal(v[h])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 v={1;2,3,4,5}local function h(v)return v%2==0 end local B=c(v,h);(expect(#B)).to.equal(2);(expect(B[1])).to.equal(2);(expect(B[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 v={1,2,3}local function h()return true end local B=c(v,h)for v,h in pairs(v)do(expect(B[v])).to.equal(h)end for h,B in pairs(B)do(expect(B)).to.equal(v[h])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 v=false local function h()v=true return true end local B=c({},h);(expect(#B)).to.equal(0);(expect(v)).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 v={6;2,8,6,7}local function h()return false end local B=c(v,h);(expect(#B)).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