Permalink
Browse files

add package tests, comprising tests from the MarkdownTest_1.0.3 suite

  • Loading branch information...
1 parent 982e585 commit 7799c9c82c1c1225750db08555464f0d001d7ae5 @knieriem committed May 4, 2012
Showing with 3,588 additions and 34 deletions.
  1. +1 −17 Makefile
  2. +10 −15 README.md
  3. +2 −2 misc/devel.mk
  4. +8 −0 tests/README.md
  5. +6 −0 tests/gen.rc
  6. +17 −0 tests/md1.0.3/Amps and angle encoding.html
  7. +21 −0 tests/md1.0.3/Amps and angle encoding.text
  8. +18 −0 tests/md1.0.3/Auto links.html
  9. +13 −0 tests/md1.0.3/Auto links.text
  10. +117 −0 tests/md1.0.3/Backslash escapes.html
  11. +120 −0 tests/md1.0.3/Backslash escapes.text
  12. +15 −0 tests/md1.0.3/Blockquotes with code blocks.html
  13. +11 −0 tests/md1.0.3/Blockquotes with code blocks.text
  14. +18 −0 tests/md1.0.3/Code Blocks.html
  15. +14 −0 tests/md1.0.3/Code Blocks.text
  16. +5 −0 tests/md1.0.3/Code Spans.html
  17. +6 −0 tests/md1.0.3/Code Spans.text
  18. +8 −0 tests/md1.0.3/Hard-wrapped paragraphs with list-like lines.html
  19. +8 −0 tests/md1.0.3/Hard-wrapped paragraphs with list-like lines.text
  20. +71 −0 tests/md1.0.3/Horizontal rules.html
  21. +67 −0 tests/md1.0.3/Horizontal rules.text
  22. +15 −0 tests/md1.0.3/Inline HTML (Advanced).html
  23. +15 −0 tests/md1.0.3/Inline HTML (Advanced).text
  24. +72 −0 tests/md1.0.3/Inline HTML (Simple).html
  25. +69 −0 tests/md1.0.3/Inline HTML (Simple).text
  26. +13 −0 tests/md1.0.3/Inline HTML comments.html
  27. +13 −0 tests/md1.0.3/Inline HTML comments.text
  28. +3 −0 tests/md1.0.3/Literal quotes in titles.html
  29. +7 −0 tests/md1.0.3/Literal quotes in titles.text
  30. +314 −0 tests/md1.0.3/Markdown Documentation - Basics.html
  31. +306 −0 tests/md1.0.3/Markdown Documentation - Basics.text
  32. +946 −0 tests/md1.0.3/Markdown Documentation - Syntax.html
  33. +888 −0 tests/md1.0.3/Markdown Documentation - Syntax.text
  34. +9 −0 tests/md1.0.3/Nested blockquotes.html
  35. +5 −0 tests/md1.0.3/Nested blockquotes.text
  36. +152 −0 tests/md1.0.3/Ordered and unordered lists.html
  37. +131 −0 tests/md1.0.3/Ordered and unordered lists.text
  38. +7 −0 tests/md1.0.3/Strong and em together.html
  39. +7 −0 tests/md1.0.3/Strong and em together.text
  40. +25 −0 tests/md1.0.3/Tabs.html
  41. +21 −0 tests/md1.0.3/Tabs.text
  42. +9 −0 tests/md1.0.3/Tidyness.html
  43. +5 −0 tests/md1.0.3/Tidyness.text
