-- Replace common spaces with middle dot at the end of any line

function replaceTrailingSpaces(text: string): string
	return text:gsub("%s+$", function(spaces)
		return string.rep(SPACE_SYMBOL, #spaces)
	end)
end

local function printReceived(object: any): string
	return RECEIVED_COLOR(replaceTrailingSpaces(stringify(object)))
end

local function printExpected(value: any): string
	return EXPECTED_COLOR(replaceTrailingSpaces(stringify(value)))
end

local function printWithType(
	name: string, -- 'Expected' or 'Received'
	value: any,
	print_: (any) -> string -- printExpected or printReceived
): string
	local type_ = getType(value)
	local hasType
	if type_ ~= "nil" then
		hasType = string.format("%s has type:  %s\n", name, type_)
	else
		hasType = ""
	end

	local hasValue = string.format("%s has value: %s", name, print_(value))
	return hasType .. hasValue
end

local function ensureNoExpected(expected: any, matcherName: string, options: MatcherHintOptions?): ()
	if typeof(expected) ~= "nil" then
		-- Prepend maybe not only for backward compatibility
		local matcherString = matcherName

		if not options then
			matcherString = "[.never]" .. matcherString
		end

		error(
			Error(
				matcherErrorMessage(
					matcherHint(matcherString, nil, "", options),
					"this matcher must not have an expected argument",
					printWithType("Expected", expected, printExpected)
				)
			)
		)
	end
end
