summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2025-03-07 00:11:37 -0800
committerKaz Kylheku <kaz@kylheku.com>2025-03-07 00:11:37 -0800
commit07e40c025d65beeced5ac83485eb13dab9b7d2ae (patch)
tree8a6569af89018d5d9ff2622c8f7ad40fd236fd0e /tests
parenta68a67376127cb9accf26c4ed43438f188eb24c8 (diff)
downloadtxr-07e40c025d65beeced5ac83485eb13dab9b7d2ae.tar.gz
txr-07e40c025d65beeced5ac83485eb13dab9b7d2ae.tar.bz2
txr-07e40c025d65beeced5ac83485eb13dab9b7d2ae.zip
New function: iterp.
* eval.c (eval_init): Register iterp intrinsic. * lib.[ch] (iterp): New function. * tests/012/iter.tl: New tests. * txr.1: Document iterp. Update documentation for iter-more, iter-item and iter-step to more precisely identify which objects are valid arguments in terms of iterp and additional conditions, and that other objects throw a type-error exception. Fix wrong references to iter-more under documentation for iter-item. Removed obsolete text specifying that iter-step uses car on list-like sequences, a dubious behavior removed in the previous commit.
Diffstat (limited to 'tests')
-rw-r--r--tests/012/iter.tl20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/012/iter.tl b/tests/012/iter.tl
index 94a50f34..cebbca55 100644
--- a/tests/012/iter.tl
+++ b/tests/012/iter.tl
@@ -154,3 +154,23 @@
(iter-item #()) :error
(iter-item #(1)) :error
(iter-item #(1 2 3)) :error)
+
+(defstruct iter ()
+ (:method iter-step (self)))
+
+(defstruct not-iter ())
+
+(mtest
+ (iterp nil) t
+ (iterp '(a . b)) t
+ (iterp (lcons 3 4)) t
+ (iterp #\a) t
+ (iterp 42) t
+ (iterp (expt 2 512)) t
+ (iterp 3.14) t
+ (iterp (new iter)) t
+ (iterp (new not-iter)) nil
+ (iterp "abc") nil
+ (iterp (fun list)) nil
+ (iterp #/regex/) nil
+ (iterp #(vec)) nil)