OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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.instantiate_abstract_class; | 5 library test.instantiate_abstract_class; |
6 | 6 |
| 7 @MirrorsUsed(targets: const ["dart.core", AbstractClass]) |
7 import 'dart:mirrors'; | 8 import 'dart:mirrors'; |
8 import 'package:expect/expect.dart'; | 9 import 'package:expect/expect.dart'; |
9 | 10 |
10 | 11 |
11 assertInstanitationErrorOnGenerativeConstructors(classMirror) { | 12 assertInstanitationErrorOnGenerativeConstructors(classMirror) { |
12 classMirror.declarations.values.forEach((decl) { | 13 classMirror.declarations.values.forEach((decl) { |
13 if (decl is! MethodMirror) return; | 14 if (decl is! MethodMirror) return; |
14 if (!decl.isGenerativeConstructor) return; | 15 if (!decl.isGenerativeConstructor) return; |
15 var args = new List(decl.parameters.length); | 16 var args = new List(decl.parameters.length); |
16 Expect.throws(() => classMirror.newInstance(decl.constructorName, args), | 17 Expect.throws(() => classMirror.newInstance(decl.constructorName, args), |
(...skipping 20 matching lines...) Expand all Loading... |
37 class ConcreteClass implements AbstractClass {} | 38 class ConcreteClass implements AbstractClass {} |
38 | 39 |
39 main() { | 40 main() { |
40 assertInstanitationErrorOnGenerativeConstructors(reflectType(num)); | 41 assertInstanitationErrorOnGenerativeConstructors(reflectType(num)); |
41 assertInstanitationErrorOnGenerativeConstructors(reflectType(double)); | 42 assertInstanitationErrorOnGenerativeConstructors(reflectType(double)); |
42 assertInstanitationErrorOnGenerativeConstructors(reflectType(StackTrace)); | 43 assertInstanitationErrorOnGenerativeConstructors(reflectType(StackTrace)); |
43 | 44 |
44 assertInstanitationErrorOnGenerativeConstructors(reflectType(AbstractClass)); | 45 assertInstanitationErrorOnGenerativeConstructors(reflectType(AbstractClass)); |
45 runFactoryConstructors(reflectType(AbstractClass)); | 46 runFactoryConstructors(reflectType(AbstractClass)); |
46 } | 47 } |
OLD | NEW |