@@ -333,9 +333,9 @@ class TestPreprocessor : public TestFixture {
333333 TEST_CASE (getConfigsU5);
334334 TEST_CASE (getConfigsU6);
335335 TEST_CASE (getConfigsU7);
336- TEST_CASE (getConfigsIssue14317);
337336
338- TEST_CASE (getCodeIssue14317);
337+ TEST_CASE (getConfigsAndCodeIssue14317);
338+ TEST_CASE (getConfigsMostGeneralConfigIssue14317);
339339
340340 TEST_CASE (if_sizeof);
341341
@@ -2403,31 +2403,20 @@ class TestPreprocessor : public TestFixture {
24032403 ASSERT_EQUALS (" \n Y\n " , getConfigsStr (code, " -DX" ));
24042404 }
24052405
2406- void getConfigsIssue14317 () {
2406+ void getConfigsAndCodeIssue14317 () {
24072407 const char filedata[] = " bool test() {\n "
2408- " return\n "
2409- " #if defined(isless)\n "
2410- " 0 != isless(1.0, 2.0)\n "
2411- " #else\n "
2412- " 0\n "
2413- " #endif\n "
2414- " ;\n "
2415- " }\n " ;
2408+ " return\n "
2409+ " #if defined(isless)\n "
2410+ " 0 != isless(1.0, 2.0)\n "
2411+ " #else\n "
2412+ " 0\n "
2413+ " #endif\n "
2414+ " ;\n "
2415+ " }\n " ;
2416+ // Test getConfigsStr()
24162417 ASSERT_EQUALS (" \n isless=isless\n " , getConfigsStr (filedata));
2417- }
2418-
2419- void getCodeIssue14317 () {
2420- // Handling include guards..
2421- const char filedata[] = " bool test() {\n "
2422- " return\n "
2423- " #if defined(isless)\n "
2424- " 0 != isless(1.0, 2.0)\n "
2425- " #else\n "
2426- " 0\n "
2427- " #endif\n "
2428- " ;\n "
2429- " }\n " ;
24302418
2419+ // Test getcode()
24312420 // Preprocess => actual result..
24322421 const std::map<std::string, std::string> actual = getcode (settings0, *this , filedata);
24332422
@@ -2437,6 +2426,30 @@ class TestPreprocessor : public TestFixture {
24372426 ASSERT_EQUALS (" bool test ( ) {\n return\n\n 0 != $isless ( 1.0 , 2.0 )\n\n\n\n ;\n }" , actual.at (" isless=isless" ));
24382427 }
24392428
2429+ void getConfigsMostGeneralConfigIssue14317 () {
2430+ // Verifies that the most general X (out of X=X and X) and Y=Y is returned
2431+ // For Z: First Z=Z is added to ret, then the ifndef else branch replaces Z=Z with the more general Z
2432+ const char filedata[] = " #ifdef X\n "
2433+ " print(X);\n "
2434+ " #endif\n "
2435+ " #if X\n "
2436+ " print(X+1);\n "
2437+ " #endif\n "
2438+ " #if defined(Y)\n "
2439+ " print(Y);\n "
2440+ " #endif\n "
2441+ " #ifdef Z\n "
2442+ " print(Z);\n "
2443+ " #endif\n "
2444+ " #ifndef Z\n "
2445+ " print(Z+1);\n "
2446+ " #else\n "
2447+ " print(Z+2);\n "
2448+ " #endif\n " ;
2449+ // Test getConfigsStr()
2450+ ASSERT_EQUALS (" \n X\n Y=Y\n Z\n " , getConfigsStr (filedata));
2451+ }
2452+
24402453 void if_sizeof () { // #4071
24412454 const char code[] = " #if sizeof(unsigned short) == 2\n "
24422455 " Fred & Wilma\n "
0 commit comments