@@ -103,4 +103,41 @@ Rebol [
103
103
104
104
===end-group===
105
105
106
+
107
+ ===start-group=== "UNPROTECT object!"
108
+ ;@@ https://github.com/Oldes/Rebol-issues/issues/1015
109
+ --test-- "unprotect object"
110
+ ; To allow adding words to o, and allow modification of words already in o, but not affect their values:
111
+ o: unprotect protect /deep o: object [a: 10 b: [20 ]]
112
+ --assert not error? try [extend o 'c 3 ]
113
+ --assert not error? try [append o 'd]
114
+ --assert not error? try [o/a: 0 ]
115
+ --assert error? try [append o/b 0 ]
116
+
117
+ --test-- "unprotect/words object!"
118
+ ; To allow modification of words already in o, but not affect their values or the object itself:
119
+ o: unprotect /words protect /deep o: object [a: 10 b: [20 ]]
120
+ --assert error? try [extend o 'c 3 ]
121
+ --assert error? try [append o 'd]
122
+ --assert not error? try [o/a: 0 ]
123
+ --assert error? try [append o/b 0 ]
124
+
125
+ --test-- "unprotect/deep object!"
126
+ ; To allow adding words to o, and allow modification of words already in o or their values:
127
+ o: unprotect /deep protect /deep o: object [a: 10 b: [20 ]]
128
+ --assert not error? try [extend o 'c 3 ]
129
+ --assert not error? try [append o 'd]
130
+ --assert not error? try [o/a: 0 ]
131
+ --assert not error? try [append o/b 0 ]
132
+
133
+ --test-- "unprotect/words/deep object!"
134
+ ; To allow modification of words already in o and their contents, but not affect the object itself:
135
+ o: unprotect /words/deep protect /deep o: object [a: 10 b: [20 ]]
136
+ --assert error? try [extend o 'c 3 ]
137
+ --assert error? try [append o 'd]
138
+ --assert not error? try [o/a: 0 ]
139
+ --assert not error? try [append o/b 0 ]
140
+
141
+ ===end-group===
142
+
106
143
~~~end-file~~~
0 commit comments