ENH: Added test for IF inside a FOREACH.

This commit is contained in:
Brad King 2002-07-16 17:42:56 -04:00
parent 08f2876bb4
commit 3d3caacf9e
9 changed files with 84 additions and 6 deletions

View File

@ -160,6 +160,20 @@ SET(REMOVE_STRING a b c d e f)
SET(removeVar1 c e) SET(removeVar1 c e)
REMOVE(REMOVE_STRING ${removeVar1} f) REMOVE(REMOVE_STRING ${removeVar1} f)
#
# Test an IF inside a FOREACH.
#
FOREACH(x "a")
IF(1)
# Should always execute.
SET(IF_INSIDE_FOREACH_THEN_EXECUTED 1)
ELSE(1)
# Should never execute.
SET(IF_INSIDE_FOREACH_ELSE_EXECUTED 1)
ENDIF(1)
ENDFOREACH(x)
# #
# Configure file # Configure file
# (plug vars to #define so that they can be tested) # (plug vars to #define so that they can be tested)

View File

@ -801,6 +801,14 @@ int main()
cmFailed("cmSystemTools::UpperCase is working"); cmFailed("cmSystemTools::UpperCase is working");
} }
// ----------------------------------------------------------------------
// Test if IF command inside a FOREACH works.
#if defined(IF_INSIDE_FOREACH_THEN_EXECUTED) && !defined(IF_INSIDE_FOREACH_ELSE_EXECUTED)
cmPassed("IF inside a FOREACH block works");
#else
cmFailed("IF inside a FOREACH block is broken");
#endif
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// Summary // Summary

View File

@ -60,3 +60,7 @@
// Test Remove command // Test Remove command
#define REMOVE_STRING "${REMOVE_STRING}" #define REMOVE_STRING "${REMOVE_STRING}"
// Test IF inside FOREACH
#cmakedefine IF_INSIDE_FOREACH_THEN_EXECUTED
#cmakedefine IF_INSIDE_FOREACH_ELSE_EXECUTED

View File

@ -160,6 +160,20 @@ SET(REMOVE_STRING a b c d e f)
SET(removeVar1 c e) SET(removeVar1 c e)
REMOVE(REMOVE_STRING ${removeVar1} f) REMOVE(REMOVE_STRING ${removeVar1} f)
#
# Test an IF inside a FOREACH.
#
FOREACH(x "a")
IF(1)
# Should always execute.
SET(IF_INSIDE_FOREACH_THEN_EXECUTED 1)
ELSE(1)
# Should never execute.
SET(IF_INSIDE_FOREACH_ELSE_EXECUTED 1)
ENDIF(1)
ENDFOREACH(x)
# #
# Configure file # Configure file
# (plug vars to #define so that they can be tested) # (plug vars to #define so that they can be tested)

View File

@ -801,6 +801,14 @@ int main()
cmFailed("cmSystemTools::UpperCase is working"); cmFailed("cmSystemTools::UpperCase is working");
} }
// ----------------------------------------------------------------------
// Test if IF command inside a FOREACH works.
#if defined(IF_INSIDE_FOREACH_THEN_EXECUTED) && !defined(IF_INSIDE_FOREACH_ELSE_EXECUTED)
cmPassed("IF inside a FOREACH block works");
#else
cmFailed("IF inside a FOREACH block is broken");
#endif
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// Summary // Summary

View File

@ -60,3 +60,7 @@
// Test Remove command // Test Remove command
#define REMOVE_STRING "${REMOVE_STRING}" #define REMOVE_STRING "${REMOVE_STRING}"
// Test IF inside FOREACH
#cmakedefine IF_INSIDE_FOREACH_THEN_EXECUTED
#cmakedefine IF_INSIDE_FOREACH_ELSE_EXECUTED

View File

@ -160,6 +160,20 @@ SET(REMOVE_STRING a b c d e f)
SET(removeVar1 c e) SET(removeVar1 c e)
REMOVE(REMOVE_STRING ${removeVar1} f) REMOVE(REMOVE_STRING ${removeVar1} f)
#
# Test an IF inside a FOREACH.
#
FOREACH(x "a")
IF(1)
# Should always execute.
SET(IF_INSIDE_FOREACH_THEN_EXECUTED 1)
ELSE(1)
# Should never execute.
SET(IF_INSIDE_FOREACH_ELSE_EXECUTED 1)
ENDIF(1)
ENDFOREACH(x)
# #
# Configure file # Configure file
# (plug vars to #define so that they can be tested) # (plug vars to #define so that they can be tested)

View File

@ -801,6 +801,14 @@ int main()
cmFailed("cmSystemTools::UpperCase is working"); cmFailed("cmSystemTools::UpperCase is working");
} }
// ----------------------------------------------------------------------
// Test if IF command inside a FOREACH works.
#if defined(IF_INSIDE_FOREACH_THEN_EXECUTED) && !defined(IF_INSIDE_FOREACH_ELSE_EXECUTED)
cmPassed("IF inside a FOREACH block works");
#else
cmFailed("IF inside a FOREACH block is broken");
#endif
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// Summary // Summary

View File

@ -60,3 +60,7 @@
// Test Remove command // Test Remove command
#define REMOVE_STRING "${REMOVE_STRING}" #define REMOVE_STRING "${REMOVE_STRING}"
// Test IF inside FOREACH
#cmakedefine IF_INSIDE_FOREACH_THEN_EXECUTED
#cmakedefine IF_INSIDE_FOREACH_ELSE_EXECUTED