OLD | NEW |
(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 // Test library uri for a library read as a file. |
| 6 |
| 7 library MirrorsTest; |
| 8 |
| 9 import 'dart:mirrors'; |
| 10 import 'dart:io'; |
| 11 import 'dart:uri'; |
| 12 import '../../../pkg/unittest/lib/unittest.dart'; |
| 13 |
| 14 class Class { |
| 15 } |
| 16 |
| 17 testLibraryUri(var value, Uri expectedUri) { |
| 18 var valueMirror = reflect(value); |
| 19 ClassMirror valueClass = valueMirror.type; |
| 20 LibraryMirror valueLibrary = valueClass.owner; |
| 21 expect(valueLibrary.uri, equals(expectedUri)); |
| 22 } |
| 23 |
| 24 main() { |
| 25 var mirrors = currentMirrorSystem(); |
| 26 test("Test current library uri", () { |
| 27 String appendSlash(String path) => path.endsWith('/') ? path : '$path/'; |
| 28 Uri cwd = new Uri.fromComponents( |
| 29 scheme: 'file', |
| 30 path: appendSlash(new Path(new File('.').fullPathSync()).toString())); |
| 31 Uri uri = cwd.resolve(new Path(new Options().script).toString()); |
| 32 testLibraryUri(new Class(), uri); |
| 33 }); |
| 34 } |
OLD | NEW |