예제 #1
0
  public void testLinenoGetProp() {
    AstRoot root = parse("\nfoo.bar");
    ExpressionStatement st = (ExpressionStatement) root.getFirstChild();
    AstNode n = st.getExpression();

    assertTrue(n instanceof PropertyGet);
    assertEquals(Token.GETPROP, n.getType());
    assertEquals(1, n.getLineno());

    PropertyGet getprop = (PropertyGet) n;
    AstNode m = getprop.getRight();

    assertTrue(m instanceof Name);
    assertEquals(Token.NAME, m.getType()); // used to be Token.STRING!
    assertEquals(1, m.getLineno());
  }
예제 #2
0
  public void testLinenoDeclaration() {
    AstNode root = parse("\na.\n" + "b=\n" + "function() {};\n");

    ExpressionStatement exprStmt = (ExpressionStatement) root.getFirstChild();
    Assignment fnAssignment = (Assignment) exprStmt.getExpression();
    PropertyGet aDotbName = (PropertyGet) fnAssignment.getLeft();
    AstNode aName = aDotbName.getLeft();
    AstNode bName = aDotbName.getRight();
    FunctionNode fnNode = (FunctionNode) fnAssignment.getRight();

    assertEquals(1, fnAssignment.getLineno());
    assertEquals(1, aDotbName.getLineno());
    assertEquals(1, aName.getLineno());
    assertEquals(2, bName.getLineno());
    assertEquals(3, fnNode.getLineno());
  }