File tree 3 files changed +27
-10
lines changed
3 files changed +27
-10
lines changed Original file line number Diff line number Diff line change @@ -316,7 +316,7 @@ remove: action [
316
316
{Removes element(s); returns same position.}
317
317
series [series! gob! port! bitset! none! map! ] {At position (modified)}
318
318
/part {Removes multiple elements or to a given position}
319
- length [number! series! pair! char! ]
319
+ range [number! series! pair! char! ]
320
320
/key {Removes a key from map.}
321
321
key-arg [any-type! ]
322
322
]
Original file line number Diff line number Diff line change 700
700
Trap_Arg (arg );
701
701
702
702
case A_REMOVE : // #"a" "abc" remove/key bs "abcd"
703
- if (D_REF (ARG_REMOVE_PART )) Trap0 (RE_BAD_REFINES );
704
- if (!D_REF (ARG_REMOVE_KEY )) Trap0 (RE_MISSING_ARG ); // /key required
705
- if (Set_Bits (VAL_SERIES (value ), D_ARG (ARG_REMOVE_KEY_ARG ), FALSE)) break ;
703
+ if (D_REF (ARG_REMOVE_KEY )) {
704
+ if (D_REF (ARG_REMOVE_PART ))
705
+ Trap0 (RE_BAD_REFINES );
706
+ arg = D_ARG (ARG_REMOVE_KEY_ARG );
707
+ } else if (D_REF (ARG_REMOVE_PART )) {
708
+ arg = D_ARG (ARG_REMOVE_RANGE );
709
+ // remove/part is allowed only with block, string, binary and char
710
+ if (!(IS_BLOCK (arg ) || IS_STRING (arg ) || IS_BINARY (arg ) || IS_CHAR (arg )))
711
+ Trap_Arg (arg );
712
+ }
713
+ else Trap0 (RE_MISSING_ARG ); // /key or /part is required
714
+ if (Set_Bits (VAL_SERIES (value ), arg , FALSE)) break ;
706
715
Trap_Arg (D_ARG (3 ));
707
716
708
717
case A_COPY :
Original file line number Diff line number Diff line change 211
211
clear bs
212
212
--assert "make bitset! #{}" = mold bs
213
213
214
- --test-- "remove-1 "
214
+ --test-- "remove/key "
215
215
;@@ https://github.com/Oldes/Rebol-wishes/issues/20
216
216
bs: charset "012345789"
217
217
--assert 64 = length? bs
218
218
--assert "make bitset! #{000000000000FDC0}" = mold bs
219
219
--assert "make bitset! #{0000000000007DC0}" = mold remove/key bs #"0"
220
220
--assert "make bitset! #{0000000000003DC0}" = mold remove/key bs 49
221
221
--assert "make bitset! #{0000000000000000}" = mold remove/key bs [#"2" - #"7" "8" #"9" ]
222
- --test-- "remove/part invalid"
223
- --assert all [
224
- error? e: try [remove/part bs "01" ]
225
- e/id = 'bad-refines
226
- ]
222
+ --test-- "remove/part"
223
+ ;@@ https://github.com/Oldes/Rebol-issues/issues/933
224
+ bs: charset "012345789"
225
+ --assert "make bitset! #{0000000000007DC0}" = mold remove/part bs #"0"
226
+ --assert "make bitset! #{0000000000003DC0}" = mold remove/part bs "1"
227
+ --assert "make bitset! #{0000000000000000}" = mold remove/part bs [#"2" - #"7" "8" #"9" ]
228
+ --assert all [ error? e: try [remove/part bs 1 ] e/id = 'invalid-arg]
229
+ --assert all [ error? e: try [remove/part/key bs "01" "" ] e/id = 'bad-refines]
230
+
227
231
--test-- "issue-1355"
228
232
;@@ https://github.com/Oldes/Rebol-issues/issues/1355
229
233
--assert pick charset [not "a" ] #"b"
230
234
--assert not pick charset [not "a" ] #"a"
231
235
--assert "make bitset! #{00000000000000000000000060}" = mold poke charset "a" #"b" true
232
236
--assert {make bitset! [not bits #{00000000000000000000000040} ]} = mold poke charset [not "a" ] #"b" true
233
237
238
+ --test-- "issue-933"
239
+ ;@@ https://github.com/Oldes/Rebol-issues/issues/933
240
+ --assert all [error? e: try [remove make bitset! #{ FF } ] e/id = 'missing-arg]
241
+
234
242
===end-group===
235
243
236
244
You can’t perform that action at this time.
0 commit comments