|
| 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 |
| 3 | +// BSD-style license that can be found in the LICENSE file. |
| 4 | + |
| 5 | +import "package:expect/expect.dart"; |
| 6 | + |
| 7 | +// Test is-test of typedefs with optional and named parameters. |
| 8 | + |
| 9 | +typedef int Func1(int a); |
| 10 | +typedef int Func2(int a, [int b]); |
| 11 | +typedef int Func3(int a, [int b, int c]); |
| 12 | +typedef int Func4([int a, int b, int c]); |
| 13 | +typedef int Func5(int a, {int b}); |
| 14 | +typedef int Func6(int a, {int b, int c}); |
| 15 | +typedef int Func7({int a, int b, int c}); |
| 16 | + |
| 17 | +void main() { |
| 18 | + int func1(int i) => -1; |
| 19 | + Expect.isTrue(func1 is Func1); |
| 20 | + Expect.isFalse(func1 is Func2); |
| 21 | + Expect.isFalse(func1 is Func3); |
| 22 | + Expect.isFalse(func1 is Func4); |
| 23 | + Expect.isFalse(func1 is Func5); |
| 24 | + Expect.isFalse(func1 is Func6); |
| 25 | + Expect.isFalse(func1 is Func7); |
| 26 | + |
| 27 | + int func2(int i, int j) => -1; |
| 28 | + Expect.isFalse(func2 is Func1); |
| 29 | + Expect.isFalse(func2 is Func2); |
| 30 | + Expect.isFalse(func2 is Func3); |
| 31 | + Expect.isFalse(func2 is Func4); |
| 32 | + Expect.isFalse(func2 is Func5); |
| 33 | + Expect.isFalse(func2 is Func6); |
| 34 | + Expect.isFalse(func2 is Func7); |
| 35 | + |
| 36 | + int func3(int i, int j, int k) => -1; |
| 37 | + Expect.isFalse(func3 is Func1); |
| 38 | + Expect.isFalse(func3 is Func2); |
| 39 | + Expect.isFalse(func3 is Func3); |
| 40 | + Expect.isFalse(func3 is Func4); |
| 41 | + Expect.isFalse(func3 is Func5); |
| 42 | + Expect.isFalse(func3 is Func6); |
| 43 | + Expect.isFalse(func3 is Func7); |
| 44 | + |
| 45 | + int func4(int i, [int j = -1]) => -1; |
| 46 | + Expect.isTrue(func4 is Func1); |
| 47 | + Expect.isTrue(func4 is Func2); |
| 48 | + Expect.isFalse(func4 is Func3); |
| 49 | + Expect.isFalse(func4 is Func4); |
| 50 | + Expect.isFalse(func4 is Func5); |
| 51 | + Expect.isFalse(func4 is Func6); |
| 52 | + Expect.isFalse(func4 is Func7); |
| 53 | + |
| 54 | + int func5(int i, [int j = -1, int k = -1]) => -1; |
| 55 | + Expect.isTrue(func5 is Func1); |
| 56 | + Expect.isTrue(func5 is Func2); |
| 57 | + Expect.isTrue(func5 is Func3); |
| 58 | + Expect.isFalse(func5 is Func4); |
| 59 | + Expect.isFalse(func5 is Func5); |
| 60 | + Expect.isFalse(func5 is Func6); |
| 61 | + Expect.isFalse(func5 is Func7); |
| 62 | + |
| 63 | + int func6([int i = -1, int j = -1, int k = -1]) => -1; |
| 64 | + Expect.isTrue(func6 is Func1); |
| 65 | + Expect.isTrue(func6 is Func2); |
| 66 | + Expect.isTrue(func6 is Func3); |
| 67 | + Expect.isTrue(func6 is Func4); |
| 68 | + Expect.isFalse(func6 is Func5); |
| 69 | + Expect.isFalse(func6 is Func6); |
| 70 | + Expect.isFalse(func6 is Func7); |
| 71 | + |
| 72 | + int func7(int i, {int j = -1}) => -1; |
| 73 | + Expect.isTrue(func7 is Func1); |
| 74 | + Expect.isFalse(func7 is Func2); |
| 75 | + Expect.isFalse(func7 is Func3); |
| 76 | + Expect.isFalse(func7 is Func4); |
| 77 | + Expect.isFalse(func7 is Func5); |
| 78 | + Expect.isFalse(func7 is Func6); |
| 79 | + Expect.isFalse(func7 is Func7); |
| 80 | + |
| 81 | + int func8(int i, {int b = -1}) => -1; |
| 82 | + Expect.isTrue(func8 is Func1); |
| 83 | + Expect.isFalse(func8 is Func2); |
| 84 | + Expect.isFalse(func8 is Func3); |
| 85 | + Expect.isFalse(func8 is Func4); |
| 86 | + Expect.isTrue(func8 is Func5); |
| 87 | + Expect.isFalse(func8 is Func6); |
| 88 | + Expect.isFalse(func8 is Func7); |
| 89 | + |
| 90 | + int func9(int i, {int b = -1, int c = -1}) => -1; |
| 91 | + Expect.isTrue(func9 is Func1); |
| 92 | + Expect.isFalse(func9 is Func2); |
| 93 | + Expect.isFalse(func9 is Func3); |
| 94 | + Expect.isFalse(func9 is Func4); |
| 95 | + Expect.isTrue(func9 is Func5); |
| 96 | + Expect.isTrue(func9 is Func6); |
| 97 | + Expect.isFalse(func9 is Func7); |
| 98 | + |
| 99 | + int func10(int i, {int c = -1, int b = -1}) => -1; |
| 100 | + Expect.isTrue(func10 is Func1); |
| 101 | + Expect.isFalse(func10 is Func2); |
| 102 | + Expect.isFalse(func10 is Func3); |
| 103 | + Expect.isFalse(func10 is Func4); |
| 104 | + Expect.isTrue(func10 is Func5); |
| 105 | + Expect.isTrue(func10 is Func6); |
| 106 | + Expect.isFalse(func10 is Func7); |
| 107 | + |
| 108 | + int func11({int a = -1, int b = -1, int c = -1}) => -1; |
| 109 | + Expect.isFalse(func11 is Func1); |
| 110 | + Expect.isFalse(func11 is Func2); |
| 111 | + Expect.isFalse(func11 is Func3); |
| 112 | + Expect.isFalse(func11 is Func4); |
| 113 | + Expect.isFalse(func11 is Func5); |
| 114 | + Expect.isFalse(func11 is Func6); |
| 115 | + Expect.isTrue(func11 is Func7); |
| 116 | + |
| 117 | + int func12({int c = -1, int a = -1, int b = -1}) => -1; |
| 118 | + Expect.isFalse(func12 is Func1); |
| 119 | + Expect.isFalse(func12 is Func2); |
| 120 | + Expect.isFalse(func12 is Func3); |
| 121 | + Expect.isFalse(func12 is Func4); |
| 122 | + Expect.isFalse(func12 is Func5); |
| 123 | + Expect.isFalse(func12 is Func6); |
| 124 | + Expect.isTrue(func12 is Func7); |
| 125 | +} |
0 commit comments