public void testLinenoPlusEq() { AstRoot root = parse("\na\n" + "+=\n" + "b\n"); ExpressionStatement expr = (ExpressionStatement) root.getFirstChild(); Assignment assign = (Assignment) expr.getExpression(); AstNode lhs = assign.getLeft(); AstNode rhs = assign.getRight(); assertEquals(1, lhs.getLineno()); assertEquals(1, assign.getLineno()); assertEquals(3, rhs.getLineno()); }
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()); }