summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2024-02-09 06:25:11 -0800
committerKaz Kylheku <kaz@kylheku.com>2024-02-09 06:25:11 -0800
commit3fb108272f762a4e3afa3f2f925db03b3128c272 (patch)
treebcc2195735027e7133ee91249d349dc9be15584c /tests
parent25bf01699c2af7f8007404d5a62aeb1d64aee7b0 (diff)
downloadtxr-3fb108272f762a4e3afa3f2f925db03b3128c272.tar.gz
txr-3fb108272f762a4e3afa3f2f925db03b3128c272.tar.bz2
txr-3fb108272f762a4e3afa3f2f925db03b3128c272.zip
New function: cons-find.
* eval.c (cons_find): Static function removed; a new one is implemented in lib.c. (eval_init): Register cons-find intrinsic. * lib.c (cons_find_rec): New static function. (cons_find): New function. * lib.h (cons_find): Declared. * tests/012/cons.tl: New file. * txr.1: Documented cons-find together with tree-find. Document that tree-find's test-fun argument is optional, defaulting to equal.
Diffstat (limited to 'tests')
-rw-r--r--tests/012/cons.tl26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/012/cons.tl b/tests/012/cons.tl
new file mode 100644
index 00000000..d72a5d74
--- /dev/null
+++ b/tests/012/cons.tl
@@ -0,0 +1,26 @@
+(load "../common")
+
+(mtest
+ (tree-find "abc" "abc") t
+ (tree-find "abc" "abc" (fun eq)) nil
+ (tree-find "b" '("a" "b" "c")) t
+ (tree-find "b" '("a" "b" "c") (fun eq)) nil
+ (tree-find "b" '(("b") "a" "c")) t
+ (tree-find "b" '("a" ("b") "c")) t
+ (tree-find "b" '("a" (("b")) "c")) t
+ (tree-find "d" '("a" (("b")) "c")) nil
+ (tree-find nil '("a" (("b")) "c")) nil)
+
+(mtest
+ (cons-find "abc" "abc") t
+ (cons-find "abc" "ABC" (fun eq)) nil
+ (cons-find "b" '("a" "b" "c")) t
+ (cons-find "b" '("a" "b" "c") (fun eq)) nil
+ (cons-find "b" '(("b") "a" "c")) t
+ (cons-find "b" '("a" ("b") "c")) t
+ (cons-find "b" '("a" (("b")) "c")) t
+ (cons-find "d" '("a" (("b")) "c")) nil
+ (cons-find "d" '("a" (("b")) "c" . "d")) t
+ (cons-find "d" '("a" (("b") . "d") "c")) t
+ (cons-find "d" '("a" . "d")) t
+ (cons-find nil '("a" (("b")) "c")) t)