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

Unified Diff: pkg/dartdoc/test/markdown_test.dart

Issue 10909214: Move dartdoc tests into dartdoc. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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
« no previous file with comments | « pkg/dartdoc/test/dartdoc_test.dart ('k') | tests/utils/dartdoc_search_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/dartdoc/test/markdown_test.dart
diff --git a/tests/utils/markdown_test.dart b/pkg/dartdoc/test/markdown_test.dart
similarity index 95%
rename from tests/utils/markdown_test.dart
rename to pkg/dartdoc/test/markdown_test.dart
index c4600313ef6dde56e329a4fd11036aebea0265ce..0dbef795839cd899d26a9e453ed706a11ab32eae 100644
--- a/tests/utils/markdown_test.dart
+++ b/pkg/dartdoc/test/markdown_test.dart
@@ -5,12 +5,11 @@
/// Unit tests for markdown.
#library('markdown_tests');
-// TODO(rnystrom): Move this test into pkg/dartdoc/test.
-#import('../../pkg/dartdoc/lib/markdown.dart');
+// TODO(rnystrom): Use "package:" URL (#4968).
+#import('../lib/markdown.dart');
// TODO(rnystrom): Better path to unittest.
-#import('../../pkg/unittest/unittest.dart');
-#import('test_utils.dart');
+#import('../../unittest/unittest.dart');
/// Most of these tests are based on observing how showdown behaves:
/// http://softwaremaniacs.org/playground/showdown-highlight/
@@ -744,6 +743,34 @@ void main() {
});
}
+/**
+ * Removes eight spaces of leading indentation from a multiline string.
+ *
+ * Note that this is very sensitive to how the literals are styled. They should
+ * be:
+ * '''
+ * Text starts on own line. Lines up with subsequent lines.
+ * Lines are indented exactly 8 characters from the left margin.'''
+ *
+ * This does nothing if text is only a single line.
+ */
+// TODO(nweiz): Make this auto-detect the indentation level from the first
+// non-whitespace line.
+String cleanUpLiteral(String text) {
+ var lines = text.split('\n');
+ if (lines.length <= 1) return text;
+
+ for (var j = 0; j < lines.length; j++) {
+ if (lines[j].length > 8) {
+ lines[j] = lines[j].substring(8, lines[j].length);
+ } else {
+ lines[j] = '';
+ }
+ }
+
+ return Strings.join(lines, '\n');
+}
+
validate(String description, String markdown, String html) {
test(description, () {
markdown = cleanUpLiteral(markdown);
« no previous file with comments | « pkg/dartdoc/test/dartdoc_test.dart ('k') | tests/utils/dartdoc_search_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698