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

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

Issue 34523011: Issue 13807. Support for type promotion rules. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updates after review comments Created 7 years, 2 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 420dafd02ed37148007a094c160d33d2c32a90f2..baaeb1c0808fe8da0cea5506405252676cd28716 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
@@ -707,6 +707,86 @@ public class StaticTypeWarningCodeTest extends ResolverTestCase {
verify(source);
}
+ public void test_typePromotion_booleanAnd_useInRight_accessedInClosureRight_mutated()
+ throws Exception {
+ Source source = addSource(createSource(//
+ "callMe(f()) { f(); }",
+ "main(Object p) {",
+ " (p is String) && callMe(() { p.length; });",
+ " p = 0;",
+ "}"));
+ resolve(source);
+ assertErrors(source, StaticTypeWarningCode.UNDEFINED_GETTER);
+ }
+
+ public void test_typePromotion_booleanAnd_useInRight_mutatedInLeft() throws Exception {
+ Source source = addSource(createSource(//
+ "main(Object p) {",
+ " ((p is String) && ((p = 42) == 42)) && p.length != 0;",
+ "}"));
+ resolve(source);
+ assertErrors(source, StaticTypeWarningCode.UNDEFINED_GETTER);
+ }
+
+ public void test_typePromotion_booleanAnd_useInRight_mutatedInRight() throws Exception {
+ Source source = addSource(createSource(//
+ "main(Object p) {",
+ " (p is String) && (((p = 42) == 42) && p.length != 0);",
+ "}"));
+ resolve(source);
+ assertErrors(source, StaticTypeWarningCode.UNDEFINED_GETTER);
+ }
+
+ public void test_typePromotion_if_accessedInClosure_hasAssignment() throws Exception {
+ Source source = addSource(createSource(//
+ "callMe(f()) { f(); }",
+ "main(Object p) {",
+ " if (p is String) {",
+ " callMe(() {",
+ " p.length;",
+ " });",
+ " }",
+ " p = 0;",
+ "}"));
+ resolve(source);
+ assertErrors(source, StaticTypeWarningCode.UNDEFINED_GETTER);
+ }
+
+ public void test_typePromotion_if_and_right_hasAssignment() throws Exception {
+ Source source = addSource(createSource(//
+ "main(Object p) {",
+ " if (p is String && (p = null) == null) {",
+ " p.length;",
+ " }",
+ "}"));
+ resolve(source);
+ assertErrors(source, StaticTypeWarningCode.UNDEFINED_GETTER);
+ }
+
+ public void test_typePromotion_if_hasAssignment_after() throws Exception {
+ Source source = addSource(createSource(//
+ "main(Object p) {",
+ " if (p is String) {",
+ " p.length;",
+ " p = 0;",
+ " }",
+ "}"));
+ resolve(source);
+ assertErrors(source, StaticTypeWarningCode.UNDEFINED_GETTER);
+ }
+
+ public void test_typePromotion_if_hasAssignment_before() throws Exception {
+ Source source = addSource(createSource(//
+ "main(Object p) {",
+ " if (p is String) {",
+ " p = 0;",
+ " p.length;",
+ " }",
+ "}"));
+ resolve(source);
+ assertErrors(source, StaticTypeWarningCode.UNDEFINED_GETTER);
+ }
+
public void test_undefinedGetter() throws Exception {
Source source = addSource(createSource(//
"class T {}",

Powered by Google App Engine
This is Rietveld 408576698