| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 test.relation_subclass; | 5 library test.relation_subclass; |
| 6 | 6 |
| 7 import "dart:mirrors"; | 7 import "dart:mirrors"; |
| 8 | 8 |
| 9 import "package:expect/expect.dart"; | 9 import "package:expect/expect.dart"; |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 Expect.isFalse(Obj.isSubclassOf(Sub2)); | 50 Expect.isFalse(Obj.isSubclassOf(Sub2)); |
| 51 | 51 |
| 52 Expect.isTrue(Super.isSubclassOf(Obj)); | 52 Expect.isTrue(Super.isSubclassOf(Obj)); |
| 53 Expect.isFalse(Obj.isSubclassOf(Super)); | 53 Expect.isFalse(Obj.isSubclassOf(Super)); |
| 54 | 54 |
| 55 var Func = coreLibrary.declarations[#Function]; | 55 var Func = coreLibrary.declarations[#Function]; |
| 56 Expect.isTrue(Func.isSubclassOf(Obj)); | 56 Expect.isTrue(Func.isSubclassOf(Obj)); |
| 57 Expect.isFalse(Obj.isSubclassOf(Func)); | 57 Expect.isFalse(Obj.isSubclassOf(Func)); |
| 58 | 58 |
| 59 // Function typedef. | 59 // Function typedef. |
| 60 var NumPred = thisLibrary.declarations[#NumberPredicate]; | 60 // TODO(16939): retrieve via declaration when dart2js supports it. |
| 61 var IntPred = thisLibrary.declarations[#IntegerPredicate]; | 61 var NumPred = reflectType(NumberPredicate); |
| 62 var DubPred = thisLibrary.declarations[#DoublePredicate]; | 62 var IntPred = reflectType(IntegerPredicate); |
| 63 var NumGen = thisLibrary.declarations[#NumberGenerator]; | 63 var DubPred = reflectType(DoublePredicate); |
| 64 var IntGen = thisLibrary.declarations[#IntegerGenerator]; | 64 var NumGen = reflectType(NumberGenerator); |
| 65 var DubGen = thisLibrary.declarations[#DoubleGenerator]; | 65 var IntGen = reflectType(IntegerGenerator); |
| 66 var DubGen = reflectType(DoubleGenerator); |
| 66 | 67 |
| 67 isArgumentOrTypeError(e) => e is ArgumentError || e is TypeError; | 68 isArgumentOrTypeError(e) => e is ArgumentError || e is TypeError; |
| 68 Expect.throws(() => Func.isSubclassOf(NumPred), isArgumentOrTypeError); | 69 Expect.throws(() => Func.isSubclassOf(NumPred), isArgumentOrTypeError); |
| 69 Expect.throws(() => Func.isSubclassOf(IntPred), isArgumentOrTypeError); | 70 Expect.throws(() => Func.isSubclassOf(IntPred), isArgumentOrTypeError); |
| 70 Expect.throws(() => Func.isSubclassOf(DubPred), isArgumentOrTypeError); | 71 Expect.throws(() => Func.isSubclassOf(DubPred), isArgumentOrTypeError); |
| 71 Expect.throws(() => Func.isSubclassOf(NumGen), isArgumentOrTypeError); | 72 Expect.throws(() => Func.isSubclassOf(NumGen), isArgumentOrTypeError); |
| 72 Expect.throws(() => Func.isSubclassOf(IntGen), isArgumentOrTypeError); | 73 Expect.throws(() => Func.isSubclassOf(IntGen), isArgumentOrTypeError); |
| 73 Expect.throws(() => Func.isSubclassOf(DubGen), isArgumentOrTypeError); | 74 Expect.throws(() => Func.isSubclassOf(DubGen), isArgumentOrTypeError); |
| 74 | 75 |
| 75 isNoSuchMethodError(e) => e is NoSuchMethodError; | 76 isNoSuchMethodError(e) => e is NoSuchMethodError; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 101 // IntPredRef.isSubclassOf(Func); | 102 // IntPredRef.isSubclassOf(Func); |
| 102 // DubPredRef.isSubclassOf(Func); | 103 // DubPredRef.isSubclassOf(Func); |
| 103 // NumGenRef.isSubclassOf(Func); | 104 // NumGenRef.isSubclassOf(Func); |
| 104 // IntGenRef.isSubclassOf(Func); | 105 // IntGenRef.isSubclassOf(Func); |
| 105 // DubGenRef.isSubclassOf(Func); | 106 // DubGenRef.isSubclassOf(Func); |
| 106 } | 107 } |
| 107 | 108 |
| 108 main() { | 109 main() { |
| 109 test(currentMirrorSystem()); | 110 test(currentMirrorSystem()); |
| 110 } | 111 } |
| OLD | NEW |