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

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

Issue 25945002: More mirror tests: initializing formals and substituted types in instantiated generics. (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/mirrors/generics_substitution_test.dart ('k') | no next file » | 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.initializing_formals;
6
7 import 'dart:mirrors';
8 import 'package:expect/expect.dart';
9
10 class Class<T> {
11 int intField;
12 bool boolField;
13 String stringField;
14 T tField;
15 dynamic _privateField;
16
17 Class.nongeneric(this.intField);
18 Class.named({this.boolField});
19 Class.optPos([this.stringField = 'default']);
20 Class.generic(this.tField);
21 Class.private(this._privateField);
22 }
23
24 class Constant {
25 final value;
26 const Constant(this.value);
27 const Constant.marked(final this.value);
28 }
29
30 main() {
31 ParameterMirror pm;
32
33 pm = reflectClass(Class).constructors[#Class.nongeneric].parameters.single;
34 Expect.equals(#intField, pm.simpleName);
35 Expect.equals(reflectClass(int), pm.type); /// 01: ok
36 Expect.isFalse(pm.isNamed);
37 Expect.isFalse(pm.isFinal);
38 Expect.isFalse(pm.isOptional);
39 Expect.isFalse(pm.hasDefaultValue);
40 Expect.isFalse(pm.isPrivate);
41 Expect.isFalse(pm.isStatic);
42 Expect.isFalse(pm.isTopLevel);
43
44 pm = reflectClass(Class).constructors[#Class.named].parameters.single;
45 Expect.equals(#boolField, pm.simpleName);
46 Expect.equals(reflectClass(bool), pm.type); /// 01: ok
47 Expect.isTrue(pm.isNamed);
48 Expect.isFalse(pm.isFinal);
49 Expect.isTrue(pm.isOptional);
50 Expect.isFalse(pm.hasDefaultValue);
51 Expect.isFalse(pm.isPrivate);
52 Expect.isFalse(pm.isStatic);
53 Expect.isFalse(pm.isTopLevel);
54
55 pm = reflectClass(Class).constructors[#Class.optPos].parameters.single;
56 Expect.equals(#stringField, pm.simpleName);
57 Expect.equals(reflectClass(String), pm.type); /// 01: ok
58 Expect.isFalse(pm.isNamed);
59 Expect.isFalse(pm.isFinal);
60 Expect.isTrue(pm.isOptional);
61 Expect.isTrue(pm.hasDefaultValue);
62 Expect.equals('default', pm.defaultValue.reflectee);
63 Expect.isFalse(pm.isPrivate);
64 Expect.isFalse(pm.isStatic);
65 Expect.isFalse(pm.isTopLevel);
66
67 pm = reflectClass(Class).constructors[#Class.generic].parameters.single;
68 Expect.equals(#tField, pm.simpleName);
69 Expect.equals(reflectClass(Class).typeVariables.single, pm.type); /// 01: ok
70 Expect.isFalse(pm.isNamed);
71 Expect.isFalse(pm.isFinal);
72 Expect.isFalse(pm.isOptional);
73 Expect.isFalse(pm.hasDefaultValue);
74 Expect.isFalse(pm.isPrivate);
75 Expect.isFalse(pm.isStatic);
76 Expect.isFalse(pm.isTopLevel);
77
78 pm = reflectClass(Class).constructors[#Class.private].parameters.single;
79 Expect.equals(#_privateField, pm.simpleName);
80 Expect.equals(currentMirrorSystem().dynamicType, pm.type);
81 Expect.isFalse(pm.isNamed);
82 Expect.isFalse(pm.isFinal);
83 Expect.isFalse(pm.isOptional);
84 Expect.isFalse(pm.hasDefaultValue);
85 Expect.isTrue(pm.isPrivate);
86 Expect.isFalse(pm.isStatic);
87 Expect.isFalse(pm.isTopLevel);
88
89 pm = reflectClass(Constant).constructors[#Constant].parameters.single;
90 Expect.equals(#value, pm.simpleName);
91 Expect.equals(currentMirrorSystem().dynamicType, pm.type);
92 Expect.isFalse(pm.isNamed);
93 Expect.isFalse(pm.isFinal); // N.B.
94 Expect.isFalse(pm.isOptional);
95 Expect.isFalse(pm.hasDefaultValue);
96 Expect.isFalse(pm.isPrivate);
97 Expect.isFalse(pm.isStatic);
98 Expect.isFalse(pm.isTopLevel);
99
100 pm = reflectClass(Constant).constructors[#Constant.marked].parameters.single;
101 Expect.equals(#value, pm.simpleName);
102 Expect.equals(currentMirrorSystem().dynamicType, pm.type);
103 Expect.isFalse(pm.isNamed);
104 Expect.isTrue(pm.isFinal); // N.B.
105 Expect.isFalse(pm.isOptional);
106 Expect.isFalse(pm.hasDefaultValue);
107 Expect.isFalse(pm.isPrivate);
108 Expect.isFalse(pm.isStatic);
109 Expect.isFalse(pm.isTopLevel);
110 }
OLDNEW
« no previous file with comments | « tests/lib/mirrors/generics_substitution_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698