| OLD | NEW | 
|    1 library single_library_test; |    1 library single_library_test; | 
|    2  |    2  | 
|    3 import 'dart:io'; |    3 import 'dart:io'; | 
|    4  |    4  | 
|    5 import 'package:path/path.dart' as path; |    5 import 'package:path/path.dart' as path; | 
|    6 import 'package:unittest/unittest.dart'; |    6 import 'package:unittest/unittest.dart'; | 
|    7  |    7  | 
|    8 import '../lib/docgen.dart'; |    8 import '../lib/docgen.dart'; | 
 |    9 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.
     dart' | 
 |   10     as dart2js_util; | 
|    9  |   11  | 
|   10 const String DART_LIBRARY_1 = ''' |   12 const String DART_LIBRARY_1 = ''' | 
|   11   library testLib; |   13   library testLib; | 
|   12   import 'temp2.dart'; |   14   import 'temp2.dart'; | 
|   13   import 'temp3.dart'; |   15   import 'temp3.dart'; | 
|   14   export 'temp2.dart'; |   16   export 'temp2.dart'; | 
|   15   export 'temp3.dart'; |   17   export 'temp3.dart'; | 
|   16  |   18  | 
|   17   /** |   19   /** | 
|   18    * Doc comment for class [A]. |   20    * Doc comment for class [A]. | 
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   97   var file = new File(fileName); |   99   var file = new File(fileName); | 
|   98   file.writeAsStringSync(DART_LIBRARY_1); |  100   file.writeAsStringSync(DART_LIBRARY_1); | 
|   99  |  101  | 
|  100   var fileName2 = path.join(TEMP_DIRNAME.path, 'temp2.dart'); |  102   var fileName2 = path.join(TEMP_DIRNAME.path, 'temp2.dart'); | 
|  101   file = new File(fileName2); |  103   file = new File(fileName2); | 
|  102   file.writeAsStringSync(DART_LIBRARY_2); |  104   file.writeAsStringSync(DART_LIBRARY_2); | 
|  103  |  105  | 
|  104   var fileName3 = path.join(TEMP_DIRNAME.path, 'temp3.dart'); |  106   var fileName3 = path.join(TEMP_DIRNAME.path, 'temp3.dart'); | 
|  105   file = new File(fileName3); |  107   file = new File(fileName3); | 
|  106   file.writeAsStringSync(DART_LIBRARY_3); |  108   file.writeAsStringSync(DART_LIBRARY_3); | 
|  107   return [new Uri.file(fileName), new Uri.file(fileName3), |  109   return [new Uri.file(fileName, windows: Platform.isWindows), | 
|  108       new Uri.file(fileName3)]; |  110           new Uri.file(fileName2, windows: Platform.isWindows), | 
 |  111           new Uri.file(fileName3, windows: Platform.isWindows)]; | 
|  109 } |  112 } | 
|  110  |  113  | 
|  111 main() { |  114 main() { | 
|  112   group('Generate docs for', () { |  115   group('Generate docs for', () { | 
|  113     test('multiple libraries.', () { |  116     test('multiple libraries.', () { | 
|  114       var files = writeLibFiles(); |  117       var files = writeLibFiles(); | 
|  115       getMirrorSystem(files) |  118       getMirrorSystem(files) | 
|  116         .then(expectAsync1((mirrorSystem) { |  119         .then(expectAsync1((mirrorSystem) { | 
|  117           var testLibraryUri = files[0]; |  120           var testLibraryUri = files[0]; | 
|  118           var library = new Library(mirrorSystem.libraries[testLibraryUri]); |  121           var library = new Library(mirrorSystem.libraries[testLibraryUri]); | 
|  119  |  122  | 
|  120           /// Testing fixReference |  123           /// Testing fixReference | 
|  121           // Testing Doc comment for class [B]. |  124           // Testing Doc comment for class [B]. | 
|  122           var libraryMirror = mirrorSystem.libraries[testLibraryUri]; |  125           var libraryMirror = mirrorSystem.libraries[testLibraryUri]; | 
|  123           var classDocComment = library.fixReference('B').children.first.text; |  126           var classDocComment = library.fixReference('B').children.first.text; | 
|  124           expect(classDocComment, 'testLib.B'); |  127           expect(classDocComment, 'testLib.B'); | 
|  125  |  128  | 
|  126           // Test for linking to parameter [c] |  129           // Test for linking to parameter [c] | 
|  127           var importedLib = libraryMirror.libraryDependencies.firstWhere( |  130           var importedLib = libraryMirror.libraryDependencies.firstWhere( | 
|  128             (dep) => dep.isImport).targetLibrary; |  131             (dep) => dep.isImport).targetLibrary; | 
|  129           var aClassMirror = importedLib.classes.values.first; |  132           var aClassMirror = | 
|  130           expect(aClassMirror.qualifiedName, 'testLib2.foo.B'); |  133               dart2js_util.classesOf(importedLib.declarations).first; | 
 |  134           expect(dart2js_util.qualifiedNameOf(aClassMirror), | 
 |  135                  'testLib2.foo.B'); | 
|  131           var exportedClass = getDocgenObject(aClassMirror, library); |  136           var exportedClass = getDocgenObject(aClassMirror, library); | 
|  132           expect(exportedClass is Class, isTrue); |  137           expect(exportedClass is Class, isTrue); | 
|  133  |  138  | 
|  134  |  139  | 
|  135           var method = exportedClass.methods['doThis']; |  140           var method = exportedClass.methods['doThis']; | 
|  136           expect(method is Method, isTrue); |  141           expect(method is Method, isTrue); | 
|  137           var methodParameterDocComment = method.fixReference( |  142           var methodParameterDocComment = method.fixReference( | 
|  138               'c').children.first.text; |  143               'c').children.first.text; | 
|  139           expect(methodParameterDocComment, 'testLib.B.doThis.c'); |  144           expect(methodParameterDocComment, 'testLib.B.doThis.c'); | 
|  140  |  145  | 
|  141  |  146  | 
|  142           expect(method.fixReference('A').children.first.text, 'testLib.A'); |  147           expect(method.fixReference('A').children.first.text, 'testLib.A'); | 
|  143           // Testing trying to refer to doThis function |  148           // Testing trying to refer to doThis function | 
|  144           expect(method.fixReference('doThis').children.first.text, |  149           expect(method.fixReference('doThis').children.first.text, | 
|  145               'testLib.B.doThis'); |  150               'testLib.B.doThis'); | 
|  146  |  151  | 
|  147           // Testing trying to refer to doThis function |  152           // Testing trying to refer to doThis function | 
|  148           expect(method.fixReference('doElse').children.first.text, |  153           expect(method.fixReference('doElse').children.first.text, | 
|  149               'testLib.B.doElse'); |  154               'testLib.B.doElse'); | 
|  150  |  155  | 
|  151  |  156  | 
|  152           // Test a third library referencing another exported library in a |  157           // Test a third library referencing another exported library in a | 
|  153           // separate file. |  158           // separate file. | 
|  154           importedLib = libraryMirror.libraryDependencies.firstWhere( |  159           importedLib = libraryMirror.libraryDependencies.firstWhere( | 
|  155             (dep) => dep.isImport && dep.targetLibrary.qualifiedName == |  160             (dep) => dep.isImport && | 
 |  161                      dart2js_util.qualifiedNameOf(dep.targetLibrary) == | 
|  156             'testLib.bar').targetLibrary; |  162             'testLib.bar').targetLibrary; | 
|  157           aClassMirror = importedLib.classes.values.first; |  163           aClassMirror = dart2js_util.classesOf(importedLib.declarations).first; | 
|  158           expect(aClassMirror.qualifiedName, 'testLib.bar.C'); |  164           expect(dart2js_util.qualifiedNameOf(aClassMirror), | 
 |  165                  'testLib.bar.C'); | 
|  159           exportedClass = getDocgenObject(aClassMirror, library); |  166           exportedClass = getDocgenObject(aClassMirror, library); | 
|  160           expect(exportedClass is Class, isTrue); |  167           expect(exportedClass is Class, isTrue); | 
|  161           expect(exportedClass.docName, 'testLib.C'); |  168           expect(exportedClass.docName, 'testLib.C'); | 
|  162  |  169  | 
|  163           methodParameterDocComment = exportedClass.fixReference( |  170           methodParameterDocComment = exportedClass.fixReference( | 
|  164               'B').children.first.text; |  171               'B').children.first.text; | 
|  165           expect(methodParameterDocComment, 'testLib.B'); |  172           expect(methodParameterDocComment, 'testLib.B'); | 
|  166  |  173  | 
|  167           methodParameterDocComment = exportedClass.fixReference( |  174           methodParameterDocComment = exportedClass.fixReference( | 
|  168               'testFunc').children.first.text; |  175               'testFunc').children.first.text; | 
|  169           expect(methodParameterDocComment, 'testLib.testFunc'); |  176           expect(methodParameterDocComment, 'testLib.testFunc'); | 
|  170  |  177  | 
|  171         })).whenComplete(() => TEMP_DIRNAME.deleteSync(recursive: true)); |  178         })).whenComplete(() => TEMP_DIRNAME.deleteSync(recursive: true)); | 
|  172     }); |  179     }); | 
|  173   }); |  180   }); | 
|  174 } |  181 } | 
| OLD | NEW |