Example #1
0
  protected void scanOnce(String source) {
    _scanner.setSource(source);

    try {
      _scanner.nextToken();
    } catch (Throwable e) {
      fail(e.getMessage());
    }
  }
Example #2
0
  /**
   * assertTokenType
   *
   * @param source
   * @param type
   * @throws Exception
   */
  protected void assertTokenType(String source, JSTokenType type) {
    _scanner.setSource(source);

    try {
      Symbol token = _scanner.nextToken();
      int id = token.getId();
      int length = token.getEnd() - token.getStart() + 1;

      assertEquals("unexpected token type", type.getIndex(), id);
      assertEquals("token length does not match source length: " + source, source.length(), length);
    } catch (Throwable e) {
      fail(e.getMessage());
    }
  }
Example #3
0
  /**
   * assertTokenTypes
   *
   * @param source
   * @param types
   * @throws Exception
   */
  protected void assertTokenTypes(String source, JSTokenType... types) {
    _scanner.setSource(source);

    for (int i = 0; i < types.length; i++) {
      try {
        JSTokenType type = types[i];
        Symbol token = _scanner.nextToken();
        int id = token.getId();

        assertEquals("in '" + source + "' at token index " + i, type.getIndex(), id);
      } catch (Throwable e) {
        fail(e.getMessage());
      }
    }
  }
Example #4
0
  @Test
  public void testMultiLineComment() {
    scanOnce("/*\n  * this is a multi-line comment\n */"); // , JSTokenType.MULTILINE_COMMENT);

    assertEquals(1, _scanner.getMultiLineComments().size());
  }
Example #5
0
  @Test
  public void testSingleLineComment() {
    scanOnce("// this is a singe line comment"); // , JSTokenType.SINGLELINE_COMMENT);

    assertEquals(1, _scanner.getSingleLineComments().size());
  }
Example #6
0
  @Test
  public void testSDocComment() {
    scanOnce("/**\n  * this is an sdoc comment\n */"); // , JSTokenType.SDOC);

    assertEquals(1, _scanner.getSDocComments().size());
  }
Example #7
0
  @Test
  public void testVSDocComment() {
    scanOnce("/// this is a vsdoc comment"); // , JSTokenType.VSDOC);

    assertEquals(1, _scanner.getVSDocComments().size());
  }