Asserts the token produced by an ANTLR tester.

@param expectedType the expected type of the token.
@param expectedText the expected text of the token.
@param lexerResults the result of {@link Work#scan(String)} which will
produce the token to assert.
427248
public static void assertToken(int expectedType, String expectedText, LexerResults lexerResults)
    {
        assertToken(expectedType, expectedText, lexerResults.getToken());
    }
341718
protected void sequence_UntilToken(ISerializationContext context, UntilToken semanticObject) {
		if (errorAcceptor != null) {
			if (transientValues.isValueTransient(semanticObject, XtextPackage.Literals.ABSTRACT_NEGATED_TOKEN__TERMINAL) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, XtextPackage.Literals.ABSTRACT_NEGATED_TOKEN__TERMINAL));
		}
		SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
		feeder.accept(grammarAccess.getUntilTokenAccess().getTerminalTerminalTokenElementParserRuleCall_1_0(), semanticObject.getTerminal());
		feeder.finish();
	}
306682
private function syntaxError( $expected, $token = null )
	{
		if ( $token === null )
			$token = $this->lexer->lookahead;

		$message = sprintf( 'Expected %s, got ', $expected );
		$message .= ( $this->lexer->lookahead === null ) ? 'end of string' : sprintf( "'%s' at position %s", $token['value'], $token['position'] );

		if ( strlen( $this->context ) )
			$message .= ' in ' . $this->context;

		$message .= '.';

		throw AnnotationException::syntaxError( $message );
	}
751845
public static <T extends Exception> org.hamcrest.Matcher<T> hasMessage(
            String expectedMessage) {
        return new ExceptionMessageMatcher<>(expectedMessage);
    }
65380
def expect(self, expr):
        
        if not self.current.test(expr):
            expr = describe_token_expr(expr)
            if self.current.type is TOKEN_EOF:
                raise TemplateSyntaxError('unexpected end of template, '
                                          'expected %r.' % expr,
                                          self.current.lineno,
                                          self.name, self.filename)
            raise TemplateSyntaxError("expected token %r, got %r" %
                                      (expr, describe_token(self.current)),
                                      self.current.lineno,
                                      self.name, self.filename)
        try:
            return self.current
        finally:
            next(self)
46194
public void accept(final TokenType tokenType) {
        if (lexer.getCurrentToken().getType() != tokenType) {
            throw new SQLParsingException(lexer, tokenType);
        }
        lexer.nextToken();
    }
15035
public function assertNotPartialOutput($expected, $type = 'stdout')
    {
        $expected = (string) $expected;
        $actual = $this->getOutputByType($type);

        if (false !== strpos($actual, $expected)) {
            throw new ExpectationException("Failed to assert \"$actual\" does not contain \"$expected\"");
        }
    }
1156213
public static void assertEquals(String message, XmlCursor expected, XmlCursor actual)
  {
    for (int child = 0; true; child++)
    {
      boolean child1 = expected.toChild(child);
      boolean child2 = actual.toChild(child);
      if (child1 != child2)
      {
        fail(message, "Different XML structure near " + QNameHelper.pretty(expected.getName()));
      }
      else if (expected.getName() != null && !expected.getName().equals(actual.getName()))
      {
        fail(message, "Expected element: '" + expected.getName()
          + "' differs from actual element: '" + actual.getName() + "'");
      }
      else if (child == 0 && !child1)
      {
        if (!(expected.getTextValue().equals(actual.getTextValue())))
        {
          fail(message, "Expected value for element " + QNameHelper.pretty(expected.getName()) + " -> '"
            + expected.getTextValue() + "' differs from actual value '" + actual.getTextValue() + "'");
        }
        break;
      }
      else if (child1)
      {
        assertEquals(message, expected, actual);
        expected.toParent();
        actual.toParent();
      }
      else
      {
        break;
      }
    }

    assertAttributesEqual(message, expected, actual);
  }
