Skip to content

Commit

Permalink
Added test of Token.getPosition()
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-eberle committed Nov 2, 2014
1 parent 69b3d45 commit d05af29
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Compiler/tests/compiler/lexer/TokenTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,21 @@ public void testToString() {
}

@Test
public void testgetTokenString() {
public void testGetTokenString() {
assertEquals("abstract", new Token(TokenType.ABSTRACT, new Position(2, 4)).getTokenString());
assertEquals("identifier main", new Token(TokenType.IDENTIFIER, null, new Symbol("main")).getTokenString());
assertEquals("integer literal 2342342", new Token(TokenType.INTEGER, null, new Symbol("2342342")).getTokenString());
assertEquals("error you idiot screwed it up", new Token(TokenType.ERROR, null,
new Symbol("you idiot screwed it up")).getTokenString());
assertEquals("==", new Token(TokenType.EQUAL, null).getTokenString());
}

@Test
public void testGetTokenPosition() {
Position expectedPosition = new Position(2, 4);
Token token = new Token(TokenType.ABSTRACT, expectedPosition);
Position position = token.getPosition();
assertEquals(expectedPosition.getLine(), position.getLine());
assertEquals(expectedPosition.getCharacter(), position.getCharacter());
}
}

0 comments on commit d05af29

Please sign in to comment.