summaryrefslogtreecommitdiffstats
path: root/Tests/StringFileTest
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-03-17 19:10:15 (GMT)
committerBrad King <brad.king@kitware.com>2009-03-17 19:10:15 (GMT)
commitecb0f3af55f8fde908edcec7f5ccf2cef4002050 (patch)
tree97e95149d7112b5832cc1094f666383ed1e6a5bf /Tests/StringFileTest
parentee00616289403ca0c8d7273eeea3a30eeb11a348 (diff)
downloadCMake-ecb0f3af55f8fde908edcec7f5ccf2cef4002050.zip
CMake-ecb0f3af55f8fde908edcec7f5ccf2cef4002050.tar.gz
CMake-ecb0f3af55f8fde908edcec7f5ccf2cef4002050.tar.bz2
ENH: New foreach(<var> IN ...) mode
This creates a new mode of the foreach command which allows precise iteration even over empty elements. This mode may be safely extended with more keyword arguments in the future. The cost now is possibly breaking scripts that iterate over a list of items beginning with 'IN', but there is no other way to extend the syntax in a readable way.
Diffstat (limited to 'Tests/StringFileTest')
-rw-r--r--Tests/StringFileTest/CMakeLists.txt19
1 files changed, 19 insertions, 0 deletions
diff --git a/Tests/StringFileTest/CMakeLists.txt b/Tests/StringFileTest/CMakeLists.txt
index f1598d7..f2789e6 100644
--- a/Tests/StringFileTest/CMakeLists.txt
+++ b/Tests/StringFileTest/CMakeLists.txt
@@ -217,3 +217,22 @@ TEST_RANGE("3;5" "3;4;5")
TEST_RANGE("5;3" "5;4;3")
TEST_RANGE("3;10;2" "3;5;7;9")
TEST_RANGE("10;0;-3" "10;7;4;1")
+
+# Test FOREACH IN signature
+set(list1 "" a "")
+set(list2 a "" b)
+set(var_)
+set(var_a)
+set(var_b)
+foreach(item IN LISTS list1 list2 ITEMS "" a "")
+ set(var_${item} "${var_${item}}x")
+endforeach(item)
+if(NOT "${var_}" STREQUAL "xxxxx")
+ message(FATAL_ERROR "count incorrect for \"\": [${var_}]")
+endif()
+if(NOT "${var_a}" STREQUAL "xxx")
+ message(FATAL_ERROR "count incorrect for \"a\": [${var_a}]")
+endif()
+if(NOT "${var_b}" STREQUAL "x")
+ message(FATAL_ERROR "count incorrect \"b\": [${var_b}]")
+endif()