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

Unified Diff: compiler/javatests/com/google/dart/compiler/parser/SyntaxTest.java

Issue 9949016: Adds fixes for the 'super' keyword used by itself in certain situations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed ResolverErrorCode Created 8 years, 8 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: compiler/javatests/com/google/dart/compiler/parser/SyntaxTest.java
diff --git a/compiler/javatests/com/google/dart/compiler/parser/SyntaxTest.java b/compiler/javatests/com/google/dart/compiler/parser/SyntaxTest.java
index 0ff46a9408dc6a58fcb3bdd1113c64d83f18e3c6..5eba5c863163c115d1374c1c67a922a7e4b40457 100644
--- a/compiler/javatests/com/google/dart/compiler/parser/SyntaxTest.java
+++ b/compiler/javatests/com/google/dart/compiler/parser/SyntaxTest.java
@@ -27,6 +27,10 @@ import com.google.dart.compiler.ast.DartTryStatement;
import com.google.dart.compiler.ast.DartTypeNode;
import com.google.dart.compiler.ast.DartUnit;
import com.google.dart.compiler.ast.DartVariableStatement;
+import com.google.dart.compiler.parser.ParserErrorCode;
+import com.google.dart.compiler.resolver.ResolverErrorCode;
+
+import static com.google.dart.compiler.common.ErrorExpectation.errEx;
import java.util.List;
@@ -463,4 +467,59 @@ public class SyntaxTest extends AbstractParserTest {
" typedef();",
"}"));
}
+
+ /**
+ * The token 'super' is valid by itself (not as a qualifier or assignment selector) in only some
+ * cases.
+ */
+ public void testLoneSuperExpression1() {
+ parseUnit("phony_lone_super_expression1.dart",
+ Joiner.on("\n").join(
+ "class A {",
+ " method() {",
+ " super;",
+ " super ? true : false;",
+ " true ? true : super;",
+ " true ? super : false;",
+ " if (super && true) { }",
+ " if (super || false) { }",
+ " }",
+ "}"),
+ ParserErrorCode.SUPER_IS_NOT_VALID_ALONE_OR_AS_A_BOOLEAN_OPERAND, 3, 5,
+ ParserErrorCode.SUPER_IS_NOT_VALID_ALONE_OR_AS_A_BOOLEAN_OPERAND, 4, 5,
+ ParserErrorCode.SUPER_IS_NOT_VALID_ALONE_OR_AS_A_BOOLEAN_OPERAND, 5, 19,
+ ParserErrorCode.SUPER_IS_NOT_VALID_ALONE_OR_AS_A_BOOLEAN_OPERAND, 6, 12,
+ ParserErrorCode.SUPER_IS_NOT_VALID_AS_A_BOOLEAN_OPERAND, 7, 9,
+ ParserErrorCode.SUPER_IS_NOT_VALID_AS_A_BOOLEAN_OPERAND, 8, 9);
+ }
+
+ public void testLoneSuperExpression2() throws Exception {
+ parseUnit("phony_lone_super_expression1.dart",
+ Joiner.on("\n").join(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class Object {}",
+ "class A {",
+ " method() {",
+ " if (1 + super) { }", // error
+ " if (super + 1) { }", // ok
+ " if (1 == super) { }", // error
+ " if (super == 1) { }", // ok
+ " if (1 | super) { }", // error
+ " if (super | 1) { }", // ok
+ " if (1 < super) { }", // error
+ " if (super < 1) { }", // ok
+ " if (1 << super) { }", // error
+ " if (super << 1) { }", // ok
+ " if (1 * super) { }", // error
+ " if (super * 1) { }", // ok
+ " var f = -super;", // ok
+ " }",
+ "}"),
+ ParserErrorCode.SUPER_CANNOT_BE_USED_AS_THE_SECOND_OPERAND, 5, 13,
+ ParserErrorCode.SUPER_CANNOT_BE_USED_AS_THE_SECOND_OPERAND, 7, 14,
+ ParserErrorCode.SUPER_CANNOT_BE_USED_AS_THE_SECOND_OPERAND, 9, 13,
+ ParserErrorCode.SUPER_CANNOT_BE_USED_AS_THE_SECOND_OPERAND, 11, 13,
+ ParserErrorCode.SUPER_CANNOT_BE_USED_AS_THE_SECOND_OPERAND, 13, 14,
+ ParserErrorCode.SUPER_CANNOT_BE_USED_AS_THE_SECOND_OPERAND, 15, 13);
+ }
}
« no previous file with comments | « compiler/javatests/com/google/dart/compiler/DartCompilerListenerTest.java ('k') | tests/co19/co19-compiler.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698