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