summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* tests: guix fixes.Kaz Kylheku2021-07-135-4/+11
| | | | | | | | | | | | | | | | * tests/002/query-1.txr: Skip test if an executable /bin/sh doesn't exist, rather than the bogus reasons. * tests/010/json.tl: Change the condition for the command-put-json tests: not whether cat is found in the search path but whether /bin/sh exists and is executable. * tests/017/realpath.tl: Also quit if /usr/bin doesn't exist. * tests/018/path-test.tl: Exit succesfully if /bin/sh does not exist. Revert the earlier change. * tests/018/process.tl: Quit if no executable /bin/sh exists.
* tests: weaken condition in path search for sh.Kaz Kylheku2021-07-121-1/+1
| | | | | | | * tests/018/path-test.tl: In the Guix build environment, the shell might be found at a path not ending in bin. Let's ust test for ending in /bin. Reported and investigated by Paul A. Patience.
* tests: json: skip tests relying on cat, if missing.Kaz Kylheku2021-07-121-7/+9
| | | | | | | * tests/010/json.tl: skip several test cases which rely on the cat utility for testing command-put-json, if the cat utility is not found in the search path. Reported and investigated by Paul A. Patience.
* tests: json: fix accidentally excluded tests.Kaz Kylheku2021-07-121-2/+2
| | | | | | * tests/010/json.tl: Fix several tests being excluded from the (mtest ...) form to which they are expected to belong, one of them having an extra quote in the expected value, too.
* tests: 002 group: skip test if utils missing.Kaz Kylheku2021-07-121-0/+2
| | | | | | * tests/002/query-1.txr: Terminate with status 13 if the needed utils cannot be found in the search path. Reported and investigated by Paul A. Patience.
* New function: add-suffix.Kaz Kylheku2021-07-101-0/+19
| | | | | | | | | | | * stream.c, stream.h (add_suffix): New function. (stream_init): add-suffix intrinsic registered. * tests/018/path.tl: Tests. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* New functions: trim-short-suffix, trim-long-suffix.Kaz Kylheku2021-07-101-0/+48
| | | | | | | | | | | | | | | * lib.c, lib.h (chk_substrdup): New function. * stream.c, stream.h (trim_short_suffix, trim_long_suffix): New functions. (stream_init): trim-short-suffix and trim-long-suffix intrinsics registered. * tests/018/path.tl: New tests. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* suffix functions: new test cases.Kaz Kylheku2021-07-101-1/+3
| | | | | * tests/018/path.tl: New cases covering dotted name situation, which is not a suffix, but can have a suffix.
* lib: tests for keep-if, remove-if, separate.Kaz Kylheku2021-07-101-0/+42
| | | | * tests/012/seq.tl: New tests.
* subtypep: handle COBJ inheritance.Kaz Kylheku2021-07-091-0/+20
| | | | | | | | | | | | | | | | | | * lib.c (class_from_sym): New static function. (subtypep): Remove special case handling of stream versus stdio-stream. If the two types are not both structures, then check whether they are both cobj classes. If so, check if they are in an inheritance relationship via the cobj_hash. (cobj_populate_hash): Map each symbol to a fixnum integer which gives class handle'position in the cobj_class table. (cobj_class_exists): Style: compare to nil instead of 0. (obj_init): Do not call cobj_populate_hash here, it is far too early: only a couple of COBJ types exist at this point. Moreover, hash_init has not been called so hash_cls and hash_iter_cls still have null symbols. (init): Call obj_populate_hash here, as the last step. * tests/012/type.tl: New file.
* with-resources: undocumented nil skip behavior.Kaz Kylheku2021-07-071-0/+18
| | | | | | | | | | | | | | | Paul A. Patience discovered the hidden "feature" of with-resourcers, that the three-argument form of the binding (var init cleanup) causes the with-resources form to terminate if init returns nil. The (var init) syntax doesn't generate this logic. * stdlib/with-resources.tl (with-resources): Do not emit the when form unless <= 265 compatibility is in effect. * tests/012/oop-mac.tl: New file. * txr.1: Compat note added.
* tests: fix malformed chmod.tl.Paul A. Patience2021-07-051-11/+11
| | | | | | * tests/018/chmod.tl (os): Fix final parentheses of defvarl form accidentally encompassing the rest of the source file. Replace tabs with spaces.
* genman, lib, tests: use defvarl where possible.Paul A. Patience2021-07-058-37/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * genman.txr (dupes, tagnum): Replace defvar with defvarl. * stdlib/doc-lookup.tl (os-symbol): Same. * tests/011/macros-3.tl (x): Same. * tests/011/mandel.txr (x-centre, y-centre, width, i-max, j-max, n) (r-max, pixel-size, x-offset, y-offset): Same. (file, colour-max): Delete (unused) variables. * tests/012/circ.tl (x): Replace defvar with defvarl. * tests/012/stack.tl (stack-limited): Same. * tests/012/struct.tl (s): Same. * tests/013/maze.tl (vi, pa, sc): Delete variables. Use function arguments instead. (usage): Fix typo. * tests/014/dgram-stream.tl (family): Rename to... (*family*): ...this. * tests/014/socket-basic.tl (socktype): Rename to... (*socktype*): ...this. (%iters%): Replace defvar with defvarl.
* stack-limit: bug: not handling RLIM_INFINITY.Kaz Kylheku2021-07-041-6/+9
| | | | | | | | | | | | | | | | * gc.c (gc_init): We must check rlim_cur for the RLIM_INFINITY value indicating unlimited stack, and not misuse this value as a limit number, otherwise hilarity ensues. This reproduced on an older platform with make 3.81, which calls setrlimit to bring about an unlimited stack, passed on to child processes. Because of this txr segfaulted, as a consequence of a false positive. * tests/012/stack.tl (stack-limited): New variable which indicates whether there is a stack limit. If there isn't, we avoid running the fork-based test case. Also, we set the stack limit to 32768 so we have a limit against which to run some of the tests.
* path-search: fix test for sh not being in /bin.Kaz Kylheku2021-07-041-1/+1
| | | | | * tests/018/path-test.tl: Check that the result of a path-search for "sh" only ends in "/bin/sh", not that it is precisely "/bin/sh".
* suffix functions: ignore trailing slashes.Kaz Kylheku2021-07-031-2/+16
| | | | | | | | | | | | | | | | Another requirements tweak to short-suffix and long-suffix: ignore one or more trailing slashes, instead of just one. This harmonizes with base-name, which does same, that requirement being copies from the POSIX basename utility. * stream.c (short_suffix, long_suffix): If sl points to a trailing slash which is the start of a suffix that consists of nothing but trailing slashes, then we pretend it isn't there. * tests/018/path.tl: Adjusted two existing test cases, and added more. * txr.1: Documented.
* compiler: add failing inline lambda tests.Kaz Kylheku2021-07-031-0/+10
| | | | | * tests/012/lambda.tl: Add tests where apply list supplies : values to optional params, which must trigger defaulting.
* tests: support for compiled test forms.Kaz Kylheku2021-07-032-23/+51
| | | | | | | | * tests/common.tl (*compile-test*): New variable. (vtest): Compile cases via compile-toplevel if *compile-test* is true, catching compile-time exceptions. * tests/012/lambda.tl: Set *compile-test* true and repeat file.
* tests: include constp test in compile case.Kaz Kylheku2021-07-021-1/+1
| | | | * tests/012/compile.tl: Add const.tl file.
* tests: simplify file name handling in compile test.Kaz Kylheku2021-07-021-5/+5
| | | | | * tests/012/compile.tl: Remove suffixes from name list, and simplify code.
* lambda: tests.Kaz Kylheku2021-07-021-0/+88
| | | | * tests/012/lambda.tl: New file.
* constantp: tests.Kaz Kylheku2021-07-021-0/+23
| | | | * tests/012/const.tl: New file.
* op: bug in do: must insert @1 into unexpanded form.Kaz Kylheku2021-06-291-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In the case when the do syntax has no metavariables, and it expands as-is without the addition of symbol in the tail position, we are doing something wrong: we are adding the @1 into the expanded version of the form, rather than the original. For instance: 1> (expand '(do pop a)) (lambda (#:arg-1-0017 . #:arg-rest-0016) (prog1 (car a) (sys:setq a (cdr a)) #:arg-1-0017)) Here, the @1 was inserted into the (prog1 ...) form which is the expansion of pop. This is incorrect; it must be inserted into the original (pop a) syntax as (pop a @1). * op.tl (op-expand): In this case when there are no metas and no do-gen that can be replaced by @1 via symacrolet, go back to the original args syntax, add the arg1 meta into that syntax, and process it from the beginning through parallel expansions steps. * tests/012/op.tl: Couple of tests added.
* path-cat: becomes variadic.Kaz Kylheku2021-06-291-0/+32
| | | | | | | | | | | | | * stream.c (path_vcat): New static function. (stream_init): Register path-cat instrinsic to path_vcat rather than path_cat. * tests/018/path.tl: path-cat tests: all examples from documentation, plus others. * txr.1: Documented existing behaviors that were not clear, like when inputs are empty. Documented new variadic semantics. Examples added.
* New function: path-search.Kaz Kylheku2021-06-291-0/+15
| | | | | | | | | | | | * lisplib.c (path_test_set_entries): Autoload on path-search. * stdlib/path-test.tl (path-search): New function. * tests/018/path-test.tl: New file. * txr.1: Documented. * stdlib/doc-lookup.tl: Updated.
* regex-from-trie: correctly handle empty trie.Kaz Kylheku2021-06-271-0/+4
| | | | | | | | | | * filter.c (regex_from_trie): An empty trie matches nothing, so we must return the t regex syntax (match nothing), not nil (match empty string). A hash-based trie matches nothing if it is empty; but if it has user data, then it matches the empty string. * tests/015/trie.tl: Test cases added.
* regex-from-trie: bugs processing compressed trie.Kaz Kylheku2021-06-271-0/+5
| | | | | | | | | | * filter.c (regex_from_trie): If a hash key maps to a string, do not treat that as a trie; it is the value for that node. A value is only a trie if it is a cons or hash. Also, in this case do not make a compound regex. * tests/015/trie.tl: Add duplicate of regex test case using regex from compressed tree.
* regex-from-trie: bugfix: incomplete regex.Kaz Kylheku2021-06-271-1/+1
| | | | | | | | | | * filter.c (regex_from_trie): The code is neglecting to check whether there is a match of the input *at* the given hash table, which is true if it has user data. In that case, the empty regex must be added as a parallel branch. * tests/015/trie.tl: The first regex test case works now. The second one is incorrect and is replaced.
* filter: regex-from-trie produces bad or syntax.Kaz Kylheku2021-06-271-0/+49
| | | | | | | | | | This is not a complete fix yet; the test case still fails. * filter.c (regex_from_trie): The (or ...) operator in the regex language is strictly binary. Do not produce a variable-argument or expression. * tests/015/trie.tl: New file.
* tests: reduce time spent in stack overflow test.Kaz Kylheku2021-06-261-0/+1
| | | | | | * tests/012/stack2.txr: This test case can prove its point in a much smaller stack limit than the one derived from the system default. Let's cut it to 32 kilobytes.
* base-name: bug with empty string suffix.Kaz Kylheku2021-06-261-0/+28
| | | | | | | | * stream.c (base_name): We must check for a zero length suffix, otherwise sub(base, zero, neg(length(suff))) produces an empty string. * tests/018/path.tl: Test cases for base-name.
* suffix functions: requirements change.Kaz Kylheku2021-06-261-22/+22
| | | | | | | | | | | | | | | | | The short-suffix and long-suffix functions will now return the suffix including the leading period. This was a suggestion from user Paul A. Patience, which is a good requirement. Since these functions were newly introduced just the last release, I'm not going to provide backwards compatibility switching for them. * stream.c (short_suffix, long_suffix): Duplicate the suffix starting at the dot, not dot + 1. * tests/018/path.tl: Test cases updated. * txr.1: Documentation updated.
* suffix functions: leading dot is not delimiterKaz Kylheku2021-06-261-13/+23
| | | | | | | | | | * stream.c (short_suffix, long_suffix): Do not treat the starting dot of the last componet as a suffix delimiter. * tests/018/path.tl: Test cases edited to reflect requirements change; new tests added. * txr.1: Updated.
* signals: disable stack overflow in handler.Kaz Kylheku2021-06-241-0/+11
| | | | | | | | | | | * signal.c (sig_handler): For a is_cpu_exception signal, we temporarily disable the stack limit. It might be executing on the sigaltstack buffer, which is almost certainly below the stack limit. * tests/012/stack.tl: New test case. We raise a SIGSEGV and check that in the handler, the stack limit is disabled, and that we can executed code.
* txr: stack protection in pattern language.Kaz Kylheku2021-06-242-0/+9
| | | | | | | | | * txr.c (do_match_line, match_files): call gc_stack_check on entry. * tests/012/stack2.txr: New file. * tests/012/stack2.expected: New file.
* Test for stack overflow protection.Kaz Kylheku2021-06-242-0/+34
| | | | | | * tests/012/stack.tl: New file. * tets/common.tl (mvtest): New macro.
* matcher: new looping macros.Kaz Kylheku2021-06-241-0/+25
| | | | | | | | | | | | | | * lisplib.c (match_set_entries): Autoload on new while-match, while-match-case and while-true-match-case symbols. * share/txr/stdlib/match.tl (while-match, while-match-case, while-true-match-case): New macros. * tests/011/patmatch.tl: Tests. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated.
* short-suffix, long-suffix: no match across slash.Kaz Kylheku2021-06-221-0/+26
| | | | | | | | | | | * stream.c (short_suffix, long_suffix): Take path separator characters into account; the suffix must not span across separators. The trailing separator must also not appear in the suffix. * tests/018/path.tl: Test cases added. * txr.1: Redocumented.
* lib: rmismatch tests and bugfix.Kaz Kylheku2021-06-221-0/+39
| | | | | | | * lib.c (rmismatch): when left is an empty string or vector, and right is nil: we must return -1 not zero. * tests/012/seq.tl: More rmismatch tests.
* lib: optimize mismatch, rmismatch for strings.Kaz Kylheku2021-06-221-0/+49
| | | | | | | | | | | * lib (mismatch, rmismatch): If the arguments are strings or literals, other than lazy strings, keyfun is identity, and equality is by character identity, the operation can be done with an efficient loop over the wchar_t strings. * tests/012/seq.tl: Tests for string case of mismatch, via starts-with function. Test mismatch via ends-with, and also directly for vectors and strings.
* New functions: long-suffix, short-suffix.Kaz Kylheku2021-06-221-0/+34
| | | | | | | | | | | | | | * stream.c (short_suffix, long_suffix): New functions. (stream_init): short-suffix and long-suffix intrinsics registered. * stream.c (short_suffix, long_suffix): Declared. * tests/018/path.tl: New file. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated.
* Dubious new functions cxr/cyr.Kaz Kylheku2021-06-211-0/+14
| | | | | | | | | | | | | | * lib.c (cxr, cyr): New functions. * lib.h (cxr, cyr): Declared. * eval.c (eval_init): Intrinsics cxr and cyr registered. * tests/012/cadr.tl: New file. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated.
* subprocesses: cygwin fixes.Kaz Kylheku2021-06-201-3/+9
| | | | | | | | | | | | | | * stream.c (fds_subst, fds_swizzle, fds_restore): These functions are used on Cygwin by some functions that are based on spawn, and so must be avaiable. * tests/018/process.tl: Two fixes here. Firstly, the 1>&1 redirection in one of the tests should be 1>&2 on all platforms. That a temporary edit left behind from massaging the tests and the code. Secondly, some weird results are observed on Cygwin. The communication with the child sees an extra carriage return and space sneak in. I'm just codifying this as Cygwin's way of passing the test case; it's likely unfixable at the application level.
* subprocesses: a few test cases.Kaz Kylheku2021-06-201-0/+18
| | | | * tests/018/process.tl: New file.
* read/get-json: reject trailing junk in string input.Kaz Kylheku2021-06-202-1/+73
| | | | | | | | | | | | | | | | | * parser.c (lisp_parse_impl): If parsing from string, check for trailing junk and diagnose. JSON parsing doesn't use lookahead because it doesn't have a.b syntax, so the recent_tok gives the last token that actually went into the syntax, and not a lookahead token. So in the case of JSON, we call yylex to see if there is any trailing token. * tests/010/json.tl: Extend get-json tests to more kinds of objects, and then replicate with trailing whitespace and trailing junk to provide coverage for these cases. * tests/012/parse.t: Slew of new read tests and iread also. * txr.1: Documented.
* op: tests, and fix (op progn ...) situationKaz Kylheku2021-06-171-0/+71
| | | | | | | | | | * share/txr/stdlib/op.tl (op-expand): For the sake of special processing applied to support the lop operator, the code assumes that the expanded syntax-2 is a list with at least two elements, such that we can do (cddr syntax-2). This is not true for instance in (op progn). * tests/012/op.tl: New file.
* txr-case: upkeep.Kaz Kylheku2021-06-162-0/+13
| | | | | | | | | | | | | | | | | | | * share/txr/stdlib/txr-case.tl (txr-case-impl): If the input is a stream, then convert it to a lazy list of lines, so that running multiple functions against it produces sane, backtracking behavior, like a @(cases) construct. * tests/011/txr-case.expected: Updated. * tests/011/txr-case.txr: Now actually contains a test case for txr-case. * txr.1: Address an issue reported by Paul A. Patience: the input to match-fun, txr-if and txr-when may be a stream. That has always been the case in the implementation. Also document that when the input is a single string, it is treated as a list. Document the new requirement in txr-case that a stream is converted into lazy list of lines.
* math: forbid dubious inequality comparisons.Kaz Kylheku2021-06-151-0/+56
| | | | | | | | | | | | | | | | | | | The issue, reported by Paul A. Patience, is that code like (< 1 "abc") is successfully producing a result. The root cause is that 1 is an iterable object, and so is treated as a sequence opposite to the "abc" operand. We should allow only true sequences in this situation. * arith.c (seq_lt_compat_check): New static function. Checks that neither of two sequences is SEQ_NOTSEQ or SEQ_HASHLIKE. (seq_lt, seq_le): Use seq_lt_compat_check to reject dubious inputs. * txr.1: Minor wording change in the related documentation, removing a gratuitous adjective. * tests/016/arith.tl: Inequality tests.
* expander: bug: atoms in quasiliteral.Kaz Kylheku2021-06-151-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Via macros, atoms can sneak into a quasiliteral which then blow up because they get treated as strings without being converted. Example: (defmacro two () 2) `@(two)xyz` -> ;; error The expansion produces the invalid form, in which the 2 is subsequently treated as a string. (sys:quasi 2 "xyz") On the other hand, symbol macros don't have this problem: (defsymacro two 2) `@{two}xyz` -> "2xyz" The reason is that the (sys:var two) syntax will expand to (sys:var 2), and not 2. The straightforward, consistent fix is to ensure that the first case will also go to (sys:var 2). * eval.c (expand_quasi): If the expanded form is an atom which is not a bindable symbol, wrap it in a sys:var. * tests/012/quasi.tl: Test cases added. Also adding a compilation test for this file, cribbed from patmatch.tl.
* defsymacro: regression: don't expand replacement.Kaz Kylheku2021-06-151-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | This is a regression that was introduced in 191. The change in 191 was trying to prevent defsymacro from being expanded immediately by the expander except in 190 compatibility. Unfortunately, this caused the whole defsymacro block not to be entered unless in 190 compatibility, otherwise taking the common exit which returns form_ex, containing the expanded replacement form. * eval.c (do_expand): Split up implementation of defvarl and defsymacro. In the defsymacro block, do not do any expanding on entry. Absent of compatibility mode, we just do some sanity checks and pass the entire form through. In 262 compatibility, we do the expansion to obtain form_ex. Then all the previous compat logic is wrapped in that block. * tests/011/macros-3.tl: Add a test case which confirms that symbol macros are lazily expanded. Weakness in the test suite is how these regressions creep in. * txr.1: Improve defsymacro documentation, spelling out clearly that the unexpanded replacement form is associated with the symbol. Eliminate obsolescent text suggesting that defsymacro is evaluated at macro time.