// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. import 'dart:async'; import 'package:expect/expect.dart'; typedef FunctionType = void Function(); typedef GenericFunctionType = T Function(T); test(o) { if (o case FunctionType(:var hashCode)) { print(hashCode); return 1; } if (o case GenericFunctionType(:var hashCode)) { print(hashCode); return 2; } if (o case GenericFunctionType(:var hashCode)) { print(hashCode); return 3; } if (o case GenericFunctionType(:var hashCode)) { print(hashCode); return 4; } if (o case GenericFunctionType(:var hashCode)) { print(hashCode); return 5; } if (o case Null(:var hashCode)) { print(hashCode); return 6; } if (o case FutureOr(:var hashCode)) { print(hashCode); return 7; } if (o case dynamic(:var hashCode)) { print(hashCode); return 0; } return -1; } void function() {} int intFunction(int i) => i; String stringFunction(String s) => s; bool boolFunction(bool b) => b; dynamic dynamicFunction(dynamic d) => d; void multiArgFunction(int i, String s) {} main() { Expect.equals(1, test(function)); Expect.equals(2, test(intFunction)); Expect.equals(3, test(stringFunction)); Expect.equals(4, test(boolFunction)); Expect.equals(0, test(boolFunction)); Expect.equals(0, test(boolFunction)); Expect.equals(4, test(dynamicFunction)); Expect.equals(4, test(dynamicFunction)); Expect.equals(5, test(dynamicFunction)); Expect.equals(0, test(multiArgFunction)); Expect.equals(6, test(null)); Expect.equals(7, test(0)); Expect.equals(7, test(new Future.value(0))); }