Validate common mark flavors in tests
diff --git a/pkgs/markdown/test/common_mark_test.dart b/pkgs/markdown/test/common_mark_test.dart new file mode 100644 index 0000000..f480037 --- /dev/null +++ b/pkgs/markdown/test/common_mark_test.dart
@@ -0,0 +1,43 @@ +// Copyright (c) 2017, 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 'package:test/test.dart'; + +import '../tool/stats_lib.dart'; + +void main() { + _registerTests(Config.commonMarkConfig); + _registerTests(Config.gfmConfig); +} + +void _registerTests(Config config) { + var tests = loadCommonMarkSections(config.prefix); + + var statsFile = getStatsFile(config.prefix); + var statsJson = JSON.decode(statsFile.readAsStringSync()) + as Map<String, Map<String, String>>; + + group(config.prefix, () { + tests.forEach((section, examples) { + group(section, () { + var sectionStats = statsJson[section]; + for (var e in examples) { + test('Example ${e.example}', () { + var expected = sectionStats[e.example.toString()]; + + expect(expected, isNotNull); + + var result = compareResult(config, e, throwOnError: true); + + // not super-pretty way to get the value section of an enum + var resultString = result.toString().split('.')[1]; + expect(resultString, expected); + }); + } + }); + }); + }); +}