| 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:unittest/unittest.dart'; | 5 import 'package:unittest/unittest.dart'; |
| 6 | 6 |
| 7 import '../lib/docgen.dart'; | 7 import '../lib/docgen.dart'; |
| 8 import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart'; | 8 import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart'; |
| 9 | 9 |
| 10 main() { | 10 main() { |
| 11 group('Generate docs for', () { | 11 group('Generate docs for', () { |
| 12 test('one simple file.', () { | 12 test('one simple file.', () { |
| 13 // TODO(janicejl): Instead of creating a new file, should use an in-memory | 13 // TODO(janicejl): Instead of creating a new file, should use an in-memory |
| 14 // file for creating the mirrorSystem. Example of the util function in | 14 // file for creating the mirrorSystem. Example of the util function in |
| 15 // sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dart. | 15 // sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dart. |
| 16 // Example of the test is in file mirrors_lookup_test.dart | 16 // Example of the test is in file mirrors_lookup_test.dart |
| 17 var file = new File('test.dart'); | 17 var file = new File('test.dart'); |
| 18 file.writeAsStringSync(''' | 18 file.writeAsStringSync(''' |
| 19 library test; | 19 library test; |
| 20 /** | 20 /** |
| 21 * Doc comment for class A. | 21 * Doc comment for class [A]. |
| 22 * | 22 * |
| 23 * Multiline Test | 23 * Multiline Test |
| 24 */ | 24 */ |
| 25 /* | 25 /* |
| 26 * Normal comment for class A. | 26 * Normal comment for class A. |
| 27 */ | 27 */ |
| 28 class A { | 28 class A { |
| 29 | 29 |
| 30 /** | |
| 31 * Markdown _test_ for **class** [A] | |
| 32 */ | |
| 33 int _someNumber; | 30 int _someNumber; |
| 34 | 31 |
| 35 A() { | 32 A() { |
| 36 _someNumber = 12; | 33 _someNumber = 12; |
| 37 } | 34 } |
| 38 | 35 |
| 39 void doThis(int a) { | 36 /** |
| 40 print(a); | 37 * Test for linking to parameter [A] |
| 38 */ |
| 39 void doThis(int A) { |
| 40 print(A); |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 | 43 |
| 44 main() { | 44 main() { |
| 45 A a = new A(); | 45 A a = new A(); |
| 46 a.doThis(5); | 46 a.doThis(5); |
| 47 } | 47 } |
| 48 '''); | 48 '''); |
| 49 | 49 |
| 50 getMirrorSystem(['test.dart'],'', parseSdk: false) | 50 getMirrorSystem(['test.dart'],'', parseSdk: false) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 72 | 72 |
| 73 var functionParameters = []; | 73 var functionParameters = []; |
| 74 functions.forEach((e) { | 74 functions.forEach((e) { |
| 75 functionParameters.addAll(e.parameters.values); | 75 functionParameters.addAll(e.parameters.values); |
| 76 }); | 76 }); |
| 77 expect(functionParameters.every((e) => e is Parameter), isTrue); | 77 expect(functionParameters.every((e) => e is Parameter), isTrue); |
| 78 | 78 |
| 79 var variables = library.variables.values; | 79 var variables = library.variables.values; |
| 80 expect(variables.every((e) => e is Variable), isTrue); | 80 expect(variables.every((e) => e is Variable), isTrue); |
| 81 | 81 |
| 82 /// Testing fixReference |
| 83 // Testing Doc comment for class [A]. |
| 84 var libraryMirror = mirrorSystem.libraries[testLibraryUri]; |
| 85 var classMirror = libraryMirror.classes.values.first; |
| 86 var classDocComment = fixReference('A', libraryMirror, |
| 87 classMirror, null).children.first.text; |
| 88 expect(classDocComment == 'test.A', isTrue); |
| 89 |
| 90 // Test for linking to parameter [A] |
| 91 var methodMirror = classMirror.methods['doThis']; |
| 92 var methodParameterDocComment = fixReference('A', libraryMirror, |
| 93 classMirror, methodMirror).children.first.text; |
| 94 expect(methodParameterDocComment == 'test.A.doThis#A', isTrue); |
| 95 |
| 96 // Testing trying to refer to doThis function |
| 97 var methodDocComment = fixReference('doThis', libraryMirror, |
| 98 classMirror, methodMirror).children.first.text; |
| 99 expect(methodDocComment == 'test.A.doThis', isTrue); |
| 100 |
| 101 // Testing something with no reference |
| 102 var libraryDocComment = fixReference('foobar', libraryMirror, |
| 103 classMirror, methodMirror).children.first.text; |
| 104 expect(libraryDocComment == 'foobar', isTrue); |
| 105 |
| 82 file.deleteSync(); | 106 file.deleteSync(); |
| 83 })); | 107 })); |
| 84 }); | 108 }); |
| 85 }); | 109 }); |
| 86 } | 110 } |
| OLD | NEW |