TestRunner: added test case for assignment simplification in do-while (#4881).

This commit is contained in:
Alexander Mai 2013-07-29 12:10:11 +02:00 committed by Daniel Marjamäki
parent d9a2f542be
commit 39ba0d36c1
1 changed files with 14 additions and 0 deletions

View File

@ -151,6 +151,7 @@ private:
TEST_CASE(whileAssign2);
TEST_CASE(whileAssign3); // varid
TEST_CASE(doWhileAssign); // varid
TEST_CASE(test_4881); // similar to doWhileAssign (#4911), taken from #4881 with full code
// "if(0==x)" => "if(!x)"
TEST_CASE(ifnot);
@ -8214,6 +8215,19 @@ private:
ASSERT_EQUALS("\"hello\" [ 7 ] ;", tok("\"hello\"[7] ;"));
ASSERT_EQUALS("\"hello\" [ -1 ] ;", tok("\"hello\"[-1] ;"));
}
void test_4881() {
const char code[] = "int evallex() {\n"
" int c, t;\n"
"again:\n"
" do {\n"
" if ((c = macroid(c)) == EOF_CHAR || c == '\n') {\n"
" }\n"
" } while ((t = type[c]) == LET && catenate());\n"
"}\n";
ASSERT_EQUALS("int evallex ( ) { int c ; int t ; do { c = macroid ( c ) ; if ( c == EOF_CHAR || c == '\n' ) { } t = type [ c ] ; } while ( t == LET && catenate ( ) ) ; }",
tok(code, true));
}
};
REGISTER_TEST(TestSimplifyTokens)