### Question:
Lexer { public Lexeme get() { final var ret = lookAhead != null ? lookAhead : next(); lookAhead = next(); return ret; } Lexer(final String input);  Lexer(final String input, boolean selectorExpression); @Override String toString(); String rest(); Lexeme get(); Lexeme peek();  }### Answer:
@Test @DisplayName("Test the lexer returning EOF multiple times when input is empty") void testNullInput() { final var lexer = new Lexer(""); final var lexeme = lexer.get(); Assertions.assertEquals(lexeme.type, Lexeme.Type.EOF); }
@Test @DisplayName("The lexer returns identifiers that may contain . and ( and ) and , ") void testIdentifiers() { final var lexer = new Lexer("identif module.java me.thod(vara , varb)"); testWord(lexer, "identif"); final var space = lexer.get(); Assertions.assertEquals(Lexeme.Type.SPACE,space.type); testWord(lexer, "module.java"); lexer.get(); testWord(lexer, "me.thod(vara,varb)"); }
@Test @DisplayName("The lexer returns regular expressions with / in it") void testRegex() { final var lexer = new Lexer("/\\s*\\/[a-zA-Z]/"); final var lexeme = lexer.get(); Assertions.assertEquals(Lexeme.Type.REGEX,lexeme.type); Assertions.assertEquals("\\s*/[a-zA-Z]",lexeme.string); }
@Test @DisplayName("The lexer skips spaces when requested to skip") void testSkipSpace() { final var lexer = new Lexer("/\\s*\\/[a-zA-Z]/ a |",true); final var regex = lexer.get(); Assertions.assertEquals(Lexeme.Type.REGEX,regex.type); Assertions.assertEquals("\\s*/[a-zA-Z]",regex.string); final var word = lexer.get(); Assertions.assertEquals(Lexeme.Type.WORD,word.type); Assertions.assertEquals("a",word.string); final var symb = lexer.get(); Assertions.assertEquals(Lexeme.Type.SYMBOL,symb.type); Assertions.assertEquals("|",symb.string); }