OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // VMOptions=--enable_type_checks | 4 // VMOptions=--enable_type_checks |
5 // | 5 // |
6 // Dart test for function type alias. | 6 // Dart test for function type alias. |
7 | 7 |
8 typedef Fun(a, b); | 8 typedef Fun(a, b); |
9 | 9 |
10 typedef int IntFun(a, b); | 10 typedef int IntFun(a, b); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 int compareStrLenReverse(String a, String b, [bool reverse = false]) { | 61 int compareStrLenReverse(String a, String b, [bool reverse = false]) { |
62 return reverse ? (a.length - b.length) : (b.length - a.length); | 62 return reverse ? (a.length - b.length) : (b.length - a.length); |
63 } | 63 } |
64 Expect.isTrue(compareStrLenReverse is Fun); | 64 Expect.isTrue(compareStrLenReverse is Fun); |
65 Expect.isTrue(compareStrLenReverse is IntFun); | 65 Expect.isTrue(compareStrLenReverse is IntFun); |
66 Expect.isTrue(compareStrLenReverse is !BoolFun); | 66 Expect.isTrue(compareStrLenReverse is !BoolFun); |
67 Expect.isTrue(compareStrLenReverse is CompareObj); | 67 Expect.isTrue(compareStrLenReverse is CompareObj); |
68 Expect.isTrue(compareStrLenReverse is !CompareInt); | 68 Expect.isTrue(compareStrLenReverse is !CompareInt); |
69 Expect.isTrue(compareStrLenReverse is CompareString); | 69 Expect.isTrue(compareStrLenReverse is CompareString); |
70 | 70 |
71 int compareObj(Object a, Object b) { return a === b ? 0 : -1; } | 71 int compareObj(Object a, Object b) { return identical(a, b) ? 0 : -1; } |
72 Expect.isTrue(compareObj is Fun); | 72 Expect.isTrue(compareObj is Fun); |
73 Expect.isTrue(compareObj is IntFun); | 73 Expect.isTrue(compareObj is IntFun); |
74 Expect.isTrue(compareObj is !BoolFun); | 74 Expect.isTrue(compareObj is !BoolFun); |
75 Expect.isTrue(compareObj is CompareObj); | 75 Expect.isTrue(compareObj is CompareObj); |
76 Expect.isTrue(compareObj is CompareInt); | 76 Expect.isTrue(compareObj is CompareInt); |
77 Expect.isTrue(compareObj is !CompareString); | 77 Expect.isTrue(compareObj is !CompareString); |
78 Expect.equals(-1, test(compareObj, "abcdef", "xyz")); | 78 Expect.equals(-1, test(compareObj, "abcdef", "xyz")); |
79 | 79 |
80 CompareInt minus = int _(int a, int b) { return a - b; }; | 80 CompareInt minus = int _(int a, int b) { return a - b; }; |
81 Expect.isTrue(minus is Fun); | 81 Expect.isTrue(minus is Fun); |
(...skipping 17 matching lines...) Expand all Loading... |
99 Function boundsTrue = void _(int arg) { }; | 99 Function boundsTrue = void _(int arg) { }; |
100 Function boundsFalse = void _(String arg) { }; | 100 Function boundsFalse = void _(String arg) { }; |
101 Expect.isTrue(boundsTrue is BoundsCheck<num>); | 101 Expect.isTrue(boundsTrue is BoundsCheck<num>); |
102 Expect.isFalse(boundsFalse is BoundsCheck<num>); | 102 Expect.isFalse(boundsFalse is BoundsCheck<num>); |
103 } | 103 } |
104 } | 104 } |
105 | 105 |
106 main() { | 106 main() { |
107 FunctionTypeAliasTest.testMain(); | 107 FunctionTypeAliasTest.testMain(); |
108 } | 108 } |
OLD | NEW |