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

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

Issue 3011633002: Added back helper file accidentally deleted during test block 219 migration. (Closed)
Patch Set: 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.constructors_test;
6
7 @MirrorsUsed(targets: "test.constructors_test")
8 import 'dart:mirrors';
9
10 import 'package:expect/expect.dart';
11
12 import 'stringify.dart';
13
14 constructorsOf(ClassMirror cm) {
15 var result = new Map();
16 cm.declarations.forEach((k, v) {
17 if (v is MethodMirror && v.isConstructor) result[k] = v;
18 });
19 return result;
20 }
21
22 class Foo {}
23
24 class Bar {
25 Bar();
26 }
27
28 class Baz {
29 Baz.named();
30 }
31
32 class Biz {
33 Biz();
34 Biz.named();
35 }
36
37 main() {
38 ClassMirror fooMirror = reflectClass(Foo);
39 Map<Symbol, MethodMirror> fooConstructors = constructorsOf(fooMirror);
40 ClassMirror barMirror = reflectClass(Bar);
41 Map<Symbol, MethodMirror> barConstructors = constructorsOf(barMirror);
42 ClassMirror bazMirror = reflectClass(Baz);
43 Map<Symbol, MethodMirror> bazConstructors = constructorsOf(bazMirror);
44 ClassMirror bizMirror = reflectClass(Biz);
45 Map<Symbol, MethodMirror> bizConstructors = constructorsOf(bizMirror);
46
47 expect('{Foo: Method(s(Foo) in s(Foo), constructor)}', fooConstructors);
48 expect('{Bar: Method(s(Bar) in s(Bar), constructor)}', barConstructors);
49 expect('{Baz.named: Method(s(Baz.named) in s(Baz), constructor)}',
50 bazConstructors);
51 expect(
52 '{Biz: Method(s(Biz) in s(Biz), constructor),'
53 ' Biz.named: Method(s(Biz.named) in s(Biz), constructor)}',
54 bizConstructors);
55 print(bizConstructors);
56
57 expect('[]', fooConstructors.values.single.parameters);
58 expect('[]', barConstructors.values.single.parameters);
59 expect('[]', bazConstructors.values.single.parameters);
60 for (var constructor in bizConstructors.values) {
61 expect('[]', constructor.parameters);
62 }
63
64 expect(
65 '[s()]', fooConstructors.values.map((m) => m.constructorName).toList());
66 expect(
67 '[s()]', barConstructors.values.map((m) => m.constructorName).toList());
68 expect('[s(named)]',
69 bazConstructors.values.map((m) => m.constructorName).toList());
70 expect(
71 '[s(), s(named)]',
72 bizConstructors.values.map((m) => m.constructorName).toList()
73 ..sort(compareSymbols));
74 }
OLDNEW
« no previous file with comments | « tests/lib/mirrors/constructor_private_name_test.dart ('k') | tests/lib/mirrors/dart2js_mirrors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698