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

Side by Side Diff: tests/language/src/OrderedMapsTest.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) 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 // Tests that map literals are ordered.
6
7 class OrderedMapsTest {
8 static testMain() {
9 testMaps(const { "a": 1, "c": 2 }, const { "c": 2, "a": 1}, true);
10 testMaps({ "a": 1, "c": 2 }, { "c": 2, "a": 1 }, false);
11 }
12
13 static void testMaps(map1, map2, bool isConst) {
14 Expect.equals(true, map1 !== map2);
15
16 var keys = map1.getKeys();
17 Expect.equals(2, keys.length);
18 Expect.equals("a", keys[0]);
19 Expect.equals("c", keys[1]);
20
21 keys = map2.getKeys();
22 Expect.equals(2, keys.length);
23 Expect.equals("c", keys[0]);
24 Expect.equals("a", keys[1]);
25
26 var values = map1.getValues();
27 Expect.equals(2, values.length);
28 Expect.equals(1, values[0]);
29 Expect.equals(2, values[1]);
30
31 values = map2.getValues();
32 Expect.equals(2, values.length);
33 Expect.equals(2, values[0]);
34 Expect.equals(1, values[1]);
35
36 if (isConst) return;
37
38 map1["b"] = 3;
39 map2["b"] = 3;
40
41 keys = map1.getKeys();
42 Expect.equals(3, keys.length);
43 Expect.equals("a", keys[0]);
44 Expect.equals("c", keys[1]);
45 Expect.equals("b", keys[2]);
46
47 keys = map2.getKeys();
48 Expect.equals(3, keys.length);
49 Expect.equals("c", keys[0]);
50 Expect.equals("a", keys[1]);
51 Expect.equals("b", keys[2]);
52
53 values = map1.getValues();
54 Expect.equals(3, values.length);
55 Expect.equals(1, values[0]);
56 Expect.equals(2, values[1]);
57 Expect.equals(3, values[2]);
58
59 values = map2.getValues();
60 Expect.equals(3, values.length);
61 Expect.equals(2, values[0]);
62 Expect.equals(1, values[1]);
63 Expect.equals(3, values[2]);
64
65 map1["a"] = 4;
66 keys = map1.getKeys();
67 Expect.equals(3, keys.length);
68 Expect.equals("a", keys[0]);
69
70 values = map1.getValues();
71 Expect.equals(3, values.length);
72 Expect.equals(4, values[0]);
73 }
74 }
75
76 main() {
77 OrderedMapsTest.testMain();
78 }
OLDNEW
« no previous file with comments | « tests/language/src/OptionalParameterSyntaxTest.dart ('k') | tests/language/src/OverriddenNoSuchMethod.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698