Chromium Code Reviews| 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:unittest/unittest.dart'; | 6 import 'package:unittest/unittest.dart'; |
| 6 | 7 |
| 7 import '../lib/docgen.dart'; | 8 import '../lib/docgen.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 var temporaryDir = new Directory('single_library').createTempSync(); |
| 14 // file for creating the mirrorSystem. Example of the util function in | 14 var file = new File(path.join(temporaryDir.path, 'temp.dart')); |
|
Emily Fortuna
2013/07/22 23:42:35
you might create a variable called fileName rather
janicejl
2013/07/23 16:56:06
Done.
| |
| 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(''' | 15 file.writeAsStringSync(''' |
| 19 library test; | 16 library test; |
| 20 /** | 17 /** |
| 21 * Doc comment for class [A]. | 18 * Doc comment for class [A]. |
| 22 * | 19 * |
| 23 * Multiline Test | 20 * Multiline Test |
| 24 */ | 21 */ |
| 25 /* | 22 /* |
| 26 * Normal comment for class A. | 23 * Normal comment for class A. |
| 27 */ | 24 */ |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 40 print(A); | 37 print(A); |
| 41 } | 38 } |
| 42 } | 39 } |
| 43 | 40 |
| 44 main() { | 41 main() { |
| 45 A a = new A(); | 42 A a = new A(); |
| 46 a.doThis(5); | 43 a.doThis(5); |
| 47 } | 44 } |
| 48 '''); | 45 '''); |
| 49 | 46 |
| 50 getMirrorSystem(['test.dart'],'', parseSdk: false) | 47 getMirrorSystem([path.join(temporaryDir.path, 'temp.dart')]) |
| 51 .then(expectAsync1((mirrorSystem) { | 48 .then(expectAsync1((mirrorSystem) { |
| 52 var testLibraryUri = currentDirectory.resolve('test.dart'); | 49 var testLibraryUri = new Uri(scheme: 'file', |
| 50 path: path.absolute(path.join(temporaryDir.path, 'temp.dart'))); | |
| 53 var library = generateLibrary(mirrorSystem.libraries[testLibraryUri], | 51 var library = generateLibrary(mirrorSystem.libraries[testLibraryUri], |
| 54 includePrivate: true); | 52 includePrivate: false); |
| 55 expect(library is Library, isTrue); | 53 expect(library is Library, isTrue); |
| 56 | 54 |
| 57 var classTypes = library.classes.values; | 55 var classTypes = library.classes.values; |
| 58 expect(classTypes.every((e) => e is Map), isTrue); | 56 expect(classTypes.every((e) => e is Map), isTrue); |
| 59 | 57 |
| 60 var classes = []; | 58 var classes = []; |
| 61 classTypes.forEach((e) => classes.addAll(e.values)); | 59 classTypes.forEach((e) => classes.addAll(e.values)); |
| 62 expect(classes.every((e) => e is Class), isTrue); | 60 expect(classes.every((e) => e is Class), isTrue); |
| 63 | 61 |
| 64 var classMethodTypes = []; | 62 var classMethodTypes = []; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 // Testing trying to refer to doThis function | 106 // Testing trying to refer to doThis function |
| 109 var methodDocComment = fixReference('doThis', libraryMirror, | 107 var methodDocComment = fixReference('doThis', libraryMirror, |
| 110 classMirror, methodMirror).children.first.text; | 108 classMirror, methodMirror).children.first.text; |
| 111 expect(methodDocComment == 'test.A.doThis', isTrue); | 109 expect(methodDocComment == 'test.A.doThis', isTrue); |
| 112 | 110 |
| 113 // Testing something with no reference | 111 // Testing something with no reference |
| 114 var libraryDocComment = fixReference('foobar', libraryMirror, | 112 var libraryDocComment = fixReference('foobar', libraryMirror, |
| 115 classMirror, methodMirror).children.first.text; | 113 classMirror, methodMirror).children.first.text; |
| 116 expect(libraryDocComment == 'foobar', isTrue); | 114 expect(libraryDocComment == 'foobar', isTrue); |
| 117 | 115 |
| 118 file.deleteSync(); | 116 temporaryDir.deleteSync(recursive: true); |
| 119 })); | 117 })); |
| 120 }); | 118 }); |
| 121 }); | 119 }); |
| 122 } | 120 } |
| OLD | NEW |