| 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 CodeUnitAt and array access. | 5 // Test optimized CodeUnitAt and array access. |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; |
| 8 |
| 9 |
| 7 String one_byte = "hest"; | 10 String one_byte = "hest"; |
| 8 String two_byte = "høns"; | 11 String two_byte = "høns"; |
| 9 | 12 |
| 10 int testOneByteCodeUnitAt(String x, int j) { | 13 int testOneByteCodeUnitAt(String x, int j) { |
| 11 int test() { | 14 int test() { |
| 12 return x.codeUnitAt(j); | 15 return x.codeUnitAt(j); |
| 13 } | 16 } |
| 14 for (int i = 0; i < 10000; i++) test(); | 17 for (int i = 0; i < 10000; i++) test(); |
| 15 return test(); | 18 return test(); |
| 16 } | 19 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 Expect.equals(248, testConstantStringCodeUnitAt(1)); | 71 Expect.equals(248, testConstantStringCodeUnitAt(1)); |
| 69 Expect.equals(101, testConstantIndexCodeUnitAt(one_byte)); | 72 Expect.equals(101, testConstantIndexCodeUnitAt(one_byte)); |
| 70 } | 73 } |
| 71 for (int j = 0; j < 2000; j++) { | 74 for (int j = 0; j < 2000; j++) { |
| 72 Expect.equals(436, testOneByteCodeUnitAtInLoop(one_byte)); | 75 Expect.equals(436, testOneByteCodeUnitAtInLoop(one_byte)); |
| 73 Expect.equals(577, testTwoByteCodeUnitAtInLoop(two_byte)); | 76 Expect.equals(577, testTwoByteCodeUnitAtInLoop(two_byte)); |
| 74 } | 77 } |
| 75 Expect.throws(() => testOneByteCodeUnitAtInLoop(123)); | 78 Expect.throws(() => testOneByteCodeUnitAtInLoop(123)); |
| 76 Expect.throws(() => testTwoByteCodeUnitAtInLoop(123)); | 79 Expect.throws(() => testTwoByteCodeUnitAtInLoop(123)); |
| 77 } | 80 } |
| OLD | NEW |