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

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

Issue 172873002: pkg/docgen: putting test code in file system (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 6 years, 10 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_code/lib/temp3.dart ('k') | pkg/docgen/test/util.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 p;
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 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util. dart' 9 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util. dart'
10 as dart2js_util; 10 as dart2js_util;
11 11
12 const String DART_LIBRARY_1 = ''' 12 import 'util.dart';
13 library testLib;
14 import 'temp2.dart';
15 import 'temp3.dart';
16 export 'temp2.dart';
17 export 'temp3.dart';
18
19 /**
20 * Doc comment for class [A].
21 *
22 * Multiline Test
23 */
24 /*
25 * Normal comment for class A.
26 */
27 class A {
28
29 int _someNumber;
30
31 A() {
32 _someNumber = 12;
33 }
34
35 A.customConstructor();
36
37 /**
38 * Test for linking to parameter [A]
39 */
40 void doThis(int A) {
41 print(A);
42 }
43 }
44 ''';
45
46 const String DART_LIBRARY_2 = '''
47 library testLib2.foo;
48 import 'temp.dart';
49
50 /**
51 * Doc comment for class [B].
52 *
53 * Multiline Test
54 */
55
56 /*
57 * Normal comment for class B.
58 */
59 class B extends A {
60
61 B();
62 B.fooBar();
63
64 /**
65 * Test for linking to super
66 */
67 int doElse(int b) {
68 print(b);
69 }
70
71 /**
72 * Test for linking to parameter [c]
73 */
74 void doThis(int c) {
75 print(a);
76 }
77 }
78
79 int testFunc(int a) {
80 }
81 ''';
82
83 const String DART_LIBRARY_3 = '''
84 library testLib.bar;
85 import 'temp.dart';
86
87 /*
88 * Normal comment for class C.
89 */
90 class C {
91 }
92 ''';
93
94 Directory _tempDir;
95 13
96 List<Uri> _writeLibFiles() { 14 List<Uri> _writeLibFiles() {
97 _tempDir = Directory.systemTemp.createTempSync('single_library_'); 15 var codePath = getMultiLibraryCodePath();
98 var fileName = path.join(_tempDir.path, 'temp.dart');
99 var file = new File(fileName);
100 file.writeAsStringSync(DART_LIBRARY_1);
101 16
102 var fileName2 = path.join(_tempDir.path, 'temp2.dart'); 17 codePath = p.join(codePath, 'lib');
103 file = new File(fileName2);
104 file.writeAsStringSync(DART_LIBRARY_2);
105 18
106 var fileName3 = path.join(_tempDir.path, 'temp3.dart'); 19 return new Directory(codePath).listSync()
107 file = new File(fileName3); 20 .where((fse) => fse is File)
108 file.writeAsStringSync(DART_LIBRARY_3); 21 .map((fse) => p.toUri(fse.path))
109 return [new Uri.file(fileName, windows: Platform.isWindows), 22 .toList();
110 new Uri.file(fileName2, windows: Platform.isWindows),
111 new Uri.file(fileName3, windows: Platform.isWindows)];
112 } 23 }
113 24
114 void main() { 25 void main() {
115 group('Generate docs for', () { 26 group('Generate docs for', () {
116 test('multiple libraries.', () { 27 test('multiple libraries.', () {
117 var files = _writeLibFiles(); 28 var files = _writeLibFiles();
118 return getMirrorSystem(files) 29 return getMirrorSystem(files)
119 .then((mirrorSystem) { 30 .then((mirrorSystem) {
120 var testLibraryUri = files[0]; 31 var testLibraryUri = files[0];
121 var library = new Library(mirrorSystem.libraries[testLibraryUri]); 32 var library = new Library(mirrorSystem.libraries[testLibraryUri]);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 expect(exportedClass.docName, 'testLib.C'); 79 expect(exportedClass.docName, 'testLib.C');
169 80
170 methodParameterDocComment = exportedClass.fixReference( 81 methodParameterDocComment = exportedClass.fixReference(
171 'B').children.first.text; 82 'B').children.first.text;
172 expect(methodParameterDocComment, 'testLib.B'); 83 expect(methodParameterDocComment, 'testLib.B');
173 84
174 methodParameterDocComment = exportedClass.fixReference( 85 methodParameterDocComment = exportedClass.fixReference(
175 'testFunc').children.first.text; 86 'testFunc').children.first.text;
176 expect(methodParameterDocComment, 'testLib.testFunc'); 87 expect(methodParameterDocComment, 'testLib.testFunc');
177 88
178 }).whenComplete(() => _tempDir.deleteSync(recursive: true)); 89 });
179 }); 90 });
180 }); 91 });
181 } 92 }
OLDNEW
« no previous file with comments | « pkg/docgen/test/multi_library_code/lib/temp3.dart ('k') | pkg/docgen/test/util.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698