Invalid route definition with unexpected character.

@param Input $definition
@param string[] $expected
@return InvalidRoute
323676
public static function unexpectedCharacter(Input $definition, array $expected = []): self
    {
        $pointer = self::createPointerString($definition->getInput(), $definition->getIndex());

        if (empty($expected)) {
            return new self("Unexpected character:\n$pointer");
        }

        $expected = $expected ?? $definition->getLatestExpectations();

        $expected = array_map(function (string $e) {
            return "'$e'";
        }, $expected);

        $expected = implode(", ", $expected);

        return new self("Unexpected character (expected $expected):\n$pointer");
    }
44911
public ResultMatcher isStringEqualTo(final String expected) {
        return new AbstractResultMatcher(path, configuration) {
            public void doMatch(Object actual) {
                isString(actual);
                Node node = getNode(actual);
                if (!node.asText().equals(expected)) {
                    failWithMessage("Node \"" + path + "\" is not equal to \"" + expected + "\".");
                }
            }
        };

    }
174356
public static function match($actual, $expected)
    {
        if (is_callable($expected)) {
            return $expected($actual);
        }
        $actual = static::_nl($actual);
        return !!preg_match($expected, $actual);
    }
433445
private function requestUrlMatchesExpectation(ServerRequestInterface $httpRequest, RequestConditions $expectedRequest)
    {
        $inputSource = $this->inputSourceLocator->locate('url');
        $matcher = $this->matcherLocator->locate($expectedRequest->getUrl()->getMatcher()->asString());

        return $matcher->match(
            $inputSource->getValue($httpRequest),
            $expectedRequest->getUrl()->getValue()->asString()
        );
    }
712959
protected function validateRequestOrThrowException(Expectation $expectation, LoggerInterface $logger)
    {
        if ($this->requestIsInvalid($expectation->getRequest())) {
            $logger->error('Invalid request specified in expectation');
            throw new \RuntimeException('Invalid request specified in expectation');
        }
    }
794355
public static function invalidAddress(string $value, string $valueName) : InvalidArgumentException
    {
        return new self(sprintf('"%s" is not valid "%s"', $value, $valueName));
    }
825688
public static function InvalidTypeException($expectedType, $key, $value) {
        throw new InvalidTypeException($expectedType, $key, is_array($value) ? serialize($value) : $value);
    }
411726
public static String validate(String value, int expected) {
        if (value.length() != expected) {
            throw new InvalidLengthException(value, expected);
        }
        return value;
    }
239278
public static function typeMisMatch($expected, $actual)
    {
        return new static(
            sprintf(
                'Expected: "%s" Received: "%s"',
                $expected,
                is_object($actual) ? get_class($actual) : gettype($actual)
            )
        );
    }
762762
private function urlConditionIsRegex(Expectation $expectation)
    {
        return $expectation->getRequest()->getUrl() && Matchers::MATCHES === $expectation->getRequest()->getUrl()->getMatcher();
    }
579764
public function parse($definition)
    {
        $values = explode(' ', $definition);
        $direction = $this->getDirection($values);
        $values = explode('/', $values[0]);
        $type = $values[0];

        switch (strtolower($type)) {
            case 'depth':
                return new Depth($direction);
            case 'field':
                return $this->buildFieldSortClause($values, $direction);
            case 'modified':
                return new DateModified($direction);
            case 'name':
                return new ContentName($direction);
            case 'priority':
                return new Priority($direction);
            case 'published':
                return new DatePublished($direction);
        }

        throw new InvalidArgumentException(
            "Could not handle sort type '{$type}'"
        );
    }
622060
public function renderInOrder(array $expected, array $actual): string
    {
        if (empty($expected)) {
            return $this->reset . 'Expected events.' . PHP_EOL .
                $this->failStart . 'No events recorded.' . $this->reset;
        }

        $from = $this->renderEvents($expected);
        $to = $this->renderEvents($actual);

        $matcher = new DifferenceSequenceMatcher($from, $to);
        $diff = [];

        foreach ($matcher->getOpcodes() as $opcode) {
            list($tag, $i1, $i2, $j1, $j2) = $opcode;

            if ($tag === 'equal') {
                foreach (array_slice($from, $i1, $i2 - $i1) as $event) {
                    $diff[] = '    ' . $this->pass . '   ' . $event;
                }
            } else {
                if ($tag === 'replace' || $tag === 'delete') {
                    foreach (array_slice($from, $i1, $i2 - $i1) as $event) {
                        $diff[] =
                            '    ' . $this->fail . ' ' .
                            $this->removeStart . $event . $this->removeEnd;
                    }
                }

                if ($tag === 'replace' || $tag === 'insert') {
                    foreach (array_slice($to, $j1, $j2 - $j1) as $event) {
                        $diff[] =
                            '    - ' . $this->addStart . $event . $this->addEnd;
                    }
                }
            }
        }

        $renderedExpected = [];

        foreach ($from as $event) {
            $renderedExpected[] = '    - ' . $event;
        }

        $renderedActual = [];

        foreach ($to as $event) {
            $renderedActual[] = '    - ' . $event;
        }

        return $this->reset . 'Expected events in order:' . PHP_EOL .
            implode(PHP_EOL, $renderedExpected) . PHP_EOL .
            'Actual order:' . PHP_EOL .
            implode(PHP_EOL, $renderedActual) . PHP_EOL .
            'Difference:' . PHP_EOL .
            implode(PHP_EOL, $diff);
    }
