Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Unified Diff: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/parser/RecoveryParserTest.java

Issue 15260002: Report ParserErrorCode.MISSING_IDENTIFIER (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes for review comments Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/parser/RecoveryParserTest.java
diff --git a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/parser/RecoveryParserTest.java b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/parser/RecoveryParserTest.java
index 4725275ab6d2d4a73ed064dedbbff2fe43323e86..d0352f2fe996fa2ea835b184e18affbf3fac77a2 100644
--- a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/parser/RecoveryParserTest.java
+++ b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/parser/RecoveryParserTest.java
@@ -52,13 +52,16 @@ public class RecoveryParserTest extends ParserTestCase {
}
public void test_additiveExpression_missing_LHS() throws Exception {
- BinaryExpression expression = parseExpression("+ y", ParserErrorCode.USE_OF_UNARY_PLUS_OPERATOR);
+ BinaryExpression expression = parseExpression("+ y", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getLeftOperand());
assertTrue(expression.getLeftOperand().isSynthetic());
}
public void test_additiveExpression_missing_LHS_RHS() throws Exception {
- BinaryExpression expression = parseExpression("+", ParserErrorCode.USE_OF_UNARY_PLUS_OPERATOR);
+ BinaryExpression expression = parseExpression(
+ "+",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getLeftOperand());
assertTrue(expression.getLeftOperand().isSynthetic());
assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand());
@@ -66,75 +69,87 @@ public class RecoveryParserTest extends ParserTestCase {
}
public void test_additiveExpression_missing_RHS() throws Exception {
- BinaryExpression expression = parseExpression("x +");
+ BinaryExpression expression = parseExpression("x +", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand());
assertTrue(expression.getRightOperand().isSynthetic());
}
public void test_additiveExpression_missing_RHS_super() throws Exception {
- BinaryExpression expression = parseExpression("super +");
+ BinaryExpression expression = parseExpression("super +", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand());
assertTrue(expression.getRightOperand().isSynthetic());
}
public void test_additiveExpression_precedence_multiplicative_left() throws Exception {
- BinaryExpression expression = parseExpression("* +", ParserErrorCode.USE_OF_UNARY_PLUS_OPERATOR);
+ BinaryExpression expression = parseExpression(
+ "* +",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(BinaryExpression.class, expression.getLeftOperand());
}
public void test_additiveExpression_precedence_multiplicative_right() throws Exception {
- BinaryExpression expression = parseExpression("+ *", ParserErrorCode.USE_OF_UNARY_PLUS_OPERATOR);
+ BinaryExpression expression = parseExpression(
+ "+ *",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(BinaryExpression.class, expression.getRightOperand());
}
public void test_additiveExpression_super() throws Exception {
BinaryExpression expression = parseExpression(
"super + +",
- ParserErrorCode.USE_OF_UNARY_PLUS_OPERATOR);
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(BinaryExpression.class, expression.getLeftOperand());
}
public void test_assignmentExpression_missing_compound1() throws Exception {
- AssignmentExpression expression = parseExpression("= y = 0");
+ AssignmentExpression expression = parseExpression("= y = 0", ParserErrorCode.MISSING_IDENTIFIER);
Expression syntheticExpression = expression.getLeftHandSide();
assertInstanceOf(SimpleIdentifier.class, syntheticExpression);
assertTrue(syntheticExpression.isSynthetic());
}
public void test_assignmentExpression_missing_compound2() throws Exception {
- AssignmentExpression expression = parseExpression("x = = 0");
+ AssignmentExpression expression = parseExpression("x = = 0", ParserErrorCode.MISSING_IDENTIFIER);
Expression syntheticExpression = ((AssignmentExpression) expression.getRightHandSide()).getLeftHandSide();
assertInstanceOf(SimpleIdentifier.class, syntheticExpression);
assertTrue(syntheticExpression.isSynthetic());
}
public void test_assignmentExpression_missing_compound3() throws Exception {
- AssignmentExpression expression = parseExpression("x = y =");
+ AssignmentExpression expression = parseExpression("x = y =", ParserErrorCode.MISSING_IDENTIFIER);
Expression syntheticExpression = ((AssignmentExpression) expression.getRightHandSide()).getRightHandSide();
assertInstanceOf(SimpleIdentifier.class, syntheticExpression);
assertTrue(syntheticExpression.isSynthetic());
}
public void test_assignmentExpression_missing_LHS() throws Exception {
- AssignmentExpression expression = parseExpression("= 0");
+ AssignmentExpression expression = parseExpression("= 0", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getLeftHandSide());
assertTrue(expression.getLeftHandSide().isSynthetic());
}
public void test_assignmentExpression_missing_RHS() throws Exception {
- AssignmentExpression expression = parseExpression("x =");
+ AssignmentExpression expression = parseExpression("x =", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getLeftHandSide());
assertTrue(expression.getRightHandSide().isSynthetic());
}
public void test_bitwiseAndExpression_missing_LHS() throws Exception {
- BinaryExpression expression = parseExpression("& y");
+ BinaryExpression expression = parseExpression("& y", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getLeftOperand());
assertTrue(expression.getLeftOperand().isSynthetic());
}
public void test_bitwiseAndExpression_missing_LHS_RHS() throws Exception {
- BinaryExpression expression = parseExpression("&");
+ BinaryExpression expression = parseExpression(
+ "&",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getLeftOperand());
assertTrue(expression.getLeftOperand().isSynthetic());
assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand());
@@ -142,40 +157,54 @@ public class RecoveryParserTest extends ParserTestCase {
}
public void test_bitwiseAndExpression_missing_RHS() throws Exception {
- BinaryExpression expression = parseExpression("x &");
+ BinaryExpression expression = parseExpression("x &", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand());
assertTrue(expression.getRightOperand().isSynthetic());
}
public void test_bitwiseAndExpression_missing_RHS_super() throws Exception {
- BinaryExpression expression = parseExpression("super &");
+ BinaryExpression expression = parseExpression("super &", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand());
assertTrue(expression.getRightOperand().isSynthetic());
}
public void test_bitwiseAndExpression_precedence_equality_left() throws Exception {
- BinaryExpression expression = parseExpression("== &");
+ BinaryExpression expression = parseExpression(
+ "== &",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(BinaryExpression.class, expression.getLeftOperand());
}
public void test_bitwiseAndExpression_precedence_equality_right() throws Exception {
- BinaryExpression expression = parseExpression("& ==");
+ BinaryExpression expression = parseExpression(
+ "& ==",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(BinaryExpression.class, expression.getRightOperand());
}
public void test_bitwiseAndExpression_super() throws Exception {
- BinaryExpression expression = parseExpression("super & &");
+ BinaryExpression expression = parseExpression(
+ "super & &",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(BinaryExpression.class, expression.getLeftOperand());
}
public void test_bitwiseOrExpression_missing_LHS() throws Exception {
- BinaryExpression expression = parseExpression("| y");
+ BinaryExpression expression = parseExpression("| y", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getLeftOperand());
assertTrue(expression.getLeftOperand().isSynthetic());
}
public void test_bitwiseOrExpression_missing_LHS_RHS() throws Exception {
- BinaryExpression expression = parseExpression("|");
+ BinaryExpression expression = parseExpression(
+ "|",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getLeftOperand());
assertTrue(expression.getLeftOperand().isSynthetic());
assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand());
@@ -183,40 +212,54 @@ public class RecoveryParserTest extends ParserTestCase {
}
public void test_bitwiseOrExpression_missing_RHS() throws Exception {
- BinaryExpression expression = parseExpression("x |");
+ BinaryExpression expression = parseExpression("x |", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand());
assertTrue(expression.getRightOperand().isSynthetic());
}
public void test_bitwiseOrExpression_missing_RHS_super() throws Exception {
- BinaryExpression expression = parseExpression("super |");
+ BinaryExpression expression = parseExpression("super |", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand());
assertTrue(expression.getRightOperand().isSynthetic());
}
public void test_bitwiseOrExpression_precedence_xor_left() throws Exception {
- BinaryExpression expression = parseExpression("^ |");
+ BinaryExpression expression = parseExpression(
+ "^ |",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(BinaryExpression.class, expression.getLeftOperand());
}
public void test_bitwiseOrExpression_precedence_xor_right() throws Exception {
- BinaryExpression expression = parseExpression("| ^");
+ BinaryExpression expression = parseExpression(
+ "| ^",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(BinaryExpression.class, expression.getRightOperand());
}
public void test_bitwiseOrExpression_super() throws Exception {
- BinaryExpression expression = parseExpression("super | |");
+ BinaryExpression expression = parseExpression(
+ "super | |",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(BinaryExpression.class, expression.getLeftOperand());
}
public void test_bitwiseXorExpression_missing_LHS() throws Exception {
- BinaryExpression expression = parseExpression("^ y");
+ BinaryExpression expression = parseExpression("^ y", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getLeftOperand());
assertTrue(expression.getLeftOperand().isSynthetic());
}
public void test_bitwiseXorExpression_missing_LHS_RHS() throws Exception {
- BinaryExpression expression = parseExpression("^");
+ BinaryExpression expression = parseExpression(
+ "^",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getLeftOperand());
assertTrue(expression.getLeftOperand().isSynthetic());
assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand());
@@ -224,52 +267,72 @@ public class RecoveryParserTest extends ParserTestCase {
}
public void test_bitwiseXorExpression_missing_RHS() throws Exception {
- BinaryExpression expression = parseExpression("x ^");
+ BinaryExpression expression = parseExpression("x ^", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand());
assertTrue(expression.getRightOperand().isSynthetic());
}
public void test_bitwiseXorExpression_missing_RHS_super() throws Exception {
- BinaryExpression expression = parseExpression("super ^");
+ BinaryExpression expression = parseExpression("super ^", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand());
assertTrue(expression.getRightOperand().isSynthetic());
}
public void test_bitwiseXorExpression_precedence_and_left() throws Exception {
- BinaryExpression expression = parseExpression("& ^");
+ BinaryExpression expression = parseExpression(
+ "& ^",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(BinaryExpression.class, expression.getLeftOperand());
}
public void test_bitwiseXorExpression_precedence_and_right() throws Exception {
- BinaryExpression expression = parseExpression("^ &");
+ BinaryExpression expression = parseExpression(
+ "^ &",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(BinaryExpression.class, expression.getRightOperand());
}
public void test_bitwiseXorExpression_super() throws Exception {
- BinaryExpression expression = parseExpression("super ^ ^");
+ BinaryExpression expression = parseExpression(
+ "super ^ ^",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(BinaryExpression.class, expression.getLeftOperand());
}
public void test_conditionalExpression_missingElse() throws Exception {
- ConditionalExpression expression = parse("parseConditionalExpression", "x ? y :");
+ ConditionalExpression expression = parse(
+ "parseConditionalExpression",
+ "x ? y :",
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getElseExpression());
assertTrue(expression.getElseExpression().isSynthetic());
}
public void test_conditionalExpression_missingThen() throws Exception {
- ConditionalExpression expression = parse("parseConditionalExpression", "x ? : z");
+ ConditionalExpression expression = parse(
+ "parseConditionalExpression",
+ "x ? : z",
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getThenExpression());
assertTrue(expression.getThenExpression().isSynthetic());
}
public void test_equalityExpression_missing_LHS() throws Exception {
- BinaryExpression expression = parseExpression("== y");
+ BinaryExpression expression = parseExpression("== y", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getLeftOperand());
assertTrue(expression.getLeftOperand().isSynthetic());
}
public void test_equalityExpression_missing_LHS_RHS() throws Exception {
- BinaryExpression expression = parseExpression("==");
+ BinaryExpression expression = parseExpression(
+ "==",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getLeftOperand());
assertTrue(expression.getLeftOperand().isSynthetic());
assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand());
@@ -277,34 +340,48 @@ public class RecoveryParserTest extends ParserTestCase {
}
public void test_equalityExpression_missing_RHS() throws Exception {
- BinaryExpression expression = parseExpression("x ==");
+ BinaryExpression expression = parseExpression("x ==", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand());
assertTrue(expression.getRightOperand().isSynthetic());
}
public void test_equalityExpression_missing_RHS_super() throws Exception {
- BinaryExpression expression = parseExpression("super ==");
+ BinaryExpression expression = parseExpression("super ==", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand());
assertTrue(expression.getRightOperand().isSynthetic());
}
public void test_equalityExpression_precedence_relational_left() throws Exception {
- BinaryExpression expression = parseExpression("is ==", ParserErrorCode.EXPECTED_TYPE_NAME);
+ BinaryExpression expression = parseExpression(
+ "is ==",
+ ParserErrorCode.EXPECTED_TYPE_NAME,
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(IsExpression.class, expression.getLeftOperand());
}
public void test_equalityExpression_precedence_relational_right() throws Exception {
- BinaryExpression expression = parseExpression("== is", ParserErrorCode.EXPECTED_TYPE_NAME);
+ BinaryExpression expression = parseExpression(
+ "== is",
+ ParserErrorCode.EXPECTED_TYPE_NAME,
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(IsExpression.class, expression.getRightOperand());
}
public void test_equalityExpression_super() throws Exception {
- BinaryExpression expression = parseExpression("super == ==");
+ BinaryExpression expression = parseExpression(
+ "super == ==",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(BinaryExpression.class, expression.getLeftOperand());
}
public void test_expressionList_multiple_end() throws Exception {
- List<Expression> result = parse("parseExpressionList", ", 2, 3, 4");
+ List<Expression> result = parse(
+ "parseExpressionList",
+ ", 2, 3, 4",
+ ParserErrorCode.MISSING_IDENTIFIER);
assertSize(4, result);
Expression syntheticExpression = result.get(0);
assertInstanceOf(SimpleIdentifier.class, syntheticExpression);
@@ -312,7 +389,10 @@ public class RecoveryParserTest extends ParserTestCase {
}
public void test_expressionList_multiple_middle() throws Exception {
- List<Expression> result = parse("parseExpressionList", "1, 2, , 4");
+ List<Expression> result = parse(
+ "parseExpressionList",
+ "1, 2, , 4",
+ ParserErrorCode.MISSING_IDENTIFIER);
assertSize(4, result);
Expression syntheticExpression = result.get(2);
assertInstanceOf(SimpleIdentifier.class, syntheticExpression);
@@ -320,7 +400,10 @@ public class RecoveryParserTest extends ParserTestCase {
}
public void test_expressionList_multiple_start() throws Exception {
- List<Expression> result = parse("parseExpressionList", "1, 2, 3,");
+ List<Expression> result = parse(
+ "parseExpressionList",
+ "1, 2, 3,",
+ ParserErrorCode.MISSING_IDENTIFIER);
assertSize(4, result);
Expression syntheticExpression = result.get(3);
assertInstanceOf(SimpleIdentifier.class, syntheticExpression);
@@ -348,13 +431,16 @@ public class RecoveryParserTest extends ParserTestCase {
}
public void test_logicalAndExpression_missing_LHS() throws Exception {
- BinaryExpression expression = parseExpression("&& y");
+ BinaryExpression expression = parseExpression("&& y", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getLeftOperand());
assertTrue(expression.getLeftOperand().isSynthetic());
}
public void test_logicalAndExpression_missing_LHS_RHS() throws Exception {
- BinaryExpression expression = parseExpression("&&");
+ BinaryExpression expression = parseExpression(
+ "&&",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getLeftOperand());
assertTrue(expression.getLeftOperand().isSynthetic());
assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand());
@@ -362,29 +448,40 @@ public class RecoveryParserTest extends ParserTestCase {
}
public void test_logicalAndExpression_missing_RHS() throws Exception {
- BinaryExpression expression = parseExpression("x &&");
+ BinaryExpression expression = parseExpression("x &&", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand());
assertTrue(expression.getRightOperand().isSynthetic());
}
public void test_logicalAndExpression_precedence_bitwiseOr_left() throws Exception {
- BinaryExpression expression = parseExpression("| &&");
+ BinaryExpression expression = parseExpression(
+ "| &&",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(BinaryExpression.class, expression.getLeftOperand());
}
public void test_logicalAndExpression_precedence_bitwiseOr_right() throws Exception {
- BinaryExpression expression = parseExpression("&& |");
+ BinaryExpression expression = parseExpression(
+ "&& |",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(BinaryExpression.class, expression.getRightOperand());
}
public void test_logicalOrExpression_missing_LHS() throws Exception {
- BinaryExpression expression = parseExpression("|| y");
+ BinaryExpression expression = parseExpression("|| y", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getLeftOperand());
assertTrue(expression.getLeftOperand().isSynthetic());
}
public void test_logicalOrExpression_missing_LHS_RHS() throws Exception {
- BinaryExpression expression = parseExpression("||");
+ BinaryExpression expression = parseExpression(
+ "||",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getLeftOperand());
assertTrue(expression.getLeftOperand().isSynthetic());
assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand());
@@ -392,29 +489,40 @@ public class RecoveryParserTest extends ParserTestCase {
}
public void test_logicalOrExpression_missing_RHS() throws Exception {
- BinaryExpression expression = parseExpression("x ||");
+ BinaryExpression expression = parseExpression("x ||", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand());
assertTrue(expression.getRightOperand().isSynthetic());
}
public void test_logicalOrExpression_precedence_logicalAnd_left() throws Exception {
- BinaryExpression expression = parseExpression("&& ||");
+ BinaryExpression expression = parseExpression(
+ "&& ||",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(BinaryExpression.class, expression.getLeftOperand());
}
public void test_logicalOrExpression_precedence_logicalAnd_right() throws Exception {
- BinaryExpression expression = parseExpression("|| &&");
+ BinaryExpression expression = parseExpression(
+ "|| &&",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(BinaryExpression.class, expression.getRightOperand());
}
public void test_multiplicativeExpression_missing_LHS() throws Exception {
- BinaryExpression expression = parseExpression("* y");
+ BinaryExpression expression = parseExpression("* y", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getLeftOperand());
assertTrue(expression.getLeftOperand().isSynthetic());
}
public void test_multiplicativeExpression_missing_LHS_RHS() throws Exception {
- BinaryExpression expression = parseExpression("*");
+ BinaryExpression expression = parseExpression(
+ "*",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getLeftOperand());
assertTrue(expression.getLeftOperand().isSynthetic());
assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand());
@@ -422,47 +530,53 @@ public class RecoveryParserTest extends ParserTestCase {
}
public void test_multiplicativeExpression_missing_RHS() throws Exception {
- BinaryExpression expression = parseExpression("x *");
+ BinaryExpression expression = parseExpression("x *", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand());
assertTrue(expression.getRightOperand().isSynthetic());
}
public void test_multiplicativeExpression_missing_RHS_super() throws Exception {
- BinaryExpression expression = parseExpression("super *");
+ BinaryExpression expression = parseExpression("super *", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand());
assertTrue(expression.getRightOperand().isSynthetic());
}
public void test_multiplicativeExpression_precedence_unary_left() throws Exception {
- BinaryExpression expression = parseExpression("-x *");
+ BinaryExpression expression = parseExpression("-x *", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(PrefixExpression.class, expression.getLeftOperand());
}
public void test_multiplicativeExpression_precedence_unary_right() throws Exception {
- BinaryExpression expression = parseExpression("* -y");
+ BinaryExpression expression = parseExpression("* -y", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(PrefixExpression.class, expression.getRightOperand());
}
public void test_multiplicativeExpression_super() throws Exception {
- BinaryExpression expression = parseExpression("super == ==");
+ BinaryExpression expression = parseExpression(
+ "super == ==",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(BinaryExpression.class, expression.getLeftOperand());
}
public void test_prefixExpression_missing_operand_minus() throws Exception {
- PrefixExpression expression = parseExpression("-");
+ PrefixExpression expression = parseExpression("-", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getOperand());
assertTrue(expression.getOperand().isSynthetic());
assertEquals(TokenType.MINUS, expression.getOperator().getType());
}
public void test_relationalExpression_missing_LHS() throws Exception {
- IsExpression expression = parseExpression("is y");
+ IsExpression expression = parseExpression("is y", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getExpression());
assertTrue(expression.getExpression().isSynthetic());
}
public void test_relationalExpression_missing_LHS_RHS() throws Exception {
- IsExpression expression = parseExpression("is", ParserErrorCode.EXPECTED_TYPE_NAME);
+ IsExpression expression = parseExpression(
+ "is",
+ ParserErrorCode.EXPECTED_TYPE_NAME,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getExpression());
assertTrue(expression.getExpression().isSynthetic());
assertInstanceOf(TypeName.class, expression.getType());
@@ -476,18 +590,25 @@ public class RecoveryParserTest extends ParserTestCase {
}
public void test_relationalExpression_precedence_shift_right() throws Exception {
- IsExpression expression = parseExpression("<< is", ParserErrorCode.EXPECTED_TYPE_NAME);
+ IsExpression expression = parseExpression(
+ "<< is",
+ ParserErrorCode.EXPECTED_TYPE_NAME,
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(BinaryExpression.class, expression.getExpression());
}
public void test_shiftExpression_missing_LHS() throws Exception {
- BinaryExpression expression = parseExpression("<< y");
+ BinaryExpression expression = parseExpression("<< y", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getLeftOperand());
assertTrue(expression.getLeftOperand().isSynthetic());
}
public void test_shiftExpression_missing_LHS_RHS() throws Exception {
- BinaryExpression expression = parseExpression("<<");
+ BinaryExpression expression = parseExpression(
+ "<<",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getLeftOperand());
assertTrue(expression.getLeftOperand().isSynthetic());
assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand());
@@ -495,13 +616,13 @@ public class RecoveryParserTest extends ParserTestCase {
}
public void test_shiftExpression_missing_RHS() throws Exception {
- BinaryExpression expression = parseExpression("x <<");
+ BinaryExpression expression = parseExpression("x <<", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand());
assertTrue(expression.getRightOperand().isSynthetic());
}
public void test_shiftExpression_missing_RHS_super() throws Exception {
- BinaryExpression expression = parseExpression("super <<");
+ BinaryExpression expression = parseExpression("super <<", ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(SimpleIdentifier.class, expression.getRightOperand());
assertTrue(expression.getRightOperand().isSynthetic());
}
@@ -509,19 +630,26 @@ public class RecoveryParserTest extends ParserTestCase {
public void test_shiftExpression_precedence_unary_left() throws Exception {
BinaryExpression expression = parseExpression(
"+ <<",
- ParserErrorCode.USE_OF_UNARY_PLUS_OPERATOR);
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(BinaryExpression.class, expression.getLeftOperand());
}
public void test_shiftExpression_precedence_unary_right() throws Exception {
BinaryExpression expression = parseExpression(
"<< +",
- ParserErrorCode.USE_OF_UNARY_PLUS_OPERATOR);
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(BinaryExpression.class, expression.getRightOperand());
}
public void test_shiftExpression_super() throws Exception {
- BinaryExpression expression = parseExpression("super << <<");
+ BinaryExpression expression = parseExpression(
+ "super << <<",
+ ParserErrorCode.MISSING_IDENTIFIER,
+ ParserErrorCode.MISSING_IDENTIFIER);
assertInstanceOf(BinaryExpression.class, expression.getLeftOperand());
}

Powered by Google App Engine
This is Rietveld 408576698