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

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

Issue 235883016: pkg/docgen: support better const rendering of String, List, and empty Map (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: nits Created 6 years, 8 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/src/models.dart ('k') | pkg/docgen/test/multi_library_code/lib/test_lib.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 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library docgen.test.typedef; 5 library docgen.test.typedef;
6 6
7 import 'dart:convert'; 7 import 'dart:convert';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:path/path.dart' as p; 10 import 'package:path/path.dart' as p;
11 import 'package:scheduled_test/descriptor.dart' as d; 11 import 'package:scheduled_test/descriptor.dart' as d;
12 import 'package:scheduled_test/scheduled_test.dart'; 12 import 'package:scheduled_test/scheduled_test.dart';
13 13
14 import 'util.dart'; 14 import 'util.dart';
15 import '../lib/docgen.dart' as dg; 15 import '../lib/docgen.dart' as dg;
16 16
17 void main() { 17 void main() {
18 18
19 setUp(() { 19 setUp(() {
20 scheduleTempDir(); 20 scheduleTempDir();
21 }); 21 });
22 22
23 test('typedef gen', () { 23 test('argument default values', () {
24 schedule(() { 24 schedule(() {
25 var codeDir = getMultiLibraryCodePath(); 25 var codeDir = getMultiLibraryCodePath();
26 expect(FileSystemEntity.isDirectorySync(codeDir), isTrue); 26 expect(FileSystemEntity.isDirectorySync(codeDir), isTrue);
27 return dg.docgen([codeDir], out: p.join(d.defaultRoot, 'docs')); 27 return dg.docgen([codeDir], out: p.join(d.defaultRoot, 'docs'));
28 }); 28 });
29 29
30 schedule(() { 30 schedule(() {
31 var path = p.join(d.defaultRoot, 'docs', 'test_lib-bar.json'); 31 var path = p.join(d.defaultRoot, 'docs', 'test_lib.json');
32 var dartCoreJson = new File(path).readAsStringSync(); 32 var dartCoreJson = new File(path).readAsStringSync();
33 33
34 var testLibBar = JSON.decode(dartCoreJson) as Map<String, dynamic>; 34 var testLibBar = JSON.decode(dartCoreJson) as Map<String, dynamic>;
35 35
36 // 36 //
37 // Validate function doc references 37 // Validate function doc references
38 // 38 //
39 var generateFoo = testLibBar['functions']['methods']['generateFoo'] 39 var functionDef =
40 testLibBar['functions']['methods']['positionalDefaultValues']
40 as Map<String, dynamic>; 41 as Map<String, dynamic>;
41 42
42 expect(generateFoo['comment'], '<p><a>test_lib-bar.generateFoo.input</a> ' 43 var params = functionDef['parameters'] as Map<String, dynamic>;
43 'is of type <a>test_lib-bar.C</a> returns an <a>test_lib.A</a>.</p>');
44 44
45 var classes = testLibBar['classes'] as Map<String, dynamic>; 45 var vals = {};
46 46 params.forEach((paramName, paramHash) {
47 expect(classes, hasLength(3)); 47 expect(_PARAM_VALUES, contains(paramName));
48 48 expect(paramHash['value'], _PARAM_VALUES[paramName],
49 expect(classes['class'], isList); 49 reason: 'Value for $paramName should match expected');
50 expect(classes['error'], isList); 50 });
51
52 var typeDefs = classes['typedef'] as Map<String, dynamic>;
53 var comparator = typeDefs['AnATransformer'] as Map<String, dynamic>;
54
55 var expectedPreview = '<p>Processes a [C] instance for testing.</p>';
56
57 expect(comparator['preview'], expectedPreview);
58
59 var expectedComment = expectedPreview + '\n'
60 '<p>To eliminate import warnings for [A] and to test typedefs.</p>';
61
62 expect(comparator['comment'], expectedComment);
63 }); 51 });
64 }); 52 });
65 } 53 }
54
55 final _PARAM_VALUES = {
56 "boolConst": "true",
57 "intConst": "42",
58 "listConst": '[true, 42, "Shanna", null, 3.14, []]',
59 "mapConst": startsWith("Map"),
60 "emptyMap": '{}',
61 "stringConst": "\"Shanna\""
62 };
OLDNEW
« no previous file with comments | « pkg/docgen/lib/src/models.dart ('k') | pkg/docgen/test/multi_library_code/lib/test_lib.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698