check static method

void check(
  1. Token? tok,
  2. TokenType type, [
  3. String? text,
  4. int lineNum = 0,
])

Implementation

static void check(
  Token? tok,
  TokenType type, [
  String? text,
  int lineNum = 0,
]) {
  UnitTest.errorIfNull(tok);
  if (tok == null) return;
  UnitTest.errorIf(
    tok.type != type,
    "Token type: expected $type, but got ${tok.type}",
  );

  UnitTest.errorIf(
    text != null && tok.text != text,
    "Token text: expected $text, but got ${tok.text}",
  );
}