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

Side by Side Diff: tests/isolate/serialization_test.dart

Issue 11361190: a === b -> identical(a, b) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. 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/isolate/mandel_isolate_test.dart ('k') | tests/language/bool_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) 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 // Dart test program for testing serialization of messages without spawning 5 // Dart test program for testing serialization of messages without spawning
6 // isolates. 6 // isolates.
7 7
8 // --------------------------------------------------------------------------- 8 // ---------------------------------------------------------------------------
9 // Serialization test. 9 // Serialization test.
10 // --------------------------------------------------------------------------- 10 // ---------------------------------------------------------------------------
(...skipping 26 matching lines...) Expand all
37 37
38 var port = new ReceivePort(); 38 var port = new ReceivePort();
39 Expect.throws(() => f(port)); 39 Expect.throws(() => f(port));
40 port.close(); 40 port.close();
41 41
42 var a = [ 1, 3, 5 ]; 42 var a = [ 1, 3, 5 ];
43 var b = { 'b': 49 }; 43 var b = { 'b': 49 };
44 var c = [ a, b, a, b, a ]; 44 var c = [ a, b, a, b, a ];
45 var copied = f(c); 45 var copied = f(c);
46 verify(c, copied); 46 verify(c, copied);
47 Expect.isFalse(c === copied); 47 Expect.isFalse(identical(c, copied));
48 Expect.isTrue(copied[0] === copied[2]); 48 Expect.identical(copied[0], copied[2]);
49 Expect.isTrue(copied[0] === copied[4]); 49 Expect.identical(copied[0], copied[4]);
50 Expect.isTrue(copied[1] === copied[3]); 50 Expect.identical(copied[1], copied[3]);
51 } 51 }
52 52
53 void copyAndVerify(o, Function f) { 53 void copyAndVerify(o, Function f) {
54 var copy = f(o); 54 var copy = f(o);
55 verify(o, copy); 55 verify(o, copy);
56 } 56 }
57 57
58 void verify(o, copy) { 58 void verify(o, copy) {
59 if ((o is bool) || (o is num) || (o is String)) { 59 if ((o is bool) || (o is num) || (o is String)) {
60 Expect.equals(o, copy); 60 Expect.equals(o, copy);
61 } else if (o is List) { 61 } else if (o is List) {
62 Expect.isTrue(copy is List); 62 Expect.isTrue(copy is List);
63 Expect.equals(o.length, copy.length); 63 Expect.equals(o.length, copy.length);
64 for (int i = 0; i < o.length; i++) { 64 for (int i = 0; i < o.length; i++) {
65 verify(o[i], copy[i]); 65 verify(o[i], copy[i]);
66 } 66 }
67 } else if (o is Map) { 67 } else if (o is Map) {
68 Expect.isTrue(copy is Map); 68 Expect.isTrue(copy is Map);
69 Expect.equals(o.length, copy.length); 69 Expect.equals(o.length, copy.length);
70 o.forEach((key, value) { 70 o.forEach((key, value) {
71 Expect.isTrue(copy.containsKey(key)); 71 Expect.isTrue(copy.containsKey(key));
72 verify(value, copy[key]); 72 verify(value, copy[key]);
73 }); 73 });
74 } else { 74 } else {
75 Expect.fail("Unexpected object encountered"); 75 Expect.fail("Unexpected object encountered");
76 } 76 }
77 } 77 }
OLDNEW
« no previous file with comments | « tests/isolate/mandel_isolate_test.dart ('k') | tests/language/bool_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698