package com.github.kmizu.jcombinator;

import com.github.kmizu.jcombinator.datatype.Tuple2;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import static org.junit.Assert.*;

import static com.github.kmizu.jcombinator.Parser.*;
import static com.github.kmizu.jcombinator.TestHelper.*;
import static com.github.kmizu.jcombinator.Functions.*;

@RunWith(JUnit4.class)
public class PrimitiveTest {

    @Test
    public void testStringParser()
    {
        Parser<String> helloWorld = string("Hello, World");
        helloWorld.invoke("Hello, World").fold(
            (success) -> {
                assertEquals("Hello, World", success.value());
                assertEquals("", success.next());
                return null;
            },
            (failure) -> {
               assertTrue(false);
               return null;
            }
        );
    }

    @Test
    public void testManyParser() {
        let(string("a").many(), ax -> {
            ax.invoke("aaaaa").fold(
                    (success) -> {
                        assertEquals(listOf("a", "a", "a", "a", "a"), success.value());
                        assertEquals("", success.next());
                        return null;
                    },
                    (failure) -> {
                        assertTrue(false);
                        return null;
                    }
            );
        });
    }

    @Test
    public void testCat() {
        let(string("a").cat(string("b")), ab -> {
            ab.invoke("ab").fold(
                    (success) -> {
                        assertEquals(new Tuple2<>("a", "b"), success.value());
                        assertEquals("", success.next());
                        return null;
                    },
                    (failure) -> {
                        assertTrue(false);
                        return null;
                    }
            );

        });
    }
}

@@ -733,37 +733,8 @@
 ));%0A
-                return null;%0A
     
@@ -736,32 +736,32 @@
 %0A            %7D,%0A
+
             (fai
@@ -809,36 +809,8 @@
 e);%0A
-               return null;%0A
     
@@ -1144,45 +1144,8 @@
 ));%0A
-                        return null;%0A
     
@@ -1245,45 +1245,8 @@
 e);%0A
-                        return null;%0A
     
@@ -1595,45 +1595,8 @@
 ));%0A
-                        return null;%0A
     
@@ -1641,32 +1641,32 @@
  (failure) -%3E %7B%0A
+
                 
@@ -1696,45 +1696,8 @@
 e);%0A
-                        return null;%0A
     

Remove extra 'return null'