@@ -0,0 +1,2303 @@
+package org.cgfalcon.myprolang.calc.lexer;%0A%0Aimport static org.junit.Assert.*;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0A%0Apublic class CalcLexerTest %7B%0A    private CalcLexer lexer;%0A%0A%0A    @Before%0A    public void setUp() throws Exception %7B%0A        lexer = new CalcLexer(%221+2%22);%0A    %7D%0A%0A    @Test%0A    public void testGetTokenSimple() throws Exception %7B%0A%0A        lexer.setLine(%221+2%22);%0A%0A        Token token = lexer.nextToken();%0A        assertEquals(new Token(0, 1, %221%22, TokenType.NUM), token);%0A%0A        Token tokenOp = lexer.nextToken();%0A        assertEquals(1, tokenOp.getPos());%0A        assertEquals(1, tokenOp.getLine());%0A        assertEquals(TokenType.OP_ADD_TOKEN, tokenOp.getKind());%0A%0A        Token tokenOperand2 = lexer.nextToken();%0A        assertEquals(new Token(2, 1, %222%22, TokenType.NUM), tokenOperand2);%0A%0A        Token tokenEndLine = lexer.nextToken();%0A        assertEquals(2, tokenEndLine.getPos());%0A        assertEquals(1, tokenEndLine.getLine());%0A        assertEquals(TokenType.EOF, tokenEndLine.getKind());%0A    %7D%0A%0A    @Test%0A    public void tesLexerComplex1() throws Exception %7B%0A        String line = %2234%5Cn%22;%0A        lexer.setLine(line);%0A%0A        Token token = lexer.nextToken();%0A        assertEquals(new Token(0, 1, %2234%22, TokenType.NUM), token);%0A%0A        String line2 = %2234.9384 0.4%5Cn%22;%0A        lexer.setLine(line2);%0A%0A        Token token2 = lexer.nextToken();%0A        assertEquals(new Token(0, 1, %2234.9384%22, TokenType.NUM), token2);%0A%0A        Token token3 = lexer.nextToken();%0A        assertEquals(new Token(8, 1, %220.4%22, TokenType.NUM), token3);%0A%0A    %7D%0A%0A    @Test%0A    public void testAdd() throws Exception %7B%0A        String line = %2245.3 + 0.23%5Cn%22;%0A        lexer.setLine(line);%0A%0A        Token token = lexer.nextToken();%0A        assertEquals(new Token(0, 1, %2245.3%22, TokenType.NUM), token);%0A%0A        Token tokenAdd = lexer.nextToken();%0A        assertEquals(5, tokenAdd.getPos());%0A        assertEquals(TokenType.OP_ADD_TOKEN, tokenAdd.getKind());%0A%0A        Token tokenOperand = lexer.nextToken();%0A        assertEquals(new Token(6, 1, %220.23%22, TokenType.NUM), tokenOperand);%0A%0A    %7D%0A%0A%0A    @Test%0A    public void testID() %7B%0A        String line = %22dbd%22;%0A        lexer.setLine(line);%0A%0A        Token token = lexer.nextToken();%0A%0A        assertEquals(new Token(0, 1, %22dbd%22, TokenType.ID), token);%0A    %7D%0A%7D%0A

Add Calc Parser