| 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 import "package:expect/expect.dart"; | |
| 6 | |
| 7 // Test to make sure the bailout environment in dart2js is correct. | |
| 8 | |
| 9 var global; | |
| 10 | |
| 11 class A { | |
| 12 var array; | |
| 13 | |
| 14 initArray() { | |
| 15 return global[0] == null ? [null] : new Map(); | |
| 16 } | |
| 17 | |
| 18 bar() { | |
| 19 array = initArray(); | |
| 20 do { | |
| 21 var element = array[0]; // bailout here | |
| 22 if (element is Map) continue; | |
| 23 if (element == null) break; | |
| 24 } while (true); | |
| 25 return global[0]; // bailout here | |
| 26 } | |
| 27 | |
| 28 baz() { | |
| 29 do { | |
| 30 var element = bar(); | |
| 31 if (element == null) return global[0]; // bailout here | |
| 32 if (element is Map) continue; | |
| 33 if (element is num) break; | |
| 34 } while (true); | |
| 35 return global[0]; // bailout here | |
| 36 } | |
| 37 } | |
| 38 | |
| 39 void main() { | |
| 40 global = [1]; | |
| 41 for (int i = 0; i < 2; i++) { | |
| 42 Expect.equals(1, new A().baz()); | |
| 43 Expect.equals(1, new A().bar()); | |
| 44 } | |
| 45 global = new Map(); | |
| 46 for (int i = 0; i < 2; i++) { | |
| 47 Expect.equals(null, new A().baz()); | |
| 48 Expect.equals(null, new A().bar()); | |
| 49 } | |
| 50 | |
| 51 global[0] = 42; | |
| 52 for (int i = 0; i < 2; i++) { | |
| 53 Expect.equals(42, new A().baz()); | |
| 54 Expect.equals(42, new A().bar()); | |
| 55 } | |
| 56 } | |
| OLD | NEW |