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.flatten it("\115\104\111\117\108\100 \118\097\108\105\100\097\116\101 \116\121\112\101\115",function()local p,s=pcall(function()J(0)end);(expect(string.find(s,"\101\120\112\101\099\116\101\100\044 \103\111\116"))).to.be.ok()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 p={};(expect(J(p))).never.to.equal(p)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 p={"\102\111\111","\098\097\114"}local s=0 setmetatable(p,{__newindex=function()s=s+1 end})J(p);(expect(s)).to.equal(0)end)it("\115\104\111\117\108\100 \102\108\097\116\116\101\110 \116\104\101 \103\105\118\101\110 \116\097\098\108\101",function()local p={{"\102\111\111";"\098\097\114"};{"\098\097\122","\113\117\120"}}local s={"\102\111\111","\098\097\114","\098\097\122";"\113\117\120"}local P=J(p)for p,P in pairs(P)do(expect(P)).to.equal(s[p])end end)it("\115\104\111\117\108\100 \115\112\114\101\097\100 \111\117\116 \101\108\101\109\101\110\116\115",function()local p={"\102\111\111",{"\098\097\114";"\098\097\122"},{"\098\097\114","\098\097\122"};"\113\117\120"}local s={"\102\111\111";"\098\097\114","\098\097\122";"\098\097\114";"\098\097\122";"\113\117\120"}local P=J(p)for p,P in pairs(P)do(expect(P)).to.equal(s[p])end end)it("\115\104\111\117\108\100 \102\108\097\116\116\101\110 \099\111\109\112\108\101\116\101\108\121",function()local p={1;{2;{3;{4}}}}local s={1,2;3;4}local P=J(p)for p,P in pairs(P)do(expect(P)).to.equal(s[p])end end)it("\115\104\111\117\108\100 \119\111\114\107 \119\105\116\104 \097\110 \101\109\112\116\121 \108\105\115\116",function()local p={}local s=J(p,function() end);(expect(s)).to.be.a("\116\097\098\108\101");(expect(s)).never.to.equal(p)end)end
return function()
	local ReplicatedStorage = game:GetService("ReplicatedStorage")

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

	local List = Llama.List
	local flatten = List.flatten

	it("should validate types", function()
		local _, err = pcall(function()
			flatten(0)
		end)

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

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

		expect(flatten(a)).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,
		})

		flatten(a)

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

	it("should flatten the given table", function()
		local a = {
			{
				"foo",
				"bar",
			}, {
				"baz",
				"qux",
			}
		}
		local flattened = {
			"foo",
			"bar",
			"baz",
			"qux",
		}

		local b = flatten(a)

		for k, v in pairs(b) do
			expect(v).to.equal(flattened[k])
		end
	end)

	it("should spread out elements", function()
		local a = {
			"foo",
			{
				"bar",
				"baz",
			}, {
				"bar",
				"baz",
			},
			"qux",
		}
		local flattened = {
			"foo",
			"bar",
			"baz",
			"bar",
			"baz",
			"qux",
		}

		local b = flatten(a)

		for k, v in pairs(b) do
			expect(v).to.equal(flattened[k])
		end
	end)

	it("should flatten completely", function()
		local a = {
			1,
			{
				2,
				{
					3,
					{
						4,
					}
				}
			},
		}
		local flattened = {
			1,
			2,
			3,
			4,
		}

		local b = flatten(a)

		for k, v in pairs(b) do
			expect(v).to.equal(flattened[k])
		end
	end)

	it("should work with an empty list", function()
		local a = {}
		local b = flatten(a, function() end)

		expect(b).to.be.a("table")
		expect(b).never.to.equal(a)
	end)
end