OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012, 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 // Test program for correct optimizations related to types fo allocated lists. |
| 5 |
| 6 // Classes to induce polymorphism of degree 10. |
| 7 class A0 { |
| 8 test() => 0; |
| 9 } |
| 10 |
| 11 class A1 { |
| 12 test() => 1; |
| 13 } |
| 14 |
| 15 class A2 { |
| 16 test() => 2; |
| 17 } |
| 18 |
| 19 class A3 { |
| 20 test() => 3; |
| 21 } |
| 22 |
| 23 class A4 { |
| 24 test() => 4; |
| 25 } |
| 26 |
| 27 class A5 { |
| 28 test() => 5; |
| 29 } |
| 30 |
| 31 class A6 { |
| 32 test() => 6; |
| 33 } |
| 34 |
| 35 class A7 { |
| 36 test() => 7; |
| 37 } |
| 38 |
| 39 class A8 { |
| 40 test() => 8; |
| 41 } |
| 42 |
| 43 class A9 { |
| 44 test() => 9; |
| 45 } |
| 46 |
| 47 // Class with no test method. |
| 48 class B { } |
| 49 |
| 50 test(obj) { |
| 51 return obj.test(); |
| 52 } |
| 53 |
| 54 main() { |
| 55 // Trigger optimization of 'test' function. |
| 56 List list = [new A0(), new A1(), new A2(), new A3(), new A4(), |
| 57 new A5(), new A6(), new A7(), new A8(), new A9()]; |
| 58 for (int i = 0; i < 1000; i++) { |
| 59 for (var obj in list) { |
| 60 test(obj); |
| 61 } |
| 62 } |
| 63 Expect.throws(() => test(new B()), (e) => e is NoSuchMethodError); |
| 64 } |
OLD | NEW |