Chromium Code Reviews| 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; | |
|
Emily Fortuna
2014/04/16 22:13:40
I hate single letter names for these, but since it
kevmoo
2014/04/17 00:01:19
'p' is a pretty common convention, at least for Bo
| |
| 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'] as Map<S tring, | |
|
Emily Fortuna
2014/04/16 22:13:40
80 char
kevmoo
2014/04/17 00:01:19
Done.
| |
| 41 dynamic>; | |
| 42 | |
| 43 var params = functionDef['parameters'] as Map<String, dynamic>; | |
| 44 | |
| 45 var vals = {}; | |
| 46 params.forEach((paramName, paramHash) { | |
| 47 expect(_PARAM_VALUES, contains(paramName)); | |
| 48 expect(paramHash['value'], _PARAM_VALUES[paramName], | |
| 49 reason: 'Value for $paramName should match expected'); | |
| 50 }); | |
| 51 }); | |
| 52 }); | |
| 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 }; | |
| OLD | NEW |