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

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

Issue 11235054: Removed IllegalAccessException and UnsupportedOperationException. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
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 4
5 const m1 = const { 'a': 400 + 99 }; 5 const m1 = const { 'a': 400 + 99 };
6 const m2 = const { 'a': 499, 'b': 42 }; 6 const m2 = const { 'a': 499, 'b': 42 };
7 const m3 = const { 'm1': m1, 'm2': m2 }; 7 const m3 = const { 'm1': m1, 'm2': m2 };
8 const m4 = const { 'z': 9, 'a': 8, 'm': 7 }; 8 const m4 = const { 'z': 9, 'a': 8, 'm': 7 };
9 const m5 = const { '': 499 }; 9 const m5 = const { '': 499 };
10 const m6 = const { 'a': 499 }; 10 const m6 = const { 'a': 499 };
11 const m7 = const {}; 11 const m7 = const {};
12 12
13 bool isIllegalAccessException(o) => o is IllegalAccessException; 13 bool isStateError(o) => o is StateError;
14 14
15 main() { 15 main() {
16 Expect.equals(499, m1['a']); 16 Expect.equals(499, m1['a']);
17 Expect.equals(null, m1['b']); 17 Expect.equals(null, m1['b']);
18 Expect.listEquals(['a'], m1.getKeys()); 18 Expect.listEquals(['a'], m1.getKeys());
19 Expect.listEquals([499], m1.getValues()); 19 Expect.listEquals([499], m1.getValues());
20 Expect.isTrue(m1.containsKey('a')); 20 Expect.isTrue(m1.containsKey('a'));
21 Expect.isFalse(m1.containsKey('toString')); 21 Expect.isFalse(m1.containsKey('toString'));
22 Expect.isTrue(m1.containsValue(499)); 22 Expect.isTrue(m1.containsValue(499));
23 Expect.isFalse(m1.containsValue(42)); 23 Expect.isFalse(m1.containsValue(42));
24 Expect.isFalse(m1.containsValue(null)); 24 Expect.isFalse(m1.containsValue(null));
25 var seenKeys = []; 25 var seenKeys = [];
26 var seenValues = []; 26 var seenValues = [];
27 m1.forEach((key, value) { 27 m1.forEach((key, value) {
28 seenKeys.add(key); 28 seenKeys.add(key);
29 seenValues.add(value); 29 seenValues.add(value);
30 }); 30 });
31 Expect.listEquals(['a'], seenKeys); 31 Expect.listEquals(['a'], seenKeys);
32 Expect.listEquals([499], seenValues); 32 Expect.listEquals([499], seenValues);
33 Expect.isFalse(m1.isEmpty()); 33 Expect.isFalse(m1.isEmpty());
34 Expect.equals(1, m1.length); 34 Expect.equals(1, m1.length);
35 Expect.throws(() => m1.remove('a'), isIllegalAccessException); 35 Expect.throws(() => m1.remove('a'), isStateError);
36 Expect.throws(() => m1.remove('b'), isIllegalAccessException); 36 Expect.throws(() => m1.remove('b'), isStateError);
37 Expect.throws(() => m1.clear(), isIllegalAccessException); 37 Expect.throws(() => m1.clear(), isStateError);
38 Expect.throws(() => m1['b'] = 42, isIllegalAccessException); 38 Expect.throws(() => m1['b'] = 42, isStateError);
39 Expect.throws(() => m1['a'] = 499, isIllegalAccessException); 39 Expect.throws(() => m1['a'] = 499, isStateError);
40 Expect.throws(() => m1.putIfAbsent('a', () => 499), 40 Expect.throws(() => m1.putIfAbsent('a', () => 499),
floitsch 2012/10/23 12:50:32 move into one line. ditto for the remaining ones b
Lasse Reichstein Nielsen 2012/10/24 12:32:15 Done.
41 isIllegalAccessException); 41 isStateError);
42 Expect.throws(() => m1.putIfAbsent('z', () => 499), 42 Expect.throws(() => m1.putIfAbsent('z', () => 499),
43 isIllegalAccessException); 43 isStateError);
44 44
45 Expect.equals(499, m2['a']); 45 Expect.equals(499, m2['a']);
46 Expect.equals(42, m2['b']); 46 Expect.equals(42, m2['b']);
47 Expect.equals(null, m2['c']); 47 Expect.equals(null, m2['c']);
48 Expect.listEquals(['a', 'b'], m2.getKeys()); 48 Expect.listEquals(['a', 'b'], m2.getKeys());
49 Expect.listEquals([499, 42], m2.getValues()); 49 Expect.listEquals([499, 42], m2.getValues());
50 Expect.isTrue(m2.containsKey('a')); 50 Expect.isTrue(m2.containsKey('a'));
51 Expect.isTrue(m2.containsKey('b')); 51 Expect.isTrue(m2.containsKey('b'));
52 Expect.isFalse(m2.containsKey('toString')); 52 Expect.isFalse(m2.containsKey('toString'));
53 Expect.isTrue(m2.containsValue(499)); 53 Expect.isTrue(m2.containsValue(499));
54 Expect.isTrue(m2.containsValue(42)); 54 Expect.isTrue(m2.containsValue(42));
55 Expect.isFalse(m2.containsValue(99)); 55 Expect.isFalse(m2.containsValue(99));
56 Expect.isFalse(m2.containsValue(null)); 56 Expect.isFalse(m2.containsValue(null));
57 seenKeys = []; 57 seenKeys = [];
58 seenValues = []; 58 seenValues = [];
59 m2.forEach((key, value) { 59 m2.forEach((key, value) {
60 seenKeys.add(key); 60 seenKeys.add(key);
61 seenValues.add(value); 61 seenValues.add(value);
62 }); 62 });
63 Expect.listEquals(['a', 'b'], seenKeys); 63 Expect.listEquals(['a', 'b'], seenKeys);
64 Expect.listEquals([499, 42], seenValues); 64 Expect.listEquals([499, 42], seenValues);
65 Expect.isFalse(m2.isEmpty()); 65 Expect.isFalse(m2.isEmpty());
66 Expect.equals(2, m2.length); 66 Expect.equals(2, m2.length);
67 Expect.throws(() => m2.remove('a'), isIllegalAccessException); 67 Expect.throws(() => m2.remove('a'), isStateError);
68 Expect.throws(() => m2.remove('b'), isIllegalAccessException); 68 Expect.throws(() => m2.remove('b'), isStateError);
69 Expect.throws(() => m2.remove('c'), isIllegalAccessException); 69 Expect.throws(() => m2.remove('c'), isStateError);
70 Expect.throws(() => m2.clear(), isIllegalAccessException); 70 Expect.throws(() => m2.clear(), isStateError);
71 Expect.throws(() => m2['a'] = 499, isIllegalAccessException); 71 Expect.throws(() => m2['a'] = 499, isStateError);
72 Expect.throws(() => m2['b'] = 42, isIllegalAccessException); 72 Expect.throws(() => m2['b'] = 42, isStateError);
73 Expect.throws(() => m2['c'] = 499, isIllegalAccessException); 73 Expect.throws(() => m2['c'] = 499, isStateError);
74 Expect.throws(() => m2.putIfAbsent('a', () => 499), 74 Expect.throws(() => m2.putIfAbsent('a', () => 499),
75 isIllegalAccessException); 75 isStateError);
76 Expect.throws(() => m2.putIfAbsent('z', () => 499), 76 Expect.throws(() => m2.putIfAbsent('z', () => 499),
77 isIllegalAccessException); 77 isStateError);
78 Expect.throws(() => m2['a'] = 499, isIllegalAccessException); 78 Expect.throws(() => m2['a'] = 499, isStateError);
79 79
80 Expect.isTrue(m3['m1'] === m1); 80 Expect.isTrue(m3['m1'] === m1);
81 Expect.isTrue(m3['m2'] === m2); 81 Expect.isTrue(m3['m2'] === m2);
82 82
83 Expect.listEquals(['z', 'a', 'm'], m4.getKeys()); 83 Expect.listEquals(['z', 'a', 'm'], m4.getKeys());
84 Expect.listEquals([9, 8, 7], m4.getValues()); 84 Expect.listEquals([9, 8, 7], m4.getValues());
85 seenKeys = []; 85 seenKeys = [];
86 seenValues = []; 86 seenValues = [];
87 m4.forEach((key, value) { 87 m4.forEach((key, value) {
88 seenKeys.add(key); 88 seenKeys.add(key);
(...skipping 18 matching lines...) Expand all
107 Expect.isFalse(m7.containsValue(499)); 107 Expect.isFalse(m7.containsValue(499));
108 Expect.isFalse(m7.containsValue(null)); 108 Expect.isFalse(m7.containsValue(null));
109 seenKeys = []; 109 seenKeys = [];
110 seenValues = []; 110 seenValues = [];
111 m7.forEach((key, value) { 111 m7.forEach((key, value) {
112 seenKeys.add(key); 112 seenKeys.add(key);
113 seenValues.add(value); 113 seenValues.add(value);
114 }); 114 });
115 Expect.listEquals([], seenKeys); 115 Expect.listEquals([], seenKeys);
116 Expect.listEquals([], seenValues); 116 Expect.listEquals([], seenValues);
117 Expect.throws(() => m7.remove('a'), isIllegalAccessException); 117 Expect.throws(() => m7.remove('a'), isStateError);
118 Expect.throws(() => m7.remove('b'), isIllegalAccessException); 118 Expect.throws(() => m7.remove('b'), isStateError);
119 Expect.throws(() => m7.clear(), isIllegalAccessException); 119 Expect.throws(() => m7.clear(), isStateError);
120 Expect.throws(() => m7['b'] = 42, isIllegalAccessException); 120 Expect.throws(() => m7['b'] = 42, isStateError);
121 Expect.throws(() => m7['a'] = 499, isIllegalAccessException); 121 Expect.throws(() => m7['a'] = 499, isStateError);
122 Expect.throws(() => m7.putIfAbsent('a', () => 499), 122 Expect.throws(() => m7.putIfAbsent('a', () => 499),
123 isIllegalAccessException); 123 isStateError);
124 Expect.throws(() => m7.putIfAbsent('z', () => 499), 124 Expect.throws(() => m7.putIfAbsent('z', () => 499),
125 isIllegalAccessException); 125 isStateError);
126 } 126 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698