summaryrefslogtreecommitdiffstats
path: root/tests/010
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-04-30 19:47:54 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-04-30 19:47:54 -0700
commit713f4c6eb6f55520e39bf7100b2e58ce65268468 (patch)
tree1dc8d829cbe6c2737ee2aca8ab27c913af69eed8 /tests/010
parent06f0b8f73fad6def2d5d921a84af8196a1cbbdaa (diff)
downloadtxr-713f4c6eb6f55520e39bf7100b2e58ce65268468.tar.gz
txr-713f4c6eb6f55520e39bf7100b2e58ce65268468.tar.bz2
txr-713f4c6eb6f55520e39bf7100b2e58ce65268468.zip
tree: new functions for reseting iterator.
* tree.c (tree_reset, tree_reset_at): New functions. (tree_init): tree-reset and tree-reset-at intrinsics registered. * tree.h (tree_reset, tree_reset_at): Declared. * tests/010/tree.tl: New tests. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated.
Diffstat (limited to 'tests/010')
-rw-r--r--tests/010/tree.tl15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/010/tree.tl b/tests/010/tree.tl
index 83b3172c..fde11300 100644
--- a/tests/010/tree.tl
+++ b/tests/010/tree.tl
@@ -40,6 +40,14 @@
(add (key n))))
(range 0 19))
+(vtest (build (for* ((j (tree-begin tr))
+ (i (progn (tree-next j) (tree-next j) (tree-reset j tr)))
+ (n (tree-next i)))
+ (n)
+ ((set n (tree-next i)))
+ (add (key n))))
+ (range 0 19))
+
(defvarl trc (copy-search-tree tr))
(vtest trc tr)
@@ -71,6 +79,13 @@
(add (key n))))
(range 8 19))
+(vtest (build (for* ((i (tree-reset-at (tree-begin #T(())) tr 8))
+ (n (tree-next i)))
+ (n)
+ ((set n (tree-next i)))
+ (add (key n))))
+ (range 8 19))
+
(test (tree-next (tree-begin-at tr 20)) nil)
(test (tree-next (tree-begin-at #T(()) 0)) nil)