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

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

Issue 2879153005: Add support to dart2js for option --enable-asserts. (Closed)
Patch Set: Added !$checked to section predicate in co19 status file 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 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 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"; 5 import "package:expect/expect.dart";
6 import 'dart:collection'; 6 import 'dart:collection';
7 7
8 class MyList extends ListBase { 8 class MyList extends ListBase {
9 List list; 9 List list;
10 MyList(this.list); 10 MyList(this.list);
11 11
12 get length => list.length; 12 get length => list.length;
13 set length(val) { 13 set length(val) {
14 list.length = val; 14 list.length = val;
15 } 15 }
16 16
17 operator [](index) => list[index]; 17 operator [](index) => list[index];
18 operator []=(index, val) => list[index] = val; 18 operator []=(index, val) => list[index] = val;
19 19
20 String toString() => "[" + join(", ") + "]"; 20 String toString() => "[" + join(", ") + "]";
21 } 21 }
22 22
23 // l1 must be a modifiable list with 5 elements from 0 to 4. 23 // l1 must be a modifiable list with 5 elements from 0 to 4.
24 void testModifiableList(l1) { 24 void testModifiableList(l1) {
25 bool checkedMode = false;
26 assert(checkedMode = true);
27
28 // Index must be integer and in range. 25 // Index must be integer and in range.
29 Expect.throws(() { 26 Expect.throws(() {
30 l1.removeAt(-1); 27 l1.removeAt(-1);
31 }, (e) => e is RangeError, "negative"); 28 }, (e) => e is RangeError, "negative");
32 Expect.throws(() { 29 Expect.throws(() {
33 l1.removeAt(5); 30 l1.removeAt(5);
34 }, (e) => e is RangeError, "too large"); 31 }, (e) => e is RangeError, "too large");
35 Expect.throws(() { 32 Expect.throws(() {
36 l1.removeAt(null); 33 l1.removeAt(null);
37 }, (e) => e is ArgumentError, "too large"); 34 }, (e) => e is ArgumentError, "too large");
38 Expect.throws(() { 35 Expect.throws(() {
39 l1.removeAt("1"); 36 l1.removeAt("1");
40 }, (e) => (checkedMode ? e is TypeError : e is ArgumentError), "string"); 37 }, (e) => (typeAssertionsEnabled ? e is TypeError : e is ArgumentError),
38 "string");
41 Expect.throws(() { 39 Expect.throws(() {
42 l1.removeAt(1.5); 40 l1.removeAt(1.5);
43 }, (e) => (checkedMode ? e is TypeError : e is ArgumentError), "double"); 41 }, (e) => (typeAssertionsEnabled ? e is TypeError : e is ArgumentError),
42 "double");
44 43
45 Expect.equals(2, l1.removeAt(2), "l1-remove2"); 44 Expect.equals(2, l1.removeAt(2), "l1-remove2");
46 Expect.equals(1, l1[1], "l1-1[1]"); 45 Expect.equals(1, l1[1], "l1-1[1]");
47 46
48 Expect.equals(3, l1[2], "l1-1[2]"); 47 Expect.equals(3, l1[2], "l1-1[2]");
49 Expect.equals(4, l1[3], "l1-1[3]"); 48 Expect.equals(4, l1[3], "l1-1[3]");
50 Expect.equals(4, l1.length, "length-1"); 49 Expect.equals(4, l1.length, "length-1");
51 50
52 Expect.equals(0, l1.removeAt(0), "l1-remove0"); 51 Expect.equals(0, l1.removeAt(0), "l1-remove0");
53 Expect.equals(1, l1[0], "l1-2[0]"); 52 Expect.equals(1, l1[0], "l1-2[0]");
(...skipping 19 matching lines...) Expand all
73 Expect.throws(() { 72 Expect.throws(() {
74 l3.removeAt(2); 73 l3.removeAt(2);
75 }, (e) => e is UnsupportedError, "unmodifiable"); 74 }, (e) => e is UnsupportedError, "unmodifiable");
76 75
77 // Empty list is not special. 76 // Empty list is not special.
78 var l4 = []; 77 var l4 = [];
79 Expect.throws(() { 78 Expect.throws(() {
80 l4.removeAt(0); 79 l4.removeAt(0);
81 }, (e) => e is RangeError, "empty"); 80 }, (e) => e is RangeError, "empty");
82 } 81 }
OLDNEW
« no previous file with comments | « tests/corelib/iterable_generate_test.dart ('k') | tests/corelib/splay_tree_from_iterable_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698