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

Side by Side Diff: test/codegen/lib/mirrors/method_mirror_properties_test.dart

Issue 2265533002: Add mirrors tests (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 4 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 import "dart:mirrors";
6
7 import "package:expect/expect.dart";
8
9 doNothing42() {}
10
11 int _x = 5;
12 int get topGetter => _x;
13 void set topSetter(x) { _x = x; }
14
15 abstract class AbstractC {
16
17 AbstractC();
18
19 void bar();
20 get priv;
21 set priv(value);
22 }
23
24 abstract class C extends AbstractC {
25
26 static foo() {}
27
28 C();
29 C.other();
30 C.other2() : this.other();
31
32 var _priv;
33 get priv => _priv;
34 set priv(value) => _priv = value;
35 }
36
37 checkKinds(method, kinds) {
38 Expect.equals(kinds[0], method.isStatic, "isStatic");
39 Expect.equals(kinds[1], method.isAbstract, "isAbstract");
40 Expect.equals(kinds[2], method.isGetter, "isGetter");
41 Expect.equals(kinds[3], method.isSetter, "isSetter");
42 Expect.equals(kinds[4], method.isConstructor, "isConstructor");
43 }
44
45 main() {
46 // Top level functions should be static.
47 var closureMirror = reflect(doNothing42);
48 checkKinds(closureMirror.function,
49 [true, false, false, false, false]);
50 var libraryMirror = reflectClass(C).owner;
51 checkKinds(libraryMirror.declarations[#topGetter],
52 [true, false, true, false, false]);
53 checkKinds(libraryMirror.declarations[const Symbol("topSetter=")],
54 [true, false, false, true, false]);
55 var classMirror;
56 classMirror = reflectClass(C);
57 checkKinds(classMirror.declarations[#foo],
58 [true, false, false, false, false]);
59 checkKinds(classMirror.declarations[#priv],
60 [false, false, true, false, false]);
61 checkKinds(classMirror.declarations[const Symbol("priv=")],
62 [false, false, false, true, false]);
63 checkKinds(classMirror.declarations[#C],
64 [false, false, false, false, true]);
65 checkKinds(classMirror.declarations[#C.other],
66 [false, false, false, false, true]);
67 checkKinds(classMirror.declarations[#C.other2],
68 [false, false, false, false, true]);
69 classMirror = reflectClass(AbstractC);
70 checkKinds(classMirror.declarations[#AbstractC],
71 [false, false, false, false, true]);
72 checkKinds(classMirror.declarations[#bar],
73 [false, true, false, false, false]);
74 checkKinds(classMirror.declarations[#priv],
75 [false, true, true, false, false]);
76 checkKinds(classMirror.declarations[const Symbol("priv=")],
77 [false, true, false, true, false]);
78 }
OLDNEW
« no previous file with comments | « test/codegen/lib/mirrors/method_mirror_name_test.dart ('k') | test/codegen/lib/mirrors/method_mirror_returntype_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698