| OLD | NEW |
| (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 '''; |
| OLD | NEW |