295168
function ensure_valid_routes(raw_routes) {
    !Array.isArray(raw_routes)
        ? throw_type_error('routes must be an array')
        : 0 === raw_routes.length
            && throw_error('There are no routes defined')
        ; // eslint-disable-line indent
    const routes = [];
    for (let i = 0, n = raw_routes.length - 1; i <= n; i++) {
        const raw_route = raw_routes[i];
        raw_route.path
            ? raw_route.pattern || raw_route.pattern_tokens
                ? throw_error(
                    'If route.path is defined,',
                    'route.pattern and route.pattern_tokens are invalid',
                    ) // eslint-disable-line indent
                : 'string' !== typeof raw_route.path
                    && throw_type_error('route.path must be a string')
            : raw_route.pattern
                ? !(raw_route.pattern instanceof RegExp)
                    && throw_type_error(
                        'route.pattern must be a regular expression',
                        ) // eslint-disable-line indent
                : throw_type_error(
                    'route.path must be a string',
                    'or route.pattern must be regular expression',
                    ) // eslint-disable-line indent
            ; // eslint-disable-line indent
        raw_route.redirect_to
            ? 'string' !== typeof raw_route.redirect_to
                ? throw_type_error('route.redirect_to must be a string')
                : raw_route.component
                    && throw_error(
                        'If route.redirect_to is defined,',
                        'route.component is invalid',
                        ) // eslint-disable-line indent
            : !(raw_route.component.prototype instanceof REACT.Component)
                && throw_type_error('route.component must be a React Component')
            ; // eslint-disable-line indent
        routes.push({
            path: raw_route.path ? ensure_valid_path(raw_route.path) : null,
            pattern: raw_route.pattern || null,
            pattern_tokens:
                ensure_valid_pattern_tokens(raw_route.pattern_tokens)
                , // eslint-disable-line
            redirect_to: raw_route.redirect_to || null,
            component: raw_route.component,
            }); // eslint-disable-line indent
    }
    return routes;
}
1094070
protected function seeJsonContains($expected)
    {
        $response = json_decode($this->response(), true);

        $this->sortJson($expected);
        $this->sortJson($response);

        foreach ($expected as $key => $value) {
            if ( ! str_contains(json_encode($response), trim(json_encode([$key => $value]), '{}'))) {
                $this->fail(sprintf(
                    "Dang! Expected %s to exist in %s, but nope. Ideas?",
                    json_encode($expected), json_encode($response)
                ));
            }
        }

        return $this;
    }
533254
private void error(String expected, String actual) {
        if (!recovering) {
            recovering = true;
            final String outputString = (EOF_STRING.equals(actual) || UNTERMINATED_COMMENT_STRING.equals(actual) || COMMENT_NOT_ALLOWED.equals(actual)) ? actual : "'"
                    + actual + "'";
            errors.add(SyntaxError._UnexpectedToken(expected, outputString,
                    lookahead(1).beginLine));
        }
    }
696217
private function normalizeComponents( $expected, $generated )
	{
		$map = array();

		// BMS 2018-02-16 This does not work because they may be mismatched names.  For example in 47200 V-01
		// the expected contexts are 'context-1' .. 'context-9'.  However the generated contexts are 'context',
		// 'context-1' .. 'context-8' so they match by name but incorrectly.
		// First look for the components with matching names as this will be quickest and easiet. Ideally all will be matched this way
		// foreach ( $expected as $expectedName => $expectedComponent )
		// {
		// 	if ( ! isset( $generated[ $expectedName ] ) ) continue;
        //
		// 	$map[ $expectedName ] = $expectedName;
		// 	unset( $expected[ $expectedName] );
		// 	unset( $generated[ $expectedName ] );
		// }

		if ( is_null( $this->comparer ) )
		{
			$this->comparer = new ContextComparer( null );
			$this->comparer->excludeWhitespace = true;
		}

		// Now match up based on whether the component contents match
		foreach ( $expected as $expectedName => $expectedNav )
		{
			foreach ( $generated as $generatedName => $generatedNav )
			{
				if ( ! $this->comparer->DeepEqualByNavigator( $expectedNav, $generatedNav ) ) continue;

				$map[ $expectedName ] = $generatedName;
				unset( $expected[ $expectedName] );
				unset( $generated[ $generatedName ] );

				break;
			}
		}

		return $map;
	}
109034
static public function formatName($definition)
	{
	    if (is_string($definition)) {
	        return $definition;
	    } elseif (is_object($definition)) {
	        return get_class($definition);
	    } elseif (is_array($definition)) {
	        if (!isset($definition['class'])) {
	            $name = $definition[0];
	        } else {
	            $name = $definition['class'];
	        }
	    } else {
	        throw new InvalidConfigException("Unsupported definition for :" . gettype($definition));
	    }
	}