Package com.google.jstestdriver.token

Examples of com.google.jstestdriver.token.Token


    }
    assertFalse(lexer.available());
  }

  public void testCreateTokensWithOtherTokens() throws Exception {
    Token otherOne = new ConcreteToken("<div></div>".toCharArray());
    BufferedInputStream stream =
      new BufferedInputStream(
        new ByteArrayInputStream((tokens[0].toString()
            + otherOne.toString() + tokens[1].toString()).getBytes()));

    BufferedTokenStream lexer = new HtmlDocLexer().createStream(stream);
    List<Token> expected =
        Lists.newArrayList(tokens[0], otherOne, tokens[1]);
    for (Token token : expected) {
View Full Code Here


      assertEquals(token, lexer.read());
    }
  }

  public void testCreateTokensWithCommentTokens() throws Exception {
    Token otherOne = new ConcreteToken("/** foo".toCharArray());
    BufferedInputStream stream =
      new BufferedInputStream(
        new ByteArrayInputStream((tokens[2].toString()
            + otherOne.toString() + tokens[1].toString() + tokens[3].toString()).getBytes()));
   
    BufferedTokenStream lexer = new HtmlDocLexer().createStream(stream);
    List<Token> expected =
      Lists.newArrayList(tokens[2], otherOne, tokens[1], tokens[3]);
    for (Token token : expected) {
View Full Code Here

* @author corysmith@google.com (Cory Smith)
*
*/
public class HtmlDocNodeFactoryTest extends TestCase {
  public void testMultipleHtmlNodes() throws Exception {
    Token docStartToken = ConcreteToken.from("/*:DOC");
    Token barToken = ConcreteToken.from(" bar ");
    Token equalsToken = ConcreteToken.from("=");
    Token htmlTokenOne = ConcreteToken.from(" <div");
    Token htmlTokenTwo = ConcreteToken.from("'foo'></div>");
    Token endDocToken = ConcreteToken.from("*/");
    List<Token> tokens = Lists.<Token>newArrayList(
        docStartToken,
        barToken,
        equalsToken,
        htmlTokenOne,
View Full Code Here

* @author corysmith@google.com (Cory Smith)
*/
public class HtmlDocParserTest extends TestCase {

  public void testParseHtmlDoc() throws Exception {
    Token id = ConcreteToken.from("foo ");
    Token html = ConcreteToken.from(" <div></div>");
    List<Token> tokens = Lists.<Token>newArrayList(
                       ConcreteToken.from("/*:DOC"),
                       id,
                       ConcreteToken.from("="),
                       html,
View Full Code Here

    assertEquals(new Nodes().add(new HtmlDocGlobalNode(id, Lists.newArrayList(html))),
                 new HtmlDocParser().parse(stream));
  }

  public void testParseHtmlDocInBlock() throws Exception {
    Token id = ConcreteToken.from("foo ");
    Token html = ConcreteToken.from(" <div></div>");
    Token functionToken = ConcreteToken.from("function foo()");
    Token blockStartToken = ConcreteToken.from("{");
    Token blockEndToken = ConcreteToken.from("}");
    List<Token> tokens = Lists.<Token>newArrayList(
                       functionToken,
                       blockStartToken,
                       ConcreteToken.from("/*:DOC"),
                       id,
View Full Code Here

                            .add(new TextNode(blockEndToken)),
                 new HtmlDocParser().parse(stream));
  }

  public void testOtherAndBlock() throws Exception {
    Token setUpToken = ConcreteToken.from("TestCase.prototype.setUp ");
    Token equalsToken = ConcreteToken.from("=");
    Token functionToken = ConcreteToken.from(" function()");
    Token blockStartToken = ConcreteToken.from("{");
    Token fooToken = ConcreteToken.from("  this.foo ");
    Token oneToken = ConcreteToken.from(" 1;  ");
    Token docStartToken = ConcreteToken.from("/*:DOC");
    Token barToken = ConcreteToken.from(" bar ");
    Token htmlToken = ConcreteToken.from(" <div></div>");
    Token endDocToken = ConcreteToken.from("*/");
    Token endBlockToken = ConcreteToken.from("}");
    List<Token> tokens = Lists.<Token>newArrayList(
        setUpToken,
        equalsToken,
        functionToken,
        blockStartToken,
View Full Code Here

      return;
    }
    nodes.add(new TextNode(BLOCK_START_TOKEN));
    stream.mark();
    while(stream.available()) {
      Token token = stream.read();
      if (BLOCK_END_TOKEN.equals(token)) {
        stream.mark();
        nodes.add(new TextNode(BLOCK_END_TOKEN));
        return;
      }
View Full Code Here

    return nodes;
  }

  public static class TextNodeFactory implements NodeFactory {
    public void create(BufferedTokenStream stream, Nodes nodes) {
      Token token = stream.read();
      if (token == null) {
        return;
      }
      nodes.add(new TextNode(token));
      stream.mark();
View Full Code Here

  public HtmlDocNodeFactory(CreateNodeStrategy createStrategy) {
    this.createStrategy = createStrategy;
  }

  public void create(BufferedTokenStream stream, Nodes nodes) {
    Token id = null;
    List<Token> html = Lists.newLinkedList();

    if (!DOC_START.equals(stream.read())) {
      stream.reset();
      return;
    }

    id = stream.read();

    if (!EQUALS.equals(stream.read())) {
      stream.reset();
      return;
    }

    while(stream.available()) {
      Token token = stream.read();
      if (END_COMMENT.equals(token)) {
        break;
      }
      html.add(token);
    }
View Full Code Here

TOP

Related Classes of com.google.jstestdriver.token.Token

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.