1229013
protected function raiseMismatch($expectedType)
    {
        $value = $this->value;

        if (is_object($value)) {
            $value = get_class($value);
        } elseif (is_array($value)) {
            $value = implode(',', $value);
        }

        throw new CastingMismatchException(sprintf(self::MISMATCH_MESSAGE, $value, $expectedType));
    }
132051
function expect(value) {
        var token = lex();
        if (token.type !== Token.Punctuator || token.value !== value) {
            throwUnexpectedToken(token);
        }
    }
195025
static public void assertEquals(String message, long expected, long actual) {
        assertEquals(message, Long.valueOf(expected), Long.valueOf(actual));
    }
855690
public static function expectedToken(
        $expected,
        array $token = null,
        DocLexer $lexer = null
    ) {
        if ((null === $token) && $lexer) {
            $token = $lexer->lookahead;
        }

        $message = "Expected $expected, received ";

        if ($token) {
            $message .= "'{$token['value']}' at position {$token['position']}.";
        } else {
            $message .= 'end of string.';
        }

        return new self($message);
    }
860666
public static void assertXpathEvaluatesTo(String expectedValue,
                                              String xpathExpression,
                                              InputSource control)
        throws SAXException, IOException,
               XpathException {
        Document document = XMLUnit.buildControlDocument(control);
        assertXpathEvaluatesTo(expectedValue, xpathExpression, document);
    }
698014
function throwUnexpected(token) {
        var s;

        if (token.type === Token.EOF) {
            throwError(token, Messages.UnexpectedEOS);
        }

        if (token.type === Token.NumericLiteral) {
            throwError(token, Messages.UnexpectedNumber);
        }

        if (token.type === Token.StringLiteral) {
            throwError(token, Messages.UnexpectedString);
        }

        if (token.type === Token.Identifier) {
            throwError(token, Messages.UnexpectedIdentifier);
        }

        if (token.type === Token.Keyword) {
            if (isFutureReservedWord(token.value)) {
                throwError(token, Messages.UnexpectedReserved);
            } else if (strict && isStrictModeReservedWord(token.value)) {
                throwError(token, Messages.StrictReservedWord);
            }
            throwError(token, Messages.UnexpectedToken, token.value);
        }

        // BooleanLiteral, NullLiteral, or Punctuator.
        throwError(token, Messages.UnexpectedToken, token.value);
    }
262452
@Override
    public void promptMatches(String expectedPromptPattern) {
        String prompt = checkPromptMatches(expectedPromptPattern, 0, 0);
        assertTrue("Prompt Text Mismatch: prompt text of '" + prompt + DOES_NOT_MATCH_PATTERN + expectedPromptPattern + "'", prompt.matches(expectedPromptPattern));
    }
168081
public function syntaxError($expected = '', $token = null)
    {
        if ($token === null) {
            $token = $this->lexer->lookahead;
        }

        $tokenPos = (isset($token['position'])) ? $token['position'] : '-1';

        $message  = "line 0, col {$tokenPos}: Error: ";
        $message .= ($expected !== '') ? "Expected {$expected}, got " : 'Unexpected ';
        $message .= ($this->lexer->lookahead === null) ? 'end of string.' : "'{$token['value']}'";

        throw QueryException::syntaxError($message, QueryException::dqlError($this->query->getDQL()));
    }
1159171
public Token getMatchedToken(final int tokenType) throws RecognitionException {
        Token result = parser.getCurrentToken();
        boolean isIdentifierCompatible = false;
        if (identifierTokenIndex == tokenType && identifierTokenIndex > result.getType()) {
            isIdentifierCompatible = true;
        }
        if (result.getType() == tokenType || isIdentifierCompatible) {
            if (Token.EOF != tokenType && isIdentifierCompatible && result instanceof CommonToken) {
                ((CommonToken) result).setType(identifierTokenIndex);
            }
            parser.getErrorHandler().reportMatch(parser);
            parser.consume();
        } else {
            result = parser.getErrorHandler().recoverInline(parser);
            if (parser.getBuildParseTree() && -1 == result.getTokenIndex()) {
                parser.getContext().addErrorNode(parser.createErrorNode(parser.getContext(), result));
            }
        }
        return result;
    }