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

Unified Diff: tests/compiler/dart2js/simple_inferrer_test.dart

Issue 23050002: Handle switch with default case, and do/while loop better in the inferrer. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/types/inferrer_visitor.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/simple_inferrer_test.dart
===================================================================
--- tests/compiler/dart2js/simple_inferrer_test.dart (revision 26047)
+++ tests/compiler/dart2js/simple_inferrer_test.dart (working copy)
@@ -296,13 +296,20 @@
}
testSwitch4() {
- switch(topLevelGetter) {
+ switch (topLevelGetter) {
case 1: break;
default: break;
}
return 42;
}
+testSwitch5() {
+ switch (topLevelGetter) {
+ case 1: return 1;
+ default: return 2;
+ }
+}
+
testContinue1() {
var a = 42;
var b;
@@ -364,6 +371,43 @@
return testReturnItselfOrInt(a);
}
+testDoWhile1() {
+ var a = 42;
+ do {
+ a = 'foo';
+ } while (true);
+ return a;
+}
+
+testDoWhile2() {
+ var a = 42;
+ do {
+ a = 'foo';
+ return;
+ } while (true);
+ return a;
+}
+
+testDoWhile3() {
+ var a = 42;
+ do {
+ a = 'foo';
+ if (true) continue;
+ return 42;
+ } while (true);
+ return a;
+}
+
+testDoWhile4() {
+ var a = 'foo';
+ do {
+ a = 54;
+ if (true) break;
+ return 3.5;
+ } while (true);
+ return a;
+}
+
testReturnInvokeDynamicGetter() => new A().myFactory();
var topLevelConstList = const [42];
@@ -453,10 +497,15 @@
testSwitch2();
testSwitch3();
testSwitch4();
+ testSwitch5();
testContinue1();
testBreak1();
testContinue2();
testBreak2();
+ testDoWhile1();
+ testDoWhile2();
+ testDoWhile3();
+ testDoWhile4();
new A() == null;
new A()..returnInt1()
..returnInt2()
@@ -544,12 +593,10 @@
checkReturn('testLabeledIf', typesTask.intType.nullable());
checkReturn('testSwitch1', typesTask.intType
.union(typesTask.doubleType, compiler).nullable().simplify(compiler));
- // TODO(12320): testSwitch2 should be non-nullable. The quick fix for 12320
- // models control flow through as though there is an additional empty default
- // case.
- checkReturn('testSwitch2', typesTask.intType.nullable());
+ checkReturn('testSwitch2', typesTask.intType);
checkReturn('testSwitch3', interceptorType.nullable());
checkReturn('testSwitch4', typesTask.intType);
+ checkReturn('testSwitch5', typesTask.intType);
checkReturn('testContinue1', interceptorType.nullable());
checkReturn('testBreak1', interceptorType.nullable());
checkReturn('testContinue2', interceptorType.nullable());
@@ -559,6 +606,11 @@
checkReturn('testReturnItselfOrInt', typesTask.intType);
checkReturn('testReturnInvokeDynamicGetter', typesTask.dynamicType);
+ checkReturn('testDoWhile1', typesTask.stringType);
+ checkReturn('testDoWhile2', typesTask.nullType);
+ checkReturn('testDoWhile3', interceptorType);
+ checkReturn('testDoWhile4', typesTask.numType);
+
checkReturnInClass(String className, String methodName, type) {
var cls = findElement(compiler, className);
var element = cls.lookupLocalMember(buildSourceString(methodName));
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/types/inferrer_visitor.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698