summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
...
* lambda-match: bug: over-strict match in variadic pattern.Kaz Kylheku2022-05-111-0/+14
| | | | | | | | | | | | * stdlib/match.tl (expand-lambda-match): A pattern that is shorter than the maximum number of arguments is augmented with a check ensuring that no fixed arguments are present beyond those that the pattern requires. However, this check must be omitted if the pattern is variadic, because those excess arguments match its tail pattern. * tests/011/patmatch.tl: Cases added.
* tests: Cygwin fixes.Kaz Kylheku2022-05-103-14/+18
| | | | | | | | | | | * tests/017/str-s.tl: Use (libc) not nil in with-dyn-lib. * tests/018/forkflush.tl: On Cygwin, produce canned output for first test case, because the real test case produces some DOS line endings that cause a mismatch. * tests/019/load-search.tl: Skip test case involving a directory with bad permissions being in the load search path.
* *load-search-dir*: Some tests.Kaz Kylheku2022-04-251-0/+33
| | | | | * tests/019/load-search.tl: Add some cases that explore the load search path.
* fork/streams: new failing test.Kaz Kylheku2022-04-232-0/+43
| | | | | | | | | | | | | | | | This test case exemplifies code that will work as expected when *stdout* is a TTY device, such that line buffering is in effect, but then break when standard output is redirected to a file. The issue is that the controlling process is not flushing its standard output when calling the external script, so the script's output gets placed ahead of the process' own earlier output. * tests/018/forkflush.tl: New file. * tests/018/forkflush.expected: New file.
* Add test for loading issue.Kaz Kylheku2022-03-3110-0/+55
| | | | | | | | | | | | | | | | | This test currently fails because when we execute an unsuffixed file like test/019/a, which exists, another file is executed instead, like test/019/a.txr. * tests/019/data/a, * tests/019/data/a.tl, * tests/019/data/a.tlo, * tests/019/data/a.txr * tests/019/data/b.tl * tests/019/data/b.tlo * tests/019/data/b.txr * tests/019/data/c.tl * tests/019/data/c.txr * tests/019/load-search.tl: New files.
* Test of a package-related file compilation problem.Kaz Kylheku2022-03-302-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This test currently fails. This problem was reported by Paul Patience, with a repro test case. The issue is that when compile-file is processing a (defpackage x ...) form, and the package x already exists, it fails to recognize the form as a package-manipulating form, and therefore fails to introduce a "fence" in the output so that subsequent material is placed into a new top-level object. The compiled image fo the (defun foo:fun ()) form in program.tl causes an error: the foo package does not exist. This is because the symbol foo:fun is being read as part of the same object which holds the compiled image of the defpackage form which defines the package. It's essentially the same problem as this (let () (defpackage :foo) foo:bar) The (defpackage ...) cannot execute until the entire form is read, but that form contains foo:bar which requires the foo package to exist. * tests/019/compile-package.tl: New file. * tests/019/data/program.tl: Likewise.
* New FFI types str-s, bstr-s and wstr-s.Kaz Kylheku2022-03-211-0/+11
| | | | | | | | | | | | | | | | | These types actually make it possible to receive a string by pointer from a C function, without trying to free it. It is now possible to write a FFI wrapper for strtol or wcstol, which is done in the new test case. * ffi.c (str_s_s, bstr_s_s, wstr_s_s): New symbol variables. (ffi_init_types): Register the types str-s, bstr-s and wstr-s. (ffi_init): Intern the new symbols. * tests/017/str-s.tl: New file. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* New function: group-map.Kaz Kylheku2022-03-021-2/+2
| | | | | | | | | | | | * hash.c (group_map): New function. (hash_init): group-map intrinsic registered. * hash.h (group_map): Declared. * tests/010/hash.tl: New test case. * txr.1: Documented together with group-by. Extra paren removed from group-by example.
* hash: add tests for group-by, group-reduce.Kaz Kylheku2022-03-021-0/+16
| | | | * tests/010/hash.tl: New tests.
* opip: pass through forms in the op family.Kaz Kylheku2022-02-241-0/+6
| | | | | | | | | | | | | | * stdlib/op.tl (sys:opip-expand): Add op, do, lop, ldo, ap, ip, ado, ido, ret and aret to the operators whose forms are passed through untransformed. This is important because it lets us override the implicit (op ...) and (do ...) chosen by the expander. When a pipeline element produces a list, for instance, we want to be able to use (ap ...) in the next element to spread the list into arguments. * tests/012/op.tl: Add bellied numbers test case. * txr.1: Documented.
* New list-builder method: oust.Kaz Kylheku2022-02-231-0/+5
| | | | | | | | | | | | | | | | * autoload.c (build_set_entries): Add oust symbol. * stdlib/build.tl (list-builder postinit): Call the self argument self instead of bc, for consistency with other methods. (list-builder oust): New method. (list-builder-flets): Add local function oust. * tests/012/seq.tl: New tests. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* New function: partition-if.Kaz Kylheku2022-02-231-0/+26
| | | | | | | | | | | | | | | | * eval.c (eval_init): Register partition-if intrinsic. * lib.c (partition_if_countdown_funv, partition_if_func): New functions. (partition_if): New function. * lib.h (partition_if): Declared. * tests/012/seq.tl: New test cases. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* find-max: convert to seq_info iteration.Kaz Kylheku2022-02-221-0/+13
| | | | | | | | | | | | * lib.c (find_max): Simplify into a single loop rather than handling various sequence types specially. This means it works for all iterable objects now. * txr.1: find-max documentation updated; discussion of hash tables removed, since the described behavior is the one expected for hash tables as iterables. * tests/012/seq.tl: Add some test coverage.
* tests: test case for combining .tlo files.Kaz Kylheku2022-02-141-0/+27
| | | | * tests/018/combine-tlo.tl: New file.
* matcher: test case for `@{nil #/regex/}`.Kaz Kylheku2022-02-091-0/+2
| | | | * tests/011/patmatch.tl: New tests for recently fixed issue.
* matcher: bug: quasiliteral allowing prefix matches.Kaz Kylheku2022-02-041-1/+4
| | | | | | | | * stdlib/match.tl (expand-quasi-match): When matching `text` or `@var`, which are matching in the final position of the specimen, it is not good enough that match-str returns true; we must check that the entire string was matched. Reported by Paul A. Patience.
* New function: copy-cptr.Kaz Kylheku2022-01-281-0/+5
| | | | | | | | | | | | | | | * eval.c (eval_init): copy-cptr intrinsic registered. * lib.c (copy_cptr): New function. (copy): Use copy_cptr for CPTR objects. * lib.h (copy_cptr): Declared. * tests/017/ffi-misc.tl: New test cases. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* typecase: merge with etypecase, handle t differnetly.Kaz Kylheku2022-01-212-1/+19
| | | | | | | | | | | | | | | | | * stdlib/type.tl (sys:typecase-expander): New function, formed from body of typecase. Bad clause syntax now handled with compile-error rather than (throwf 'eval-error). The t symbol is handled specially: it turns into a t conditon in the resulting cond rather than a typep test. The compiler will nicely eliminate dead code after that. Now etypecase is handled here also: if we are expanding etypecase, we just emit the extra clause. (typecase, etypecase): Reduced to sys:typecase-expander calls. * tests/012/typecase.tl: New file. * tests/012/compile.tl: Add type.tl to list of compile-tested files.
* quasiquote: make new @,expr work in dot position.Kaz Kylheku2022-01-181-0/+12
| | | | | | | | | | | | | | | Bugfix: the newly introduced @.expr fails in the dotted position because ^(a . @,expr) turns into (list 'a 'let ...). * eval.c (is_meta_unquote): New static function. (expand_qquote_rec): Replace existing shape test with is_meta_unquote. We must also use this test in one more place: whenever the cdr of a list has the meta unquote shape, we must treat the result similarly to a dotted atom, by converting to append format. * tests/010/qquote.tl: Test cases to cover this.
* quasiquote: support @,expr hack.Kaz Kylheku2022-01-181-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For better or worse, TXR Lisp has a dichotomy of representation that @<atom> produces sys:var syntax, whereas @<compound> produces sys:expr. This can cause an issue in backquoting. Suppose you want to use backquote to generate sytax like (a @b) where the b comes from a variable. The problem is that (let ((x 'b)) ^(a @,x)) doesn't do what you might expect: it produces (sys:expr b) rather than (sys:var b). This patch adds a hack into the quasiquote expander which causes it to generate code to do what you expect. Old behavior: 1> (expand '^(a @,x)) (list 'a (list 'sys:expr x)) New behavior: 1> (expand '^(a @,x)) (list 'a (let ((#:g0012 x)) (if (atom #:g0012) (list 'sys:var #:g0012) (list 'sys:expr #:g0012)))) In other words, x will be evaluted, and the based on the type of the object which emerges, either sys:var or sys:expr syntax is generated. * eval.c (expand_qquote_rec): Implement the above hack. We are careful to only do this when this exact shape occurs in the syntax: (sys:expr (sys:unquote item)). * tests/010/qquote.tl: New file. * txr.1: Documented.
* New function: match-fboundp.Kaz Kylheku2022-01-171-1/+6
| | | | | | | | | | | | | | | | | | User vapnik spaknik was asking in the mailing list whether there is an existence test for TXR pattern functions. Now there is. * eval.c (eval_init): Register match-fboundp intrinsic. * match.c (match_fbound): New function. * match.h (match_fbound): Declared. * tests/011/txr-case.txr: New test cases. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* keyparams: fix broken.Kaz Kylheku2022-01-171-0/+38
| | | | | | | | | | | | | | | | | | | Issues reported by user vapnik spaknik. The evaluation of init forms is incorrect. Init forms like '(x) evaluate to '(x) rather than (x), Also, init forms are evaluated even when the argument is present, so the entire current approach is wrong. * stdlib/keyparams.tl (extract-keys, extract-keys-p, build-key-list-expr): Functions removed. (stuff-key-params): New function. (:key): Rework using simplified approach, with just the stuff-key-params helper. All variables from the keyword parameter list are bound with let. Generated code searches the keyword parameters for values and assigns the variables as needed, evaluating default init forms in the not-found cases. * tests/011/keyparams.tl: New file.
* testing: cover compiled, non-inlined lambda.Kaz Kylheku2022-01-141-13/+28
| | | | | | | | | | | | | | | | | | | The lambda.tl test, when compiled, is only testing the compiler's implementation of the inlined lambda: code generated from a lambda expression to which arguments are statically applied. We augment this to also compile real lambda functions which are called. Everything passes. * tests/012/lambda.tl (call-lambda): New function. (ltest): New macro, specifically geared for testing lambda expressions. When *compile-test* is true, this generates code which performs two tests: applying the arguments directly to the lambda, and evaluating the lambda to a function which is passed to call-lambda, which will then apply the arguments. We cannot use apply, because the compiler sees through that and will inline the lambda anyway. (mltest): Multi-expression version of ltest. This is a drop-in replacement for mtest in the rest of the file.
* carray-replace: two overrun bugs.Kaz Kylheku2022-01-131-0/+16
| | | | | | | | | | | | | * ffi.c (carray_replace): In the case when we replace a larger range by a smaller one, when the upper part of the aray shifts down, we are not correctly clearing to zeros the vacated part of the array. The variable whole is a displacement from the base of the array, not from ptr. Secondly, the copying loop must go rom fr to below sn, not below vn; sn is derived from vn but truncated not to go past the array. * tests/017/carray.tl: New file. Several cases here fail before this fix.
* New macros: each-true, some-true, each-false, some-false.Kaz Kylheku2022-01-122-42/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisplib.c (arith_each_set_entries): Trigger autoload on new symbols. * stdilb/arith-each.tl (sys:arith-each): Generalize macro to handle short-circuiting logical operations. The op-iv parameter, which is a cons, is spread into two op and iv parameter. One new argument appears, short-circ. This specifies a code for short-circuiting behavior: t means iteration continues while the result is true; nil means it continues while it is nil, and + means iteration continues while the accumulator is nonzero. A new convention is in effect: the operator has to be specified as a list in order to request accumulating behavior, e.g (+) or (*). Otherwise the operator specifies a predicate that is applied to the forms, without taking into account the prior value. (sum-each, sum-each*, mul-each, mul-each*): Spread the op-iv arguments. Wrap the op argument in a list to request accumulation. In the case of mul-each and mul-each*, specify + for the short-circ argument, which means that iteration stops when the accumulator becomes zerop. sum-each and sum-each* specify : for the short-circ argument which is unrecognized, and so ther is no short-circuiting behavior. (each-true, some-true, each-false, some-false): New macros. * tests/016/arith.tl: New tests. * txr.1: Documented new macros and added note about possible short-circuiting in mul-each and mul-each*. * stdlib/doc-syms.tl: Updated.
* sum-each, mul-each: handle no vars case.Kaz Kylheku2022-01-112-0/+62
| | | | | | | | | | | | | | | * stdlib/arith-each.tl (sys:arith-each): If there are no vars, then just reduce to the identity element value. This is alreading happening fine for the each-prod family of operators. * tests/016/arith.tl: Test cases covering the no vars and empty iteration identity element cases for sum-each and mul-each, as well as the *-prod variants. * txr.1: Document empty iteration and empty vars behavior for arithmetic each operators as well as the each-prod family.
* json: add tests with multi-line literals.Kaz Kylheku2022-01-101-0/+10
| | | | | | * tests/010/json.tl: New tests. These work. Odd; I'm seeing an issue whereby typing multi-line #J expressions into the listener does not work.
* lazy-str-get-trailing-list: spurious empty string issue.Kaz Kylheku2022-01-042-1/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | * lib.c (lazy_str_get_trailing_list): Remove the spurious empty string caused by splitting on the terminator. Whenever the materialized prefix is not-empty, and there is a non-empty terminator, the prefix necessarily ends in the termintator. If we split on the terminator, the list of pieces ends in in an empty string, which is undesirable. This has to be subject to compat, unfortunately; it's a very visible behavior that affects the continuation of line-based matching after the @(freeform) directive. * tests/006/freeform-5.txr: With this fix, we no longer have to match the spurious blank line coming from @(freeform). * tests/015/lazy-str.tl: New file. * txr.1: Updated documentation with compat notes. There was some outright incorrect text describing lazy-str-get-trailing-list. Also, the lazy-str-force-upto and lazy-str-force were under-documented. The return value of the former was not completely described: that it returns t in the other case when not returning nil. It wasn't mentioned that the functions observe the limit-count. Moreover, the exact algorithm for forcing is now documented.
* freeform: bug: account for consumed prefix.Kaz Kylheku2022-01-042-0/+12
| | | | | | | | | | | | | | | | | | | | This was reported by user vapnik spaknik. The @(freeform), when reconstituting the unmatched trailing portion of the virtual line back into a list of lines, uses the abstract match position, neglecting to account for the fact that a prefix of the line may have been physically consumed to save memory. * match.c (v_freeform): When calling lazy_str_get_trailing_list, indicate the correct amount of prefix material, by subtracting, from the matching length, the base variable, which indicates how much of the prefix had been consumed. This consumption takes place above 4000 bytes, which is why the freeform test cases are not catching this. * tests/006/freeform-5.txr: New file. * tests/006/freeform-5.expected: New file.
* ffi: allow enumed bitfield.Kaz Kylheku2022-01-021-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * ffi.c (ffi_type_copy): Function moved earlier in file without change. (ffi_type_copy_new_ops): New stati function. (make_ffi_type_enum): Do not create a new type object using cobj; copy the existing base_type, and then tweak its properties, just like what is done with bool. Thus if base_type is a bitfield, the enum will be a bitfield. Add check against doign this to anything but an FFI_KIND_NUM, with the awareness that this does include floating-point types. Since tft is now a copy, we no longer have to copy a number of things from btft. We do set he kind field to FFI_KIND_ENUM. (ffi_type_compile): In the two bitfield cases, we now calculate the mask field for the bitfield type (leaving the shift at zero). The struct or union type into which the bitfield is embedded will still re-calculate this. The reason is that when an (enumed (bit ...) ...) type is defined, it constructs hash tables for converting between the symbolic and numeric values. It calls the put function of the underlying type to test whether each enumeration value can be converted (i.e. is in range). So the bitfield type must have a valid mask at that time, or else it will reject every nonzero value as being out of range for the bitfield. I'm also replacing the max_int variable with bits_int. Since bitfields are restricted to no wider than int, why pretend? * tests/017/ffi-misc.tl: New test cases. * txr.1: Documented.
* match: allow bound variables with regex modifier.Kaz Kylheku2021-12-271-0/+6
| | | | | | | | | * stdlib/match.tl (expand-quasi-match): Add regex cases with bound variable. * tests/011/patmatch.tl: Test cases for this. * txr.1: Documented.
* txr: do not ignore regex in positive match.Kaz Kylheku2021-12-271-0/+11
| | | | | | | | | | | | | | | | | * match.c (h_var): Refactor the logic here a bit. Without regard for whether the variable has a value, we dispatch the regex, fixed field and function cases. These handle the binding against the existing value. Then before all other cases, we check for the existing value and convert that to a literal text match. The effect of this is that now the regular expression is processed even if the variable has a value. * tests/010/span-var.txr: Last two test cases hardened a bit so they cannot fall through to a successful exit, if they invoke the wrong case. This is not related to this change. New test cases for regex span. * txr.1: Updated documentation and compatibility notes.
* txr: function span variable must match existing value.Kaz Kylheku2021-12-271-0/+13
| | | | | | | | | | | | | | | | | | | | * match.c (h_var_compat): New function; verbatim copy of existing h_var prior to this commit. (h_var): If a variable has an existing binding, but is a function spanning match, do not substitute it with text. Handle it with the ordinary case, in which we now use dest_bind instead of cons. (v_var): Similarly, here, we must also use dest_bind, rather than always freshly binding the variable. (match_compat_fixup): For 272 compatibility, substitute h_var_compat for h_var in the horizontal directive table. * tests/010/span-var.txr: New test cases. * txr.1: Documentation updated and also improved overall. The behavior when a variable has an existing value is clarified for the regex and fixed field case. Also update and condense compat notes for 272.
* txr: allow variable to span vertical function.Kaz Kylheku2021-12-261-0/+15
| | | | | | | | | | | | | | | * match.c (v_var_compat, v_var): New static functions. (match_files): No longer recognize v_var specially; it is now handled via vertical table. (dir_tables_init): Register a vertical sys:var directive also via v_var function. (match_compat_fixup): New function. * txr.c (compat): Call match_compat_fixup. * tests/010/span-var.txr: New file. * txr.1: Documented.
* new feature: :mass-delegate struct clause macro.Kaz Kylheku2021-12-231-0/+33
| | | | | | | | | | | | | | | With :mass-delegate, it is possible to generate delegation methods in bulk. All of the methods of a struct type can be mirrored by delegates in another struct type just by writing a single :mass-delegate clause. * stdlib/struct.tlk (:mass-delegate): New struct clause macro. * tests/012/oop.tl: New tests. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* eval: fix optional parameter bug from 2014.Kaz Kylheku2021-12-231-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This bug affects optional parameters which either have no default expression, or one that is nil. For instance x in (lambda (: (x nil))) or (lambda (: x)). When such a parameter is given the : symbol as an argument, it is not being bound, as if it weren't there. ((lambda (: x) x) :) -> ;; error: unbound variable x This issue is not a regression; it was introduced in the commit which introduced the colon convention to optionals, as well as init expressions and presence-indicating variables, commit 68c084269581f32f0a7b859446ae2efb6c6a26c0 made in February 2014. This might be the first instance of an interpreter bug being found that is not present in the compiler. * eval.c (bind_args): The idea here was that when the argument to an optional the colon keyword symbol, and the optional's initform is nil, we can skip the overhead of calling eval to get that initform's value. Unfortunately, the skip was extended over the code which binds the parameter. Only the eval can be skipped! * tests/012/lambda.tl: New test cases to cover this.
* new feature: defstruct clause macros.Kaz Kylheku2021-12-221-0/+15
| | | | | | | | | | | | | | | | | | | | | | * lisplib.c (struct_set_entries): Trigger autoload on new symbols define-struct-clause and *struct-clause-expander*. * stdlib/struct.tl (*struct-clause-expander*): New variable. (defstruct): expand-slot local function now returns list of expanded slots, not a single slot; every case in the tree-case is converted to return a list. The syntax of a slot clause is first expanded through *struct-clause-expander hash; if that works then the resulting list is further scanned for expansions. (define-struct-clause): New macro. (:delegate): New struct clause defined with define-struct-clause. Provides single-slot delegation. * tests/012/oop.tl: Tests for :delegate. * txr.1: Documented define-struct-clause and :delegate. * stdlib/doc-syms.tl: Updated.
* The pairlis function comes to TXR Lisp.Kaz Kylheku2021-12-221-0/+8
| | | | | | | | | | | | * eval.c (eval_init): Register pairlis intrinsic. * lib.c, lib.h (pairlis): New function. * tests/012/seq.tl: New test cases. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* New functions: subq, subql, subqual and subst.Kaz Kylheku2021-12-221-0/+50
| | | | | | | | | | | | | | | * eval.c (eval_init): Register new intrinsics. * lib.c, lib.h (subq, subql, subqual, subst): New functions. * tests/012/seq.tl: New test cases. * stdlib/optimize.tl (subst): Function removed. The new subst drop-in replaces this one. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* less: bug, vectors not supported.Kaz Kylheku2021-12-201-0/+21
| | | | | | | | * lib.c (less_tab_init): Add missing initialization for VEC, with a priority above CONS: all vectors are greater than conses. The BUF priority is bumped to 7. * test/012/less.tl: New file.
* tree: new functions for priority queue operation.Kaz Kylheku2021-12-181-0/+30
| | | | | | | | | | | | | | | | * tree.c (tree_min_node, tree_min, tree_del_min_node, tree_del_min): New functions. (tree_init): tree-min-node, tree-min, tree-del-min-node, tree-del-min: New intrinsics registered. * tree.h (tree_min_node, tree_min, tree_del_min_node, tree_del_min): Declared. * txr.1: Documented. * tests/010/tree.tl: New tests. * stdlib/doc-syms.tl: Updated.
* tree: bugfix wrong tree-count.Kaz Kylheku2021-12-181-0/+10
| | | | | | | | | | | | | When duplicate keys are inserted in the default way with replacement, the tree size must not be incremented. * tree.c (tr_insert): Increment the tr->size and maintain tr->max_size here. In the case of replacing an existing node, do not touch the count. * tests/010/tree.tl: Add test cases covering duplicate insertion and tree-count. (tree_insert_node): Remove unconditional size increment.
* tree: support for duplicate keys.Kaz Kylheku2021-12-171-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * tree.c (tr_insert): New argument for allowing duplicate. If it is true, suppresses the case of replacing a node, causing the logic to fall through to traversing right, so the duplicate key effectively looks like it is greater than the existing duplicates, and gets inserted as the rightmost duplicate. (tr_do_delete_specific, tr_delete_specific): New static functions. (tree_insert_node): New parameter, passed to tr_insert. (tree_insert): New parameter, passed to tree_insert_node. (tree_delete_specific_node): New function. (tree): New parameter to allow duplicate keys in the elements sequence. (tree_construct): Pass t to tree to allow duplicate elements. (tree_init): Update registrations of tree, tree-insert and tree-insert-node. Register tree-delete-specific-node function. * tree.h (tree, tree_insert_node, tree_insert): Declarations updated. (tree_delete_specific_node): Declared. * lib.c (seq): Pass t argument to tree_insert, allowing duplicates. * parser.c (circ_backpatch): Likewise. * parser.y (tree): Pass t to new argument of tree, so duplicates are preserved in the element list of the #T literal. * y.tab.c.shipped: Updated. * tests/010/tree.tl: Test cases for duplicate keys. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* tree-count: new function.Kaz Kylheku2021-12-171-2/+10
| | | | | | | | | | | | | * tree.c (tree_count): New function. (tree_init): tree-count intrinsic registered. * tree.h (tree_count): Declared. * lib.c (length): Support search tree argument via tree_count. * tests/010/tree.tl: Test cases for tree-count, indirectly via len. * txr.1: Documented.
* define-accessor: fix broken arg handling.Kaz Kylheku2021-12-101-0/+12
| | | | | | | | | | | I discovered this off chance by searching for occurrences of (let ,(zip ...) ...) or (let (,*(zip ...)) ...) in the code base, noticing an incorrect one. * stdlib/place.tl (sys:register-simple-accessor): Remove spurious list around ,(zip temps args). * tests/012/defset.tl: Test cases for define-accessor added.
* each-match macro family: missing anon block.Kaz Kylheku2021-12-081-0/+3
| | | | | | | | | | | | | | | | | * txr.1: Adding the missing requirement that each-match and the other macros in that family must have an implicit anonymous block around the body forms. This is a requirements bug, effectively: the programmer expects these operators to be consistent with the each operator, as part of the same family. * match.tl (each-match-expander): Implement the requirement. Since we are using mapping functions, we must use temporary variables: the evaluation of the expressions which produce the sequence argument values to the mapping functions must be outside of the anonymous block. The block must surround only the function call. * tests/011/patmatch.tl: Add small test case covering this.
* case macros: bug in singleton key optimization.Kaz Kylheku2021-12-081-0/+32
| | | | | | | | | | | | * eval.c (me_case): Reduce (key) to key only if key is an atom. Otherwise we reduce ((a b c)), which is a single list-valued key to (a b c), which looks like three keys. This was introduced on Oct 25, 2017 in commit b72c9309c8d8f1af320dce616a69412510531b48, making it a regression. * tests/012/case.tl: New file. The last test case fails without this bugfix. The others pass either way.
* rot, nrot: new functions.Kaz Kylheku2021-12-071-0/+78
| | | | | | | | | | | | | | * eval.c (eval_init): nrot, rot intrinsics registered. * lib.c (nrot, rot): New functions. * lib.h (nrot, rot): Declared. * tests/012/seq.tl: New test cases. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* tuples*: new function.Kaz Kylheku2021-12-041-0/+47
| | | | | | | | | | | | | | | * eval.c (eval_init): Register tuples* intrinsic. * lib.c (tuples_star_func): New static function. (tuples_star): New function. * lib.h (tuples_star): Declared. * tests/012/seq.tl: New test cases. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* tuples: add test cases.Kaz Kylheku2021-12-021-1/+48
| | | | * tests/012/seq.tl: Numerous test cases for tuples.