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

Unified Diff: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/NonErrorResolverTest.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/NonErrorResolverTest.java
diff --git a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/NonErrorResolverTest.java b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/NonErrorResolverTest.java
index cec3747c83bd04bfc4ca36ee8e4b95e04153eab6..1ea4b75bcd7c2e434d606aa5933f7622adcfbfab 100644
--- a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/NonErrorResolverTest.java
+++ b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/NonErrorResolverTest.java
@@ -2987,6 +2987,119 @@ public class NonErrorResolverTest extends ResolverTestCase {
verify(source);
}
+ public void test_typePromotion_booleanAnd_useInRight() throws Exception {
+ Source source = addSource(createSource(//
+ "main(Object p) {",
+ " p is String && p.length != 0;",
+ "}"));
+ resolve(source);
+ assertNoErrors(source);
+ verify(source);
+ }
+
+ public void test_typePromotion_booleanAnd_useInRight_accessedInClosureRight_noAssignment()
+ throws Exception {
+ Source source = addSource(createSource(//
+ "callMe(f()) { f(); }",
+ "main(Object p) {",
+ " (p is String) && callMe(() { p.length; });",
+ "}"));
+ resolve(source);
+ assertNoErrors(source);
+ verify(source);
+ }
+
+ public void test_typePromotion_if_accessedInClosure_noAssignment() throws Exception {
+ Source source = addSource(createSource(//
+ "callMe(f()) { f(); }",
+ "main(Object p) {",
+ " if (p is String) {",
+ " callMe(() {",
+ " p.length;",
+ " });",
+ " }",
+ "}"));
+ resolve(source);
+ assertNoErrors(source);
+ verify(source);
+ }
+
+ public void test_typePromotion_if_hasAssignment_outsideAfter() throws Exception {
+ Source source = addSource(createSource(//
+ "main(Object p) {",
+ " if (p is String) {",
+ " p.length;",
+ " }",
+ " p = 0;",
+ "}"));
+ resolve(source);
+ assertNoErrors(source);
+ verify(source);
+ }
+
+ public void test_typePromotion_if_hasAssignment_outsideBefore() throws Exception {
+ Source source = addSource(createSource(//
+ "main(Object p, Object p2) {",
+ " p = p2;",
+ " if (p is String) {",
+ " p.length;",
+ " }",
+ "}"));
+ resolve(source);
+ assertNoErrors(source);
+ verify(source);
+ }
+
+ public void test_typePromotion_if_is_and_left() throws Exception {
+ Source source = addSource(createSource(//
+ "bool tt() => true;",
+ "main(Object p) {",
+ " if (p is String && tt()) {",
+ " p.length;",
+ " }",
+ "}"));
+ resolve(source);
+ assertNoErrors(source);
+ verify(source);
+ }
+
+ public void test_typePromotion_if_is_and_right() throws Exception {
+ Source source = addSource(createSource(//
+ "bool tt() => true;",
+ "main(Object p) {",
+ " if (tt() && p is String) {",
+ " p.length;",
+ " }",
+ "}"));
+ resolve(source);
+ assertNoErrors(source);
+ verify(source);
+ }
+
+ public void test_typePromotion_if_is_parenthesized() throws Exception {
+ Source source = addSource(createSource(//
+ "main(Object p) {",
+ " if ((p is String)) {",
+ " p.length;",
+ " }",
+ "}"));
+ resolve(source);
+ assertNoErrors(source);
+ verify(source);
+ }
+
+ public void test_typePromotion_if_is_single() throws Exception {
+ Source source = addSource(createSource(//
+ "main(Object p) {",
+ " if (p is String) {",
+ " p.length;",
+ " }",
+ "}"));
+ resolve(source);
+ assertNoErrors(source);
+ verify(source);
+ }
+
public void test_undefinedConstructorInInitializer_explicit_named() throws Exception {
Source source = addSource(createSource(//
"class A {",

Powered by Google App Engine
This is Rietveld 408576698