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

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

Issue 241823002: Change UNDEFINED_FUNCTION from an error to a warning (issues 18274, 15315). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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/StaticTypeWarningCodeTest.java
diff --git a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/StaticTypeWarningCodeTest.java b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/StaticTypeWarningCodeTest.java
index c1e3fe22161d6c53ce2549cfca6e922aa21723f2..7af67604bbafbbb6fbab3f39e5f5a1d8ca8daf16 100644
--- a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/StaticTypeWarningCodeTest.java
+++ b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/StaticTypeWarningCodeTest.java
@@ -14,6 +14,7 @@
package com.google.dart.engine.resolver;
import com.google.dart.engine.error.StaticTypeWarningCode;
+import com.google.dart.engine.error.StaticWarningCode;
import com.google.dart.engine.source.Source;
public class StaticTypeWarningCodeTest extends ResolverTestCase {
@@ -26,6 +27,24 @@ public class StaticTypeWarningCodeTest extends ResolverTestCase {
verify(source);
}
+ public void test_ambiguousImport_function() throws Exception {
+ Source source = addSource(createSource(//
+ "import 'lib1.dart';",
+ "import 'lib2.dart';",
+ "g() { return f(); }"));
+ addNamedSource("/lib1.dart", createSource(//
+ "library lib1;",
+ "f() {}"));
+ addNamedSource("/lib2.dart", createSource(//
+ "library lib2;",
+ "f() {}"));
+ resolve(source);
+ assertErrors(
+ source,
+ StaticWarningCode.AMBIGUOUS_IMPORT,
+ StaticTypeWarningCode.UNDEFINED_FUNCTION);
+ }
+
public void test_expectedOneListTypeArgument() throws Exception {
Source source = addSource(createSource(//
"main() {",
@@ -949,6 +968,47 @@ public class StaticTypeWarningCodeTest extends ResolverTestCase {
assertErrors(source, StaticTypeWarningCode.UNDEFINED_GETTER);
}
+ public void test_undefinedFunction() throws Exception {
+ Source source = addSource(createSource(//
+ "void f() {",
+ " g();",
+ "}"));
+ resolve(source);
+ assertErrors(source, StaticTypeWarningCode.UNDEFINED_FUNCTION);
+ }
+
+ public void test_undefinedFunction_hasImportPrefix() throws Exception {
+ Source source = addSource(createSource(//
+ "import 'lib.dart' as f;",
+ "main() { return f(); }"));
+ addNamedSource("/lib.dart", "library lib;");
+ resolve(source);
+ assertErrors(source, StaticTypeWarningCode.UNDEFINED_FUNCTION);
+ }
+
+ public void test_undefinedFunction_inCatch() throws Exception {
+ Source source = addSource(createSource(//
+ "void f() {",
+ " try {",
+ " } on Object {",
+ " g();",
+ " }",
+ "}"));
+ resolve(source);
+ assertErrors(source, StaticTypeWarningCode.UNDEFINED_FUNCTION);
+ }
+
+ public void test_undefinedFunction_inImportedLib() throws Exception {
+ Source source = addSource(createSource(//
+ "import 'lib.dart' as f;",
+ "main() { return f.g(); }"));
+ addNamedSource("/lib.dart", createSource(//
+ "library lib;",
+ "h() {}"));
+ resolve(source);
+ assertErrors(source, StaticTypeWarningCode.UNDEFINED_FUNCTION);
+ }
+
public void test_undefinedGetter() throws Exception {
Source source = addSource(createSource(//
"class T {}",

Powered by Google App Engine
This is Rietveld 408576698