diff options
author | Brad King <brad.king@kitware.com> | 2019-11-07 15:26:39 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-11-07 15:27:59 (GMT) |
commit | 74569996e8fe798386cca2d4241acea0644f6275 (patch) | |
tree | 34d7992c75adac14f922d8d2b18247d9f2726998 /Tests | |
parent | d4611b05a87e125406588921a7cedc4efae8c8cd (diff) | |
parent | 53227a4ff27c6eda7cb5b3b283f96d1f2d2d56ca (diff) | |
download | CMake-74569996e8fe798386cca2d4241acea0644f6275.zip CMake-74569996e8fe798386cca2d4241acea0644f6275.tar.gz CMake-74569996e8fe798386cca2d4241acea0644f6275.tar.bz2 |
Merge topic 'refactor-foreach'
53227a4ff2 Refactor: Modernize `foreach` code and fix some bugs
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3986
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/foreach/RunCMakeTest.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/foreach/foreach-all-test-stdout.txt | 44 | ||||
-rw-r--r-- | Tests/RunCMake/foreach/foreach-all-test.cmake | 67 |
3 files changed, 112 insertions, 0 deletions
diff --git a/Tests/RunCMake/foreach/RunCMakeTest.cmake b/Tests/RunCMake/foreach/RunCMakeTest.cmake index 4b74cfe..0f1fdd4 100644 --- a/Tests/RunCMake/foreach/RunCMakeTest.cmake +++ b/Tests/RunCMake/foreach/RunCMakeTest.cmake @@ -1,3 +1,4 @@ include(RunCMake) run_cmake(BadRangeInFunction) +run_cmake(foreach-all-test) diff --git a/Tests/RunCMake/foreach/foreach-all-test-stdout.txt b/Tests/RunCMake/foreach/foreach-all-test-stdout.txt new file mode 100644 index 0000000..e8f622d --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-all-test-stdout.txt @@ -0,0 +1,44 @@ +-- foreach\(RANGE\): +-- \[0\.\.1\]/1 +-- < 0 +-- < 1 +-- \[1\.\.1\]/1 +-- < 1 +-- \[0\.\.10\]/2 +-- < 0 +-- < 2 +-- < 4 +-- < 6 +-- < 8 +-- < 10 +-- \[-10\.\.0\]/3 +-- < -10 +-- < -7 +-- < -4 +-- < -1 +-- \[0\.\.-10\]/-5 +-- < 0 +-- < -5 +-- < -10 +-- foreach\(IN ITEMS\): +-- < one +-- < two +-- < three +-- foreach\(IN LISTS\): +-- < satu +-- < dua +-- < tiga +-- foreach\(IN LISTS and ITEMS\): +-- < satu +-- < dua +-- < tiga +-- < one +-- < two +-- < three +-- foreach\(IN ITEMS and LISTS\): +-- < one +-- < two +-- < three +-- < satu +-- < dua +-- < tiga diff --git a/Tests/RunCMake/foreach/foreach-all-test.cmake b/Tests/RunCMake/foreach/foreach-all-test.cmake new file mode 100644 index 0000000..2e377c8 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-all-test.cmake @@ -0,0 +1,67 @@ +message(STATUS "foreach(RANGE):") +list(APPEND CMAKE_MESSAGE_INDENT " ") + +message(STATUS "[0..1]/1") +list(APPEND CMAKE_MESSAGE_INDENT " < ") +foreach(i RANGE 1) + message(STATUS ${i}) +endforeach() +list(POP_BACK CMAKE_MESSAGE_INDENT) + +message(STATUS "[1..1]/1") +list(APPEND CMAKE_MESSAGE_INDENT " < ") +foreach(i RANGE 1 1) + message(STATUS ${i}) +endforeach() +list(POP_BACK CMAKE_MESSAGE_INDENT) + +message(STATUS "[0..10]/2") +list(APPEND CMAKE_MESSAGE_INDENT " < ") +foreach(i RANGE 0 10 2) + message(STATUS ${i}) +endforeach() +list(POP_BACK CMAKE_MESSAGE_INDENT) + +message(STATUS "[-10..0]/3") +list(APPEND CMAKE_MESSAGE_INDENT " < ") +foreach(i RANGE -10 0 3) + message(STATUS ${i}) +endforeach() +list(POP_BACK CMAKE_MESSAGE_INDENT) + +message(STATUS "[0..-10]/-5") +list(APPEND CMAKE_MESSAGE_INDENT " < ") +foreach(i RANGE 0 -10 -5) + message(STATUS ${i}) +endforeach() +list(POP_BACK CMAKE_MESSAGE_INDENT) +list(POP_BACK CMAKE_MESSAGE_INDENT) + +message(STATUS "foreach(IN ITEMS):") +list(APPEND CMAKE_MESSAGE_INDENT " < ") +foreach(i IN ITEMS one two three) + message(STATUS ${i}) +endforeach() +list(POP_BACK CMAKE_MESSAGE_INDENT) + +message(STATUS "foreach(IN LISTS):") +list(APPEND CMAKE_MESSAGE_INDENT " < ") +list(APPEND count satu dua tiga) +foreach(i IN LISTS count) + message(STATUS ${i}) +endforeach() +list(POP_BACK CMAKE_MESSAGE_INDENT) + +message(STATUS "foreach(IN LISTS and ITEMS):") +list(APPEND CMAKE_MESSAGE_INDENT " < ") +foreach(i IN LISTS count ITEMS one two three) + message(STATUS ${i}) +endforeach() +list(POP_BACK CMAKE_MESSAGE_INDENT) + +message(STATUS "foreach(IN ITEMS and LISTS):") +list(APPEND CMAKE_MESSAGE_INDENT " < ") +foreach(i IN ITEMS one two three LISTS count) + message(STATUS ${i}) +endforeach() +list(POP_BACK CMAKE_MESSAGE_INDENT) |