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

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

Issue 22824048: Fix method_mirror_source test for analyzer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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
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 if (mirror is ClosureMirror) { 10 if (mirror is ClosureMirror) {
11 mirror = mirror.function; 11 mirror = mirror.function;
12 } 12 }
13 Expect.isTrue(mirror is MethodMirror); 13 Expect.isTrue(mirror is MethodMirror);
14 Expect.equals(mirror.source, source); 14 Expect.equals(mirror.source, source);
15 } 15 }
16 16
17 foo1() {} 17 foo1() {}
18 doSomething(e) => e;
18 19
19 int get x => 42; 20 int get x => 42;
20 set x(value) { } 21 set x(value) { }
21 22
22 class S {} 23 class S {}
23 24
24 class C extends S { 25 class C extends S {
25 26
26 var _x; 27 var _x;
27 var _y; 28 var _y;
28 29
29 C(this.x, y) 30 C(this._x, y)
30 : _y = y, 31 : _y = y,
31 super(); 32 super();
32 33
33 factory C.other(num z) {} 34 factory C.other(num z) {}
34 factory C.other2() {} 35 factory C.other2() {}
35 factory C.other3() = C.other2; 36 factory C.other3() = C.other2;
36 37
37 static dynamic foo() { 38 static dynamic foo() {
38 // Happy foo. 39 // Happy foo.
39 } 40 }
(...skipping 30 matching lines...) Expand all
70 expectSource(cm.members[const Symbol("bar")], 71 expectSource(cm.members[const Symbol("bar")],
71 "void bar() { /* Not so happy bar. */ }"); 72 "void bar() { /* Not so happy bar. */ }");
72 expectSource(cm.members[const Symbol("someX")], 73 expectSource(cm.members[const Symbol("someX")],
73 "num get someX =>\n" 74 "num get someX =>\n"
74 " 181;"); 75 " 181;");
75 expectSource(cm.members[const Symbol("someX=")], 76 expectSource(cm.members[const Symbol("someX=")],
76 "set someX(v) {\n" 77 "set someX(v) {\n"
77 " // Discard this one.\n" 78 " // Discard this one.\n"
78 " }"); 79 " }");
79 expectSource(cm.constructors[const Symbol("C")], 80 expectSource(cm.constructors[const Symbol("C")],
80 "C(this.x, y)\n" 81 "C(this._x, y)\n"
81 " : _y = y,\n" 82 " : _y = y,\n"
82 " super();"); 83 " super();");
83 expectSource(cm.constructors[const Symbol("C.other")], 84 expectSource(cm.constructors[const Symbol("C.other")],
84 "factory C.other(num z) {}"); 85 "factory C.other(num z) {}");
85 expectSource(cm.constructors[const Symbol("C.other3")], 86 expectSource(cm.constructors[const Symbol("C.other3")],
86 "factory C.other3() = C.other2;"); 87 "factory C.other3() = C.other2;");
87 88
88 // Closures 89 // Closures
89 expectSource(reflect((){}), "(){}"); 90 expectSource(reflect((){}), "(){}");
90 expectSource(reflect((x,y,z) { return x*y*z; }), "(x,y,z) { return x*y*z; }"); 91 expectSource(reflect((x,y,z) { return x*y*z; }), "(x,y,z) { return x*y*z; }");
91 expectSource(reflect((e) => doSomething(e)), "(e) => doSomething(e)"); 92 expectSource(reflect((e) => doSomething(e)), "(e) => doSomething(e)");
92 93
93 namedClosure(x,y,z) => 1; 94 namedClosure(x,y,z) => 1;
94 var a = () {}; 95 var a = () {};
95 expectSource(reflect(namedClosure), "namedClosure(x,y,z) => 1;"); 96 expectSource(reflect(namedClosure), "namedClosure(x,y,z) => 1;");
96 expectSource(reflect(a), "() {}"); 97 expectSource(reflect(a), "() {}");
97 } 98 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698