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

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

Issue 8564027: Report errors for default parameter values, issue 351 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweaks for tests and other Created 9 years, 1 month 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/NegativeParserTest.java
diff --git a/compiler/javatests/com/google/dart/compiler/parser/NegativeParserTest.java b/compiler/javatests/com/google/dart/compiler/parser/NegativeParserTest.java
index aa002ff5f6de9e97a1bed909b00ccc2560ee2ac5..8cabf932a615c343ed1a584186e141971a76bd1a 100644
--- a/compiler/javatests/com/google/dart/compiler/parser/NegativeParserTest.java
+++ b/compiler/javatests/com/google/dart/compiler/parser/NegativeParserTest.java
@@ -172,4 +172,39 @@ public class NegativeParserTest extends CompilerTestCase {
assertEquals(true, factory.getName() instanceof DartIdentifier);
assertEquals("foo<T>", ((DartIdentifier) factory.getName()).getTargetName());
}
+ public void test_defaultParameterValue_inInterfaceMethod() {
+ parseExpectErrors(
+ "interface A { f(int a, [int b = 12345]); }",
+ errEx(ParserErrorCode.DEFAULT_PARAMETER_INTERFACE, 1, 33, 5));
+ }
+
+ public void test_defaultParameterValue_inAbstractMethod() {
+ parseExpectErrors(
+ "class A { abstract f(int a, [int b = 12345, int c]); }",
+ errEx(ParserErrorCode.DEFAULT_PARAMETER_ABSTRACT, 1, 38, 5));
+ }
+
+ public void test_defaultParameterValue_inClosureTypedef() {
+ parseExpectErrors(
+ "typedef void f(int a, [int b = 12345, inc c]);",
+ errEx(ParserErrorCode.DEFAULT_PARAMETER_TYPEDEF, 1, 32, 5));
+ }
+
+ public void test_defaultParameterValue_inClosure() {
+ parseExpectErrors(
+ "class A {void f(void cb(int a, [int b = 12345, int c])) {}}",
+ errEx(ParserErrorCode.DEFAULT_PARAMETER_CLOSURE, 1, 41, 5));
+ }
+
+ public void test_namedParameterValue_inSetter() {
+ parseExpectErrors(
+ "class A { set f([int b]); }",
+ errEx(ParserErrorCode.EACH_PARAMETER_IS_REQUIRED, 1, 18, 5));
+ }
+
+ public void test_namedParameterValue_inOperator() {
+ parseExpectErrors(
+ "class A { operator []=(int a, [int b]); }",
+ errEx(ParserErrorCode.EACH_PARAMETER_IS_REQUIRED, 1, 32, 5));
+ }
}

Powered by Google App Engine
This is Rietveld 408576698