| 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 class C<T> {} | 5 class C<T> {} |
| 6 | 6 |
| 7 sameType(a, b) { | 7 sameType(a, b) { |
| 8 Expect.identical(a.runtimeType, b.runtimeType); | 8 Expect.equals(a.runtimeType, b.runtimeType); |
| 9 } | 9 } |
| 10 | 10 |
| 11 differentType(a, b) { | 11 differentType(a, b) { |
| 12 print("a: ${a.runtimeType}"); | 12 Expect.isFalse(a.runtimeType == b.runtimeType); |
| 13 print("b: ${b.runtimeType}"); | |
| 14 Expect.isFalse(a.runtimeType === b.runtimeType); | |
| 15 } | 13 } |
| 16 | 14 |
| 17 main() { | 15 main() { |
| 18 // Test types obtained by calling runtimeType. | 16 // Test types obtained by calling runtimeType. |
| 19 var v1 = new C<int>(); | 17 var v1 = new C<int>(); |
| 20 var v2 = new C<int>(); | 18 var v2 = new C<int>(); |
| 21 sameType(v1, v2); | 19 sameType(v1, v2); |
| 22 | 20 |
| 23 var v3 = new C<num>(); | 21 var v3 = new C<num>(); |
| 24 differentType(v1, v3); | 22 differentType(v1, v3); |
| 25 | 23 |
| 26 var i = 1; | 24 var i = 1; |
| 27 var s = 'string'; | 25 var s = 'string'; |
| 28 var d = 3.14; | 26 var d = 3.14; |
| 29 sameType(2, i); | 27 sameType(2, i); |
| 30 sameType('hest', s); | 28 sameType('hest', s); |
| 31 sameType(1.2, d); | 29 sameType(1.2, d); |
| 32 | 30 |
| 33 var l = [1, 2, 3]; | 31 var l = [1, 2, 3]; |
| 34 var m = {'a': 1, 'b': 2}; | 32 var m = {'a': 1, 'b': 2}; |
| 35 sameType([], l); | 33 sameType([], l); |
| 36 sameType({}, m); | 34 sameType({}, m); |
| 37 } | 35 } |
| OLD | NEW |