Skip to content

Commit f101d9f

Browse files
committed
FEAT: empty? to accept typesets
It was already accepting bitsets, so why not to support typesets too. Added a few `typeset!` unit tests (not complete)
1 parent 6632c61 commit f101d9f

File tree

5 files changed

+49
-2
lines changed

5 files changed

+49
-2
lines changed

src/boot/actions.r

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ head?: action [
140140

141141
tail?: action [
142142
{Returns TRUE if series is at or past its end; or empty for other types.}
143-
series [series! gob! port! bitset! map!]
143+
series [series! gob! port! bitset! typeset! map!]
144144
]
145145

146146
past?: action [

src/core/t-typeset.c

+4
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,10 @@
254254
VAL_TYPESET(val) = ~VAL_TYPESET(val);
255255
return R_ARG1;
256256

257+
case A_TAILQ:
258+
// Necessary to make EMPTY? work:
259+
return (VAL_TYPESET(val) == 0) ? R_TRUE : R_FALSE;
260+
257261
default:
258262
Trap_Action(REB_TYPESET, action);
259263
}

src/mezz/mezz-series.r

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ REBOL [
1414
empty?: make :tail? [
1515
[
1616
{Returns TRUE if empty or NONE, or for series if index is at or beyond its tail.}
17-
series [series! object! gob! port! bitset! map! none!]
17+
series [series! object! gob! port! bitset! typeset! map! none!]
1818
]
1919
]
2020

src/tests/run-tests.r3

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ dt [ ;- delta time
4040
wrap load %units/image-test.r3
4141
wrap load %units/file-test.r3
4242
wrap load %units/func-test.r3
43+
wrap load %units/typeset-test.r3
4344

4445
recycle/torture
4546
recycle

src/tests/units/typeset-test.r3

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Rebol [
2+
Title: "Rebol3 typeset! test script"
3+
Author: "Oldes, Peter W A Wood"
4+
File: %typeset-test.r3
5+
Tabs: 4
6+
Needs: [%../quick-test-module.r3]
7+
]
8+
9+
~~~start-file~~~ "typeset"
10+
11+
===start-group=== "typeset!"
12+
--test-- "make typeset!"
13+
--assert typeset? types: make typeset! [block! map! object!]
14+
--test-- "find in typeset"
15+
--assert find types block!
16+
--assert find types map!
17+
--assert find types object!
18+
--assert not find types string!
19+
20+
--test-- "union of typesets"
21+
types2: union types make typeset! [string!]
22+
--assert typeset? types2
23+
--assert find types2 string!
24+
25+
--test-- "complement of typesets"
26+
not-types: complement types
27+
--assert typeset? not-types
28+
--assert find not-types integer!
29+
30+
--test-- "difference of typesets"
31+
types3: difference types make typeset! [object!]
32+
--assert typeset? types3
33+
--assert not find types3 object!
34+
35+
--test-- "empty typeset test"
36+
;@@ requested: https://github.com/red/REP/issues/55
37+
--assert empty? make typeset! []
38+
--assert not empty? types
39+
40+
===end-group===
41+
42+
~~~end-file~~~

0 commit comments

Comments
 (0)