| 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 |
| 5 // Test optimized charCodeAt and array access. | 7 // Test optimized charCodeAt and array access. |
| 6 | 8 |
| 7 String one_byte = "hest"; | 9 String one_byte = "hest"; |
| 8 String two_byte = "høns"; | 10 String two_byte = "høns"; |
| 9 | 11 |
| 10 int testOneByteCharCodeAt(String x, int i) { | 12 int testOneByteCharCodeAt(String x, int i) { |
| 11 int test() { | 13 int test() { |
| 12 return x.charCodeAt(i); | 14 return x.charCodeAt(i); |
| 13 } | 15 } |
| 14 for (int i = 0; i < 10000; i++) test(); | 16 for (int i = 0; i < 10000; i++) test(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 42 return test(); | 44 return test(); |
| 43 } | 45 } |
| 44 | 46 |
| 45 | 47 |
| 46 main() { | 48 main() { |
| 47 Expect.equals(101, testOneByteCharCodeAt(one_byte, 1)); | 49 Expect.equals(101, testOneByteCharCodeAt(one_byte, 1)); |
| 48 Expect.equals(248, testTwoByteCharCodeAt(two_byte, 1)); | 50 Expect.equals(248, testTwoByteCharCodeAt(two_byte, 1)); |
| 49 Expect.equals(248, testConstantStringCharCodeAt(1)); | 51 Expect.equals(248, testConstantStringCharCodeAt(1)); |
| 50 Expect.equals(101, testConstantIndexCharCodeAt(one_byte)); | 52 Expect.equals(101, testConstantIndexCharCodeAt(one_byte)); |
| 51 } | 53 } |
| OLD | NEW |