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

Side by Side Diff: tests/utils/src/MarkdownTest.dart

Issue 10153004: Add a basic YAML processor. Much of the language is still unimplemented. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: More code review changes. Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/utils/src/YamlTest.dart » ('j') | tools/test.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// Unit tests for markdown. 5 /// Unit tests for markdown.
6 #library('markdown_tests'); 6 #library('markdown_tests');
7 7
8 #import('../../../lib/dartdoc/markdown.dart'); 8 #import('../../../lib/dartdoc/markdown.dart');
9 9
10 // TODO(rnystrom): Better path to unittest. 10 // TODO(rnystrom): Better path to unittest.
11 #import('../../../lib/unittest/unittest.dart'); 11 #import('../../../lib/unittest/unittest.dart');
12 #import('test_utils.dart');
12 13
13 /// Most of these tests are based on observing how showdown behaves: 14 /// Most of these tests are based on observing how showdown behaves:
14 /// http://softwaremaniacs.org/playground/showdown-highlight/ 15 /// http://softwaremaniacs.org/playground/showdown-highlight/
15 void main() { 16 void main() {
16 group('Paragraphs', () { 17 group('Paragraphs', () {
17 validate('consecutive lines form a single paragraph', ''' 18 validate('consecutive lines form a single paragraph', '''
18 This is the first line. 19 This is the first line.
19 This is the second line. 20 This is the second line.
20 ''', ''' 21 ''', '''
21 <p>This is the first line. 22 <p>This is the first line.
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 print('FAIL: $description'); 758 print('FAIL: $description');
758 print(' expect: ${html.replaceAll("\n", "\n ")}'); 759 print(' expect: ${html.replaceAll("\n", "\n ")}');
759 print(' actual: ${result.replaceAll("\n", "\n ")}'); 760 print(' actual: ${result.replaceAll("\n", "\n ")}');
760 print(''); 761 print('');
761 } 762 }
762 763
763 expect(passed).isTrue(); 764 expect(passed).isTrue();
764 }); 765 });
765 } 766 }
766 767
767 /// The tests uses triple-quoted strings, which will include leading indentation
768 /// to make them look nice in code. But we don't want the markdown parser to
769 /// actually see that, so this cleans it all up.
770 ///
771 /// Note that this is very sensitive to how the literals are styled. They should
772 /// be:
773 /// '''
774 /// Text starts on own line. Lines up with subsequent lines.
775 /// Lines are indented exactly 8 characters from the left margin.
776 /// Close is on the same line.'''
777 ///
778 cleanUpLiteral(String text) {
779 var lines = text.split('\n');
780 for (var j = 0; j < lines.length; j++) {
781 if (lines[j].length > 8) {
782 lines[j] = lines[j].substring(8, lines[j].length);
783 } else {
784 lines[j] = '';
785 }
786 }
787
788 return Strings.join(lines, '\n');
789 }
790
791 /// Does a loose comparison of the two strings of HTML. Ignores differences in 768 /// Does a loose comparison of the two strings of HTML. Ignores differences in
792 /// newlines and indentation. 769 /// newlines and indentation.
793 compareOutput(String a, String b) { 770 compareOutput(String a, String b) {
794 int i = 0; 771 int i = 0;
795 int j = 0; 772 int j = 0;
796 773
797 skipIgnored(String s, int i) { 774 skipIgnored(String s, int i) {
798 // Ignore newlines. 775 // Ignore newlines.
799 while ((i < s.length) && (s[i] == '\n')) { 776 while ((i < s.length) && (s[i] == '\n')) {
800 i++; 777 i++;
(...skipping 10 matching lines...) Expand all
811 788
812 // If one string runs out of non-ignored strings, the other must too. 789 // If one string runs out of non-ignored strings, the other must too.
813 if (i == a.length) return j == b.length; 790 if (i == a.length) return j == b.length;
814 if (j == b.length) return i == a.length; 791 if (j == b.length) return i == a.length;
815 792
816 if (a[i] != b[j]) return false; 793 if (a[i] != b[j]) return false;
817 i++; 794 i++;
818 j++; 795 j++;
819 } 796 }
820 } 797 }
OLDNEW
« no previous file with comments | « no previous file | tests/utils/src/YamlTest.dart » ('j') | tools/test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698