Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Unified Diff: pkg/docgen/test/constant_argument_test.dart

Issue 235883016: pkg/docgen: support better const rendering of String, List, and empty Map (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/docgen/test/constant_argument_test.dart
diff --git a/pkg/docgen/test/constant_argument_test.dart b/pkg/docgen/test/constant_argument_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..8b38a28d483ba1479ddab24177e7c77bdaedb2e6
--- /dev/null
+++ b/pkg/docgen/test/constant_argument_test.dart
@@ -0,0 +1,62 @@
+// 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;
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
+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,
Emily Fortuna 2014/04/16 22:13:40 80 char
kevmoo 2014/04/17 00:01:19 Done.
+ 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\""
+};

Powered by Google App Engine
This is Rietveld 408576698