-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regression tests from cmark and commonmark.js
There were two failing tests, related to: * Backslash in link destinations (see commonmark/commonmark-spec#493) * Tabs in ATX/Setext headers Change the implementation to match the reference implementation.
- Loading branch information
Showing
21 changed files
with
377 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
commonmark-test-util/src/main/java/org/commonmark/testutil/TestResources.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.commonmark.testutil; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import java.net.URL; | ||
import java.nio.charset.Charset; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class TestResources { | ||
|
||
public static URL getSpec() { | ||
return TestResources.class.getResource("/spec.txt"); | ||
} | ||
|
||
public static List<URL> getRegressions() { | ||
return Arrays.asList( | ||
TestResources.class.getResource("/cmark-regression.txt"), | ||
TestResources.class.getResource("/commonmark.js-regression.txt") | ||
); | ||
} | ||
|
||
public static String readAsString(URL url) { | ||
StringBuilder sb = new StringBuilder(); | ||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(), Charset.forName("UTF-8")))) { | ||
String line; | ||
while ((line = reader.readLine()) != null) { | ||
sb.append(line); | ||
sb.append("\n"); | ||
} | ||
return sb.toString(); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
These files are copied from the CommonMark repositories, namely: | ||
|
||
https://github.com/commonmark/CommonMark/blob/master/spec.txt | ||
https://github.com/commonmark/cmark/blob/master/test/regression.txt | ||
https://github.com/commonmark/commonmark.js/blob/master/test/regression.txt | ||
|
||
They are licensed as stated in those repositories. |
95 changes: 95 additions & 0 deletions
95
commonmark-test-util/src/main/resources/cmark-regression.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
### Regression tests | ||
|
||
Issue #113: EOL character weirdness on Windows | ||
(Important: first line ends with CR + CR + LF) | ||
|
||
```````````````````````````````` example | ||
line1 | ||
|
||
line2 | ||
. | ||
<p>line1</p> | ||
<p>line2</p> | ||
```````````````````````````````` | ||
|
||
Issue #114: cmark skipping first character in line | ||
(Important: the blank lines around "Repeatedly" contain a tab.) | ||
|
||
```````````````````````````````` example | ||
By taking it apart | ||
|
||
- alternative solutions | ||
→ | ||
Repeatedly solving | ||
→ | ||
- how techniques | ||
. | ||
<p>By taking it apart</p> | ||
<ul> | ||
<li>alternative solutions</li> | ||
</ul> | ||
<p>Repeatedly solving</p> | ||
<ul> | ||
<li>how techniques</li> | ||
</ul> | ||
```````````````````````````````` | ||
|
||
Issue jgm/CommonMark#430: h2..h6 not recognized as block tags. | ||
|
||
```````````````````````````````` example | ||
<h1>lorem</h1> | ||
|
||
<h2>lorem</h2> | ||
|
||
<h3>lorem</h3> | ||
|
||
<h4>lorem</h4> | ||
|
||
<h5>lorem</h5> | ||
|
||
<h6>lorem</h6> | ||
. | ||
<h1>lorem</h1> | ||
<h2>lorem</h2> | ||
<h3>lorem</h3> | ||
<h4>lorem</h4> | ||
<h5>lorem</h5> | ||
<h6>lorem</h6> | ||
```````````````````````````````` | ||
|
||
Issue jgm/commonmark.js#109 - tabs after setext header line | ||
|
||
|
||
```````````````````````````````` example | ||
hi | ||
--→ | ||
. | ||
<h2>hi</h2> | ||
```````````````````````````````` | ||
|
||
Issue #177 - incorrect emphasis parsing | ||
|
||
```````````````````````````````` example | ||
a***b* c* | ||
. | ||
<p>a*<em><em>b</em> c</em></p> | ||
```````````````````````````````` | ||
|
||
Issue #193 - unescaped left angle brackets in link destination | ||
|
||
```````````````````````````````` example | ||
[a] | ||
|
||
[a]: <te<st> | ||
. | ||
<p><a href="%3Cte%3Cst%3E">a</a></p> | ||
```````````````````````````````` | ||
|
||
Issue #192 - escaped spaces in link destination | ||
|
||
|
||
```````````````````````````````` example | ||
[a](te\ st) | ||
. | ||
<p>[a](te\ st)</p> | ||
```````````````````````````````` |
Oops, something went wrong.