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

Side by Side Diff: tests/corelib/indexed_list_access_test.dart

Issue 2990623002: Migrate test block 9 to Dart 2.0 (Closed)
Patch Set: nits Created 3 years, 5 months 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
« no previous file with comments | « tests/corelib/hidden_library2_test.dart ('k') | tests/corelib/int_ceil_test.dart » ('j') | 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) 2011, 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 import "package:expect/expect.dart";
6
7 // Check that indexed access to lists throws correct exception if index
8 // is not int.
9
10 main() {
11 checkList(new List(10));
12 var growable = new List();
13 growable.add(1);
14 growable.add(1);
15 checkList(growable);
16 }
17
18 checkList(var list) {
19 // Check unoptimized.
20 Expect.isFalse(checkCatch(getIt, list, 1));
21 Expect.isTrue(checkCatch(getIt, list, "hi"));
22 Expect.isFalse(checkCatch(putIt, list, 1));
23 Expect.isTrue(checkCatch(putIt, list, "hi"));
24 // Optimize 'getIt' and 'putIt'.
25 for (int i = 0; i < 2000; i++) {
26 putIt(list, 1);
27 getIt(list, 1);
28 }
29 Expect.isTrue(checkCatch(getIt, list, "hi"));
30 Expect.isTrue(checkCatch(putIt, list, "hi"));
31 }
32
33 checkCatch(var f, var list, var index) {
34 try {
35 f(list, index);
36 } on ArgumentError catch (e) {
37 return true;
38 } on TypeError catch (t) {
39 return true; // thrown in type checked mode.
40 }
41 return false;
42 }
43
44 getIt(var a, var i) {
45 return a[i];
46 }
47
48 putIt(var a, var i) {
49 a[i] = null;
50 }
OLDNEW
« no previous file with comments | « tests/corelib/hidden_library2_test.dart ('k') | tests/corelib/int_ceil_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698