package kalang.test;

import java.util.List;
import kalang.util.TokenStreamFactory;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.IntStream;
import org.antlr.v4.runtime.Token;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author Kason Yang <i@kasonyang.com>
 */
public class TokenUtilTest {
    
    public TokenUtilTest() {
    }
    
    @Test
    public void test(){
        CommonTokenStream ts = TokenStreamFactory.createTokenStream("class{    }");
        int tokenSize = ts.size();
        assertEquals(0, tokenSize);
        List<Token> tokens = ts.getTokens();
        assertEquals(0, tokens.size());
        ts.consume();
        //why is it two?
        assertEquals(2, ts.size());
        int consumeSize = 1;
        while(ts.LA(1)!=IntStream.EOF){
            ts.consume();
            consumeSize++;
        }
        tokens = ts.getTokens();
        assertEquals(5, tokens.size());
        assertEquals(3, consumeSize);
    }
    
}

@@ -669,32 +669,201 @@
   ts.consume();%0A
+        ts.consume();%0A        assertEquals(%22%7D%22, ts.LT(1).getText());%0A        assertEquals(%22%7B%22, ts.LT(-1).getText());%0A        assertEquals(%22class%22, ts.LT(-2).getText());%0A
         //why is
@@ -870,11 +870,9 @@
  it 
-two
+4
 ?%0A  
@@ -890,17 +890,17 @@
 tEquals(
-2
+4
 , ts.siz
@@ -931,17 +931,17 @@
 eSize = 
-1
+2
 ;%0A      

test update