OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 library MirrorsTest; | 5 library MirrorsTest; |
6 | 6 |
7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
8 | 8 |
9 import '../../light_unittest.dart'; | 9 import '../../light_unittest.dart'; |
10 | 10 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 | 199 |
200 expect(variableMirror.simpleName, equals(#field)); | 200 expect(variableMirror.simpleName, equals(#field)); |
201 expect(variableMirror.qualifiedName, | 201 expect(variableMirror.qualifiedName, |
202 equals(const Symbol('MirrorsTest.Class.field'))); | 202 equals(const Symbol('MirrorsTest.Class.field'))); |
203 } | 203 } |
204 | 204 |
205 testLibraryUri(var value, bool check(Uri)) { | 205 testLibraryUri(var value, bool check(Uri)) { |
206 var valueMirror = reflect(value); | 206 var valueMirror = reflect(value); |
207 ClassMirror valueClass = valueMirror.type; | 207 ClassMirror valueClass = valueMirror.type; |
208 LibraryMirror valueLibrary = valueClass.owner; | 208 LibraryMirror valueLibrary = valueClass.owner; |
209 expect(check(valueLibrary.uri), isTrue); | 209 Uri uri = valueLibrary.uri; |
| 210 if (uri.scheme != "https" || |
| 211 uri.host != "dartlang.org" || |
| 212 uri.path != "/dart2js-stripped-uri") { |
| 213 expect(check(uri), isTrue); |
| 214 } |
210 } | 215 } |
211 | 216 |
212 main() { | 217 main() { |
213 var mirrors = currentMirrorSystem(); | 218 var mirrors = currentMirrorSystem(); |
214 test("Test reflective method invocation", () { testInvoke(mirrors); }); | 219 test("Test reflective method invocation", () { testInvoke(mirrors); }); |
215 test('Test intercepted objects', () { testIntercepted(mirrors); }); | 220 test('Test intercepted objects', () { testIntercepted(mirrors); }); |
216 test("Test field access", () { testFieldAccess(mirrors); }); | 221 test("Test field access", () { testFieldAccess(mirrors); }); |
217 test("Test closure mirrors", () { testClosureMirrors(mirrors); }); | 222 test("Test closure mirrors", () { testClosureMirrors(mirrors); }); |
218 test("Test invoke constructor", () { testInvokeConstructor(mirrors); }); | 223 test("Test invoke constructor", () { testInvokeConstructor(mirrors); }); |
219 test("Test current library uri", () { | 224 test("Test current library uri", () { |
220 testLibraryUri(new Class(), | 225 testLibraryUri(new Class(), |
221 // TODO(floitsch): change this to "/mirrors_test.dart" when | 226 // TODO(floitsch): change this to "/mirrors_test.dart" when |
222 // dart2js_mirrors_test.dart has been removed. | 227 // dart2js_mirrors_test.dart has been removed. |
223 (Uri uri) => uri.path.endsWith('mirrors_test.dart')); | 228 (Uri uri) => uri.path.endsWith('mirrors_test.dart')); |
224 }); | 229 }); |
225 test("Test dart library uri", () { | 230 test("Test dart library uri", () { |
226 testLibraryUri("test", | 231 testLibraryUri("test", |
227 (Uri uri) { | 232 (Uri uri) { |
228 if (uri == Uri.parse('dart:core')) return true; | 233 if (uri == Uri.parse('dart:core')) return true; |
229 // TODO(floitsch): do we want to fake the interceptors to | 234 // TODO(floitsch): do we want to fake the interceptors to |
230 // be in dart:core? | 235 // be in dart:core? |
231 return (uri == Uri.parse('dart:_interceptors')); | 236 return (uri == Uri.parse('dart:_interceptors')); |
232 }); | 237 }); |
233 }); | 238 }); |
234 test("Test simple and qualifiedName", () { testNames(mirrors); }); | 239 test("Test simple and qualifiedName", () { testNames(mirrors); }); |
235 test("Test reflect type", () { testReflectClass(mirrors); }); | 240 test("Test reflect type", () { testReflectClass(mirrors); }); |
236 } | 241 } |
OLD | NEW |