Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Side by Side Diff: tests/lib_strong/mirrors/constructor_kinds_test.dart

Issue 2999373002: Migrated test block 218 to Dart 2.0. (Closed)
Patch Set: Addressed Bob's comments. Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library test.constructor_kinds_test;
6
7 import 'dart:mirrors';
8 import 'package:expect/expect.dart';
9
10 class ClassWithDefaultConstructor {}
11
12 class Class {
13 Class.generativeConstructor();
14 Class.redirectingGenerativeConstructor() : this.generativeConstructor();
15 factory Class.factoryConstructor() => new Class.generativeConstructor();
16 factory Class.redirectingFactoryConstructor() = Class.factoryConstructor;
17
18 const Class.constGenerativeConstructor();
19 const Class.constRedirectingGenerativeConstructor()
20 : this.constGenerativeConstructor();
21 // Not legal.
22 // const factory Class.constFactoryConstructor() => ...
23 const factory Class.constRedirectingFactoryConstructor() =
24 Class.constGenerativeConstructor;
25 }
26
27 main() {
28 ClassMirror cm;
29 MethodMirror mm;
30
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
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.
35 new ClassWithDefaultConstructor(); // //# 01: ok
36 new Class.generativeConstructor(); // //# 01: ok
37 new Class.redirectingGenerativeConstructor(); // //# 01: ok
38 new Class.factoryConstructor(); // //# 01: ok
39 new Class.redirectingFactoryConstructor(); // //# 01: ok
40 const Class.constGenerativeConstructor(); // //# 01: ok
41 const Class.constRedirectingGenerativeConstructor(); // //# 01: ok
42 const Class.constRedirectingFactoryConstructor(); // //# 01: ok
43
44 cm = reflectClass(ClassWithDefaultConstructor);
45 mm = cm.declarations.values
46 .where((d) => d is MethodMirror && d.isConstructor)
47 .single;
48 Expect.isTrue(mm.isConstructor);
49 Expect.isTrue(mm.isGenerativeConstructor);
50 Expect.isFalse(mm.isFactoryConstructor);
51 Expect.isFalse(mm.isRedirectingConstructor);
52 Expect.isFalse(mm.isConstConstructor);
53
54 cm = reflectClass(Class);
55
56 mm = cm.declarations[#Class.generativeConstructor];
57 Expect.isTrue(mm.isConstructor);
58 Expect.isTrue(mm.isGenerativeConstructor);
59 Expect.isFalse(mm.isFactoryConstructor);
60 Expect.isFalse(mm.isRedirectingConstructor);
61 Expect.isFalse(mm.isConstConstructor);
62
63 mm = cm.declarations[#Class.redirectingGenerativeConstructor];
64 Expect.isTrue(mm.isConstructor);
65 Expect.isTrue(mm.isGenerativeConstructor);
66 Expect.isFalse(mm.isFactoryConstructor);
67 Expect.isTrue(mm.isRedirectingConstructor);
68 Expect.isFalse(mm.isConstConstructor);
69
70 mm = cm.declarations[#Class.factoryConstructor];
71 Expect.isTrue(mm.isConstructor);
72 Expect.isFalse(mm.isGenerativeConstructor);
73 Expect.isTrue(mm.isFactoryConstructor);
74 Expect.isFalse(mm.isRedirectingConstructor);
75 Expect.isFalse(mm.isConstConstructor);
76
77 mm = cm.declarations[#Class.redirectingFactoryConstructor];
78 Expect.isTrue(mm.isConstructor);
79 Expect.isFalse(mm.isGenerativeConstructor);
80 Expect.isTrue(mm.isFactoryConstructor);
81 Expect.isTrue(mm.isRedirectingConstructor);
82 Expect.isFalse(mm.isConstConstructor);
83
84 mm = cm.declarations[#Class.constGenerativeConstructor];
85 Expect.isTrue(mm.isConstructor);
86 Expect.isTrue(mm.isGenerativeConstructor);
87 Expect.isFalse(mm.isFactoryConstructor);
88 Expect.isFalse(mm.isRedirectingConstructor);
89 Expect.isTrue(mm.isConstConstructor);
90
91 mm = cm.declarations[#Class.constRedirectingGenerativeConstructor];
92 Expect.isTrue(mm.isConstructor);
93 Expect.isTrue(mm.isGenerativeConstructor);
94 Expect.isFalse(mm.isFactoryConstructor);
95 Expect.isTrue(mm.isRedirectingConstructor);
96 Expect.isTrue(mm.isConstConstructor);
97
98 // Not legal.
99 // mm = cm.declarations[#Class.constFactoryConstructor];
100 // Expect.isTrue(mm.isConstructor);
101 // Expect.isFalse(mm.isGenerativeConstructor);
102 // Expect.isTrue(mm.isFactoryConstructor);
103 // Expect.isFalse(mm.isRedirectingConstructor);
104 // Expect.isTrue(mm.isConstConstructor);
105
106 mm = cm.declarations[#Class.constRedirectingFactoryConstructor];
107 Expect.isTrue(mm.isConstructor);
108 Expect.isFalse(mm.isGenerativeConstructor);
109 Expect.isTrue(mm.isFactoryConstructor);
110 Expect.isTrue(mm.isRedirectingConstructor);
111 Expect.isTrue(mm.isConstConstructor);
112 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698