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

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

Issue 10542098: Issue 3404. Static & top level functions are constant (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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/resolver/CompileTimeConstantTest.java
diff --git a/compiler/javatests/com/google/dart/compiler/resolver/CompileTimeConstantTest.java b/compiler/javatests/com/google/dart/compiler/resolver/CompileTimeConstantTest.java
index b851c8c697f3265c43460d3616bbb5b05746e0e7..356c138547179f754541cb78284391d1773a02da 100644
--- a/compiler/javatests/com/google/dart/compiler/resolver/CompileTimeConstantTest.java
+++ b/compiler/javatests/com/google/dart/compiler/resolver/CompileTimeConstantTest.java
@@ -79,6 +79,45 @@ public class CompileTimeConstantTest extends ResolverTestCase {
errEx(ResolverErrorCode.CIRCULAR_REFERENCE, 3, 20, 1),
errEx(ResolverErrorCode.CIRCULAR_REFERENCE, 4, 20, 1));
}
+
+ public void test_topLevelFunctionReference() {
+ resolveAndTestCtConstExpectErrors(Joiner.on("\n").join(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class Object {}",
+ "m() {}",
+ "class A {",
+ " static final V1 = m;",
+ "}",
+ "final V2 = m;",
+ ""));
+ }
+
+ public void test_staticMethodReference() {
+ resolveAndTestCtConstExpectErrors(Joiner.on("\n").join(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class Object {}",
+ "class A {",
+ " static m() {}",
+ " static final V1 = m;",
+ "}",
+ "final V2 = A.m;",
+ ""));
+ }
+
+ public void test_instanceMethodReference() {
+ resolveAndTestCtConstExpectErrors(
+ Joiner.on("\n").join(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class Object {}",
+ "class A {",
+ " m() {}",
+ " static final V1 = m;",
+ "}",
+ "final V2 = A.m;",
+ ""),
+ errEx(ResolverErrorCode.EXPECTED_CONSTANT_EXPRESSION, 5, 21, 1),
+ errEx(ResolverErrorCode.EXPECTED_CONSTANT_EXPRESSION, 7, 12, 3));
+ }
public void testConstantBinaryExpression12() {
// Multiple binary expressions
@@ -524,17 +563,6 @@ public class CompileTimeConstantTest extends ResolverTestCase {
errEx(ResolverErrorCode.EXPECTED_CONSTANT_EXPRESSION, 4, 19, 14),
errEx(ResolverErrorCode.EXPECTED_CONSTANT_EXPRESSION, 3, 1, 39));
}
-
- public void testInvalidDefaultParameterWithFunction() {
- resolveAndTestCtConstExpectErrors(
- Joiner.on("\n").join(
- "class Object {}",
- "class Function {}",
- "qwerty() => () {};",
- "topLevel([var x = qwerty]) { x(); }",
- "main() { topLevel(); }"),
- errEx(ResolverErrorCode.EXPECTED_CONSTANT_EXPRESSION, 4, 19, 6));
- }
/**
* Integers used in parenthesis result in integer values.
« no previous file with comments | « compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java ('k') | tests/co19/co19-compiler.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698