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

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

Issue 25609003: Add missing test coverage for constructor kinds, generic function typedefs and generic mixin applic… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « tests/lib/lib.status ('k') | tests/lib/mirrors/constructors_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.generative();
14 Class.redirectingGenerative() : this.generative();
15 factory Class.faktory () => new Class.generative();
16 factory Class.redirectingFactory() = Class.faktory;
17
18 const Class.constGenerative();
19 const Class.constRedirectingGenerative() : this.constGenerative();
20 // Not legal.
21 // const factory Class.constFaktory () => const Class.constGenerative();
22 const factory Class.constRedirectingFactory() = Class.constGenerative;
23 }
24
25 main() {
26 ClassMirror cm;
27 MethodMirror mm;
28
29 new Class.generative();
30 new Class.redirectingGenerative();
31 new Class.faktory();
32 new Class.redirectingFactory();
33 const Class.constGenerative();
34 const Class.constRedirectingGenerative();
35 const Class.constRedirectingFactory();
36
37 cm = reflectClass(ClassWithDefaultConstructor);
38 mm = cm.constructors.values.single;
39 Expect.isTrue(mm.isConstructor);
40 Expect.isTrue(mm.isGenerativeConstructor);
41 Expect.isFalse(mm.isFactoryConstructor);
42 Expect.isFalse(mm.isRedirectingConstructor);
43 Expect.isFalse(mm.isConstConstructor);
44
45
46 cm = reflectClass(Class);
47
48 mm = cm.constructors[#generative];
49 Expect.isTrue(mm.isConstructor);
50 Expect.isTrue(mm.isGenerativeConstructor);
51 Expect.isFalse(mm.isFactoryConstructor);
52 Expect.isFalse(mm.isRedirectingConstructor);
53 Expect.isFalse(mm.isConstConstructor);
54
55 mm = cm.constructors[#redirectingGenerative];
56 Expect.isTrue(mm.isConstructor);
57 Expect.isTrue(mm.isGenerativeConstructor);
58 Expect.isFalse(mm.isFactoryConstructor);
59 Expect.isTrue(mm.isRedirectingConstructor);
60 Expect.isFalse(mm.isConstConstructor);
61
62 mm = cm.constructors[#faktory];
63 Expect.isTrue(mm.isConstructor);
64 Expect.isFalse(mm.isGenerativeConstructor);
65 Expect.isTrue(mm.isFactoryConstructor);
66 Expect.isFalse(mm.isRedirectingConstructor);
67 Expect.isFalse(mm.isConstConstructor);
68
69 mm = cm.constructors[#redirectingFactory];
70 Expect.isTrue(mm.isConstructor);
71 Expect.isFalse(mm.isGenerativeConstructor);
72 Expect.isTrue(mm.isFactoryConstructor);
73 Expect.isTrue(mm.isRedirectingConstructor);
74 Expect.isFalse(mm.isConstConstructor);
75
76 mm = cm.constructors[#constGenerative];
77 Expect.isTrue(mm.isConstructor);
78 Expect.isTrue(mm.isGenerativeConstructor);
79 Expect.isFalse(mm.isFactoryConstructor);
80 Expect.isFalse(mm.isRedirectingConstructor);
81 Expect.isTrue(mm.isConstConstructor);
82
83 mm = cm.constructors[#constRedirectingGenerative];
84 Expect.isTrue(mm.isConstructor);
85 Expect.isTrue(mm.isGenerativeConstructor);
86 Expect.isFalse(mm.isFactoryConstructor);
87 Expect.isTrue(mm.isRedirectingConstructor);
88 Expect.isTrue(mm.isConstConstructor);
89
90 // Not legal.
91 // mm = cm.constructors[#constFaktory];
92 // Expect.isTrue(mm.isConstructor);
93 // Expect.isFalse(mm.isGenerativeConstructor);
94 // Expect.isTrue(mm.isFactoryConstructor);
95 // Expect.isFalse(mm.isRedirectingConstructor);
96 // Expect.isTrue(mm.isConstConstructor);
97
98 mm = cm.constructors[#constRedirectingFactory];
99 Expect.isTrue(mm.isConstructor);
100 Expect.isFalse(mm.isGenerativeConstructor);
101 Expect.isTrue(mm.isFactoryConstructor);
102 Expect.isTrue(mm.isRedirectingConstructor);
103 Expect.isTrue(mm.isConstConstructor);
104 }
OLDNEW
« no previous file with comments | « tests/lib/lib.status ('k') | tests/lib/mirrors/constructors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698