Skip to content

Commit 0ce1664

Browse files
committed
Adapt tests for safeguard_properties()
1 parent c5d1df3 commit 0ce1664

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed
Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
include("rsp/testing")
22
include("rsp/helpers")
3+
include("rsp/debug")
34

45
define_test_case(
56
"Safeguard Properties Test"
@@ -13,18 +14,14 @@ function(can_safeguard_properties)
1314
set(c "ccc")
1415

1516
function(risky_callback)
17+
message(VERBOSE "risky callback invoked (function)")
18+
1619
set(a "1" PARENT_SCOPE)
1720
set(b "2" PARENT_SCOPE)
1821
set(c "3" PARENT_SCOPE)
1922
endfunction()
2023

21-
safeguard_properties(
22-
CALLBACK "risky_callback"
23-
PROPERTIES
24-
a
25-
b
26-
c
27-
)
24+
safeguard_properties("risky_callback" "a;b;c")
2825

2926
# Debug
3027
#risky_callback()
@@ -33,3 +30,28 @@ function(can_safeguard_properties)
3330
assert_string_equals("bbb" ${b} MESSAGE "Property b was modified")
3431
assert_string_equals("ccc" ${c} MESSAGE "Property c was modified")
3532
endfunction()
33+
34+
define_test("unguarded properties can be changed" "unguarded_properties_can_be_changed")
35+
function(unguarded_properties_can_be_changed)
36+
set(a "aaa")
37+
set(b "bbb")
38+
set(c "ccc")
39+
40+
macro(risky_callback)
41+
message(NOTICE "risky callback invoked (macro)")
42+
43+
set(a "1")
44+
set(b "2")
45+
set(c "3")
46+
endmacro()
47+
48+
# Note: "c" is NOT safeguarded here
49+
safeguard_properties("risky_callback" "a;b")
50+
51+
# Debug
52+
#risky_callback()
53+
54+
assert_string_equals("aaa" ${a} MESSAGE "Property a was modified")
55+
assert_string_equals("bbb" ${b} MESSAGE "Property b was modified")
56+
assert_string_equals("3" ${c} MESSAGE "Property c SHOULD had been modified")
57+
endfunction()

0 commit comments

Comments
 (0)