Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: pkg/docgen/test/single_library_test.dart

Issue 138623002: Enable re-export in docgen. Work in progress. More to come. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/docgen/test/multi_library_test.dart ('k') | pkg/observe/lib/observe.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 9
10 const String DART_LIBRARY = ''' 10 const String DART_LIBRARY = '''
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 group('Generate docs for', () { 43 group('Generate docs for', () {
44 test('one simple file.', () { 44 test('one simple file.', () {
45 var temporaryDir = Directory.systemTemp.createTempSync('single_library_'); 45 var temporaryDir = Directory.systemTemp.createTempSync('single_library_');
46 var fileName = path.join(temporaryDir.path, 'temp.dart'); 46 var fileName = path.join(temporaryDir.path, 'temp.dart');
47 var file = new File(fileName); 47 var file = new File(fileName);
48 file.writeAsStringSync(DART_LIBRARY); 48 file.writeAsStringSync(DART_LIBRARY);
49 getMirrorSystem([new Uri.file(fileName)]) 49 getMirrorSystem([new Uri.file(fileName)])
50 .then(expectAsync1((mirrorSystem) { 50 .then(expectAsync1((mirrorSystem) {
51 var testLibraryUri = new Uri(scheme: 'file', 51 var testLibraryUri = new Uri(scheme: 'file',
52 path: path.absolute(fileName)); 52 path: path.absolute(fileName));
53 var library = generateLibrary(mirrorSystem.libraries[testLibraryUri]); 53 var library = new Library(mirrorSystem.libraries[testLibraryUri]);
54 expect(library is Library, isTrue); 54 expect(library is Library, isTrue);
55 55
56 var classTypes = library.classes; 56 var classTypes = library.classes;
57 expect(classTypes is ClassGroup, isTrue);
58
59 var classes = []; 57 var classes = [];
60 classes.addAll(classTypes.classes.values); 58 classes.addAll(classTypes.values);
61 classes.addAll(classTypes.errors.values); 59 classes.addAll(library.errors.values);
62 expect(classes.every((e) => e is Class), isTrue); 60 expect(classes.every((e) => e is Class), isTrue);
63 61
64 expect(classTypes.typedefs.values.every((e) => e is Typedef), isTrue); 62 expect(library.typedefs.values.every((e) => e is Typedef), isTrue);
65 63
66 var classMethodTypes = []; 64 var classMethodTypes = [];
67 classes.forEach((e) { 65 classes.forEach((e) {
68 classMethodTypes.add(e.methods); 66 classMethodTypes.add(e.methods);
69 classMethodTypes.add(e.inheritedMethods); 67 classMethodTypes.add(e.inheritedMethods);
70 }); 68 });
71 expect(classMethodTypes.every((e) => e is MethodGroup), isTrue); 69 expect(classMethodTypes.every((e) => e is Map<String, Method>), isTrue );
72 70
73 var classMethods = []; 71 var classMethods = [];
74 classMethodTypes.forEach((e) { 72 classMethodTypes.forEach((e) {
75 classMethods.addAll(e.setters.values); 73 classMethods.addAll(e.values);
76 classMethods.addAll(e.getters.values);
77 classMethods.addAll(e.constructors.values);
78 classMethods.addAll(e.operators.values);
79 classMethods.addAll(e.regularMethods.values);
80 }); 74 });
81 expect(classMethods.every((e) => e is Method), isTrue); 75 expect(classMethods.every((e) => e is Method), isTrue);
82 76
83 var methodParameters = []; 77 var methodParameters = [];
84 classMethods.forEach((e) { 78 classMethods.forEach((e) {
85 methodParameters.addAll(e.parameters.values); 79 methodParameters.addAll(e.parameters.values);
86 }); 80 });
87 expect(methodParameters.every((e) => e is Parameter), isTrue); 81 expect(methodParameters.every((e) => e is Parameter), isTrue);
88 82
89 var functionTypes = library.functions; 83 var functionTypes = library.functions;
90 expect(functionTypes is MethodGroup, isTrue); 84 expect(functionTypes is Map<String, Method>, isTrue);
91 85
92 var functions = []; 86 var functions = [];
93 functions.addAll(functionTypes.setters.values); 87 functions.addAll(functionTypes.values);
94 functions.addAll(functionTypes.getters.values);
95 functions.addAll(functionTypes.constructors.values);
96 functions.addAll(functionTypes.operators.values);
97 functions.addAll(functionTypes.regularMethods.values);
98 expect(functions.every((e) => e is Method), isTrue); 88 expect(functions.every((e) => e is Method), isTrue);
99 89
100 var functionParameters = []; 90 var functionParameters = [];
101 functions.forEach((e) { 91 functions.forEach((e) {
102 functionParameters.addAll(e.parameters.values); 92 functionParameters.addAll(e.parameters.values);
103 }); 93 });
104 expect(functionParameters.every((e) => e is Parameter), isTrue); 94 expect(functionParameters.every((e) => e is Parameter), isTrue);
105 95
106 var variables = library.variables.values; 96 var variables = library.variables.values;
107 expect(variables.every((e) => e is Variable), isTrue); 97 expect(variables.every((e) => e is Variable), isTrue);
108 98
109 /// Testing fixReference 99 /// Testing fixReference
110 // Testing Doc comment for class [A]. 100 // Testing Doc comment for class [A].
111 var libraryMirror = mirrorSystem.libraries[testLibraryUri]; 101 var libraryMirror = mirrorSystem.libraries[testLibraryUri];
112 var classMirror = libraryMirror.classes.values.first; 102 var classMirror = libraryMirror.classes.values.first;
113 var classDocComment = fixReference('A', libraryMirror, 103 var classDocComment = library.fixReference('A').children.first.text;
114 classMirror, null).children.first.text; 104 expect(classDocComment, 'test.A');
115 expect(classDocComment == 'test.A', isTrue);
116 105
117 // Test for linking to parameter [A] 106 // Test for linking to parameter [A]
118 var methodMirror = classMirror.methods['doThis']; 107 var method = getDocgenObject(classMirror.methods['doThis']);
119 var methodParameterDocComment = fixReference('A', libraryMirror, 108 var methodParameterDocComment = method.fixReference(
120 classMirror, methodMirror).children.first.text; 109 'A').children.first.text;
121 // TODO(alanknight) : We're not supporting linking to parameters yet 110 expect(methodParameterDocComment, 'test.A.doThis.A');
122 // expect(methodParameterDocComment == 'test.A.doThis#A', isTrue);
123 111
124 // Testing trying to refer to doThis function 112 // Testing trying to refer to doThis function
125 var methodDocComment = fixReference('doThis', libraryMirror, 113 var methodDocComment = method.fixReference(
126 classMirror, methodMirror).children.first.text; 114 'doThis').children.first.text;
127 expect(methodDocComment == 'test.A.doThis', isTrue); 115 expect(methodDocComment, 'test.A.doThis');
128 116
129 // Testing something with no reference 117 // Testing something with no reference
130 var libraryDocComment = fixReference('foobar', libraryMirror, 118 var libraryDocComment = method.fixReference('foobar').text;
131 classMirror, methodMirror).text; 119 expect(libraryDocComment, 'foobar');
132 expect(libraryDocComment == 'foobar', isTrue);
133 })).whenComplete(() => temporaryDir.deleteSync(recursive: true)); 120 })).whenComplete(() => temporaryDir.deleteSync(recursive: true));
134 }); 121 });
135 }); 122 });
136 } 123 }
OLDNEW
« no previous file with comments | « pkg/docgen/test/multi_library_test.dart ('k') | pkg/observe/lib/observe.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698