OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 // Test that generic methods with optional parameters are of correct type. |
| 6 |
| 7 library generic_methods_optional_parameters_test; |
| 8 |
| 9 import "test_base.dart"; |
| 10 |
| 11 typedef FunObjObj = Object Function<T>(Object, [Object]); |
| 12 typedef FunTypObj = Object Function<T>(T, [Object]); |
| 13 typedef FunObjTyp = Object Function<T>(Object, [T]); |
| 14 typedef FunTypTyp = Object Function<T>(T, [T]); |
| 15 |
| 16 Object funObjObj<T>(Object x, [Object y]) => x; |
| 17 Object funTypObj<T>(T x, [Object y]) => y; |
| 18 Object funObjTyp<T>(Object x, [T y]) => x; |
| 19 Object funTypTyp<T>(T x, [T y]) => null; |
| 20 |
| 21 main() { |
| 22 expectTrue(funObjObj is FunObjObj); |
| 23 expectTrue(funObjObj is FunTypObj); |
| 24 expectTrue(funObjObj is FunObjTyp); |
| 25 expectTrue(funObjObj is FunTypTyp); |
| 26 |
| 27 expectTrue(funTypObj is! FunObjObj); |
| 28 expectTrue(funTypObj is FunTypObj); |
| 29 expectTrue(funTypObj is! FunObjTyp); |
| 30 expectTrue(funTypObj is FunTypTyp); |
| 31 |
| 32 expectTrue(funObjTyp is! FunObjObj); |
| 33 expectTrue(funObjTyp is! FunTypObj); |
| 34 expectTrue(funObjTyp is FunObjTyp); |
| 35 expectTrue(funObjTyp is FunTypTyp); |
| 36 |
| 37 expectTrue(funTypTyp is! FunObjObj); |
| 38 expectTrue(funTypTyp is! FunTypObj); |
| 39 expectTrue(funTypTyp is! FunObjTyp); |
| 40 expectTrue(funTypTyp is FunTypTyp); |
| 41 } |
OLD | NEW |