| 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 // VMOptions=--optimization-counter-threshold=10 --no-use-osr --no-background-co
mpilation | 4 // VMOptions=--optimization-counter-threshold=10 --no-use-osr --no-background-co
mpilation |
| 5 | 5 |
| 6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 | 7 |
| 8 // Test optimized [] on strings. | 8 // Test optimized [] on strings. |
| 9 | 9 |
| 10 var a = "abc"; | 10 var a = "abc"; |
| 11 var b = "øbc"; | 11 var b = "øbc"; |
| 12 var c = new String.fromCharCodes([123, 456, 789]); | 12 var c = new String.fromCharCodes([123, 456, 789]); |
| 13 | 13 |
| 14 test_charat(s, i) { | 14 test_charat(s, i) { |
| 15 return s[i]; | 15 return s[i]; |
| 16 } | 16 } |
| 17 | 17 |
| 18 test_const_str(i) { | 18 test_const_str(i) { |
| 19 return "abc"[i]; | 19 return "abc"[i]; |
| 20 } | 20 } |
| 21 | 21 |
| 22 | |
| 23 test_const_index(s) { | 22 test_const_index(s) { |
| 24 return s[0]; | 23 return s[0]; |
| 25 } | 24 } |
| 26 | 25 |
| 27 test_const_index2(s) { | 26 test_const_index2(s) { |
| 28 return s[3]; | 27 return s[3]; |
| 29 } | 28 } |
| 30 | 29 |
| 31 main() { | 30 main() { |
| 32 Expect.equals("a", test_charat(a, 0)); | 31 Expect.equals("a", test_charat(a, 0)); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 56 Expect.equals("b", test_charat(b, 1)); | 55 Expect.equals("b", test_charat(b, 1)); |
| 57 Expect.equals("c", test_charat(b, 2)); | 56 Expect.equals("c", test_charat(b, 2)); |
| 58 Expect.throws(() => test_charat(b, 3)); | 57 Expect.throws(() => test_charat(b, 3)); |
| 59 | 58 |
| 60 Expect.equals(new String.fromCharCodes([123]), test_charat(c, 0)); | 59 Expect.equals(new String.fromCharCodes([123]), test_charat(c, 0)); |
| 61 for (var i = 0; i < 20; i++) test_charat(c, 0); | 60 for (var i = 0; i < 20; i++) test_charat(c, 0); |
| 62 Expect.equals(new String.fromCharCodes([123]), test_charat(c, 0)); | 61 Expect.equals(new String.fromCharCodes([123]), test_charat(c, 0)); |
| 63 Expect.equals(new String.fromCharCodes([456]), test_charat(c, 1)); | 62 Expect.equals(new String.fromCharCodes([456]), test_charat(c, 1)); |
| 64 Expect.equals(new String.fromCharCodes([789]), test_charat(c, 2)); | 63 Expect.equals(new String.fromCharCodes([789]), test_charat(c, 2)); |
| 65 Expect.throws(() => test_charat(c, 3)); | 64 Expect.throws(() => test_charat(c, 3)); |
| 66 | |
| 67 | |
| 68 } | 65 } |
| OLD | NEW |