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.constructor_kinds_test; | 5 library test.constructor_kinds_test; |
6 | 6 |
7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
8 import 'package:expect/expect.dart'; | 8 import 'package:expect/expect.dart'; |
9 | 9 |
10 class ClassWithDefaultConstructor {} | 10 class ClassWithDefaultConstructor {} |
(...skipping 14 matching lines...) Expand all Loading... |
25 } | 25 } |
26 | 26 |
27 main() { | 27 main() { |
28 ClassMirror cm; | 28 ClassMirror cm; |
29 MethodMirror mm; | 29 MethodMirror mm; |
30 | 30 |
31 // Multitest with and without constructor calls. On the VM, we want to check | 31 // Multitest with and without constructor calls. On the VM, we want to check |
32 // that constructor properties are correctly set even if the constructor | 32 // that constructor properties are correctly set even if the constructor |
33 // hasn't been fully compiled. On dart2js, we want to check that constructors | 33 // hasn't been fully compiled. On dart2js, we want to check that constructors |
34 // are retain even if there are no base-level calls. | 34 // are retain even if there are no base-level calls. |
35 new ClassWithDefaultConstructor(); /// 01: ok | 35 new ClassWithDefaultConstructor(); // /// 01: ok |
36 new Class.generativeConstructor(); /// 01: ok | 36 new Class.generativeConstructor(); // /// 01: ok |
37 new Class.redirectingGenerativeConstructor(); /// 01: ok | 37 new Class.redirectingGenerativeConstructor(); // /// 01: ok |
38 new Class.factoryConstructor(); /// 01: ok | 38 new Class.factoryConstructor(); // /// 01: ok |
39 new Class.redirectingFactoryConstructor(); /// 01: ok | 39 new Class.redirectingFactoryConstructor(); // /// 01: ok |
40 const Class.constGenerativeConstructor(); /// 01: ok | 40 const Class.constGenerativeConstructor(); // /// 01: ok |
41 const Class.constRedirectingGenerativeConstructor(); /// 01: ok | 41 const Class.constRedirectingGenerativeConstructor(); // /// 01: ok |
42 const Class.constRedirectingFactoryConstructor(); /// 01: ok | 42 const Class.constRedirectingFactoryConstructor(); // /// 01: ok |
43 | 43 |
44 cm = reflectClass(ClassWithDefaultConstructor); | 44 cm = reflectClass(ClassWithDefaultConstructor); |
45 mm = cm.declarations.values | 45 mm = cm.declarations.values |
46 .where((d) => d is MethodMirror && d.isConstructor).single; | 46 .where((d) => d is MethodMirror && d.isConstructor).single; |
47 Expect.isTrue(mm.isConstructor); | 47 Expect.isTrue(mm.isConstructor); |
48 Expect.isTrue(mm.isGenerativeConstructor); | 48 Expect.isTrue(mm.isGenerativeConstructor); |
49 Expect.isFalse(mm.isFactoryConstructor); | 49 Expect.isFalse(mm.isFactoryConstructor); |
50 Expect.isFalse(mm.isRedirectingConstructor); | 50 Expect.isFalse(mm.isRedirectingConstructor); |
51 Expect.isFalse(mm.isConstConstructor); | 51 Expect.isFalse(mm.isConstConstructor); |
52 | 52 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 // Expect.isFalse(mm.isRedirectingConstructor); | 102 // Expect.isFalse(mm.isRedirectingConstructor); |
103 // Expect.isTrue(mm.isConstConstructor); | 103 // Expect.isTrue(mm.isConstConstructor); |
104 | 104 |
105 mm = cm.declarations[#Class.constRedirectingFactoryConstructor]; | 105 mm = cm.declarations[#Class.constRedirectingFactoryConstructor]; |
106 Expect.isTrue(mm.isConstructor); | 106 Expect.isTrue(mm.isConstructor); |
107 Expect.isFalse(mm.isGenerativeConstructor); | 107 Expect.isFalse(mm.isGenerativeConstructor); |
108 Expect.isTrue(mm.isFactoryConstructor); | 108 Expect.isTrue(mm.isFactoryConstructor); |
109 Expect.isTrue(mm.isRedirectingConstructor); | 109 Expect.isTrue(mm.isRedirectingConstructor); |
110 Expect.isTrue(mm.isConstConstructor); | 110 Expect.isTrue(mm.isConstConstructor); |
111 } | 111 } |
OLD | NEW |