return function()local Q=require(script.Parent.None)local n=require(script.Parent.produce)it("\115\104\111\117\108\100 \110\111\116 \109\117\116\097\116\101 \116\104\101 \111\114\105\103\105\110\097\108 \116\097\098\108\101",function()local Q={number=2}local u=n(Q,function(Q)Q.foo=true Q.number+=2 end);(expect(u.foo)).to.equal(true);(expect(u.number)).to.equal(4);(expect(Q.foo)).to.equal(nil);(expect(Q.number)).to.equal(2);(expect(Q)).to.never.equal(u)end)it("\115\104\111\117\108\100 \110\111\116 \109\117\116\097\116\101 \110\101\115\116\101\100 \116\097\098\108\101\115",function()local Q={modified=nil;nested={modified=nil;nestedDeep={modified=nil}}}local u=n(Q,function(Q)Q.nested.modified=true Q.nested.nestedDeep.modified=true end);(expect(u.nested.modified)).to.be.ok();(expect(u.nested.nestedDeep.modified)).to.be.ok();(expect(Q.nested.modified)).to.never.be.ok();(expect(Q.nested.nestedDeep.modified)).to.never.be.ok()end)it("\115\104\111\117\108\100 \114\101\116\117\114\110 \116\104\101 \114\101\116\117\114\110 \118\097\108\117\101 \111\102 \116\104\101 \114\101\099\105\112\101 \119\104\101\110 \110\111\116 \110\105\108 \111\114 \078\111\110\101",function()local Q={foo=true}local u=n({},function(n)return Q end);(expect(u.foo)).to.equal(true);(expect(u)).to.equal(Q)end)it("\115\104\111\117\108\100 \114\101\116\117\114\110 \110\105\108 \119\104\101\110 \116\104\101 \114\101\116\117\114\110 \118\097\108\117\101 \111\102 \116\104\101 \114\101\099\105\112\101 \105\115 \078\111\110\101",function()local u=n({},function(n)return Q end);(expect(u)).to.equal(nil)end)it("\115\104\111\117\108\100 \097\099\099\101\112\116 \110\111\110-\116\097\098\108\101 \110\111\110-\100\114\097\102\116\097\098\108\101 \098\097\115\101",function()(expect(function()n(1,function() end)end)).to.never.throw();(expect(function()n(true,function() end)end)).to.never.throw();(expect(function()n("\115\116\114\105\110\103",function() end)end)).to.never.throw();(expect(function()n(nil,function() end)end)).to.never.throw()end)it("\115\104\111\117\108\100 \098\101 \097\098\108\101 \116\111 \114\101\116\117\114\110 \110\111\110-\116\097\098\108\101 \110\111\110-\100\114\097\102\116\097\098\108\101 \118\097\108\117\101\115",function()do local Q=n(nil,function() end);(expect(Q)).to.equal(nil)end do local Q=n(1,function() end);(expect(Q)).to.equal(1)end do local Q=n("\115\116\114\105\110\103",function() end);(expect(Q)).to.equal("\115\116\114\105\110\103")end do local Q=n(true,function() end);(expect(Q)).to.equal(true)end end)end
--!nocheck
return function()
	local None = require(script.Parent.None)
	local produce = require(script.Parent.produce)

	it("should not mutate the original table", function()
		local original = { number = 2 }

		local new = produce(original, function(draft)
			draft.foo = true
			draft.number += 2
		end)

		expect(new.foo).to.equal(true)
		expect(new.number).to.equal(4)
		expect(original.foo).to.equal(nil)
		expect(original.number).to.equal(2)
		expect(original).to.never.equal(new)
	end)

	it("should not mutate nested tables", function()
		local original = {
			modified = nil,
			nested = {
				modified = nil,
				nestedDeep = { modified = nil },
			},
		}

		local new = produce(original, function(draft)
			draft.nested.modified = true
			draft.nested.nestedDeep.modified = true
		end)

		expect(new.nested.modified).to.be.ok()
		expect(new.nested.nestedDeep.modified).to.be.ok()
		expect(original.nested.modified).to.never.be.ok()
		expect(original.nested.nestedDeep.modified).to.never.be.ok()
	end)

	it("should return the return value of the recipe when not nil or None", function()
		local override = { foo = true }

		local new = produce({}, function(_draft)
			return override
		end)

		expect(new.foo).to.equal(true)
		expect(new).to.equal(override)
	end)

	it("should return nil when the return value of the recipe is None", function()
		local new = produce({}, function(_draft)
			return None
		end)

		expect(new).to.equal(nil)
	end)

	it("should accept non-table non-draftable base", function()
		expect(function()
			produce(1, function() end)
		end).to.never.throw()

		expect(function()
			produce(true, function() end)
		end).to.never.throw()

		expect(function()
			produce("string", function() end)
		end).to.never.throw()

		expect(function()
			produce(nil, function() end)
		end).to.never.throw()
	end)

	it("should be able to return non-table non-draftable values", function()
		do
			local new = produce(nil, function() end)
			expect(new).to.equal(nil)
		end

		do
			local new = produce(1, function() end)
			expect(new).to.equal(1)
		end

		do
			local new = produce("string", function() end)
			expect(new).to.equal("string")
		end

		do
			local new = produce(true, function() end)
			expect(new).to.equal(true)
		end
	end)
end
