summaryrefslogtreecommitdiffstats
path: root/tests/012
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2024-10-01 13:38:15 -0700
committerKaz Kylheku <kaz@kylheku.com>2024-10-01 13:38:15 -0700
commit8eeaeb95154d868b9fd201ff9cbf88b1031921cc (patch)
tree3889a2c1beccf43ee7568462e782a7909f78a3a5 /tests/012
parente46abe3ec8b59826842dd5cc9ac3b5381240ec95 (diff)
downloadtxr-8eeaeb95154d868b9fd201ff9cbf88b1031921cc.tar.gz
txr-8eeaeb95154d868b9fd201ff9cbf88b1031921cc.tar.bz2
txr-8eeaeb95154d868b9fd201ff9cbf88b1031921cc.zip
copy: now handles range objects.
Ranges are iterable, denoting abstract sequences. The copy function now copies a range by constructing the array. This is useful when copy is used for the purpose of obtaining a mutable copy. For example, (shuffle 0..100) will now work, returning a shuffled vector of the integers from 0 to 99. * lib.c (copy): Handle RNG case via vec_seq. * tests/012/seq.tl, * tests/012/sort.tl: New test cases. * txr.1: Documented. Documentation for the copy function improved.
Diffstat (limited to 'tests/012')
-rw-r--r--tests/012/seq.tl3
-rw-r--r--tests/012/sort.tl3
2 files changed, 6 insertions, 0 deletions
diff --git a/tests/012/seq.tl b/tests/012/seq.tl
index 5d63fbf5..c831e6c5 100644
--- a/tests/012/seq.tl
+++ b/tests/012/seq.tl
@@ -1621,3 +1621,6 @@
(mtest
[keep-if (lop find "aiueo") "vertebrate" : chr-toupper] "EEAE"
[remove-if (lop find "aiueo") "vertebrate" : chr-toupper] "VRTBRT")
+
+(test
+ (copy 1..10) #(1 2 3 4 5 6 7 8 9))
diff --git a/tests/012/sort.tl b/tests/012/sort.tl
index bca4a3d8..d08bce3a 100644
--- a/tests/012/sort.tl
+++ b/tests/012/sort.tl
@@ -96,3 +96,6 @@
(test
[hist-sort-by upcase-str '("a" "b" "c" "a" "b" "a" "b" "a")] (("A" . 4) ("B" . 3) ("C" . 1)))
+
+(let ((*random-state* (make-random-state 0)))
+ (test (shuffle 1..10) #(4 1 7 6 2 8 3 5 9)))