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