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 | |
7 // Test optimized [] on strings. | 5 // Test optimized [] on strings. |
8 | 6 |
9 var a = "abc"; | 7 var a = "abc"; |
10 var b = "øbc"; | 8 var b = "øbc"; |
11 var c = new String.fromCharCodes([123, 456, 789]); | 9 var c = new String.fromCharCodes([123, 456, 789]); |
12 | 10 |
13 test_charat(s, i) { | 11 test_charat(s, i) { |
14 return s[i]; | 12 return s[i]; |
15 } | 13 } |
16 | 14 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 56 |
59 Expect.equals(new String.fromCharCodes([123]), test_charat(c, 0)); | 57 Expect.equals(new String.fromCharCodes([123]), test_charat(c, 0)); |
60 for (var i=0; i<10000; i++) test_charat(c, 0); | 58 for (var i=0; i<10000; i++) test_charat(c, 0); |
61 Expect.equals(new String.fromCharCodes([123]), test_charat(c, 0)); | 59 Expect.equals(new String.fromCharCodes([123]), test_charat(c, 0)); |
62 Expect.equals(new String.fromCharCodes([456]), test_charat(c, 1)); | 60 Expect.equals(new String.fromCharCodes([456]), test_charat(c, 1)); |
63 Expect.equals(new String.fromCharCodes([789]), test_charat(c, 2)); | 61 Expect.equals(new String.fromCharCodes([789]), test_charat(c, 2)); |
64 Expect.throws(() => test_charat(c, 3)); | 62 Expect.throws(() => test_charat(c, 3)); |
65 | 63 |
66 | 64 |
67 } | 65 } |
OLD | NEW |