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 // Test optimized constant string and constant array access. | 5 // Test optimized constant string and constant array access. |
6 | 6 |
7 int testConstantStringAndIndexCharCodeAt() { | 7 int testConstantStringAndIndexCodeUnitAt() { |
8 int test(b) { | 8 int test(b) { |
9 if (b) return "hest".charCodeAt(400); | 9 if (b) return "hest".codeUnitAt(400); |
10 return "hest".charCodeAt(2); | 10 return "hest".codeUnitAt(2); |
11 } | 11 } |
12 | 12 |
13 Expect.throws(() => test(true)); | 13 Expect.throws(() => test(true)); |
14 for (int i = 0; i < 10000; i++) test(false); | 14 for (int i = 0; i < 10000; i++) test(false); |
15 Expect.throws(() => test(true)); | 15 Expect.throws(() => test(true)); |
16 } | 16 } |
17 | 17 |
18 | 18 |
19 int testConstantArrayAndIndexAt() { | 19 int testConstantArrayAndIndexAt() { |
20 int test(b) { | 20 int test(b) { |
(...skipping 15 matching lines...) Expand all Loading... |
36 } | 36 } |
37 | 37 |
38 | 38 |
39 int testNonSmiIndex() { | 39 int testNonSmiIndex() { |
40 for (int i = 0; i < 10000; i++) { foo(1); } | 40 for (int i = 0; i < 10000; i++) { foo(1); } |
41 Expect.throws(() => foo(2)); | 41 Expect.throws(() => foo(2)); |
42 } | 42 } |
43 | 43 |
44 | 44 |
45 main() { | 45 main() { |
46 testConstantStringAndIndexCharCodeAt(); | 46 testConstantStringAndIndexCodeUnitAt(); |
47 testConstantArrayAndIndexAt(); | 47 testConstantArrayAndIndexAt(); |
48 testNonSmiIndex(); | 48 testNonSmiIndex(); |
49 } | 49 } |
OLD | NEW |