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.Dictionary local p=C.flatten it("\115\104\111\117\108\100 \118\097\108\105\100\097\116\101 \116\121\112\101\115",function()local v,E=pcall(function()p(0)end);(expect(string.find(E,"\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 v={};(expect(p(v))).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={foo=1,bar=2,baz=3}local E=0 setmetatable(v,{__newindex=function()E=E+1 end})p(v);(expect(E)).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 v={foo={bar=1,baz=2},oof={rab=3;zab=4}}local E=p(v);(expect(E.bar)).to.equal(v.foo.bar);(expect(E.baz)).to.equal(v.foo.baz);(expect(E.rab)).to.equal(v.oof.rab);(expect(E.zab)).to.equal(v.oof.zab);(expect(E.foo)).never.to.be.ok();(expect(E.oof)).never.to.be.ok()end)it("\115\104\111\117\108\100 \107\101\101\112 \104\105\103\104\101\114 \108\101\118\101\108 \101\110\116\114\105\101\115",function()local v={foo=1,bar={foo=2}}local E=p(v);(expect(E.foo)).to.equal(1)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 v={foo=1,foobar={bar=2,barbaz={baz=3;bazqux={qux=4}}}}local E=p(v);(expect(E.foo)).to.equal(1);(expect(E.bar)).to.equal(2);(expect(E.baz)).to.equal(3);(expect(E.qux)).to.equal(4);(expect(E.foobar)).never.to.be.ok();(expect(E.barbaz)).never.to.be.ok();(expect(E.bazqux)).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={}local E=p(v);(expect(E)).to.be.a("\116\097\098\108\101")end)end
return function()
	local ReplicatedStorage = game:GetService("ReplicatedStorage")

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

	local Dictionary = Llama.Dictionary
	local flatten = Dictionary.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 = 1,
			bar = 2,
			baz = 3,
		}
		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 = 1,
				baz = 2,
			},
			oof = {
				rab = 3,
				zab = 4,
			}
		}

		local b = flatten(a)

		expect(b.bar).to.equal(a.foo.bar)
		expect(b.baz).to.equal(a.foo.baz)
		expect(b.rab).to.equal(a.oof.rab)
		expect(b.zab).to.equal(a.oof.zab)
		expect(b.foo).never.to.be.ok()
		expect(b.oof).never.to.be.ok()
	end)

	it("should keep higher level entries", function()
		local a = {
			foo = 1,
			bar = {
				foo = 2,
			},
		}

		local b = flatten(a)

		expect(b.foo).to.equal(1)
	end)

	it("should flatten completely", function()
		local a = {
			foo = 1,
			foobar = {
				bar = 2,
				barbaz = {
					baz = 3,
					bazqux = {
						qux = 4,
					}
				}
			},
		}

		local b = flatten(a)

		expect(b.foo).to.equal(1)
		expect(b.bar).to.equal(2)
		expect(b.baz).to.equal(3)
		expect(b.qux).to.equal(4)
		expect(b.foobar).never.to.be.ok()
		expect(b.barbaz).never.to.be.ok()
		expect(b.bazqux).never.to.be.ok()
	end)

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

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