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

Side by Side Diff: tests/language/src/CompileTimeConstantATest.dart

Issue 10248007: test rename overhaul: step 8 - language tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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
(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 final m1 = const { 'a': 400 + 99 };
6 final m2 = const { 'a': 499, 'b': 42 };
7 final m3 = const { 'm1': m1, 'm2': m2 };
8 final m4 = const { 'z': 9, 'a': 8, 'm': 7 };
9 final m5 = const { '': 499 };
10 final m6 = const { 'a': 499 };
11 final m7 = const {};
12
13 bool isIllegalAccessException(o) => o is IllegalAccessException;
14
15 main() {
16 Expect.equals(499, m1['a']);
17 Expect.equals(null, m1['b']);
18 Expect.listEquals(['a'], m1.getKeys());
19 Expect.listEquals([499], m1.getValues());
20 Expect.isTrue(m1.containsKey('a'));
21 Expect.isFalse(m1.containsKey('toString'));
22 Expect.isTrue(m1.containsValue(499));
23 Expect.isFalse(m1.containsValue(42));
24 Expect.isFalse(m1.containsValue(null));
25 var seenKeys = [];
26 var seenValues = [];
27 m1.forEach((key, value) {
28 seenKeys.add(key);
29 seenValues.add(value);
30 });
31 Expect.listEquals(['a'], seenKeys);
32 Expect.listEquals([499], seenValues);
33 Expect.isFalse(m1.isEmpty());
34 Expect.equals(1, m1.length);
35 Expect.throws(() => m1.remove('a'), isIllegalAccessException);
36 Expect.throws(() => m1.remove('b'), isIllegalAccessException);
37 Expect.throws(() => m1.clear(), isIllegalAccessException);
38 Expect.throws(() => m1['b'] = 42, isIllegalAccessException);
39 Expect.throws(() => m1['a'] = 499, isIllegalAccessException);
40 Expect.throws(() => m1.putIfAbsent('a', () => 499),
41 isIllegalAccessException);
42 Expect.throws(() => m1.putIfAbsent('z', () => 499),
43 isIllegalAccessException);
44
45 Expect.equals(499, m2['a']);
46 Expect.equals(42, m2['b']);
47 Expect.equals(null, m2['c']);
48 Expect.listEquals(['a', 'b'], m2.getKeys());
49 Expect.listEquals([499, 42], m2.getValues());
50 Expect.isTrue(m2.containsKey('a'));
51 Expect.isTrue(m2.containsKey('b'));
52 Expect.isFalse(m2.containsKey('toString'));
53 Expect.isTrue(m2.containsValue(499));
54 Expect.isTrue(m2.containsValue(42));
55 Expect.isFalse(m2.containsValue(99));
56 Expect.isFalse(m2.containsValue(null));
57 seenKeys = [];
58 seenValues = [];
59 m2.forEach((key, value) {
60 seenKeys.add(key);
61 seenValues.add(value);
62 });
63 Expect.listEquals(['a', 'b'], seenKeys);
64 Expect.listEquals([499, 42], seenValues);
65 Expect.isFalse(m2.isEmpty());
66 Expect.equals(2, m2.length);
67 Expect.throws(() => m2.remove('a'), isIllegalAccessException);
68 Expect.throws(() => m2.remove('b'), isIllegalAccessException);
69 Expect.throws(() => m2.remove('c'), isIllegalAccessException);
70 Expect.throws(() => m2.clear(), isIllegalAccessException);
71 Expect.throws(() => m2['a'] = 499, isIllegalAccessException);
72 Expect.throws(() => m2['b'] = 42, isIllegalAccessException);
73 Expect.throws(() => m2['c'] = 499, isIllegalAccessException);
74 Expect.throws(() => m2.putIfAbsent('a', () => 499),
75 isIllegalAccessException);
76 Expect.throws(() => m2.putIfAbsent('z', () => 499),
77 isIllegalAccessException);
78 Expect.throws(() => m2['a'] = 499, isIllegalAccessException);
79
80 Expect.isTrue(m3['m1'] === m1);
81 Expect.isTrue(m3['m2'] === m2);
82
83 Expect.listEquals(['z', 'a', 'm'], m4.getKeys());
84 Expect.listEquals([9, 8, 7], m4.getValues());
85 seenKeys = [];
86 seenValues = [];
87 m4.forEach((key, value) {
88 seenKeys.add(key);
89 seenValues.add(value);
90 });
91 Expect.listEquals(['z', 'a', 'm'], seenKeys);
92 Expect.listEquals([9, 8, 7], seenValues);
93
94 Expect.equals(499, m5['']);
95 Expect.isTrue(m5.containsKey(''));
96 Expect.equals(1, m5.length);
97
98 Expect.isTrue(m1 === m6);
99
100 Expect.isTrue(m7.isEmpty());
101 Expect.equals(0, m7.length);
102 Expect.equals(null, m7['b']);
103 Expect.listEquals([], m7.getKeys());
104 Expect.listEquals([], m7.getValues());
105 Expect.isFalse(m7.containsKey('a'));
106 Expect.isFalse(m7.containsKey('toString'));
107 Expect.isFalse(m7.containsValue(499));
108 Expect.isFalse(m7.containsValue(null));
109 seenKeys = [];
110 seenValues = [];
111 m7.forEach((key, value) {
112 seenKeys.add(key);
113 seenValues.add(value);
114 });
115 Expect.listEquals([], seenKeys);
116 Expect.listEquals([], seenValues);
117 Expect.throws(() => m7.remove('a'), isIllegalAccessException);
118 Expect.throws(() => m7.remove('b'), isIllegalAccessException);
119 Expect.throws(() => m7.clear(), isIllegalAccessException);
120 Expect.throws(() => m7['b'] = 42, isIllegalAccessException);
121 Expect.throws(() => m7['a'] = 499, isIllegalAccessException);
122 Expect.throws(() => m7.putIfAbsent('a', () => 499),
123 isIllegalAccessException);
124 Expect.throws(() => m7.putIfAbsent('z', () => 499),
125 isIllegalAccessException);
126 }
OLDNEW
« no previous file with comments | « tests/language/src/CompileTimeConstant9Test.dart ('k') | tests/language/src/CompileTimeConstantBTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698