Add more tests for flow control simplification.
This commit is contained in:
parent
44e348d018
commit
fa34a14d57
|
@ -3143,6 +3143,67 @@ private:
|
||||||
ASSERT_EQUALS("void foo ( ) { " + *it + " ; { label : ; ok ( ) ; } }", tok(code));
|
ASSERT_EQUALS("void foo ( ) { " + *it + " ; { label : ; ok ( ) ; } }", tok(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::string code = "void foo () {"
|
||||||
|
" " + *it + ";"
|
||||||
|
" switch (n) {"
|
||||||
|
" case 1:"
|
||||||
|
" label:"
|
||||||
|
" foo(); break;"
|
||||||
|
" default:"
|
||||||
|
" break;"
|
||||||
|
" }"
|
||||||
|
"}";
|
||||||
|
std::string expected = "void foo ( ) { " + *it + " ; { label : ; foo ( ) ; break ; } }";
|
||||||
|
ASSERT_EQUALS(expected, tok(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::string code = "void foo () {"
|
||||||
|
" " + *it + ";"
|
||||||
|
" switch (n) {"
|
||||||
|
" case 1:"
|
||||||
|
" label:"
|
||||||
|
" foo(); break;"
|
||||||
|
" default:"
|
||||||
|
" break; break;"
|
||||||
|
" }"
|
||||||
|
"}";
|
||||||
|
std::string expected = "void foo ( ) { " + *it + " ; { label : ; foo ( ) ; break ; break ; } }";
|
||||||
|
std::string actual = "void foo ( ) { " + *it + " ; { label : ; foo ( ) ; break ; } }";
|
||||||
|
TODO_ASSERT_EQUALS(expected, actual, tok(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::string code = "void foo () {"
|
||||||
|
" " + *it + ";"
|
||||||
|
" switch (n) {"
|
||||||
|
" case 1:"
|
||||||
|
" label:"
|
||||||
|
" foo(); break; break;"
|
||||||
|
" default:"
|
||||||
|
" break;"
|
||||||
|
" }"
|
||||||
|
"}";
|
||||||
|
std::string expected = "void foo ( ) { " + *it + " ; { label : ; foo ( ) ; break ; break ; } }";
|
||||||
|
ASSERT_EQUALS(expected, tok(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::string code = "void foo () {"
|
||||||
|
" " + *it + ";"
|
||||||
|
" switch (n) {"
|
||||||
|
" case 1:"
|
||||||
|
" label:"
|
||||||
|
" foo(); break; break;"
|
||||||
|
" default:"
|
||||||
|
" break; break;"
|
||||||
|
" }"
|
||||||
|
"}";
|
||||||
|
std::string expected = "void foo ( ) { " + *it + " ; { label : ; foo ( ) ; break ; break ; } }";
|
||||||
|
ASSERT_EQUALS(expected, tok(code));
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
std::string code = "int f() { "
|
std::string code = "int f() { "
|
||||||
"switch (x) { case 1: " + *it + "; bar(); tack; { ticak(); " + *it + " } " + *it + " "
|
"switch (x) { case 1: " + *it + "; bar(); tack; { ticak(); " + *it + " } " + *it + " "
|
||||||
|
@ -3177,6 +3238,16 @@ private:
|
||||||
" case 3 : ; if ( blah6 ) { " + *it + " ; } break ; } }";
|
" case 3 : ; if ( blah6 ) { " + *it + " ; } break ; } }";
|
||||||
ASSERT_EQUALS(expected, tok(code));
|
ASSERT_EQUALS(expected, tok(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::string code = "void foo () {"
|
||||||
|
" " + *it + ";"
|
||||||
|
" switch (i) { case 0: switch (j) { case 0: foo(); }"
|
||||||
|
" case 1: switch (j) { case -1: bar(); label:; ok(); }"
|
||||||
|
" case 3: if (blah6) { boo(); break; } } }";
|
||||||
|
std::string expected = "void foo ( ) { " + *it + " ; { { label : ; ok ( ) ; } case 3 : ; if ( blah6 ) { boo ( ) ; break ; } } }";
|
||||||
|
ASSERT_EQUALS(expected, tok(code));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue