// Path: advance/src/java/com/dwarfartisan/parsec/Txt.java
// public static <Status, Tran> Parsec<Character, Character, Status, Tran> space() {
//     return new Space<>();
// }


import static com.dwarfartisan.parsec.Txt.space;
import org.hamcrest.core.IsEqual;
import org.hamcrest.core.IsInstanceOf;
import org.junit.Test;
import static org.junit.Assert.*;
package com.dwarfartisan.parsec;



/**
 * Created by Mars Liu on 16/9/15.
 *
 * Tests About look behind.
 */
public class AheadTest extends Base {

    @Test
    public void simple() throws Exception{
        State<Character, Integer, Integer> state = newState("this is a string data.");
        Parsec<String, Character, Integer, Integer> parser =
                new Text<Integer, Integer>("this").over(new Ahead<>(new Text<>(" is")));

        String re = parser.parse(state);

        assertEquals(re, "this");
        assertThat("Expect status stop after this but is. ", state.status(), IsEqual.equalTo(4));
    }

    @Test
    public void result() throws Exception{
        State<Character, Integer, Integer> state = newState("this is a string data.");
        Parsec<String, Character, Integer, Integer> parser =
// Path: advance/src/java/com/dwarfartisan/parsec/Txt.java
// public static <Status, Tran> Parsec<Character, Character, Status, Tran> space() {
//     return new Space<>();
// }


// Path: advance/test/java/com/dwarfartisan/parsec/AheadTest.java
import static com.dwarfartisan.parsec.Txt.space;
import org.hamcrest.core.IsEqual;
import org.hamcrest.core.IsInstanceOf;
import org.junit.Test;
import static org.junit.Assert.*;

package com.dwarfartisan.parsec;



/**
 * Created by Mars Liu on 16/9/15.
 *
 * Tests About look behind.
 */
public class AheadTest extends Base {

    @Test
    public void simple() throws Exception{
        State<Character, Integer, Integer> state = newState("this is a string data.");
        Parsec<String, Character, Integer, Integer> parser =
                new Text<Integer, Integer>("this").over(new Ahead<>(new Text<>(" is")));

        String re = parser.parse(state);

        assertEquals(re, "this");
        assertThat("Expect status stop after this but is. ", state.status(), IsEqual.equalTo(4));
    }

    @Test
    public void result() throws Exception{
        State<Character, Integer, Integer> state = newState("this is a string data.");
        Parsec<String, Character, Integer, Integer> parser =
                new Text<Integer, Integer>("this").then(space()).then(new Ahead<>(new Text<>("is")));