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

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: more nits 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 });
21
22 currentSchedule.onComplete.schedule(() {
23 d.defaultRoot = null;
24 return tempDir.delete(recursive: true);
25 });
26 });
27
28 test('json output', () {
29 print(d.defaultRoot);
30
31 d.dir('lib', [
32 d.file('temp.dart', DART_LIBRARY_1),
33 d.file('temp2.dart', DART_LIBRARY_2),
34 d.file('temp3.dart', DART_LIBRARY_3),
35 ]).create();
36
37 schedule(() {
38 return dg.docgen([d.defaultRoot], out: p.join(d.defaultRoot, 'docs'));
39 });
40
41 d.dir('docs', [
42 d.matcherFile('index.json', _isJsonMap),
43 d.matcherFile('index.txt', isNotNull),
44 d.matcherFile('library_list.json', _isJsonMap),
45 d.matcherFile('testLib-bar.C.json', _isJsonMap),
46 d.matcherFile('testLib-bar.json', _isJsonMap),
47 d.matcherFile('testLib.A.json', _isJsonMap),
48 d.matcherFile('testLib.B.json', _isJsonMap),
49 d.matcherFile('testLib.C.json', _isJsonMap),
50 d.matcherFile('testLib.json', _isJsonMap),
51 d.matcherFile('testLib2-foo.B.json', _isJsonMap),
52 d.matcherFile('testLib2-foo.json', _isJsonMap)
53 ]).validate();
54 });
55 }
56
57 final Matcher _isJsonMap = predicate((input) {
58 try {
59 return JSON.decode(input) is Map;
60 } catch (e) {
61 return false;
62 }
63 }, 'Output is JSON encoded Map');
64
65 const String DART_LIBRARY_1 = '''
66 library testLib;
67 import 'temp2.dart';
68 import 'temp3.dart';
69 export 'temp2.dart';
70 export 'temp3.dart';
71
72 /**
73 * Doc comment for class [A].
74 *
75 * Multiline Test
76 */
77 /*
78 * Normal comment for class A.
79 */
80 class A {
81
82 int _someNumber;
83
84 A() {
85 _someNumber = 12;
86 }
87
88 A.customConstructor();
89
90 /**
91 * Test for linking to parameter [A]
92 */
93 void doThis(int A) {
94 print(A);
95 }
96 }
97 ''';
98
99 const String DART_LIBRARY_2 = '''
100 library testLib2.foo;
101 import 'temp.dart';
102
103 /**
104 * Doc comment for class [B].
105 *
106 * Multiline Test
107 */
108
109 /*
110 * Normal comment for class B.
111 */
112 class B extends A {
113
114 B();
115 B.fooBar();
116
117 /**
118 * Test for linking to super
119 */
120 int doElse(int b) {
121 print(b);
122 }
123
124 /**
125 * Test for linking to parameter [c]
126 */
127 void doThis(int c) {
128 print(a);
129 }
130 }
131
132 int testFunc(int a) {
133 }
134 ''';
135
136 const String DART_LIBRARY_3 = '''
137 library testLib.bar;
138 import 'temp.dart';
139
140 /*
141 * Normal comment for class C.
142 */
143 class C {
144 }
145 ''';
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