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

Unified Diff: tests/language/issue10581_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/simple_inferrer_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/issue10581_test.dart
===================================================================
--- tests/language/issue10581_test.dart (revision 0)
+++ tests/language/issue10581_test.dart (revision 0)
@@ -0,0 +1,58 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Regression test for https://code.google.com/p/dart/issues/detail?id=10581.
+
+import 'package:expect/expect.dart';
+
+abstract class AxesObject {
+ Update();
+}
+
+String result = '';
+
+class Point2DObject extends AxesObject {
+ Update() { result += 'P'; }
+}
+
+class BestFitObject extends AxesObject {
+ Update() { result += 'B'; }
+}
+
+class Foo {
+ AddAxesObject(type) {
+ AxesObject a = null;
+ switch (type) {
+ case 100:
+ a = new Point2DObject();
+ break;
+ case 200:
+ a = new BestFitObject();
+ break;
+ }
+ if (a != null) {
+ a.Update();
+ }
+ }
+ AddAxesObject2(type) {
+ AxesObject a = null;
+ if (type == 100) {
+ a = new Point2DObject();
+ } else if (type == 200) {
+ a = new BestFitObject();
+ }
+ if (a != null) {
+ a.Update();
+ }
+ }
+}
+
+main() {
+ var f = new Foo();
+ f.AddAxesObject(100);
+ f.AddAxesObject(200);
+ f.AddAxesObject2(100);
+ f.AddAxesObject2(200);
+ Expect.equals('PBPB', result);
+}
« no previous file with comments | « tests/compiler/dart2js/simple_inferrer_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698