diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2023-08-17 09:47:20 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2023-08-17 10:07:41 (GMT) |
commit | 45ed175f0898fb407dbc327b660449e1d773c197 (patch) | |
tree | 200c770e0bfa3f0c742e98574b358a67530aa44a /Tests | |
parent | a69c783749f769f41875ff818c68ead277fd24f9 (diff) | |
download | CMake-45ed175f0898fb407dbc327b660449e1d773c197.zip CMake-45ed175f0898fb407dbc327b660449e1d773c197.tar.gz CMake-45ed175f0898fb407dbc327b660449e1d773c197.tar.bz2 |
list(INSERT): restore old behavior
Fixes: #25191
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeTests/ListTest.cmake.in | 21 | ||||
-rw-r--r-- | Tests/RunCMake/GenEx-LIST/INSERT.cmake.in | 47 |
2 files changed, 68 insertions, 0 deletions
diff --git a/Tests/CMakeTests/ListTest.cmake.in b/Tests/CMakeTests/ListTest.cmake.in index 76737e5..0120c84 100644 --- a/Tests/CMakeTests/ListTest.cmake.in +++ b/Tests/CMakeTests/ListTest.cmake.in @@ -161,3 +161,24 @@ foreach (_pol ${thelist}) message(SEND_ERROR "returned element '${thevalue}', but expected '${_pol}'") endif() endforeach (_pol) + +block(SCOPE_FOR POLICIES) + cmake_policy(SET CMP0007 NEW) + set(result andy bill brad ken bob) + list(INSERT result 1 "") + TEST("INSERT result 1 \"\"" "andy;;bill;brad;ken;bob") + list(INSERT result 4 ";") + TEST("INSERT result 1 ;" "andy;;bill;brad;;;ken;bob") + list(INSERT result 0 "x") + TEST("INSERT result 1 x" "x;andy;;bill;brad;;;ken;bob") +endblock() +block(SCOPE_FOR POLICIES) + cmake_policy(SET CMP0007 OLD) + set(result andy bill brad ken bob) + list(INSERT result 1 "") + TEST("INSERT result 1 \"\"" "andy;;bill;brad;ken;bob") + list(INSERT result 4 ";") + TEST("INSERT result 1 ;" "andy;bill;brad;ken;;;bob") + list(INSERT result 0 "x") + TEST("INSERT result 1 x" "x;andy;bill;brad;ken;bob") +endblock() diff --git a/Tests/RunCMake/GenEx-LIST/INSERT.cmake.in b/Tests/RunCMake/GenEx-LIST/INSERT.cmake.in index d3bb9b9..48add61 100644 --- a/Tests/RunCMake/GenEx-LIST/INSERT.cmake.in +++ b/Tests/RunCMake/GenEx-LIST/INSERT.cmake.in @@ -46,5 +46,52 @@ if (NOT output STREQUAL listvar) list (APPEND errors "returns bad value: ${output}") endif() +block(SCOPE_FOR POLICIES) + cmake_policy(SET CMP0007 NEW) + + set(listvar "0;1;2;3;4") + list(INSERT listvar 1 "") + set (output "$<LIST:INSERT,0;1;2;3;4,1,>") + if (NOT output STREQUAL listvar) + list (APPEND errors "returns bad value: ${output}") + endif() + + list(INSERT listvar 4 ";") + set (output "$<LIST:INSERT,0;;1;2;3;4,4,;>") + if (NOT output STREQUAL listvar) + list (APPEND errors "returns bad value: ${output}") + endif() + + list(INSERT listvar 0 "x") + set (output "$<LIST:INSERT,0;;1;2;;;3;4,0,x>") + if (NOT output STREQUAL listvar) + list (APPEND errors "returns bad value: ${output}") + endif() +endblock() +block(SCOPE_FOR POLICIES) + set(CMAKE_WARN_DEPRECATED OFF CACHE BOOL "") + cmake_policy(SET CMP0007 OLD) + + set(listvar "0;1;2;3;4") + list(INSERT listvar 1 "") + set (output "$<LIST:INSERT,0;1;2;3;4,1,>") + if (NOT output STREQUAL listvar) + list (APPEND errors "returns bad value: ${output}") + endif() + + list(INSERT listvar 4 ";") + set (output "$<LIST:INSERT,0;1;2;3;4,4,;>") + if (NOT output STREQUAL listvar) + list (APPEND errors "returns bad value: ${output}") + endif() + + list(INSERT listvar 0 "x") + set (output "$<LIST:INSERT,0;1;2;3;4,0,x>") + if (NOT output STREQUAL listvar) + list (APPEND errors "returns bad value: ${output}") + endif() + + unset(CMAKE_WARN_DEPRECATED CACHE) +endblock() check_errors("LIST:INSERT..." ${errors}) |