local c=require(script.Parent.Expectation)local M=c.checkMatcherNameCollisions local function n(c)local M={}for c,n in pairs(c)do M[c]=n end return M end local F={}F.__index=F function F.new(c)local M={_extensions=c and n(c._extensions)or{}}return setmetatable(M,F)end function F.startExpectationChain(M,...)return(c.new(...)):extend(M._extensions)end function F.extend(n,c)for c,F in pairs(c)do assert(n._extensions[c]==nil,string.format("\067\097\110\110\111\116 \114\101\097\115\115\105\103\110 \037\113 \105\110 \101\120\112\101\099\116\046\101\120\116\101\110\100",c))assert(M(c),string.format("\067\097\110\110\111\116 \111\118\101\114\119\114\105\116\101 \109\097\116\099\104\101\114 \037\113\059 \105\116 \097\108\114\101\097\100\121 \101\120\105\115\116\115",c))n._extensions[c]=F end end return F
local Expectation = require(script.Parent.Expectation)
local checkMatcherNameCollisions = Expectation.checkMatcherNameCollisions

local function copy(t)
	local result = {}

	for key, value in pairs(t) do
		result[key] = value
	end

	return result
end

local ExpectationContext = {}
ExpectationContext.__index = ExpectationContext

function ExpectationContext.new(parent)
	local self = {
		_extensions = parent and copy(parent._extensions) or {},
	}

	return setmetatable(self, ExpectationContext)
end

function ExpectationContext:startExpectationChain(...)
	return Expectation.new(...):extend(self._extensions)
end

function ExpectationContext:extend(config)
	for key, value in pairs(config) do
		assert(self._extensions[key] == nil, string.format("Cannot reassign %q in expect.extend", key))
		assert(checkMatcherNameCollisions(key), string.format("Cannot overwrite matcher %q; it already exists", key))

		self._extensions[key] = value
	end
end

return ExpectationContext
