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/corelib_2/hashcode_test.dart

Issue 2990623002: Migrate test block 9 to Dart 2.0 (Closed)
Patch Set: nits Created 3 years, 4 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
« no previous file with comments | « tests/corelib_2/hashcode_boxed_test.dart ('k') | tests/corelib_2/hidden_library2_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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 6
7 class Override { 7 class Override {
8 int hash; 8 int hash;
9 int get superHash => super.hashCode; 9 int get superHash => super.hashCode;
10 int get hashCode => hash; 10 int get hashCode => hash;
11 11
12 int foo() => hash; // Just some function that can be closurized. 12 int foo() => hash; // Just some function that can be closurized.
13 13
14 bool operator ==(Object other) => 14 bool operator ==(Object other) => other is Override && other.hash == hash;
15 other is Override && (other as Override).hash == hash;
16 } 15 }
17 16
18 int bar() => 42; // Some global function. 17 int bar() => 42; // Some global function.
19 18
20 main() { 19 main() {
21 var o = new Object(); 20 var o = new Object();
22 var hash = o.hashCode; 21 var hash = o.hashCode;
23 // Doesn't change. 22 // Doesn't change.
24 Expect.equals(hash, o.hashCode); 23 Expect.equals(hash, o.hashCode);
25 Expect.equals(hash, identityHashCode(o)); 24 Expect.equals(hash, identityHashCode(o));
(...skipping 13 matching lines...) Expand all
39 } 38 }
40 // These do, or might do, but we can still use hashCodeOf and get the same 39 // These do, or might do, but we can still use hashCodeOf and get the same
41 // result each time. 40 // result each time.
42 samples = ["string", "", (x) => 42, c.foo, bar]; 41 samples = ["string", "", (x) => 42, c.foo, bar];
43 for (var v in samples) { 42 for (var v in samples) {
44 print(v); 43 print(v);
45 Expect.equals(v.hashCode, v.hashCode); 44 Expect.equals(v.hashCode, v.hashCode);
46 Expect.equals(identityHashCode(v), identityHashCode(v)); 45 Expect.equals(identityHashCode(v), identityHashCode(v));
47 } 46 }
48 } 47 }
OLDNEW
« no previous file with comments | « tests/corelib_2/hashcode_boxed_test.dart ('k') | tests/corelib_2/hidden_library2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698