| OLD | NEW |
| 1 library single_library_test; | 1 library single_library_test; |
| 2 | 2 |
| 3 import 'package:path/path.dart' as p; | 3 import 'package:path/path.dart' as p; |
| 4 import 'package:unittest/unittest.dart'; | 4 import 'package:unittest/unittest.dart'; |
| 5 | 5 |
| 6 import '../lib/docgen.dart'; | 6 import '../lib/docgen.dart'; |
| 7 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.
dart' | 7 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.
dart' |
| 8 as dart2js_util; | 8 as dart2js_util; |
| 9 | 9 |
| 10 import 'util.dart'; | 10 import 'util.dart'; |
| 11 | 11 |
| 12 List<Uri> _writeLibFiles() { | 12 List<Uri> _writeLibFiles() { |
| 13 var codePath = getMultiLibraryCodePath(); | 13 var codePath = getMultiLibraryCodePath(); |
| 14 | 14 |
| 15 codePath = p.join(codePath, 'lib'); | 15 codePath = p.join(codePath, 'lib'); |
| 16 | 16 |
| 17 return ['temp.dart', 'temp2.dart', 'temp3.dart'] | 17 return ['test_lib.dart', 'test_lib_bar.dart', 'test_lib_foo.dart'] |
| 18 .map((name) => p.join(codePath, name)) | 18 .map((name) => p.join(codePath, name)) |
| 19 .map(p.toUri) | 19 .map(p.toUri) |
| 20 .toList(); | 20 .toList(); |
| 21 } | 21 } |
| 22 | 22 |
| 23 void main() { | 23 void main() { |
| 24 group('Generate docs for', () { | 24 group('Generate docs for', () { |
| 25 test('multiple libraries.', () { | 25 test('multiple libraries.', () { |
| 26 var files = _writeLibFiles(); | 26 var files = _writeLibFiles(); |
| 27 return getMirrorSystem(files) | 27 return getMirrorSystem(files) |
| 28 .then((mirrorSystem) { | 28 .then((mirrorSystem) { |
| 29 var testLibraryUri = files[0]; | 29 var test_libraryUri = files[0]; |
| 30 var library = new Library(mirrorSystem.libraries[testLibraryUri]); | 30 var library = new Library(mirrorSystem.libraries[test_libraryUri]); |
| 31 | 31 |
| 32 /// Testing fixReference | 32 /// Testing fixReference |
| 33 // Testing Doc comment for class [B]. | 33 // Testing Doc comment for class [B]. |
| 34 var libraryMirror = mirrorSystem.libraries[testLibraryUri]; | 34 var libraryMirror = mirrorSystem.libraries[test_libraryUri]; |
| 35 var classDocComment = library.fixReference('B').children.first.text; | 35 var classDocComment = library.fixReference('B').children.first.text; |
| 36 expect(classDocComment, 'testLib.B'); | 36 expect(classDocComment, 'test_lib.B'); |
| 37 | 37 |
| 38 // Test for linking to parameter [c] | 38 // Test for linking to parameter [c] |
| 39 var importedLib = libraryMirror.libraryDependencies.firstWhere( | 39 var importedLib = libraryMirror.libraryDependencies.firstWhere( |
| 40 (dep) => dep.isImport).targetLibrary; | 40 (dep) => dep.isImport).targetLibrary; |
| 41 var aClassMirror = | 41 var aClassMirror = |
| 42 dart2js_util.classesOf(importedLib.declarations).first; | 42 dart2js_util.classesOf(importedLib.declarations).first; |
| 43 expect(dart2js_util.qualifiedNameOf(aClassMirror), | 43 expect(dart2js_util.qualifiedNameOf(aClassMirror), |
| 44 'testLib2.foo.B'); | 44 'test_lib.foo.B'); |
| 45 var exportedClass = Indexable.getDocgenObject(aClassMirror, library); | 45 var exportedClass = Indexable.getDocgenObject(aClassMirror, library); |
| 46 expect(exportedClass is Class, isTrue); | 46 expect(exportedClass is Class, isTrue); |
| 47 | 47 |
| 48 | 48 |
| 49 var method = exportedClass.methods['doThis']; | 49 var method = exportedClass.methods['doThis']; |
| 50 expect(method is Method, isTrue); | 50 expect(method is Method, isTrue); |
| 51 var methodParameterDocComment = method.fixReference( | 51 var methodParameterDocComment = method.fixReference( |
| 52 'c').children.first.text; | 52 'c').children.first.text; |
| 53 expect(methodParameterDocComment, 'testLib.B.doThis.c'); | 53 expect(methodParameterDocComment, 'test_lib.B.doThis.c'); |
| 54 | 54 |
| 55 | 55 |
| 56 expect(method.fixReference('A').children.first.text, 'testLib.A'); | 56 expect(method.fixReference('A').children.first.text, 'test_lib.A'); |
| 57 // Testing trying to refer to doThis function | 57 // Testing trying to refer to doThis function |
| 58 expect(method.fixReference('doThis').children.first.text, | 58 expect(method.fixReference('doThis').children.first.text, |
| 59 'testLib.B.doThis'); | 59 'test_lib.B.doThis'); |
| 60 | 60 |
| 61 // Testing trying to refer to doThis function | 61 // Testing trying to refer to doThis function |
| 62 expect(method.fixReference('doElse').children.first.text, | 62 expect(method.fixReference('doElse').children.first.text, |
| 63 'testLib.B.doElse'); | 63 'test_lib.B.doElse'); |
| 64 | 64 |
| 65 | 65 |
| 66 // Test a third library referencing another exported library in a | 66 // Test a third library referencing another exported library in a |
| 67 // separate file. | 67 // separate file. |
| 68 importedLib = libraryMirror.libraryDependencies.firstWhere( | 68 importedLib = libraryMirror.libraryDependencies.firstWhere( |
| 69 (dep) => dep.isImport && | 69 (dep) => dep.isImport && |
| 70 dart2js_util.qualifiedNameOf(dep.targetLibrary) == | 70 dart2js_util.qualifiedNameOf(dep.targetLibrary) == |
| 71 'testLib.bar').targetLibrary; | 71 'test_lib.bar').targetLibrary; |
| 72 aClassMirror = dart2js_util.classesOf(importedLib.declarations).first; | 72 aClassMirror = dart2js_util.classesOf(importedLib.declarations).first; |
| 73 expect(dart2js_util.qualifiedNameOf(aClassMirror), | 73 expect(dart2js_util.qualifiedNameOf(aClassMirror), |
| 74 'testLib.bar.C'); | 74 'test_lib.bar.C'); |
| 75 exportedClass = Indexable.getDocgenObject(aClassMirror, library); | 75 exportedClass = Indexable.getDocgenObject(aClassMirror, library); |
| 76 expect(exportedClass is Class, isTrue); | 76 expect(exportedClass is Class, isTrue); |
| 77 expect(exportedClass.docName, 'testLib.C'); | 77 expect(exportedClass.docName, 'test_lib.C'); |
| 78 | 78 |
| 79 methodParameterDocComment = exportedClass.fixReference( | 79 methodParameterDocComment = exportedClass.fixReference( |
| 80 'B').children.first.text; | 80 'B').children.first.text; |
| 81 expect(methodParameterDocComment, 'testLib.B'); | 81 expect(methodParameterDocComment, 'test_lib.B'); |
| 82 | 82 |
| 83 methodParameterDocComment = exportedClass.fixReference( | 83 methodParameterDocComment = exportedClass.fixReference( |
| 84 'testFunc').children.first.text; | 84 'testFunc').children.first.text; |
| 85 expect(methodParameterDocComment, 'testLib.testFunc'); | 85 expect(methodParameterDocComment, 'test_lib.testFunc'); |
| 86 | 86 |
| 87 }); | 87 }); |
| 88 }); | 88 }); |
| 89 }); | 89 }); |
| 90 } | 90 } |
| OLD | NEW |