local function f(f)local e={callCount=0,values={};valuesLength=0}e.value=function(...)e.callCount=e.callCount+1 e.values={...}e.valuesLength=select("\035",...)if f~=nil then return f(...)end end e.assertCalledWith=function(f,...)local t=select("\035",...)assert(e.valuesLength,t,"\108\101\110\103\116\104 \111\102 \101\120\112\101\099\116\101\100 \118\097\108\117\101\115 \100\105\102\102\101\114\115 \102\114\111\109 \115\116\111\114\101\100 \118\097\108\117\101\115")for f=1,t,1 do local t=select(f,...)assert(e.values[f],t,"\118\097\108\117\101 \100\105\102\102\101\114\115")end end setmetatable(e,{__index=function(f,e)error(("\037\113 \105\115 \110\111\116 \097 \118\097\108\105\100 \109\101\109\098\101\114 \111\102 \115\112\121"):format(e))end})return e end return f
local function createSpy(inner)
	local self = {
		callCount = 0,
		values = {},
		valuesLength = 0,
	}

	self.value = function(...)
		self.callCount = self.callCount + 1
		self.values = {...}
		self.valuesLength = select("#", ...)

		if inner ~= nil then
			return inner(...)
		end
	end

	self.assertCalledWith = function(_, ...)
		local len = select("#", ...)

		assert(self.valuesLength, len, "length of expected values differs from stored values")

		for i = 1, len do
			local expected = select(i, ...)
			assert(self.values[i], expected, "value differs")
		end
	end

	setmetatable(self, {
		__index = function(_, key)
			error(("%q is not a valid member of spy"):format(key))
		end,
	})

	return self
end

return createSpy