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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/compiler/dart2js/simple_inferrer_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 // Regression test for https://code.google.com/p/dart/issues/detail?id=10581.
6
7 import 'package:expect/expect.dart';
8
9 abstract class AxesObject {
10 Update();
11 }
12
13 String result = '';
14
15 class Point2DObject extends AxesObject {
16 Update() { result += 'P'; }
17 }
18
19 class BestFitObject extends AxesObject {
20 Update() { result += 'B'; }
21 }
22
23 class Foo {
24 AddAxesObject(type) {
25 AxesObject a = null;
26 switch (type) {
27 case 100:
28 a = new Point2DObject();
29 break;
30 case 200:
31 a = new BestFitObject();
32 break;
33 }
34 if (a != null) {
35 a.Update();
36 }
37 }
38 AddAxesObject2(type) {
39 AxesObject a = null;
40 if (type == 100) {
41 a = new Point2DObject();
42 } else if (type == 200) {
43 a = new BestFitObject();
44 }
45 if (a != null) {
46 a.Update();
47 }
48 }
49 }
50
51 main() {
52 var f = new Foo();
53 f.AddAxesObject(100);
54 f.AddAxesObject(200);
55 f.AddAxesObject2(100);
56 f.AddAxesObject2(200);
57 Expect.equals('PBPB', result);
58 }
OLDNEW
« 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