simplify tokens: added todo test case, the varid is lost when simplifying variable declarations

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

View File

@ -94,6 +94,7 @@ private:
TEST_CASE(varid2);
TEST_CASE(varid3);
// TODO TEST_CASE(varid4); // There is currently a problem for "*(a+10)" => "a[10]"
// TODO TEST_CASE(varid5); // There is currently a problem for "int a,b;" => "int a; int b;"
TEST_CASE(file1);
TEST_CASE(file2);
@ -755,6 +756,31 @@ private:
ASSERT_EQUALS(expected, actual);
}
void varid5()
{
const std::string code("void f()\n"
"{\n"
" int a,b;\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 ( )\n"
"2: {\n"
"3: int a@1 ; int b@2 ;\n"
"4: }\n");
ASSERT_EQUALS(expected, actual);
}
void file1()
{