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

Unified Diff: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java

Issue 258393003: Further work on 17522 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase with bleeding_edge before commit Created 6 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: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java
diff --git a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java
index cf275109ab793a47881c3940f0ce23eeac086574..7cecdb9debb6e1ca328835fe92656dc691824492 100644
--- a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java
+++ b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java
@@ -601,6 +601,36 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
verify(source);
}
+ public void test_constInitializedWithNonConstValueFromDeferredClass() throws Exception {
+ addNamedSource("/lib1.dart", createSource(//
+ "library lib1;",
+ "const V = 1;"));
+ Source source = addSource(createSource(//
+ "library root;",
+ "import 'lib1.dart' deferred as a;",
+ "const B = a.V;"));
+ resolve(source);
+ assertErrors(
+ source,
+ CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY);
+ verify(source);
+ }
+
+ public void test_constInitializedWithNonConstValueFromDeferredClass_nested() throws Exception {
+ addNamedSource("/lib1.dart", createSource(//
+ "library lib1;",
+ "const V = 1;"));
+ Source source = addSource(createSource(//
+ "library root;",
+ "import 'lib1.dart' deferred as a;",
+ "const B = a.V + 1;"));
+ resolve(source);
+ assertErrors(
+ source,
+ CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY);
+ verify(source);
+ }
+
public void test_constInstanceField() throws Exception {
Source source = addSource(createSource(//
"class C {",
@@ -2076,6 +2106,49 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
assertErrors(source, CompileTimeErrorCode.INVALID_ANNOTATION);
}
+ public void test_invalidAnnotationFromDeferredLibrary() throws Exception {
+ // See test_invalidAnnotation_notConstantVariable
+ addNamedSource("/lib1.dart", createSource(//
+ "library lib1;",
+ "class V { const V(); }",
+ "const v = const V();"));
+ Source source = addSource(createSource(//
+ "library root;",
+ "import 'lib1.dart' deferred as a;",
+ "@a.v main () {}"));
+ resolve(source);
+ assertErrors(source, CompileTimeErrorCode.INVALID_ANNOTATION_FROM_DEFERRED_LIBRARY);
+ verify(source);
+ }
+
+ public void test_invalidAnnotationFromDeferredLibrary_constructor() throws Exception {
+ // See test_invalidAnnotation_notConstantVariable
+ addNamedSource("/lib1.dart", createSource(//
+ "library lib1;",
+ "class C { const C(); }"));
+ Source source = addSource(createSource(//
+ "library root;",
+ "import 'lib1.dart' deferred as a;",
+ "@a.C() main () {}"));
+ resolve(source);
+ assertErrors(source, CompileTimeErrorCode.INVALID_ANNOTATION_FROM_DEFERRED_LIBRARY);
+ verify(source);
+ }
+
+ public void test_invalidAnnotationFromDeferredLibrary_namedConstructor() throws Exception {
+ // See test_invalidAnnotation_notConstantVariable
+ addNamedSource("/lib1.dart", createSource(//
+ "library lib1;",
+ "class C { const C.name(); }"));
+ Source source = addSource(createSource(//
+ "library root;",
+ "import 'lib1.dart' deferred as a;",
+ "@a.C.name() main () {}"));
+ resolve(source);
+ assertErrors(source, CompileTimeErrorCode.INVALID_ANNOTATION_FROM_DEFERRED_LIBRARY);
+ verify(source);
+ }
+
public void test_invalidConstructorName_notEnclosingClassName_defined() throws Exception {
Source source = addSource(createSource(//
"class A {",
@@ -2795,6 +2868,32 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
verify(source);
}
+ public void test_nonConstantDefaultValueFromDeferredLibrary() throws Exception {
+ addNamedSource("/lib1.dart", createSource(//
+ "library lib1;",
+ "const V = 1;"));
+ Source source = addSource(createSource(//
+ "library root;",
+ "import 'lib1.dart' deferred as a;",
+ "f({x : a.V}) {}"));
+ resolve(source);
+ assertErrors(source, CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBRARY);
+ verify(source);
+ }
+
+ public void test_nonConstantDefaultValueFromDeferredLibrary_nested() throws Exception {
+ addNamedSource("/lib1.dart", createSource(//
+ "library lib1;",
+ "const V = 1;"));
+ Source source = addSource(createSource(//
+ "library root;",
+ "import 'lib1.dart' deferred as a;",
+ "f({x : a.V + 1}) {}"));
+ resolve(source);
+ assertErrors(source, CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBRARY);
+ verify(source);
+ }
+
public void test_nonConstCaseExpression() throws Exception {
Source source = addSource(createSource(//
"f(int p, int q) {",

Powered by Google App Engine
This is Rietveld 408576698