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

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

Issue 11316108: Correct file names for tests in tests/language. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: fixed status Created 8 years 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
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 constant string and constant array access.
6
7 int testConstantStringAndIndexCharCodeAt() {
8 int test(b) {
9 if (b) return "hest".charCodeAt(400);
10 return "hest".charCodeAt(2);
11 }
12
13 Expect.throws(() => test(true));
14 for (int i = 0; i < 10000; i++) test(false);
15 Expect.throws(() => test(true));
16 }
17
18
19 int testConstantArrayAndIndexAt() {
20 int test(b) {
21 var a = const [1,2,3,4];
22 if (b) return a[400];
23 return a[2];
24 }
25
26 Expect.throws(() => test(true));
27 for (int i = 0; i < 10000; i++) test(false);
28 Expect.throws(() => test(true));
29 }
30
31
32 foo(a) {
33 if (a == 1) { return 2; }
34 var aa = const [1, 2];
35 return aa[2.3];
36 }
37
38
39 int testNonSmiIndex() {
40 for (int i = 0; i < 10000; i++) { foo(1); }
41 Expect.throws(() => foo(2));
42 }
43
44
45 main() {
46 testConstantStringAndIndexCharCodeAt();
47 testConstantArrayAndIndexAt();
48 testNonSmiIndex();
49 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698