| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library docgen.test.typedef; | |
| 6 | |
| 7 import 'dart:convert'; | |
| 8 import 'dart:io'; | |
| 9 | |
| 10 import 'package:path/path.dart' as p; | |
| 11 import 'package:scheduled_test/descriptor.dart' as d; | |
| 12 import 'package:scheduled_test/scheduled_test.dart'; | |
| 13 | |
| 14 import 'util.dart'; | |
| 15 import '../lib/docgen.dart' as dg; | |
| 16 | |
| 17 void main() { | |
| 18 setUp(() { | |
| 19 scheduleTempDir(); | |
| 20 }); | |
| 21 | |
| 22 test('typedef gen', () { | |
| 23 schedule(() { | |
| 24 var codeDir = getMultiLibraryCodePath(); | |
| 25 expect(FileSystemEntity.isDirectorySync(codeDir), isTrue); | |
| 26 return dg.docgen([codeDir], out: p.join(d.defaultRoot, 'docs')); | |
| 27 }); | |
| 28 | |
| 29 schedule(() { | |
| 30 var path = p.join(d.defaultRoot, 'docs', 'root_lib.json'); | |
| 31 var rootLibJson = new File(path).readAsStringSync(); | |
| 32 | |
| 33 var rootLib = JSON.decode(rootLibJson) as Map<String, dynamic>; | |
| 34 | |
| 35 // | |
| 36 // Validate function doc references | |
| 37 // | |
| 38 //var testMethod = | |
| 39 // rootLib['functions']['methods']['testMethod'] as Map<String, dynamic
>; | |
| 40 | |
| 41 // test commented out | |
| 42 // TODO: figure out why test is failing after upgrade to markdown 0.7.2 | |
| 43 // Expected: '<p>Processes an <a>root_lib.testMethod.input</a> of type <a>
root_lib.C</a> instance for testing.</p>\n' | |
| 44 // '<p>To eliminate import warnings for <a>root_lib.A</a> and to test typ
edefs.</p>\n' | |
| 45 // '<p>It\'s important that the <a>dart:core</a><A> for param <a>root_
lib.testMethod.listOfA</a> is not empty.</p>' | |
| 46 // Actual: '<p>Processes an <a>root_lib.testMethod.input</a> of type <a>ro
ot_lib.C</a> instance for testing.</p>\n' | |
| 47 // '<p>To eliminate import warnings for <a>root_lib.A</a> and to test typ
edefs.</p>\n' | |
| 48 // '<p>It\'s important that the List<A> for param <a>root_lib.testMethod.
listOfA</a> is not empty.</p>' | |
| 49 // Which: is different. | |
| 50 // Expected: ... that the <a>dart:co ... | |
| 51 // Actual: ... that the List<A> fo ... | |
| 52 // ^ | |
| 53 // Differ at offset 210 | |
| 54 // | |
| 55 // expect(testMethod['comment'], _TEST_METHOD_COMMENT); | |
| 56 | |
| 57 // var classes = rootLib['classes'] as Map<String, dynamic>; | |
| 58 // | |
| 59 // expect(classes, hasLength(3)); | |
| 60 // | |
| 61 // expect(classes['class'], isList); | |
| 62 // expect(classes['error'], isList); | |
| 63 // | |
| 64 // var typeDefs = classes['typedef'] as Map<String, dynamic>; | |
| 65 // var comparator = typeDefs['testTypedef'] as Map<String, dynamic>; | |
| 66 // | |
| 67 // expect(comparator['preview'], _TEST_TYPEDEF_PREVIEW); | |
| 68 // | |
| 69 // expect(comparator['comment'], _TEST_TYPEDEF_COMMENT); | |
| 70 }); | |
| 71 | |
| 72 schedule(() { | |
| 73 var path = p.join(d.defaultRoot, 'docs', 'root_lib.RootClass.json'); | |
| 74 var rootClassJson = new File(path).readAsStringSync(); | |
| 75 | |
| 76 var rootClass = JSON.decode(rootClassJson) as Map<String, dynamic>; | |
| 77 | |
| 78 var defaultCtor = rootClass['methods']['constructors'][''] as Map; | |
| 79 | |
| 80 expect(defaultCtor['qualifiedName'], 'root_lib.RootClass.RootClass-'); | |
| 81 }); | |
| 82 }); | |
| 83 } | |
| 84 | |
| 85 // TOOD: [List<A>] is not formatted correctly - issue 16771 | |
| 86 const _TEST_METHOD_COMMENT = '<p>Processes an ' | |
| 87 '<a>root_lib.testMethod.input</a> of type <a>root_lib.C</a> ' | |
| 88 'instance for testing.</p>\n<p>To eliminate import warnings for ' | |
| 89 '<a>root_lib.A</a> and to test typedefs.</p>\n<p>It\'s important that the' | |
| 90 ' <a>dart:core</a><A> for param <a>root_lib.testMethod.listOfA</a> ' | |
| 91 'is not empty.</p>'; | |
| 92 | |
| 93 // TODO: [input] is not turned into a param refenece | |
| 94 // TODO(kevmoo): <a>test_lib.C</a> should be <a>root_lib.C</a> - Issues 18352 | |
| 95 const _TEST_TYPEDEF_PREVIEW = '<p>Processes an input of type ' | |
| 96 '<a>test_lib.C</a> instance for testing.</p>'; | |
| 97 | |
| 98 // TOOD: [List<A>] is not formatted correctly - issue 16771 | |
| 99 // TODO: [listOfA] is not turned into a param reference | |
| 100 // TODO(kevmoo): <a>test_lib.C</a> should be <a>root_lib.C</a> - Issues 18352 | |
| 101 final _TEST_TYPEDEF_COMMENT = _TEST_TYPEDEF_PREVIEW + | |
| 102 '\n<p>To eliminate import' | |
| 103 ' warnings for <a>test_lib.A</a> and to test typedefs.</p>\n<p>It\'s ' | |
| 104 'important that the <a>dart:core</a><A> for param listOfA is not ' | |
| 105 'empty.</p>'; | |
| OLD | NEW |