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

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

Issue 172743003: pkg/docgen: basic test of json output (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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/pubspec.yaml ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 import 'dart:convert';
2 import 'dart:io';
3 import 'package:path/path.dart' as p;
4 import 'package:scheduled_test/descriptor.dart' as d;
5 import 'package:scheduled_test/scheduled_test.dart';
6
7 import '../lib/docgen.dart' as dg;
8
9 void main() {
10
11 setUp(() {
12 var tempDir;
13 schedule(() {
14 return Directory.systemTemp
15 .createTemp('_docgen_test-')
16 .then((dir) {
17 tempDir = dir;
18 d.defaultRoot = tempDir.path;
19
20 print(tempDir.path);
21 });
22 });
23
24 currentSchedule.onComplete.schedule(() {
25 d.defaultRoot = null;
26 return tempDir.delete(recursive: true);
27 });
28 });
29
30 test('json output', () {
31 print(d.defaultRoot);
32
33 d.dir('lib', [
34 d.file('temp.dart', DART_LIBRARY_1),
35 d.file('temp2.dart', DART_LIBRARY_2),
36 d.file('temp3.dart', DART_LIBRARY_3),
37 ]).create();
38
39 schedule(() {
40 return dg.docgen([d.defaultRoot], out: p.join(d.defaultRoot, 'docs'));
41 });
42
43 d.dir('docs', [
44 d.matcherFile('index.json', _isJsonMap),
45 d.matcherFile('index.txt', isNotNull),
46 d.matcherFile('library_list.json', _isJsonMap),
47 d.matcherFile('testLib-bar.C.json', _isJsonMap),
48 d.matcherFile('testLib-bar.json', _isJsonMap),
49 d.matcherFile('testLib.A.json', _isJsonMap),
50 d.matcherFile('testLib.B.json', _isJsonMap),
51 d.matcherFile('testLib.C.json', _isJsonMap),
52 d.matcherFile('testLib.json', _isJsonMap),
53 d.matcherFile('testLib2-foo.B.json', _isJsonMap),
54 d.matcherFile('testLib2-foo.json', _isJsonMap)
55 ]).validate();
56
57 });
58 }
59
60 final Matcher _isJsonMap = predicate((input) {
61 try {
62 return JSON.decode(input) is Map;
63 } catch (e) {
64 return false;
65 }
66 }, 'Output is JSON encoded Map');
67
68 const String DART_LIBRARY_1 = '''
Alan Knight 2014/02/19 18:50:49 Is there a reason to have these as strings in the
69 library testLib;
70 import 'temp2.dart';
71 import 'temp3.dart';
72 export 'temp2.dart';
73 export 'temp3.dart';
74
75 /**
76 * Doc comment for class [A].
77 *
78 * Multiline Test
79 */
80 /*
81 * Normal comment for class A.
82 */
83 class A {
84
85 int _someNumber;
86
87 A() {
88 _someNumber = 12;
89 }
90
91 A.customConstructor();
92
93 /**
94 * Test for linking to parameter [A]
95 */
96 void doThis(int A) {
97 print(A);
98 }
99 }
100 ''';
101
102 const String DART_LIBRARY_2 = '''
103 library testLib2.foo;
104 import 'temp.dart';
105
106 /**
107 * Doc comment for class [B].
108 *
109 * Multiline Test
110 */
111
112 /*
113 * Normal comment for class B.
114 */
115 class B extends A {
116
117 B();
118 B.fooBar();
119
120 /**
121 * Test for linking to super
122 */
123 int doElse(int b) {
124 print(b);
125 }
126
127 /**
128 * Test for linking to parameter [c]
129 */
130 void doThis(int c) {
131 print(a);
132 }
133 }
134
135 int testFunc(int a) {
136 }
137 ''';
138
139 const String DART_LIBRARY_3 = '''
140 library testLib.bar;
141 import 'temp.dart';
142
143 /*
144 * Normal comment for class C.
145 */
146 class C {
147 }
148 ''';
OLDNEW
« no previous file with comments | « pkg/docgen/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698