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