OLD | NEW |
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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 // dart2js specific test to make sure hashCode on intercepted types behaves as | 7 // dart2js specific test to make sure hashCode on intercepted types behaves as |
8 // intended. | 8 // intended. |
9 | 9 |
| 10 @NoInline() |
| 11 @AssumeDynamic() |
| 12 confuse(x) => x; |
10 | 13 |
11 class Hasher { | 14 class Hasher { |
12 confuse(x) => [1, 'x', true, null, x].last; | |
13 hash(x) => confuse(x).hashCode; | 15 hash(x) => confuse(x).hashCode; |
14 } | 16 } |
15 | 17 |
16 // Hashing via [hash] should be forced to use the general interceptor, but the | 18 // Hashing via [hash] should be forced to use the general interceptor, but the |
17 // local x.hashCode calls might be optimized. | 19 // local x.hashCode calls might be optimized. |
18 var hash = new Hasher().hash; | 20 var hash = new Hasher().hash; |
19 | 21 |
20 check(value1, value2, {identityHashCode}) { | 22 check(value1, value2, {identityHashCode}) { |
21 var h1 = hash(value1); | 23 var h1 = hash(value1); |
22 var h2 = hash(value2); | 24 var h2 = hash(value2); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 Expect.equals(0x0DB819B, 'b'.hashCode); | 79 Expect.equals(0x0DB819B, 'b'.hashCode); |
78 Expect.equals(0xEBA5D59, 'c'.hashCode); | 80 Expect.equals(0xEBA5D59, 'c'.hashCode); |
79 } | 81 } |
80 | 82 |
81 main() { | 83 main() { |
82 bools(); | 84 bools(); |
83 ints(); | 85 ints(); |
84 lists(); | 86 lists(); |
85 strings(); | 87 strings(); |
86 } | 88 } |
OLD | NEW |