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

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

Issue 64793003: Update mirror tests for removed API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: . Created 7 years, 1 month 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import "dart:mirrors"; 5 import "dart:mirrors";
6 6
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 8
9 expectSource(Mirror mirror, String source) { 9 expectSource(Mirror mirror, String source) {
10 MethodMirror methodMirror; 10 MethodMirror methodMirror;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 set someX(v) { 52 set someX(v) {
53 // Discard this one. 53 // Discard this one.
54 } 54 }
55 } 55 }
56 56
57 57
58 main() { 58 main() {
59 // Top-level members 59 // Top-level members
60 LibraryMirror lib = reflectClass(C).owner; 60 LibraryMirror lib = reflectClass(C).owner;
61 expectSource(lib.members[#foo1], 61 expectSource(lib.declarations[#foo1],
62 "foo1() {}"); 62 "foo1() {}");
63 expectSource(lib.members[#x], 63 expectSource(lib.declarations[#x],
64 "int get x => 42;"); 64 "int get x => 42;");
65 expectSource(lib.members[const Symbol("x=")], 65 expectSource(lib.declarations[const Symbol("x=")],
66 "set x(value) { }"); 66 "set x(value) { }");
67 67
68 // Class members 68 // Class members
69 ClassMirror cm = reflectClass(C); 69 ClassMirror cm = reflectClass(C);
70 expectSource(cm.members[#foo], 70 expectSource(cm.declarations[#foo],
71 "static dynamic foo() {\n" 71 "static dynamic foo() {\n"
72 " // Happy foo.\n" 72 " // Happy foo.\n"
73 " }"); 73 " }");
74 expectSource(cm.members[#bar], 74 expectSource(cm.declarations[#bar],
75 "void bar() { /* Not so happy bar. */ }"); 75 "void bar() { /* Not so happy bar. */ }");
76 expectSource(cm.members[#someX], 76 expectSource(cm.declarations[#someX],
77 "num get someX =>\n" 77 "num get someX =>\n"
78 " 181;"); 78 " 181;");
79 expectSource(cm.members[const Symbol("someX=")], 79 expectSource(cm.declarations[const Symbol("someX=")],
80 "set someX(v) {\n" 80 "set someX(v) {\n"
81 " // Discard this one.\n" 81 " // Discard this one.\n"
82 " }"); 82 " }");
83 expectSource(cm.constructors[#C], 83 expectSource(cm.declarations[#C],
84 "C(this._x, y)\n" 84 "C(this._x, y)\n"
85 " : _y = y,\n" 85 " : _y = y,\n"
86 " super();"); 86 " super();");
87 expectSource(cm.constructors[#C.other], 87 expectSource(cm.declarations[#C.other],
88 "factory C.other(num z) {}"); 88 "factory C.other(num z) {}");
89 expectSource(cm.constructors[#C.other3], 89 expectSource(cm.declarations[#C.other3],
90 "factory C.other3() = C.other2;"); 90 "factory C.other3() = C.other2;");
91 91
92 // Closures 92 // Closures
93 expectSource(reflect((){}), "(){}"); 93 expectSource(reflect((){}), "(){}");
94 expectSource(reflect((x,y,z) { return x*y*z; }), "(x,y,z) { return x*y*z; }"); 94 expectSource(reflect((x,y,z) { return x*y*z; }), "(x,y,z) { return x*y*z; }");
95 expectSource(reflect((e) => doSomething(e)), "(e) => doSomething(e)"); 95 expectSource(reflect((e) => doSomething(e)), "(e) => doSomething(e)");
96 96
97 namedClosure(x,y,z) => 1; 97 namedClosure(x,y,z) => 1;
98 var a = () {}; 98 var a = () {};
99 expectSource(reflect(namedClosure), "namedClosure(x,y,z) => 1;"); 99 expectSource(reflect(namedClosure), "namedClosure(x,y,z) => 1;");
100 expectSource(reflect(a), "() {}"); 100 expectSource(reflect(a), "() {}");
101 } 101 }
OLDNEW
« no previous file with comments | « tests/lib/mirrors/method_mirror_returntype_test.dart ('k') | tests/lib/mirrors/mirrors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698