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

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

Issue 20017003: single library test (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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/lib/docgen.dart ('k') | pkg/pkg.status » ('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: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 fileName = path.join(temporaryDir.path, 'temp.dart');
15 // sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dart. 15 var file = new File(fileName);
16 // Example of the test is in file mirrors_lookup_test.dart
17 var file = new File('test.dart');
18 file.writeAsStringSync(''' 16 file.writeAsStringSync('''
19 library test; 17 library test;
20 /** 18 /**
21 * Doc comment for class [A]. 19 * Doc comment for class [A].
22 * 20 *
23 * Multiline Test 21 * Multiline Test
24 */ 22 */
25 /* 23 /*
26 * Normal comment for class A. 24 * Normal comment for class A.
27 */ 25 */
(...skipping 12 matching lines...) Expand all
40 print(A); 38 print(A);
41 } 39 }
42 } 40 }
43 41
44 main() { 42 main() {
45 A a = new A(); 43 A a = new A();
46 a.doThis(5); 44 a.doThis(5);
47 } 45 }
48 '''); 46 ''');
49 47
50 getMirrorSystem(['test.dart'],'', parseSdk: false) 48 getMirrorSystem([fileName])
51 .then(expectAsync1((mirrorSystem) { 49 .then(expectAsync1((mirrorSystem) {
52 var testLibraryUri = currentDirectory.resolve('test.dart'); 50 var testLibraryUri = new Uri(scheme: 'file',
51 path: path.absolute(fileName));
53 var library = generateLibrary(mirrorSystem.libraries[testLibraryUri], 52 var library = generateLibrary(mirrorSystem.libraries[testLibraryUri],
54 includePrivate: true); 53 includePrivate: false);
55 expect(library is Library, isTrue); 54 expect(library is Library, isTrue);
56 55
57 var classTypes = library.classes.values; 56 var classTypes = library.classes.values;
58 expect(classTypes.every((e) => e is Map), isTrue); 57 expect(classTypes.every((e) => e is Map), isTrue);
59 58
60 var classes = []; 59 var classes = [];
61 classTypes.forEach((e) => classes.addAll(e.values)); 60 classTypes.forEach((e) => classes.addAll(e.values));
62 expect(classes.every((e) => e is Class), isTrue); 61 expect(classes.every((e) => e is Class), isTrue);
63 62
64 var classMethodTypes = []; 63 var classMethodTypes = [];
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // Testing trying to refer to doThis function 107 // Testing trying to refer to doThis function
109 var methodDocComment = fixReference('doThis', libraryMirror, 108 var methodDocComment = fixReference('doThis', libraryMirror,
110 classMirror, methodMirror).children.first.text; 109 classMirror, methodMirror).children.first.text;
111 expect(methodDocComment == 'test.A.doThis', isTrue); 110 expect(methodDocComment == 'test.A.doThis', isTrue);
112 111
113 // Testing something with no reference 112 // Testing something with no reference
114 var libraryDocComment = fixReference('foobar', libraryMirror, 113 var libraryDocComment = fixReference('foobar', libraryMirror,
115 classMirror, methodMirror).children.first.text; 114 classMirror, methodMirror).children.first.text;
116 expect(libraryDocComment == 'foobar', isTrue); 115 expect(libraryDocComment == 'foobar', isTrue);
117 116
118 file.deleteSync(); 117 temporaryDir.deleteSync(recursive: true);
119 })); 118 }));
120 }); 119 });
121 }); 120 });
122 } 121 }
OLDNEW
« no previous file with comments | « pkg/docgen/lib/docgen.dart ('k') | pkg/pkg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698