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

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

Issue 11267018: Make getKeys, getValues getters (keys, values). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status files with co19 issue number. 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
« no previous file with comments | « tests/html/utils.dart ('k') | tests/language/compile_time_constant_b_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
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 isUnsupportedError(o) => o is UnsupportedError; 13 bool isUnsupportedError(o) => o is UnsupportedError;
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.keys);
19 Expect.listEquals([499], m1.getValues()); 19 Expect.listEquals([499], m1.values);
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'), isUnsupportedError); 35 Expect.throws(() => m1.remove('a'), isUnsupportedError);
36 Expect.throws(() => m1.remove('b'), isUnsupportedError); 36 Expect.throws(() => m1.remove('b'), isUnsupportedError);
37 Expect.throws(() => m1.clear(), isUnsupportedError); 37 Expect.throws(() => m1.clear(), isUnsupportedError);
38 Expect.throws(() => m1['b'] = 42, isUnsupportedError); 38 Expect.throws(() => m1['b'] = 42, isUnsupportedError);
39 Expect.throws(() => m1['a'] = 499, isUnsupportedError); 39 Expect.throws(() => m1['a'] = 499, isUnsupportedError);
40 Expect.throws(() => m1.putIfAbsent('a', () => 499), isUnsupportedError); 40 Expect.throws(() => m1.putIfAbsent('a', () => 499), isUnsupportedError);
41 Expect.throws(() => m1.putIfAbsent('z', () => 499), isUnsupportedError); 41 Expect.throws(() => m1.putIfAbsent('z', () => 499), isUnsupportedError);
42 42
43 Expect.equals(499, m2['a']); 43 Expect.equals(499, m2['a']);
44 Expect.equals(42, m2['b']); 44 Expect.equals(42, m2['b']);
45 Expect.equals(null, m2['c']); 45 Expect.equals(null, m2['c']);
46 Expect.listEquals(['a', 'b'], m2.getKeys()); 46 Expect.listEquals(['a', 'b'], m2.keys);
47 Expect.listEquals([499, 42], m2.getValues()); 47 Expect.listEquals([499, 42], m2.values);
48 Expect.isTrue(m2.containsKey('a')); 48 Expect.isTrue(m2.containsKey('a'));
49 Expect.isTrue(m2.containsKey('b')); 49 Expect.isTrue(m2.containsKey('b'));
50 Expect.isFalse(m2.containsKey('toString')); 50 Expect.isFalse(m2.containsKey('toString'));
51 Expect.isTrue(m2.containsValue(499)); 51 Expect.isTrue(m2.containsValue(499));
52 Expect.isTrue(m2.containsValue(42)); 52 Expect.isTrue(m2.containsValue(42));
53 Expect.isFalse(m2.containsValue(99)); 53 Expect.isFalse(m2.containsValue(99));
54 Expect.isFalse(m2.containsValue(null)); 54 Expect.isFalse(m2.containsValue(null));
55 seenKeys = []; 55 seenKeys = [];
56 seenValues = []; 56 seenValues = [];
57 m2.forEach((key, value) { 57 m2.forEach((key, value) {
(...skipping 11 matching lines...) Expand all
69 Expect.throws(() => m2['a'] = 499, isUnsupportedError); 69 Expect.throws(() => m2['a'] = 499, isUnsupportedError);
70 Expect.throws(() => m2['b'] = 42, isUnsupportedError); 70 Expect.throws(() => m2['b'] = 42, isUnsupportedError);
71 Expect.throws(() => m2['c'] = 499, isUnsupportedError); 71 Expect.throws(() => m2['c'] = 499, isUnsupportedError);
72 Expect.throws(() => m2.putIfAbsent('a', () => 499), isUnsupportedError); 72 Expect.throws(() => m2.putIfAbsent('a', () => 499), isUnsupportedError);
73 Expect.throws(() => m2.putIfAbsent('z', () => 499), isUnsupportedError); 73 Expect.throws(() => m2.putIfAbsent('z', () => 499), isUnsupportedError);
74 Expect.throws(() => m2['a'] = 499, isUnsupportedError); 74 Expect.throws(() => m2['a'] = 499, isUnsupportedError);
75 75
76 Expect.isTrue(m3['m1'] === m1); 76 Expect.isTrue(m3['m1'] === m1);
77 Expect.isTrue(m3['m2'] === m2); 77 Expect.isTrue(m3['m2'] === m2);
78 78
79 Expect.listEquals(['z', 'a', 'm'], m4.getKeys()); 79 Expect.listEquals(['z', 'a', 'm'], m4.keys);
80 Expect.listEquals([9, 8, 7], m4.getValues()); 80 Expect.listEquals([9, 8, 7], m4.values);
81 seenKeys = []; 81 seenKeys = [];
82 seenValues = []; 82 seenValues = [];
83 m4.forEach((key, value) { 83 m4.forEach((key, value) {
84 seenKeys.add(key); 84 seenKeys.add(key);
85 seenValues.add(value); 85 seenValues.add(value);
86 }); 86 });
87 Expect.listEquals(['z', 'a', 'm'], seenKeys); 87 Expect.listEquals(['z', 'a', 'm'], seenKeys);
88 Expect.listEquals([9, 8, 7], seenValues); 88 Expect.listEquals([9, 8, 7], seenValues);
89 89
90 Expect.equals(499, m5['']); 90 Expect.equals(499, m5['']);
91 Expect.isTrue(m5.containsKey('')); 91 Expect.isTrue(m5.containsKey(''));
92 Expect.equals(1, m5.length); 92 Expect.equals(1, m5.length);
93 93
94 Expect.isTrue(m1 === m6); 94 Expect.isTrue(m1 === m6);
95 95
96 Expect.isTrue(m7.isEmpty); 96 Expect.isTrue(m7.isEmpty);
97 Expect.equals(0, m7.length); 97 Expect.equals(0, m7.length);
98 Expect.equals(null, m7['b']); 98 Expect.equals(null, m7['b']);
99 Expect.listEquals([], m7.getKeys()); 99 Expect.listEquals([], m7.keys);
100 Expect.listEquals([], m7.getValues()); 100 Expect.listEquals([], m7.values);
101 Expect.isFalse(m7.containsKey('a')); 101 Expect.isFalse(m7.containsKey('a'));
102 Expect.isFalse(m7.containsKey('toString')); 102 Expect.isFalse(m7.containsKey('toString'));
103 Expect.isFalse(m7.containsValue(499)); 103 Expect.isFalse(m7.containsValue(499));
104 Expect.isFalse(m7.containsValue(null)); 104 Expect.isFalse(m7.containsValue(null));
105 seenKeys = []; 105 seenKeys = [];
106 seenValues = []; 106 seenValues = [];
107 m7.forEach((key, value) { 107 m7.forEach((key, value) {
108 seenKeys.add(key); 108 seenKeys.add(key);
109 seenValues.add(value); 109 seenValues.add(value);
110 }); 110 });
111 Expect.listEquals([], seenKeys); 111 Expect.listEquals([], seenKeys);
112 Expect.listEquals([], seenValues); 112 Expect.listEquals([], seenValues);
113 Expect.throws(() => m7.remove('a'), isUnsupportedError); 113 Expect.throws(() => m7.remove('a'), isUnsupportedError);
114 Expect.throws(() => m7.remove('b'), isUnsupportedError); 114 Expect.throws(() => m7.remove('b'), isUnsupportedError);
115 Expect.throws(() => m7.clear(), isUnsupportedError); 115 Expect.throws(() => m7.clear(), isUnsupportedError);
116 Expect.throws(() => m7['b'] = 42, isUnsupportedError); 116 Expect.throws(() => m7['b'] = 42, isUnsupportedError);
117 Expect.throws(() => m7['a'] = 499, isUnsupportedError); 117 Expect.throws(() => m7['a'] = 499, isUnsupportedError);
118 Expect.throws(() => m7.putIfAbsent('a', () => 499), 118 Expect.throws(() => m7.putIfAbsent('a', () => 499),
119 isUnsupportedError); 119 isUnsupportedError);
120 Expect.throws(() => m7.putIfAbsent('z', () => 499), 120 Expect.throws(() => m7.putIfAbsent('z', () => 499),
121 isUnsupportedError); 121 isUnsupportedError);
122 } 122 }
OLDNEW
« no previous file with comments | « tests/html/utils.dart ('k') | tests/language/compile_time_constant_b_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698