Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 library subtype_test; | 5 library subtype_test; |
| 6 | 6 |
| 7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
| 8 import "package:async_helper/async_helper.dart"; | 8 import "package:async_helper/async_helper.dart"; |
| 9 import 'type_test_helper.dart'; | 9 import 'type_test_helper.dart'; |
| 10 import 'package:compiler/src/dart_types.dart'; | 10 import 'package:compiler/src/dart_types.dart'; |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 } | 270 } |
| 271 """).then((env) { | 271 """).then((env) { |
| 272 void expect(bool expectSubtype, DartType T, DartType S, | 272 void expect(bool expectSubtype, DartType T, DartType S, |
| 273 {bool expectMoreSpecific}) { | 273 {bool expectMoreSpecific}) { |
| 274 testTypes(env, T, S, expectSubtype, expectMoreSpecific); | 274 testTypes(env, T, S, expectSubtype, expectMoreSpecific); |
| 275 } | 275 } |
| 276 | 276 |
| 277 ClassElement classA = env.getElement('A'); | 277 ClassElement classA = env.getElement('A'); |
| 278 DartType A = classA.rawType; | 278 DartType A = classA.rawType; |
| 279 DartType function = env['Function']; | 279 DartType function = env['Function']; |
| 280 DartType call = env.getMemberType(classA, 'call'); | |
| 280 DartType m1 = env.getMemberType(classA, 'm1'); | 281 DartType m1 = env.getMemberType(classA, 'm1'); |
| 281 DartType m2 = env.getMemberType(classA, 'm2'); | 282 DartType m2 = env.getMemberType(classA, 'm2'); |
| 282 DartType m3 = env.getMemberType(classA, 'm3'); | 283 DartType m3 = env.getMemberType(classA, 'm3'); |
| 283 DartType m4 = env.getMemberType(classA, 'm4'); | 284 DartType m4 = env.getMemberType(classA, 'm4'); |
| 284 DartType m5 = env.getMemberType(classA, 'm5'); | 285 DartType m5 = env.getMemberType(classA, 'm5'); |
| 285 | 286 |
| 286 expect(true, A, function, expectMoreSpecific: false); | 287 expect(true, A, function); |
|
ahe
2016/09/02 13:07:11
I'm not sure this is what the specification says.
Johnni Winther
2016/09/02 13:12:37
A << call and call << Function + transitivity.
| |
| 287 expect(true, A, m1, expectMoreSpecific: false); | 288 expect(true, A, call); |
| 289 expect(true, call, m1); | |
| 290 expect(true, A, m1); | |
| 288 expect(true, A, m2, expectMoreSpecific: false); | 291 expect(true, A, m2, expectMoreSpecific: false); |
| 289 expect(false, A, m3); | 292 expect(false, A, m3); |
| 290 expect(false, A, m4); | 293 expect(false, A, m4); |
| 291 expect(true, A, m5, expectMoreSpecific: false); | 294 expect(true, A, m5); |
| 292 })); | 295 })); |
| 293 } | 296 } |
| 294 | 297 |
| 295 testFunctionSubtyping() { | 298 testFunctionSubtyping() { |
| 296 asyncTest(() => TypeEnvironment.create(r""" | 299 asyncTest(() => TypeEnvironment.create(r""" |
| 297 _() => null; | 300 _() => null; |
| 298 void void_() {} | 301 void void_() {} |
| 299 void void_2() {} | 302 void void_2() {} |
| 300 int int_() => 0; | 303 int int_() => 0; |
| 301 int int_2() => 0; | 304 int int_2() => 0; |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 748 expect(false, J_U, num_); | 751 expect(false, J_U, num_); |
| 749 expect(false, J_U, int_); | 752 expect(false, J_U, int_); |
| 750 expect(false, J_U, String_); | 753 expect(false, J_U, String_); |
| 751 expect(true, J_U, dynamic_); | 754 expect(true, J_U, dynamic_); |
| 752 expect(false, J_U, J_T); | 755 expect(false, J_U, J_T); |
| 753 expect(true, J_U, J_S); | 756 expect(true, J_U, J_S); |
| 754 expect(true, J_U, J_U); | 757 expect(true, J_U, J_U); |
| 755 expect(false, J_U, A_T); | 758 expect(false, J_U, A_T); |
| 756 })); | 759 })); |
| 757 } | 760 } |
| OLD | NEW |