Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(640)

Side by Side Diff: tests/language/optimized_string_charat_test.dart

Issue 11416129: Inline [] operator on one-byte strings. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: removed unnecessary change Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« runtime/vm/flow_graph_optimizer.cc ('K') | « runtime/vm/symbols.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« runtime/vm/flow_graph_optimizer.cc ('K') | « runtime/vm/symbols.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698