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

Unified Diff: compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java

Issue 10854106: Issue 4347. Report error if ++/-- is applied to final variable (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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
« no previous file with comments | « compiler/java/com/google/dart/compiler/resolver/Resolver.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java
diff --git a/compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java b/compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java
index 7650db981044de9f39add0140e3295d035672a88..02132fa18e4c6154ca4c5b8116654437d3947c22 100644
--- a/compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java
+++ b/compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java
@@ -1358,4 +1358,68 @@ public class NegativeResolverTest extends CompilerTestCase {
"}"),
errEx(ResolverErrorCode.CANNOT_BE_RESOLVED, 4, 21, 1));
}
+
+ /**
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=4374
+ */
+ public void test_unaryOperatorForFinal_variable() throws Exception {
+ checkSourceErrors(
+ makeCode(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "main() {",
+ " final v = 0;",
+ " v++;",
+ " v--;",
+ " ++v;",
+ " --v;",
+ "}"),
+ errEx(ResolverErrorCode.CANNOT_ASSIGN_TO_FINAL, 4, 3, 1),
+ errEx(ResolverErrorCode.CANNOT_ASSIGN_TO_FINAL, 5, 3, 1),
+ errEx(ResolverErrorCode.CANNOT_ASSIGN_TO_FINAL, 6, 5, 1),
+ errEx(ResolverErrorCode.CANNOT_ASSIGN_TO_FINAL, 7, 5, 1));
+ }
+
+ /**
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=4374
+ */
+ public void test_unaryOperatorForFinal_parameter() throws Exception {
+ checkSourceErrors(
+ makeCode(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "foo(final v) {",
+ " v++;",
+ " v--;",
+ " ++v;",
+ " --v;",
+ "}"),
+ errEx(ResolverErrorCode.CANNOT_ASSIGN_TO_FINAL, 3, 3, 1),
+ errEx(ResolverErrorCode.CANNOT_ASSIGN_TO_FINAL, 4, 3, 1),
+ errEx(ResolverErrorCode.CANNOT_ASSIGN_TO_FINAL, 5, 5, 1),
+ errEx(ResolverErrorCode.CANNOT_ASSIGN_TO_FINAL, 6, 5, 1));
+ }
+
+ /**
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=4374
+ */
+ public void test_unaryOperatorForFinal_field() throws Exception {
+ checkSourceErrors(
+ makeCode(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A {",
+ " final v = 0;",
+ " foo() {",
+ " v++;",
+ " v--;",
+ " ++v;",
+ " --v;",
+ " }",
+ "}"),
+ errEx(ResolverErrorCode.CANNOT_ASSIGN_TO_FINAL, 5, 5, 1),
+ errEx(ResolverErrorCode.CANNOT_ASSIGN_TO_FINAL, 6, 5, 1),
+ errEx(ResolverErrorCode.CANNOT_ASSIGN_TO_FINAL, 7, 7, 1),
+ errEx(ResolverErrorCode.CANNOT_ASSIGN_TO_FINAL, 8, 7, 1));
+ }
}
« no previous file with comments | « compiler/java/com/google/dart/compiler/resolver/Resolver.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698