simplify token list: Added a TODO test case. variable id is lost

This commit is contained in:
Daniel Marjamäki 2009-02-13 16:23:02 +00:00
parent de80baeea1
commit 3b194ff851
1 changed files with 26 additions and 0 deletions

View File

@ -93,6 +93,7 @@ private:
TEST_CASE(varid1);
TEST_CASE(varid2);
TEST_CASE(varid3);
// TODO TEST_CASE(varid4); // There is currently a problem for "*(a+10)" => "a[10]"
TEST_CASE(file1);
TEST_CASE(file2);
@ -729,6 +730,31 @@ private:
ASSERT_EQUALS(expected, actual);
}
void varid4()
{
const std::string code("void f(const unsigned int a[])\n"
"{\n"
" int i = *(a+10);\n"
"}\n");
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
tokenizer.setVarId();
tokenizer.simplifyTokenList();
// result..
const std::string actual(tokenizer.tokens()->stringifyList(true));
const std::string expected("\n"
"1: void f ( const int a@1 [ ] )\n"
"2: {\n"
"3: int i@2 ; i@2 = a@1 [ 10 ] ;\n"
"4: }\n");
ASSERT_EQUALS(expected, actual);
}
void file1()
{