OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // Test that optimized JSArray removeLast() calls generate the same error as | 5 // Test that optimized JSArray removeLast() calls generate the same error as |
6 // dyncamically dispatched calls. | 6 // dyncamically dispatched calls. |
7 | 7 |
8 import 'package:expect/expect.dart'; | 8 import 'package:expect/expect.dart'; |
9 | 9 |
10 @NoInline() @AssumeDynamic() | 10 @NoInline() |
| 11 @AssumeDynamic() |
11 confuse(x) => x; | 12 confuse(x) => x; |
12 | 13 |
13 | |
14 Error getError(action()) { | 14 Error getError(action()) { |
15 try { | 15 try { |
16 action(); | 16 action(); |
17 Expect.fail('must throw'); | 17 Expect.fail('must throw'); |
18 } catch (e) { | 18 } catch (e) { |
19 return e; | 19 return e; |
20 } | 20 } |
21 } | 21 } |
22 | 22 |
23 main() { | 23 main() { |
24 fault1() { | 24 fault1() { |
25 return confuse([]).removeLast(); | 25 return confuse([]).removeLast(); |
26 } | 26 } |
27 | 27 |
28 fault2() { | 28 fault2() { |
29 var a = []; | 29 var a = []; |
30 while (confuse(false)) a.add(1); | 30 while (confuse(false)) a.add(1); |
31 // This one should be optimized since [a] is a growable JSArray. | 31 // This one should be optimized since [a] is a growable JSArray. |
32 return a.removeLast(); | 32 return a.removeLast(); |
33 } | 33 } |
34 | 34 |
35 var e1 = getError(fault1); | 35 var e1 = getError(fault1); |
36 var e2 = getError(fault2); | 36 var e2 = getError(fault2); |
37 | 37 |
38 Expect.equals('$e1', '$e2'); | 38 Expect.equals('$e1', '$e2'); |
39 } | 39 } |
OLD | NEW |