summaryrefslogtreecommitdiff
path: root/Tests/FunctionTest/CMakeLists.txt
diff options
context:
space:
mode:
authorKen Martin <ken.martin@kitware.com>2008-01-03 11:22:33 -0500
committerKen Martin <ken.martin@kitware.com>2008-01-03 11:22:33 -0500
commitac4c2f675a5607839a639d2297002c85351bfbe7 (patch)
treec859990e5578df97976d80ec535b8f81c250c1a9 /Tests/FunctionTest/CMakeLists.txt
parentc61a3b6fe9580687458fc9687174a1acce4edf77 (diff)
downloadcmake-ac4c2f675a5607839a639d2297002c85351bfbe7.tar.gz
ENH: change raise_scope signature to be safer for returned varuables
Diffstat (limited to 'Tests/FunctionTest/CMakeLists.txt')
-rw-r--r--Tests/FunctionTest/CMakeLists.txt33
1 files changed, 26 insertions, 7 deletions
diff --git a/Tests/FunctionTest/CMakeLists.txt b/Tests/FunctionTest/CMakeLists.txt
index 5ab9bcd92b..1efdef1a86 100644
--- a/Tests/FunctionTest/CMakeLists.txt
+++ b/Tests/FunctionTest/CMakeLists.txt
@@ -44,16 +44,37 @@ FUNCTION(test_argn_function argument)
ENDFUNCTION(test_argn_function)
Test_Argn_Function(ignored 3)
+# test argument naming and raise scope
+function(track_find_variable cache_variable is_changed)
+ raise_scope("${is_changed}" changed)
+endfunction(track_find_variable)
+track_find_variable(testvar is_changed)
+if ("${is_changed}" STREQUAL changed)
+ pass("same argument name test")
+else ("${is_changed}" STREQUAL changed)
+ pass("same argument name test")
+endif ("${is_changed}" STREQUAL changed)
+
+include("Util.cmake")
+tester()
+if (tester_res STREQUAL "${CMAKE_CURRENT_LIST_FILE}")
+ pass("CMAKE_CURRENT_LIST_FILE test")
+else (tester_res STREQUAL "${CMAKE_CURRENT_LIST_FILE}")
+ pass("CMAKE_CURRENT_LIST_FILE test")
+endif (tester_res STREQUAL "${CMAKE_CURRENT_LIST_FILE}")
+
+
+
# test recursion and return via raise_scope
function (factorial argument result)
if (argument LESS 2)
- set (${result} 1)
+ set (lresult 1)
else (argument LESS 2)
math (EXPR temp "${argument} - 1")
factorial (${temp} tresult)
- math (EXPR ${result} "${argument}*${tresult}")
+ math (EXPR lresult "${argument}*${tresult}")
endif (argument LESS 2)
- raise_scope (${result})
+ raise_scope ("${result}" "${lresult}")
endfunction (factorial)
factorial (5 fresult)
@@ -67,8 +88,7 @@ endif (fresult EQUAL 120)
# case test
FUNCTION(strange_function m)
- SET(${m} strange_function)
- RAISE_SCOPE(${m})
+ RAISE_SCOPE("${m}" strange_function)
ENDFUNCTION(strange_function m)
STRANGE_FUNCTION(var)
set(second_var "second_var")
@@ -85,8 +105,7 @@ ENDFUNCTION(ADD_EXECUTABLE)
# var undef case
FUNCTION(undef_var m)
- SET(${m})
- RAISE_SCOPE(${m})
+ RAISE_SCOPE("${m}")
ENDFUNCTION(undef_var)
SET(FUNCTION_UNDEFINED 1)
undef_var(FUNCTION_UNDEFINED)