OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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"; | |
6 | |
7 // Test optimized constant string and constant array access. | 5 // Test optimized constant string and constant array access. |
8 | 6 |
9 int testConstantStringAndIndexCodeUnitAt() { | 7 int testConstantStringAndIndexCodeUnitAt() { |
10 int test(b) { | 8 int test(b) { |
11 if (b) return "hest".codeUnitAt(400); | 9 if (b) return "hest".codeUnitAt(400); |
12 return "hest".codeUnitAt(2); | 10 return "hest".codeUnitAt(2); |
13 } | 11 } |
14 | 12 |
15 Expect.throws(() => test(true)); | 13 Expect.throws(() => test(true)); |
16 for (int i = 0; i < 10000; i++) test(false); | 14 for (int i = 0; i < 10000; i++) test(false); |
(...skipping 25 matching lines...) Expand all Loading... |
42 for (int i = 0; i < 10000; i++) { foo(1); } | 40 for (int i = 0; i < 10000; i++) { foo(1); } |
43 Expect.throws(() => foo(2)); | 41 Expect.throws(() => foo(2)); |
44 } | 42 } |
45 | 43 |
46 | 44 |
47 main() { | 45 main() { |
48 testConstantStringAndIndexCodeUnitAt(); | 46 testConstantStringAndIndexCodeUnitAt(); |
49 testConstantArrayAndIndexAt(); | 47 testConstantArrayAndIndexAt(); |
50 testNonSmiIndex(); | 48 testNonSmiIndex(); |
51 } | 49 } |
OLD | NEW |