View
@@ -1,12 +1,5 @@
all:
- @echo 'targets: test nuke parser clean'
-
-#
-# run MarkdownTests-1.0.3 that come with original C sources
-#
-test: package cmd orig-c-src
- cd orig-c-src/MarkdownTest_1.0.3; \
- ./MarkdownTest.pl --script=../../cmd/markdown/markdown --tidy
+ @echo 'targets: nuke parser clean'
cmd: package
cd cmd/markdown && go build -v
@@ -16,7 +9,6 @@ package: parser.leg.go
clean:
go clean . ./...
- rm -rf orig-c-src
rm -rf ,,prevmd ,,pmd
parser: parser.leg.go
@@ -35,13 +27,6 @@ include $(shell go list -f '{{.Dir}}' github.com/knieriem/peg)/Make.inc
endif
-#
-# get access to original C source files
-#
-orig-c-src:
- hg clone git://github.com/jgm/peg-markdown.git $@
-
-
include misc/devel.mk
.PHONY: \
@@ -50,4 +35,3 @@ include misc/devel.mk
nuke\
package\
parser\
- test\
View
@@ -11,7 +11,7 @@ by peg-markdown.
[Go]: http://golang.org/
Support for HTML output is implemented, but Groff and LaTeX
-output have not been ported. The output should be identical
+output have not been ported. The output is identical
to that of peg-markdown.
A simple benchmark has been done by comparing the
@@ -42,21 +42,16 @@ To create the command line program *markdown,* run
the binary should then be available in the current directory.
-To run the Markdown 1.0.3 test suite, type
+To run tests, type
- make test
+ go test github.com/knieriem/markdown
-This will download peg-markdown, in case you have Mercurial
-and the hg-git extension available, build cmd/markdown, and
-run the test suite.
-
-The test suite should fail on exactly one test –
-*Ordered and unordered lists* –, for the same reason which
-applies to peg-markdown, because the grammar is the same.
-See the [original README][] for details.
-
-[original README]: https://github.com/jgm/peg-markdown/blob/master/README.markdown
+At the moment, tests are based on the .text files from the
+Markdown 1.0.3 test suite created by John Gruber, [imported from
+peg-markdown][testsuite]. The output of the conversion of these
+.text files to html is compared to the output of peg-markdown.
+[testsuite]: https://github.com/jgm/peg-markdown/tree/master/MarkdownTest_1.0.3
## Development
@@ -66,8 +61,8 @@ when building packages and commands using the Go tool. To make
*markdown* installable using `go get`, `parser.leg.go` has
been added to the VCS.
-`Make parser` will update `parser.leg.go` using `leg`, which
-is part of [knieriem/peg][] at github, if parser.leg has
+`Make parser` will update `parser.leg.go` using `leg` which
+is part of [knieriem/peg][] at github, if parser.leg has
been changed, or if the Go file is missing. If a copy of *peg*
is not yet present on your system, run
View
@@ -9,7 +9,7 @@ gofmt:
diff: ,,c
tkdiff $< parser.leg
-,,c: orig-c-src/markdown_parser.leg
+,,c: ,,pmd/markdown_parser.leg
sed -f misc/c2go.sed < $< > $@
orig-c-src/markdown_parser.leg: orig-c-src
@@ -18,7 +18,7 @@ orig-c-src/markdown_parser.leg: orig-c-src
bmprepare:
rc ./misc/bmprepare.rc
-benchmark: m ,,pmd ,,prevmd
+benchmark: cmd m ,,pmd ,,prevmd
rc ./misc/benchmark.rc
View
@@ -0,0 +1,8 @@
+This directory contains test files used by ../markdown_test.go.
+
+## INDEX
+
+* *md1.0.3*
+
+ Files from John Gruber's test suite MarkdownTest_1.0.3,
+ imported from https://github.com/jgm/peg-markdown/.
View
@@ -0,0 +1,6 @@
+pmd=../../,,pmd/markdown
+
+for (i in *.text) {
+ stem=`{echo $i | sed 's,.text$,,'}
+ $pmd < $i >$"stem.html
+}
@@ -0,0 +1,17 @@
+<p>AT&amp;T has an ampersand in their name.</p>
+
+<p>AT&amp;T is another way to write it.</p>
+
+<p>This &amp; that.</p>
+
+<p>4 &lt; 5.</p>
+
+<p>6 &gt; 5.</p>
+
+<p>Here's a <a href="http://example.com/?foo=1&amp;bar=2">link</a> with an ampersand in the URL.</p>
+
+<p>Here's a link with an amersand in the link text: <a href="http://att.com/" title="AT&amp;T">AT&amp;T</a>.</p>
+
+<p>Here's an inline <a href="/script?foo=1&amp;bar=2">link</a>.</p>
+
+<p>Here's an inline <a href="/script?foo=1&amp;bar=2">link</a>.</p>
@@ -0,0 +1,21 @@
+AT&T has an ampersand in their name.
+
+AT&amp;T is another way to write it.
+
+This & that.
+
+4 < 5.
+
+6 > 5.
+
+Here's a [link] [1] with an ampersand in the URL.
+
+Here's a link with an amersand in the link text: [AT&T] [2].
+
+Here's an inline [link](/script?foo=1&bar=2).
+
+Here's an inline [link](</script?foo=1&bar=2>).
+
+
+[1]: http://example.com/?foo=1&bar=2
+[2]: http://att.com/ "AT&T"
@@ -0,0 +1,18 @@
+<p>Link: <a href="http://example.com/">http://example.com/</a>.</p>
+
+<p>With an ampersand: <a href="http://example.com/?foo=1&amp;bar=2">http://example.com/?foo=1&amp;bar=2</a></p>
+
+<ul>
+<li>In a list?</li>
+<li><a href="http://example.com/">http://example.com/</a></li>
+<li>It should.</li>
+</ul>
+
+<blockquote>
+<p>Blockquoted: <a href="http://example.com/">http://example.com/</a></p>
+</blockquote>
+
+<p>Auto-links should not occur here: <code>&lt;http://example.com/&gt;</code></p>
+
+<pre><code>or here: &lt;http://example.com/&gt;
+</code></pre>
@@ -0,0 +1,13 @@
+Link: <http://example.com/>.
+
+With an ampersand: <http://example.com/?foo=1&bar=2>
+
+* In a list?
+* <http://example.com/>
+* It should.
+
+> Blockquoted: <http://example.com/>
+
+Auto-links should not occur here: `<http://example.com/>`
+
+ or here: <http://example.com/>
@@ -0,0 +1,117 @@
+<p>These should all get escaped:</p>
+
+<p>Backslash: \</p>
+
+<p>Backtick: `</p>
+
+<p>Asterisk: *</p>
+
+<p>Underscore: _</p>
+
+<p>Left brace: {</p>
+
+<p>Right brace: }</p>
+
+<p>Left bracket: [</p>
+
+<p>Right bracket: ]</p>
+
+<p>Left paren: (</p>
+
+<p>Right paren: )</p>
+
+<p>Greater-than: &gt;</p>
+
+<p>Hash: #</p>
+
+<p>Period: .</p>
+
+<p>Bang: !</p>
+
+<p>Plus: +</p>
+
+<p>Minus: -</p>
+
+<p>These should not, because they occur within a code block:</p>
+
+<pre><code>Backslash: \\
+
+Backtick: \`
+
+Asterisk: \*
+
+Underscore: \_
+
+Left brace: \{
+
+Right brace: \}
+
+Left bracket: \[
+
+Right bracket: \]
+
+Left paren: \(
+
+Right paren: \)
+
+Greater-than: \&gt;
+
+Hash: \#
+
+Period: \.
+
+Bang: \!
+
+Plus: \+
+
+Minus: \-
+</code></pre>
+
+<p>Nor should these, which occur in code spans:</p>
+
+<p>Backslash: <code>\\</code></p>
+
+<p>Backtick: <code>\`</code></p>
+
+<p>Asterisk: <code>\*</code></p>
+
+<p>Underscore: <code>\_</code></p>
+
+<p>Left brace: <code>\{</code></p>
+
+<p>Right brace: <code>\}</code></p>
+
+<p>Left bracket: <code>\[</code></p>
+
+<p>Right bracket: <code>\]</code></p>
+
+<p>Left paren: <code>\(</code></p>
+
+<p>Right paren: <code>\)</code></p>
+
+<p>Greater-than: <code>\&gt;</code></p>
+
+<p>Hash: <code>\#</code></p>
+
+<p>Period: <code>\.</code></p>
+
+<p>Bang: <code>\!</code></p>
+
+<p>Plus: <code>\+</code></p>
+
+<p>Minus: <code>\-</code></p>
+
+<p>These should get escaped, even though they're matching pairs for
+other Markdown constructs:</p>
+
+<p>*asterisks*</p>
+
+<p>_underscores_</p>
+
+<p>`backticks`</p>
+
+<p>This is a code span with a literal backslash-backtick sequence: <code>\`</code></p>
+
+<p>This is a tag with unescaped backticks <span attr='`ticks`'>bar</span>.</p>
+
+<p>This is a tag with backslashes <span attr='\\backslashes\\'>bar</span>.</p>
Oops, something went wrong.

0 comments on commit 7799c9c

Please sign in to comment.