Fix output from tool/stats_lib
diff --git a/tool/stats_lib.dart b/tool/stats_lib.dart
index 7e55671..2460dd8 100644
--- a/tool/stats_lib.dart
+++ b/tool/stats_lib.dart
@@ -1,12 +1,15 @@
+// Copyright (c) 2019, 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.
+
import 'dart:convert';
import 'dart:io';
import 'dart:mirrors';
-import 'package:path/path.dart' as p;
-
-import 'package:html/dom.dart';
+import 'package:html/dom.dart' show Element;
import 'package:html/parser.dart' show parseFragment;
import 'package:markdown/markdown.dart' show markdownToHtml, ExtensionSet;
+import 'package:path/path.dart' as p;
// Locate the "tool" directory. Use mirrors so that this works with the test
// package, which loads this suite into an isolate.
@@ -79,43 +82,41 @@
enum CompareLevel { strict, loose, fail, error }
-CompareLevel compareResult(Config config, CommonMarkTestCase expected,
+CompareLevel compareResult(Config config, CommonMarkTestCase testCase,
{bool throwOnError = false,
bool verboseFail = false,
bool verboseLooseMatch = false}) {
String output;
try {
output =
- markdownToHtml(expected.markdown, extensionSet: config.extensionSet);
+ markdownToHtml(testCase.markdown, extensionSet: config.extensionSet);
} catch (err, stackTrace) {
if (throwOnError) {
rethrow;
}
if (verboseFail) {
- _printVerboseFailure(config.baseUrl, 'ERROR', expected, expected.html,
- 'Thrown: $err\n$stackTrace');
+ _printVerboseFailure(
+ config.baseUrl, 'ERROR', testCase, 'Thrown: $err\n$stackTrace');
}
return CompareLevel.error;
}
- if (expected.html == output) {
+ if (testCase.html == output) {
return CompareLevel.strict;
}
- var expectedParsed = parseFragment(expected.html);
+ var expectedParsed = parseFragment(testCase.html);
var actual = parseFragment(output);
var looseMatch = _compareHtml(expectedParsed.children, actual.children);
if (!looseMatch && verboseFail) {
- _printVerboseFailure(config.baseUrl, 'FAIL', expected,
- expectedParsed.outerHtml, actual.outerHtml);
+ _printVerboseFailure(config.baseUrl, 'FAIL', testCase, output);
}
if (looseMatch && verboseLooseMatch) {
- _printVerboseFailure(
- config.baseUrl, 'LOOSE', expected, output, actual.outerHtml);
+ _printVerboseFailure(config.baseUrl, 'LOOSE', testCase, output);
}
return looseMatch ? CompareLevel.loose : CompareLevel.fail;
@@ -124,13 +125,13 @@
String _indent(String s) => s.splitMapJoin('\n', onNonMatch: (n) => ' $n');
void _printVerboseFailure(String baseUrl, String message,
- CommonMarkTestCase test, String expected, String actual) {
- print('$message: $baseUrl#example-${test.example} '
- '@ ${test.section}');
+ CommonMarkTestCase testCase, String actual) {
+ print('$message: $baseUrl#example-${testCase.example} '
+ '@ ${testCase.section}');
print('input:');
- print(_indent(test.markdown));
+ print(_indent(testCase.markdown));
print('expected:');
- print(_indent(expected));
+ print(_indent(testCase.html));
print('actual:');
print(_indent(actual));
print('-----------------------');