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

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

Issue 14890026: Handle switch statement in simple types inferrer. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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 | « tests/compiler/dart2js/mock_compiler.dart ('k') | tests/language/issue10581_test.dart » ('j') | 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 22849)
+++ tests/compiler/dart2js/simple_inferrer_test.dart (working copy)
@@ -236,6 +236,36 @@
return topLevelGetter() as Foo;
}
+testSwitch1() {
+ var a = null;
+ switch (topLevelGetter) {
+ case 100: a = 42.5; break;
+ case 200: a = 42; break;
+ }
+ return a;
+}
+
+testSwitch2() {
+ var a = null;
+ switch (topLevelGetter) {
+ case 100: a = 42; break;
+ case 200: a = 42; break;
+ default:
+ a = 43;
+ }
+ return a;
+}
+
+testSwitch3() {
+ var a = 42;
+ var b;
+ switch (topLevelGetter) {
+ L1: case 1: b = a + 42; break;
+ case 2: a = 'foo'; continue L1;
+ }
+ return b;
+}
+
get topLevelGetter => 42;
returnDynamic() => topLevelGetter(42);
@@ -307,6 +337,9 @@
returnAsString();
returnIntAsNum();
returnAsTypedef();
+ testSwitch1();
+ testSwitch2();
+ testSwitch3();
new A() == null;
new A()..returnInt1()
..returnInt2()
@@ -379,6 +412,10 @@
new TypeMask.subtype(compiler.stringClass.computeType(compiler)));
checkReturn('returnIntAsNum', typesInferrer.intType);
checkReturn('returnAsTypedef', typesInferrer.functionType.nullable());
+ checkReturn('testSwitch1',
+ typesInferrer.intType.union(typesInferrer.doubleType, compiler).nullable());
+ checkReturn('testSwitch2', typesInferrer.intType);
+ checkReturn('testSwitch3', interceptorType.nullable());
checkReturnInClass(String className, String methodName, type) {
var cls = findElement(compiler, className);
« no previous file with comments | « tests/compiler/dart2js/mock_compiler.dart ('k') | tests/language/issue10581_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698