| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 single_library_test; | 5 library single_library_test; |
| 6 | 6 |
| 7 import 'package:path/path.dart' as p; | 7 import 'package:path/path.dart' as p; |
| 8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 9 | 9 |
| 10 import '../lib/docgen.dart'; | 10 import '../lib/docgen.dart'; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 return ['test_lib.dart', 'test_lib_bar.dart', 'test_lib_foo.dart'] | 21 return ['test_lib.dart', 'test_lib_bar.dart', 'test_lib_foo.dart'] |
| 22 .map((name) => p.join(codePath, name)) | 22 .map((name) => p.join(codePath, name)) |
| 23 .map(p.toUri) | 23 .map(p.toUri) |
| 24 .toList(); | 24 .toList(); |
| 25 } | 25 } |
| 26 | 26 |
| 27 void main() { | 27 void main() { |
| 28 group('Generate docs for', () { | 28 group('Generate docs for', () { |
| 29 test('multiple libraries.', () { | 29 test('multiple libraries.', () { |
| 30 var files = _writeLibFiles(); | 30 var files = _writeLibFiles(); |
| 31 return getMirrorSystem(files) | 31 return getMirrorSystem(files, false) |
| 32 .then((mirrorSystem) { | 32 .then((mirrorSystem) { |
| 33 var test_libraryUri = files[0]; | 33 var test_libraryUri = files[0]; |
| 34 var library = new Library(mirrorSystem.libraries[test_libraryUri]); | 34 var library = new Library(mirrorSystem.libraries[test_libraryUri]); |
| 35 | 35 |
| 36 /// Testing fixReference | 36 /// Testing fixReference |
| 37 // Testing Doc comment for class [B]. | 37 // Testing Doc comment for class [B]. |
| 38 var libraryMirror = mirrorSystem.libraries[test_libraryUri]; | 38 var libraryMirror = mirrorSystem.libraries[test_libraryUri]; |
| 39 var classDocComment = library.fixReference('B').children.first.text; | 39 var classDocComment = library.fixReference('B').children.first.text; |
| 40 expect(classDocComment, 'test_lib.B'); | 40 expect(classDocComment, 'test_lib.B'); |
| 41 | 41 |
| 42 // Test for linking to parameter [c] | 42 // Test for linking to parameter [c] |
| 43 var importedLib = libraryMirror.libraryDependencies.firstWhere( | 43 var importedLib = libraryMirror.libraryDependencies.firstWhere( |
| 44 (dep) => dep.isImport).targetLibrary; | 44 (dep) => dep.isImport).targetLibrary; |
| 45 var aClassMirror = | 45 var aClassMirror = |
| 46 dart2js_util.classesOf(importedLib.declarations).first; | 46 dart2js_util.classesOf(importedLib.declarations).first; |
| 47 expect(dart2js_util.qualifiedNameOf(aClassMirror), | 47 expect(dart2js_util.qualifiedNameOf(aClassMirror), |
| 48 'test_lib.foo.B'); | 48 'test_lib.foo.B'); |
| 49 var exportedClass = Indexable.getDocgenObject(aClassMirror, library); | 49 var exportedClass = getDocgenObject(aClassMirror, library); |
| 50 expect(exportedClass is Class, isTrue); | 50 expect(exportedClass is Class, isTrue); |
| 51 | 51 |
| 52 | 52 |
| 53 var method = exportedClass.methods['doThis']; | 53 var method = exportedClass.methods['doThis']; |
| 54 expect(method is Method, isTrue); | 54 expect(method is Method, isTrue); |
| 55 var methodParameterDocComment = method.fixReference( | 55 var methodParameterDocComment = method.fixReference( |
| 56 'c').children.first.text; | 56 'c').children.first.text; |
| 57 expect(methodParameterDocComment, 'test_lib.B.doThis.c'); | 57 expect(methodParameterDocComment, 'test_lib.B.doThis.c'); |
| 58 | 58 |
| 59 | 59 |
| 60 expect(method.fixReference('A').children.first.text, 'test_lib.A'); | 60 expect(method.fixReference('A').children.first.text, 'test_lib.A'); |
| 61 // Testing trying to refer to doThis function | 61 // Testing trying to refer to doThis function |
| 62 expect(method.fixReference('doThis').children.first.text, | 62 expect(method.fixReference('doThis').children.first.text, |
| 63 'test_lib.B.doThis'); | 63 'test_lib.B.doThis'); |
| 64 | 64 |
| 65 // Testing trying to refer to doThis function | 65 // Testing trying to refer to doThis function |
| 66 expect(method.fixReference('doElse').children.first.text, | 66 expect(method.fixReference('doElse').children.first.text, |
| 67 'test_lib.B.doElse'); | 67 'test_lib.B.doElse'); |
| 68 | 68 |
| 69 | 69 |
| 70 // Test a third library referencing another exported library in a | 70 // Test a third library referencing another exported library in a |
| 71 // separate file. | 71 // separate file. |
| 72 importedLib = libraryMirror.libraryDependencies.firstWhere( | 72 importedLib = libraryMirror.libraryDependencies.firstWhere( |
| 73 (dep) => dep.isImport && | 73 (dep) => dep.isImport && |
| 74 dart2js_util.qualifiedNameOf(dep.targetLibrary) == | 74 dart2js_util.qualifiedNameOf(dep.targetLibrary) == |
| 75 'test_lib.bar').targetLibrary; | 75 'test_lib.bar').targetLibrary; |
| 76 aClassMirror = dart2js_util.classesOf(importedLib.declarations).first; | 76 aClassMirror = dart2js_util.classesOf(importedLib.declarations).first; |
| 77 expect(dart2js_util.qualifiedNameOf(aClassMirror), | 77 expect(dart2js_util.qualifiedNameOf(aClassMirror), |
| 78 'test_lib.bar.C'); | 78 'test_lib.bar.C'); |
| 79 exportedClass = Indexable.getDocgenObject(aClassMirror, library); | 79 exportedClass = getDocgenObject(aClassMirror, library); |
| 80 expect(exportedClass is Class, isTrue); | 80 expect(exportedClass is Class, isTrue); |
| 81 expect(exportedClass.docName, 'test_lib.C'); | 81 expect(exportedClass.docName, 'test_lib.C'); |
| 82 | 82 |
| 83 methodParameterDocComment = exportedClass.fixReference( | 83 methodParameterDocComment = exportedClass.fixReference( |
| 84 'B').children.first.text; | 84 'B').children.first.text; |
| 85 expect(methodParameterDocComment, 'test_lib.B'); | 85 expect(methodParameterDocComment, 'test_lib.B'); |
| 86 | 86 |
| 87 methodParameterDocComment = exportedClass.fixReference( | 87 methodParameterDocComment = exportedClass.fixReference( |
| 88 'testFunc').children.first.text; | 88 'testFunc').children.first.text; |
| 89 expect(methodParameterDocComment, 'test_lib.testFunc'); | 89 expect(methodParameterDocComment, 'test_lib.testFunc'); |
| 90 | 90 |
| 91 }); | 91 }); |
| 92 }); | 92 }); |
| 93 }); | 93 }); |
| 94 } | 94 } |
| OLD | NEW |