| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 // Test optimized [] on strings. |
| 6 |
| 7 var a = "abc"; |
| 8 var b = "øbc"; |
| 9 var c = new String.fromCharCodes([123, 456, 789]); |
| 10 |
| 11 test_charat(s, i) { |
| 12 return s[i]; |
| 13 } |
| 14 |
| 15 main() { |
| 16 Expect.equals("a", test_charat(a, 0)); |
| 17 for (var i=0; i<10000; i++) test_charat(a, 0); |
| 18 Expect.equals("a", test_charat(a, 0)); |
| 19 Expect.equals("b", test_charat(a, 1)); |
| 20 Expect.equals("c", test_charat(a, 2)); |
| 21 Expect.throws(() => test_charat(a, 3)); |
| 22 |
| 23 Expect.equals("ø", test_charat(b, 0)); |
| 24 for (var i=0; i<10000; i++) test_charat(b, 0); |
| 25 Expect.equals("ø", test_charat(b, 0)); |
| 26 Expect.equals("b", test_charat(b, 1)); |
| 27 Expect.equals("c", test_charat(b, 2)); |
| 28 Expect.throws(() => test_charat(b, 3)); |
| 29 |
| 30 Expect.equals(new String.fromCharCodes([123]), test_charat(c, 0)); |
| 31 for (var i=0; i<10000; i++) test_charat(c, 0); |
| 32 Expect.equals(new String.fromCharCodes([123]), test_charat(c, 0)); |
| 33 Expect.equals(new String.fromCharCodes([456]), test_charat(c, 1)); |
| 34 Expect.equals(new String.fromCharCodes([789]), test_charat(c, 2)); |
| 35 Expect.throws(() => test_charat(c, 3)); |
| 36 } |
| OLD | NEW |