| OLD | NEW |
| (Empty) | |
| 1 library single_library_test; |
| 2 |
| 3 import 'dart:io'; |
| 4 |
| 5 import 'package:unittest/unittest.dart'; |
| 6 |
| 7 import '../lib/docgen.dart'; |
| 8 import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart'; |
| 9 |
| 10 main() { |
| 11 group('Generate docs for', () { |
| 12 test('one simple file.', () { |
| 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 |
| 15 // sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dart. |
| 16 // Example of the test is in file mirrors_lookup_test.dart |
| 17 var file = new File('test.dart'); |
| 18 file.writeAsStringSync(''' |
| 19 library test; |
| 20 /** |
| 21 * Doc comment for class A. |
| 22 * |
| 23 * Multiline Test |
| 24 */ |
| 25 /* |
| 26 * Normal comment for class A. |
| 27 */ |
| 28 class A { |
| 29 |
| 30 /** |
| 31 * Markdown _test_ for **class** [A] |
| 32 */ |
| 33 int _someNumber; |
| 34 |
| 35 A() { |
| 36 _someNumber = 12; |
| 37 } |
| 38 |
| 39 void doThis(int a) { |
| 40 print(a); |
| 41 } |
| 42 } |
| 43 |
| 44 main() { |
| 45 A a = new A(); |
| 46 a.doThis(5); |
| 47 } |
| 48 '''); |
| 49 |
| 50 getMirrorSystem(['test.dart'],'', parseSdk: false) |
| 51 .then(expectAsync1((mirrorSystem) { |
| 52 var testLibraryUri = currentDirectory.resolve('test.dart'); |
| 53 var library = generateLibrary(mirrorSystem.libraries[testLibraryUri], |
| 54 includePrivate: true); |
| 55 expect(library is Library, isTrue); |
| 56 |
| 57 var classes = library.classes.values; |
| 58 expect(classes.every((e) => e is Class), isTrue); |
| 59 |
| 60 var classMethods = []; |
| 61 classes.forEach((e) => classMethods.addAll(e.methods.values)); |
| 62 expect(classMethods.every((e) => e is Method), isTrue); |
| 63 |
| 64 var methodParameters = []; |
| 65 classMethods.forEach((e) { |
| 66 methodParameters.addAll(e.parameters.values); |
| 67 }); |
| 68 expect(methodParameters.every((e) => e is Parameter), isTrue); |
| 69 |
| 70 var functions = library.functions.values; |
| 71 expect(functions.every((e) => e is Method), isTrue); |
| 72 |
| 73 var functionParameters = []; |
| 74 functions.forEach((e) { |
| 75 functionParameters.addAll(e.parameters.values); |
| 76 }); |
| 77 expect(functionParameters.every((e) => e is Parameter), isTrue); |
| 78 |
| 79 var variables = library.variables.values; |
| 80 expect(variables.every((e) => e is Variable), isTrue); |
| 81 |
| 82 file.deleteSync(); |
| 83 })); |
| 84 }); |
| 85 }); |
| 86 } |
| OLD | NEW |