@Test public void hash_followed_by_word() { List<Token> tokens = lexer.lex("#a"); assertThat(tokens, hasToken("#", CppPunctuator.HASH)); assertThat(tokens, hasToken("a", IDENTIFIER)); }
@Test public void cpp_operators() { assertThat(lexer.lex("#"), hasToken("#", CppPunctuator.HASH)); assertThat(lexer.lex("##"), hasToken("##", CppPunctuator.HASHHASH)); }
@Test public void cpp_keywords_indented() { assertThat(lexer.lex(" #define"), hasToken("#define", CppKeyword.DEFINE)); assertThat(lexer.lex("\t#define"), hasToken("#define", CppKeyword.DEFINE)); }
@Test public void cpp_identifiers() { assertThat(lexer.lex("lala"), hasToken("lala", IDENTIFIER)); }
@Test public void cpp_keywords_with_whitespaces() { assertThat(lexer.lex("# define"), hasToken("#define", CppKeyword.DEFINE)); assertThat(lexer.lex("#\tinclude"), hasToken("#include", CppKeyword.INCLUDE)); }