| 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 | |
| 19 setUp(() { | |
| 20 scheduleTempDir(); | |
| 21 }); | |
| 22 | |
| 23 test('argument default values', () { | |
| 24 schedule(() { | |
| 25 var codeDir = getMultiLibraryCodePath(); | |
| 26 expect(FileSystemEntity.isDirectorySync(codeDir), isTrue); | |
| 27 return dg.docgen([codeDir], out: p.join(d.defaultRoot, 'docs')); | |
| 28 }); | |
| 29 | |
| 30 schedule(() { | |
| 31 var path = p.join(d.defaultRoot, 'docs', 'test_lib.json'); | |
| 32 var dartCoreJson = new File(path).readAsStringSync(); | |
| 33 | |
| 34 var testLibBar = JSON.decode(dartCoreJson) as Map<String, dynamic>; | |
| 35 | |
| 36 // | |
| 37 // Validate function doc references | |
| 38 // | |
| 39 var functionDef = | |
| 40 testLibBar['functions']['methods']['positionalDefaultValues'] | |
| 41 as Map<String, dynamic>; | |
| 42 | |
| 43 var params = functionDef['parameters'] as Map<String, dynamic>; | |
| 44 | |
| 45 expect(params.keys, orderedEquals(_PARAM_NAME_ORDER), | |
| 46 reason: 'parameter order must be maintained'); | |
| 47 | |
| 48 var vals = {}; | |
| 49 params.forEach((paramName, paramHash) { | |
| 50 expect(_PARAM_VALUES, contains(paramName)); | |
| 51 expect(paramHash['value'], _PARAM_VALUES[paramName], | |
| 52 reason: 'Value for $paramName should match expected'); | |
| 53 }); | |
| 54 }); | |
| 55 }); | |
| 56 } | |
| 57 | |
| 58 final _PARAM_VALUES = { | |
| 59 "intConst": "42", | |
| 60 "boolConst": "true", | |
| 61 "listConst": 'const [true, 42, "Shanna", null, 3.14, const []]', | |
| 62 "stringConst": "\"Shanna\"", | |
| 63 "mapConst": 'const {"a": 1, 2: true, "c": const [1, null, true]}', | |
| 64 "emptyMap": 'const {}', | |
| 65 "referencedConst": "INT_CONST", | |
| 66 "constructedConstant1": "const ConstClass<int>(0, true)", | |
| 67 "constructedConstant2": 'const ConstClass(1, false, str: "str")' | |
| 68 }; | |
| 69 | |
| 70 const _PARAM_NAME_ORDER = const [ | |
| 71 "intConst", | |
| 72 "boolConst", | |
| 73 "listConst", | |
| 74 "stringConst", | |
| 75 "mapConst", | |
| 76 "emptyMap", | |
| 77 "referencedConst", | |
| 78 "constructedConstant1", | |
| 79 "constructedConstant2" | |
| 80 ]; | |
| OLD | NEW |