Skip to content

Commit

Permalink
Fix tests after adding Parser.State param
Browse files Browse the repository at this point in the history
  • Loading branch information
lytefast committed Oct 21, 2020
1 parent 68e7e35 commit ebdf5da
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

public class ParserTest {

private Parser<Object, Node<Object>> parser;
private Parser<Object, Node<Object>, Object> parser;
private TreeMatcher treeMatcher;

@Before
Expand All @@ -41,13 +41,13 @@ public void tearDown() {

@Test
public void testEmptyParse() throws Exception {
final List<Node<Object>> ast = parser.parse("");
final List<Node<Object>> ast = parser.parse("", null);
Assert.assertTrue(ast.isEmpty());
}

@Test
public void testParseFormattedText() throws Exception {
final List<Node<Object>> ast = parser.parse("**bold**");
final List<Node<Object>> ast = parser.parse("**bold**", null);

final StyleNode boldNode = StyleNode.Companion.createWithText("bold", Collections.singletonList((CharacterStyle) new StyleSpan(Typeface.BOLD)));

Expand All @@ -57,7 +57,7 @@ public void testParseFormattedText() throws Exception {

@Test
public void testParseLeadingFormatting() throws Exception {
final List<Node<Object>> ast = parser.parse("**bold** and not bold");
final List<Node<Object>> ast = parser.parse("**bold** and not bold", null);

final StyleNode boldNode = StyleNode.Companion.createWithText("bold", Collections.singletonList((CharacterStyle) new StyleSpan(Typeface.BOLD)));
final TextNode trailingText = new TextNode(" and not bold");
Expand All @@ -68,7 +68,7 @@ public void testParseLeadingFormatting() throws Exception {

@Test
public void testParseTrailingFormatting() throws Exception {
final List<Node<Object>> ast = parser.parse("not bold **and bold**");
final List<Node<Object>> ast = parser.parse("not bold **and bold**", null);

final TextNode leadingText = new TextNode("not bold ");
final StyleNode boldNode = StyleNode.Companion.createWithText("and bold", Collections.singletonList((CharacterStyle) new StyleSpan(Typeface.BOLD)));
Expand All @@ -80,7 +80,7 @@ public void testParseTrailingFormatting() throws Exception {
@Test
public void testNestedFormatting() throws Exception {
// final List<Node> ast = parser.parse("*** test1 ** test2 * test3 * test4 ** test5 ***");
final List<Node<Object>> ast = parser.parse("**bold *and italics* and more bold**");
final List<Node<Object>> ast = parser.parse("**bold *and italics* and more bold**", null);
// final List<Node> ast = parser.parse("______" +
// "t"
// + "______");
Expand All @@ -97,7 +97,7 @@ public void testNestedFormatting() throws Exception {

@Test
public void testNewlineRule() {
final List<Node<Object>> ast = parser.parse("Some text\n\n\n \n\n\nnewline above");
final List<Node<Object>> ast = parser.parse("Some text\n\n\n \n\n\nnewline above", null);

final List<? extends Node> model = Arrays.asList(
new TextNode<>("Some text"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import org.junit.Test

class MarkdownRulesTest {

private lateinit var parser: Parser<Any, Node<Any>>
private lateinit var parser: Parser<Any, Node<Any>, Any?>
private lateinit var treeMatcher: TreeMatcher

@Before
Expand Down Expand Up @@ -48,7 +48,7 @@ class MarkdownRulesTest {
* item 2
End
""".trimIndent())
""".trimIndent(), Unit)

val listItemNodes = ArrayList<MarkdownListItemNode<*>>()
ASTUtils.traversePreOrder(ast) {
Expand All @@ -68,7 +68,7 @@ class MarkdownRulesTest {
List of stuff
-* item 1
=* item 2
""".trimIndent())
""".trimIndent(), Unit)

val listItemNodes = ArrayList<MarkdownListItemNode<*>>()
ASTUtils.traversePreOrder(ast) {
Expand All @@ -85,7 +85,8 @@ class MarkdownRulesTest {
val ast = parser.parse("""
List of stuff
* item 1
* item 2""".trimIndent())
* item 2
""".trimIndent(), Unit)

val listItemNodes = ArrayList<MarkdownListItemNode<*>>()
ASTUtils.traversePreOrder(ast) {
Expand All @@ -107,7 +108,7 @@ class MarkdownRulesTest {
some content
## Header 2
### Header 3
""".trimIndent())
""".trimIndent(), Unit)

val styledNodes = ArrayList<StyleNode<*, *>>()
ASTUtils.traversePreOrder(ast) {
Expand All @@ -130,7 +131,7 @@ class MarkdownRulesTest {
# Header 2
""".trimIndent())
""".trimIndent(), Unit)

val expected = listOf<Node<Any>>(
TextNode("Title"),
Expand All @@ -153,7 +154,7 @@ class MarkdownRulesTest {
some content
-## Header 2
other content for listing # of items
""".trimIndent())
""".trimIndent(), Unit)

val styledNodes = ArrayList<StyleNode<*, *>>()
ASTUtils.traversePreOrder(ast) {
Expand All @@ -170,7 +171,7 @@ class MarkdownRulesTest {
__Alt__ Header
======
some content
""".trimIndent())
""".trimIndent(), Unit)

val styledNodes = ArrayList<StyleNode<*, *>>()
ASTUtils.traversePreOrder(ast) {
Expand All @@ -192,14 +193,14 @@ class MarkdownRulesTest {

@Test
fun headerAltAfterParagraph() {
val ast = parser.parse("""
val ast = parser.parse("""
Some introduction text.
Alt Header
=======
some content
""".trimIndent())
""".trimIndent(), Unit)

val expected = listOf<Node<Any>>(
TextNode("Some introduction text"),
Expand All @@ -221,7 +222,7 @@ class MarkdownRulesTest {
Should Succeed. Alt Header
======
some content
""".trimIndent())
""".trimIndent(), Unit)

val styledNodes = ArrayList<StyleNode<*, *>>()
ASTUtils.traversePreOrder(ast) {
Expand All @@ -244,7 +245,7 @@ class MarkdownRulesTest {
*Alt*. Header {strike unknown}
======
some content
""".trimIndent())
""".trimIndent(), Unit)

val styledNodes = ArrayList<StyleNode<*, *>>()
ASTUtils.traversePreOrder(ast) {
Expand Down

0 comments on commit ebdf5da

Please sign in to comment.