diff --git a/src/token.cpp b/src/token.cpp index 92bd6f958..eb22dfc82 100644 --- a/src/token.cpp +++ b/src/token.cpp @@ -471,12 +471,20 @@ void Token::printOut(const char *title) const std::cout << "########"; std::cout << "###" << std::endl; + unsigned int lineNum = 0; for (const Token *t = this; t; t = t->next()) { - std::cout << t->linenr() << ": " << t->str(); - if (t->varId()) - std::cout << " (" << t->varId() << ")"; + if (lineNum != t->linenr()) + { + std::cout << std::endl << t->linenr() << ": "; + lineNum = t->linenr(); + } - std::cout << std::endl; + std::cout << t->str(); +// if (t->varId()) + // std::cout << " (" << t->varId() << ")"; + + std::cout << " "; } + std::cout << std::endl; } diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index ed4a4dc53..cbb78f94c 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -40,6 +40,7 @@ private: TEST_CASE(sizeof1); TEST_CASE(iftruefalse); TEST_CASE(combine_strings); + // TODO TEST_CASE(double_plus); } std::string tok(const char code[]) @@ -163,6 +164,27 @@ private: "}\n"; ASSERT_EQUALS(tok(code2), tok(code1)); } + + void double_plus() + { + { + const char code1[] = "void foo( int a )\n" + "{\n" + "a++;\n" + "a--;\n" + "++a;\n" + "--a;\n" + "}\n"; + ASSERT_EQUALS("void foo ( int a ) { a ++ ; a -- ; ++ a ; -- a ; } ", tok(code1)); + } + { + const char code1[] = "void foo( int a )\n" + "{\n" + "a=a+a;\n" + "}\n"; + ASSERT_EQUALS("void foo ( int a ) { a = a + a ; } ", tok(code1)); + } + } }; REGISTER_TEST(TestSimplifyTokens)