blob: ca735f4781e98c4faa69cfa0c537039fff092dfe [file] [log] [blame]
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library docgen.test.typedef;
import 'dart:convert';
import 'dart:io';
import 'package:path/path.dart' as p;
import 'package:scheduled_test/descriptor.dart' as d;
import 'package:scheduled_test/scheduled_test.dart';
import 'util.dart';
import '../lib/docgen.dart' as dg;
void main() {
setUp(() {
scheduleTempDir();
});
test('argument default values', () {
schedule(() {
var codeDir = getMultiLibraryCodePath();
expect(FileSystemEntity.isDirectorySync(codeDir), isTrue);
return dg.docgen([codeDir], out: p.join(d.defaultRoot, 'docs'));
});
schedule(() {
var path = p.join(d.defaultRoot, 'docs', 'test_lib.json');
var dartCoreJson = new File(path).readAsStringSync();
var testLibBar = JSON.decode(dartCoreJson) as Map<String, dynamic>;
//
// Validate function doc references
//
var functionDef =
testLibBar['functions']['methods']['positionalDefaultValues']
as Map<String, dynamic>;
var params = functionDef['parameters'] as Map<String, dynamic>;
var vals = {};
params.forEach((paramName, paramHash) {
expect(_PARAM_VALUES, contains(paramName));
expect(paramHash['value'], _PARAM_VALUES[paramName],
reason: 'Value for $paramName should match expected');
});
});
});
}
final _PARAM_VALUES = {
"boolConst": "true",
"intConst": "42",
"listConst": '[true, 42, "Shanna", null, 3.14, []]',
"mapConst": startsWith("Map"),
"emptyMap": '{}',
"stringConst": "\"Shanna\""
};