diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2023-06-28 22:57:12 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2023-06-28 22:57:12 -0700 |
commit | d7ea45f4c26ff460d062f24f3fbb33c018874dcf (patch) | |
tree | b99849362e2955c4714b09d4a3774d77196317f1 /tests | |
parent | 1c583965749a40cdbe15846c2487f32a426dcbeb (diff) | |
download | txr-d7ea45f4c26ff460d062f24f3fbb33c018874dcf.tar.gz txr-d7ea45f4c26ff460d062f24f3fbb33c018874dcf.tar.bz2 txr-d7ea45f4c26ff460d062f24f3fbb33c018874dcf.zip |
New: callable integers and ranges.
* lib.c (do_generic_funcall): Allow integers and ranges
to be function callable. They take one argument and
index into it or extract a slice. In the case of ranges,
this is a breaking change. Ranges can already be used
in the function position in some limited ways that are
not worth preserving.
* tests/012/callable.tl: New file.
* tests/012/iter.tl: Here we fix two instances of
breakage. Using txr -C 288 will restore the
behaviors previously tested here.
* txr.1: Documented.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/012/callable.tl | 23 | ||||
-rw-r--r-- | tests/012/iter.tl | 4 |
2 files changed, 25 insertions, 2 deletions
diff --git a/tests/012/callable.tl b/tests/012/callable.tl new file mode 100644 index 00000000..0f0e9327 --- /dev/null +++ b/tests/012/callable.tl @@ -0,0 +1,23 @@ +(load "../common") + +(mtest + [0 '(1 2 3)] 1 + [1 '(1 2 3)] 2 + [2 '(1 2 3)] 3) + +(mtest + [0 "abc"] #\a + [1 "abc"] #\b + [2 "abc"] #\c) + +(mtest + [0..1 '(1 2 3)] (1) + [1..3 '(1 2 3)] (2 3)) + +(mtest + [0..0 "abc"] "" + [0..2 "abc"] "ab" + [-1..: "abc"] "c") + +(test (mapcar [callf list* 2 0 1 3..:] '((A B C X) (D E F Y) (G H I Z))) + ((C A B X) (F D E Y) (I G H Z))) diff --git a/tests/012/iter.tl b/tests/012/iter.tl index 9b1db6f5..1b1bfd1e 100644 --- a/tests/012/iter.tl +++ b/tests/012/iter.tl @@ -49,7 +49,7 @@ "D01" "D02" "D03" "D04" "D05" "D10" "D11" "D12" "D13" "D14" "D15" "E01" "E02" "E03" "E04" "E05" "E10" "E11" "E12" "E13" "E14" "E15" "F01" "F02" "F03" "F04" "F05" "F10" "F11" "F12" "F13" "F14" "F15") - [maprod append "A".."F" ["00".."99" 1..11]] + [maprod append "A".."F" [1..11 "00".."99"]] ("A01" "A02" "A03" "A04" "A05" "A06" "A07" "A08" "A09" "A10" "B01" "B02" "B03" "B04" "B05" "B06" "B07" "B08" "B09" "B10" "C01" "C02" "C03" "C04" "C05" "C06" "C07" "C08" "C09" "C10" "D01" "D02" "D03" @@ -58,7 +58,7 @@ "F06" "F07" "F08" "F09" "F10")) (test - [mapcar identity [0..10 3 6]] (3 4 5)) + [mapcar identity [3..6 0..10]] (3 4 5)) ;; iterating from fixnum to bignum was rejected in up to txr-269. (test (each ((x fixnum-max..(* 5 fixnum-max))) (return 42)) 42) |