| OLD | NEW |
| 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 // Note: This test relies on LF line endings in the source file. | 5 // Note: This test relies on LF line endings in the source file. |
| 6 | 6 |
| 7 import "dart:mirrors"; | 7 import "dart:mirrors"; |
| 8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 9 import "method_mirror_source_other.dart"; | 9 import "method_mirror_source_other.dart"; |
| 10 | 10 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 "foo1() {}"); | 64 "foo1() {}"); |
| 65 expectSource(lib.declarations[#x], | 65 expectSource(lib.declarations[#x], |
| 66 "int get x => 42;"); | 66 "int get x => 42;"); |
| 67 expectSource(lib.declarations[const Symbol("x=")], | 67 expectSource(lib.declarations[const Symbol("x=")], |
| 68 "set x(value) { }"); | 68 "set x(value) { }"); |
| 69 | 69 |
| 70 // Class members | 70 // Class members |
| 71 ClassMirror cm = reflectClass(C); | 71 ClassMirror cm = reflectClass(C); |
| 72 expectSource(cm.declarations[#foo], | 72 expectSource(cm.declarations[#foo], |
| 73 "static dynamic foo() {\n" | 73 "static dynamic foo() {\n" |
| 74 " // Happy foo.\n" | 74 " // Happy foo.\n" |
| 75 " }"); | 75 " }"); |
| 76 expectSource(cm.declarations[#bar], | 76 expectSource(cm.declarations[#bar], |
| 77 "void bar() { /* Not so happy bar. */ }"); | 77 "void bar() { /* Not so happy bar. */ }"); |
| 78 expectSource(cm.declarations[#someX], | 78 expectSource(cm.declarations[#someX], |
| 79 "num get someX =>\n" | 79 "num get someX =>\n" |
| 80 " 181;"); | 80 " 181;"); |
| 81 expectSource(cm.declarations[const Symbol("someX=")], | 81 expectSource(cm.declarations[const Symbol("someX=")], |
| 82 "set someX(v) {\n" | 82 "set someX(v) {\n" |
| 83 " // Discard this one.\n" | 83 " // Discard this one.\n" |
| 84 " }"); | 84 " }"); |
| 85 expectSource(cm.declarations[#C], | 85 expectSource(cm.declarations[#C], |
| 86 "C(this._x, y)\n" | 86 "C(this._x, y)\n" |
| 87 " : _y = y,\n" | 87 " : _y = y,\n" |
| 88 " super();"); | 88 " super();"); |
| 89 expectSource(cm.declarations[#C.other], | 89 expectSource(cm.declarations[#C.other], |
| 90 "factory C.other(num z) {}"); | 90 "factory C.other(num z) {}"); |
| 91 expectSource(cm.declarations[#C.other3], | 91 expectSource(cm.declarations[#C.other3], |
| 92 "factory C.other3() = C.other2;"); | 92 "factory C.other3() = C.other2;"); |
| 93 | 93 |
| 94 // Closures | 94 // Closures |
| 95 expectSource(reflect((){}), "(){}"); | 95 expectSource(reflect((){}), "(){}"); |
| 96 expectSource(reflect((x,y,z) { return x*y*z; }), "(x,y,z) { return x*y*z; }"); | 96 expectSource(reflect((x,y,z) { return x*y*z; }), "(x,y,z) { return x*y*z; }"); |
| 97 expectSource(reflect((e) => doSomething(e)), "(e) => doSomething(e)"); | 97 expectSource(reflect((e) => doSomething(e)), "(e) => doSomething(e)"); |
| 98 | 98 |
| 99 namedClosure(x,y,z) => 1; | 99 namedClosure(x,y,z) => 1; |
| 100 var a = () {}; | 100 var a = () {}; |
| 101 expectSource(reflect(namedClosure), "namedClosure(x,y,z) => 1;"); | 101 expectSource(reflect(namedClosure), "namedClosure(x,y,z) => 1;"); |
| 102 expectSource(reflect(a), "() {}"); | 102 expectSource(reflect(a), "() {}"); |
| 103 | 103 |
| 104 // Function at first line. | 104 // Function at first line. |
| 105 LibraryMirror otherLib = reflectClass(SomethingInOther).owner; | 105 LibraryMirror otherLib = reflectClass(SomethingInOther).owner; |
| 106 expectSource(otherLib.declarations[#main], | 106 expectSource(otherLib.declarations[#main], |
| 107 """main() { | 107 """main() { |
| 108 print("Blah"); | 108 print("Blah"); |
| 109 }"""); | 109 }"""); |
| 110 } | 110 } |
| OLD | NEW |