| OLD | NEW |
| (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 } |
| OLD | NEW |