diff --git a/ansi-tests/concatenate.lsp b/ansi-tests/concatenate.lsp index 9e154882192060b16ff69be0eb95c953cd81a893..2d87448cca2efa82118249163c605e9814af1762 100644 --- a/ansi-tests/concatenate.lsp +++ b/ansi-tests/concatenate.lsp @@ -194,6 +194,17 @@ (concatenate '(array nil (*))) "") +(deftest concatenate.33 + (do-special-strings + (s "abc" nil) + (assert (string= (concatenate 'string s s s) "abcabcabc")) + (assert (string= (concatenate 'string "xy" s) "xyabc")) + (assert (string= (concatenate 'simple-string s "z" s "w" s) "abczabcwabc")) + (assert (string= (concatenate 'base-string s "z" s "w" s) "abczabcwabc")) + (assert (string= (concatenate 'simple-base-string s "z" s "w" s) "abczabcwabc")) + (assert (string= (concatenate '(vector character) s "z" s "w" s) "abczabcwabc"))) + nil) + (deftest concatenate.order.1 (let ((i 0) w x y z) (values diff --git a/ansi-tests/find-if-not.lsp b/ansi-tests/find-if-not.lsp index 937b1ed3b87758e23fb9ae0a7cbc0d0e82343fcb..c774e4defb3e2c7022487c1f7a309a75ed885a33 100644 --- a/ansi-tests/find-if-not.lsp +++ b/ansi-tests/find-if-not.lsp @@ -484,6 +484,11 @@ (nil #\6) (#\6))) +(deftest find-if-not-string.19 + (do-special-strings + (s "abc1def" nil) + (assert (eql (find-if-not #'alpha-char-p s) #\1))) + nil) ;;; Keyword tests diff --git a/ansi-tests/find-if.lsp b/ansi-tests/find-if.lsp index b0ce49bd1faf74db1af66ac33b961f8cd1a9f848..01bf0f86988d738d2d890fdbe78de0a2e1635547 100644 --- a/ansi-tests/find-if.lsp +++ b/ansi-tests/find-if.lsp @@ -507,6 +507,12 @@ )) #\2 #\4 #\1 #\5) +(deftest find-if-string.20 + (do-special-strings + (s "123a456" nil) + (assert (eql (find-if #'alpha-char-p s) #\a))) + nil) + ;;; Keyword tests (deftest find-if.allow-other-keys.1 diff --git a/ansi-tests/find.lsp b/ansi-tests/find.lsp index 8ebca9b5382e7ca1bb3287cce9406f39008ff9d6..e1360c871b1d2ed14bd27cf95f892ed64d3fe621 100644 --- a/ansi-tests/find.lsp +++ b/ansi-tests/find.lsp @@ -781,6 +781,12 @@ (find #\k "abcdmnop" :test-not #'char>=) #\m) +(deftest find-string.28 + (do-special-strings + (s "abcdef" nil) + (assert (char= (find #\c s :test #'char<) #\d))) + nil) + ;;; Test & test not (defharmless find-list.test-and-test-not.1 diff --git a/ansi-tests/merge.lsp b/ansi-tests/merge.lsp index 6ed2a09a51c63e3dfa86b3bfa04f669ffe879aec..700a91b156ff7b42483c262e9d3f35c5152e4bff 100644 --- a/ansi-tests/merge.lsp +++ b/ansi-tests/merge.lsp @@ -319,6 +319,36 @@ (merge 'string x nil #'char<)) "adgkm") +(deftest merge-string.19 + (do-special-strings + (s "ace" nil) + (assert (string= (merge 'string s (copy-seq "bdf") #'char<) "abcdef"))) + nil) + +(deftest merge-string.20 + (do-special-strings + (s "ace" nil) + (assert (string= (merge 'base-string (copy-seq "bdf") s #'char<) "abcdef"))) + nil) + +(deftest merge-string.21 + (do-special-strings + (s "ace" nil) + (assert (string= (merge 'simple-string s (copy-seq "bdf") #'char<) "abcdef"))) + nil) + +(deftest merge-string.22 + (do-special-strings + (s "ace" nil) + (assert (string= (merge 'simple-base-string s (copy-seq "bdf") #'char<) "abcdef"))) + nil) + +(deftest merge-string.23 + (do-special-strings + (s "ace" nil) + (assert (string= (merge '(vector character) s (copy-seq "bdf") #'char<) "abcdef"))) + nil) + ;;; Tests for bit vectors (deftest merge-bit-vector.1 diff --git a/ansi-tests/nsubstitute-if-not.lsp b/ansi-tests/nsubstitute-if-not.lsp index ecdd43f6b09ed14350cafdee67ea662262a8665b..45849707726a5661675bb9c6060f42f15c800ed7 100644 --- a/ansi-tests/nsubstitute-if-not.lsp +++ b/ansi-tests/nsubstitute-if-not.lsp @@ -244,6 +244,20 @@ result) #(a b z c b)) +(deftest nsubstitute-if-not-vector.32 + (let* ((v1 (copy-seq #(a b c d a b c d a b c d a b c d))) + (v2 (make-array '(8) :displaced-to v1 + :displaced-index-offset 3))) + (nsubstitute-if-not 'x (is-not-eql-p 'c) v2 :count 1)) + #(d a b x d a b c)) + +(deftest nsubstitute-if-not-vector.33 + (let* ((v1 (copy-seq #(a b c d a b c d a b c d a b c d))) + (v2 (make-array '(8) :displaced-to v1 + :displaced-index-offset 3))) + (nsubstitute-if-not 'x (is-not-eql-p 'c) v2 :count 1 :from-end t)) + #(d a b c d a b x)) + ;;; Tests on strings (deftest nsubstitute-if-not-string.1 @@ -381,6 +395,24 @@ result) "abzcb") +(deftest nsubstitute-if-not-string.32 + (do-special-strings + (s "xyzabcxyzabc" nil) + (assert (string= (nsubstitute-if-not #\! (is-not-eql-p #\a) s) "xyz!bcxyz!bc"))) + nil) + +(deftest nsubstitute-if-not-string.33 + (do-special-strings + (s "xyzabcxyzabc" nil) + (assert (string= (nsubstitute-if-not #\! (is-not-eql-p #\a) s :count 1) "xyz!bcxyzabc"))) + nil) + +(deftest nsubstitute-if-not-string.34 + (do-special-strings + (s "xyzabcxyzabc" nil) + (assert (string= (nsubstitute-if-not #\! (is-not-eql-p #\a) s :count 1 :from-end t) "xyzabcxyz!bc"))) + nil) + ;;; Tests on bit-vectors diff --git a/ansi-tests/nsubstitute-if.lsp b/ansi-tests/nsubstitute-if.lsp index a9347b58714cbc6de74f3f0cd87d1fe2e01a6f0c..8d2888241ff7e36094725e1dca34cecf724cae59 100644 --- a/ansi-tests/nsubstitute-if.lsp +++ b/ansi-tests/nsubstitute-if.lsp @@ -243,6 +243,26 @@ result) #(a b z c b)) +(deftest nsubstitute-if-vector.32 + (let* ((v1 (copy-seq #(a b c d a b c d a b c d a b c d))) + (v2 (make-array '(8) :displaced-to v1 + :displaced-index-offset 3))) + (values + (nsubstitute-if 'x (is-eql-p 'c) v2 :count 1) + v1)) + #(d a b x d a b c) + #(a b c d a b x d a b c d a b c d)) + +(deftest nsubstitute-if-vector.33 + (let* ((v1 (copy-seq #(a b c d a b c d a b c d a b c d))) + (v2 (make-array '(8) :displaced-to v1 + :displaced-index-offset 3))) + (values + (nsubstitute-if 'x (is-eql-p 'c) v2 :count 1 :from-end t) + v1)) + #(d a b c d a b x) + #(a b c d a b c d a b x d a b c d)) + ;;; Tests on strings (deftest nsubstitute-if-string.1 @@ -379,6 +399,27 @@ result) "abzcb") +(deftest nsubstitute-if-string.32 + (do-special-strings + (s "xyzabcxyzabc" nil) + (assert (string= (nsubstitute-if #\! (is-eql-p #\a) s) "xyz!bcxyz!bc")) + (assert (string= s "xyz!bcxyz!bc"))) + nil) + +(deftest nsubstitute-if-string.33 + (do-special-strings + (s "xyzabcxyzabc" nil) + (assert (string= (nsubstitute-if #\! (is-eql-p #\a) s :count 1) "xyz!bcxyzabc")) + (assert (string= s "xyz!bcxyzabc"))) + nil) + +(deftest nsubstitute-if-string.34 + (do-special-strings + (s "xyzabcxyzabc" nil) + (assert (string= (nsubstitute-if #\! (is-eql-p #\a) s :count 1 :from-end t) "xyzabcxyz!bc")) + (assert (string= s "xyzabcxyz!bc"))) + nil) + ;;; Tests on bit-vectors diff --git a/ansi-tests/nsubstitute.lsp b/ansi-tests/nsubstitute.lsp index 51b6fe784b148cddd21d691caf89a2db10608450..0ae765bd36e7bec83f334aac9bb3628cb4026970 100644 --- a/ansi-tests/nsubstitute.lsp +++ b/ansi-tests/nsubstitute.lsp @@ -805,6 +805,27 @@ result) #((a 1) (a 10) (a 3) (a 10) (a 10) (a 6) (a 10))) +(deftest nsubstitute-vector.32 + (let* ((v1 (copy-seq #(a b c d a b c d a b c d a b c d))) + (v2 (make-array '(8) :displaced-to v1 + :displaced-index-offset 3))) + (values + (nsubstitute 'x 'c v2 :count 1) + v1)) + #(d a b x d a b c) + #(a b c d a b x d a b c d a b c d)) + +(deftest nsubstitute-vector.33 + (let* ((v1 (copy-seq #(a b c d a b c d a b c d a b c d))) + (v2 (make-array '(8) :displaced-to v1 + :displaced-index-offset 3))) + (values + (nsubstitute 'x 'c v2 :count 1 :from-end t) + v1)) + #(d a b c d a b x) + #(a b c d a b c d a b x d a b c d)) + + (deftest nsubstitute-string.24 (let* ((orig "0102342015") (x (copy-seq orig)) @@ -833,6 +854,29 @@ result) "0a0aaaa0aa") +(deftest nsubstitute-string.32 + (do-special-strings + (s "xyzabcxyzabc" nil) + (assert (string= (nsubstitute #\! #\a s) "xyz!bcxyz!bc")) + (assert (string= s "xyz!bcxyz!bc"))) + nil) + +(deftest nsubstitute-string.33 + (do-special-strings + (s "xyzabcxyzabc" nil) + (assert (string= (nsubstitute #\! #\a s :count 1) "xyz!bcxyzabc")) + (assert (string= s "xyz!bcxyzabc"))) + nil) + +(deftest nsubstitute-string.34 + (do-special-strings + (s "xyzabcxyzabc" nil) + (assert (string= (nsubstitute #\! #\a s :count 1 :from-end t) "xyzabcxyz!bc")) + (assert (string= s "xyzabcxyz!bc"))) + nil) + +;;; More bit vector tests + (deftest nsubstitute-bit-vector.30 (let* ((x (make-array '(10) :initial-contents '(0 1 0 1 1 0 1 1 0 1) :fill-pointer 5 :element-type 'bit)) diff --git a/ansi-tests/remove.lsp b/ansi-tests/remove.lsp index 27e651e8b6f304d6ea889e04f956259d400c2c75..ec11fbebe41f7e9fc9c138a923fb4716c81a5817 100644 --- a/ansi-tests/remove.lsp +++ b/ansi-tests/remove.lsp @@ -323,6 +323,20 @@ (remove #\a (copy-seq "bcd") :count -1) "bcd") +(deftest remove-string.4 + (do-special-strings + (s "abcdbad" nil) + (let ((s2 (remove #\b s))) + (assert (equal (array-element-type s) (array-element-type s2))) + (assert (string= s2 "acdad"))) + (let ((s2 (remove #\b s :count 1))) + (assert (equal (array-element-type s) (array-element-type s2))) + (assert (string= s2 "acdbad"))) + (let ((s2 (remove #\b s :count 1 :from-end t))) + (assert (equal (array-element-type s) (array-element-type s2))) + (assert (string= s2 "abcdad")))) + nil) + (deftest delete-vector.1 (delete 'a (vector 'b 'c 'd)) #(b c d)) @@ -347,6 +361,30 @@ (delete #\a (copy-seq "bcd") :count -1) "bcd") +(deftest delete-string.4 + (do-special-strings + (s "abcdbad" nil) + (let ((s2 (delete #\b s))) + (assert (equal (array-element-type s) (array-element-type s2))) + (assert (string= s2 "acdad")))) + nil) + +(deftest delete-string.5 + (do-special-strings + (s "abcdbad" nil) + (let ((s2 (delete #\b s :count 1))) + (assert (equal (array-element-type s) (array-element-type s2))) + (assert (string= s2 "acdbad")))) + nil) + +(deftest delete-string.6 + (do-special-strings + (s "abcdbad" nil) + (let ((s2 (delete #\b s :count 1 :from-end t))) + (assert (equal (array-element-type s) (array-element-type s2))) + (assert (string= s2 "abcdad")))) + nil) + (deftest remove-bit-vector.1 (remove 0 (copy-seq #*00011101101)) #*111111) @@ -865,3 +903,120 @@ (deftest delete.error.10 (signals-error (delete 'a (list 'a 'b 'c) :key #'car) type-error) t) + +;;; More specialized string tests + +(deftest remove-if-string.1 + (do-special-strings + (s "ab1c23def4" nil) + (let ((s2 (remove-if #'alpha-char-p s))) + (assert (equal (array-element-type s) + (array-element-type s2))) + (assert (string= s2 "1234")) + (assert (string= s "ab1c23def4")))) + nil) + +(deftest remove-if-string.2 + (do-special-strings + (s "ab1c23def4" nil) + (let ((s2 (remove-if #'alpha-char-p s :count 3))) + (assert (equal (array-element-type s) + (array-element-type s2))) + (assert (string= s2 "123def4")) + (assert (string= s "ab1c23def4")))) + nil) + +(deftest remove-if-string.3 + (do-special-strings + (s "ab1c23def4" nil) + (let ((s2 (remove-if #'alpha-char-p s :count 3 :from-end t))) + (assert (equal (array-element-type s) + (array-element-type s2))) + (assert (string= s2 "ab1c234")) + (assert (string= s "ab1c23def4")))) + nil) + +(deftest remove-if-not-string.1 + (do-special-strings + (s "ab1c23def4" nil) + (let ((s2 (remove-if-not #'digit-char-p s))) + (assert (equal (array-element-type s) + (array-element-type s2))) + (assert (string= s2 "1234")) + (assert (string= s "ab1c23def4")))) + nil) + +(deftest remove-if-not-string.2 + (do-special-strings + (s "ab1c23def4" nil) + (let ((s2 (remove-if-not #'digit-char-p s :count 3))) + (assert (equal (array-element-type s) + (array-element-type s2))) + (assert (string= s2 "123def4")) + (assert (string= s "ab1c23def4")))) + nil) + +(deftest remove-if-not-string.3 + (do-special-strings + (s "ab1c23def4" nil) + (let ((s2 (remove-if-not #'digit-char-p s :count 3 :from-end t))) + (assert (equal (array-element-type s) + (array-element-type s2))) + (assert (string= s2 "ab1c234")) + (assert (string= s "ab1c23def4")))) + nil) + + +(deftest delete-if-string.1 + (do-special-strings + (s "ab1c23def4" nil) + (let ((s2 (delete-if #'alpha-char-p s))) + (assert (equal (array-element-type s) + (array-element-type s2))) + (assert (string= s2 "1234")))) + nil) + +(deftest delete-if-string.2 + (do-special-strings + (s "ab1c23def4" nil) + (let ((s2 (delete-if #'alpha-char-p s :count 3))) + (assert (equal (array-element-type s) + (array-element-type s2))) + (assert (string= s2 "123def4")))) + nil) + +(deftest delete-if-string.3 + (do-special-strings + (s "ab1c23def4" nil) + (let ((s2 (delete-if #'alpha-char-p s :count 3 :from-end t))) + (assert (equal (array-element-type s) + (array-element-type s2))) + (assert (string= s2 "ab1c234")))) + nil) + +(deftest delete-if-not-string.1 + (do-special-strings + (s "ab1c23def4" nil) + (let ((s2 (delete-if-not #'digit-char-p s))) + (assert (equal (array-element-type s) + (array-element-type s2))) + (assert (string= s2 "1234")))) + nil) + +(deftest delete-if-not-string.2 + (do-special-strings + (s "ab1c23def4" nil) + (let ((s2 (delete-if-not #'digit-char-p s :count 3))) + (assert (equal (array-element-type s) + (array-element-type s2))) + (assert (string= s2 "123def4")))) + nil) + +(deftest delete-if-not-string.3 + (do-special-strings + (s "ab1c23def4" nil) + (let ((s2 (delete-if-not #'digit-char-p s :count 3 :from-end t))) + (assert (equal (array-element-type s) + (array-element-type s2))) + (assert (string= s2 "ab1c234")))) + nil) diff --git a/ansi-tests/replace.lsp b/ansi-tests/replace.lsp index 2bbf7c828b1dde7e7b4bf0b93b9801ca3d9a88b7..aed081d5896790d2b0531a5cd889aefc3203ff16 100644 --- a/ansi-tests/replace.lsp +++ b/ansi-tests/replace.lsp @@ -586,6 +586,45 @@ t "aabcef") +(deftest replace-string.22 + (do-special-strings + (s "abcdefg" nil) + (assert (eq s (replace s "XYZ"))) + (assert (string= s "XYZdefg"))) + nil) + +(deftest replace-string.23 + (do-special-strings + (s "abcdefg" nil) + (assert (eq s (replace s "XYZ" :start1 1))) + (assert (string= s "aXYZefg"))) + nil) + +(deftest replace-string.24 + (do-special-strings + (s "abcdefg" nil) + (assert (eq s (replace s "XYZ" :start1 1 :end2 2))) + (assert (string= s "aXYdefg"))) + nil) + +(deftest replace-string.25 + (do-special-strings + (s "abcdefg" nil) + (assert (eq s (replace s "XYZ" :end1 2))) + (assert (string= s "XYcdefg"))) + nil) + +(deftest replace-string.26 + (do-special-strings + (s "abcdefg" nil) + (assert (eq s (replace s "XYZ" :start2 1))) + (assert (string= s "YZcdefg"))) + nil) + + + + + ;;; Order of evaluation tests (deftest replace.order.1 diff --git a/ansi-tests/substitute-if-not.lsp b/ansi-tests/substitute-if-not.lsp index d5e6bf6f5c0bf7d63c8c30eb3e1cdce8019cea69..c8c3e5418dab3573441fe5e6e84e1308d68eebef 100644 --- a/ansi-tests/substitute-if-not.lsp +++ b/ansi-tests/substitute-if-not.lsp @@ -276,6 +276,27 @@ result) #(a b z c b)) +(deftest substitute-if-not-vector.32 + (let* ((v1 (copy-seq #(a b c d a b c d a b c d a b c d))) + (v2 (make-array '(8) :displaced-to v1 + :displaced-index-offset 3))) + (values + (substitute-if-not 'x (is-not-eql-p 'c) v2 :count 1) + v1)) + #(d a b x d a b c) + #(a b c d a b c d a b c d a b c d)) + +(deftest substitute-if-not-vector.33 + (let* ((v1 (copy-seq #(a b c d a b c d a b c d a b c d))) + (v2 (make-array '(8) :displaced-to v1 + :displaced-index-offset 3))) + (values + (substitute-if-not 'x (is-not-eql-p 'c) v2 :count 1 :from-end t) + v1)) + #(d a b c d a b x) + #(a b c d a b c d a b c d a b c d)) + + ;;; Tests on strings @@ -667,6 +688,15 @@ result)) "01a2342015") +(deftest substitute-if-not-string.26 + (do-special-strings + (s "xyzabcxyzabc" nil) + (assert (string= (substitute-if-not #\! (is-not-eql-p #\a) s) "xyz!bcxyz!bc")) + (assert (string= (substitute-if-not #\! (is-not-eql-p #\a) s :count 1) "xyz!bcxyzabc")) + (assert (string= (substitute-if-not #\! (is-not-eql-p #\a) s :count 1 :from-end t) "xyzabcxyz!bc")) + (assert (string= s "xyzabcxyzabc"))) + nil) + (deftest substitute-if-not-bitstring.26 (let* ((orig #*00111001011010110) (x (copy-seq orig)) diff --git a/ansi-tests/substitute-if.lsp b/ansi-tests/substitute-if.lsp index fd74d85f0469e4e76b6ac47b442074d9477d7261..b0868389aa7ceabb92ebbf986ca9d0b093f893ac 100644 --- a/ansi-tests/substitute-if.lsp +++ b/ansi-tests/substitute-if.lsp @@ -292,6 +292,26 @@ result) #(a b z c b)) +(deftest substitute-if-vector.32 + (let* ((v1 (copy-seq #(a b c d a b c d a b c d a b c d))) + (v2 (make-array '(8) :displaced-to v1 + :displaced-index-offset 3))) + (values + (substitute-if 'x (is-eql-p 'c) v2 :count 1) + v1)) + #(d a b x d a b c) + #(a b c d a b c d a b c d a b c d)) + +(deftest substitute-if-vector.33 + (let* ((v1 (copy-seq #(a b c d a b c d a b c d a b c d))) + (v2 (make-array '(8) :displaced-to v1 + :displaced-index-offset 3))) + (values + (substitute-if 'x (is-eql-p 'c) v2 :count 1 :from-end t) + v1)) + #(d a b c d a b x) + #(a b c d a b c d a b c d a b c d)) + ;;; Tests on strings (deftest substitute-if-string.1 @@ -691,7 +711,18 @@ result)) "01a2342015") -(deftest substitute-if-bit-vector.26 +(deftest substitute-if-string.26 + (do-special-strings + (s "xyzabcxyzabc" nil) + (assert (string= (substitute-if #\! (is-eql-p #\a) s) "xyz!bcxyz!bc")) + (assert (string= (substitute-if #\! (is-eql-p #\a) s :count 1) "xyz!bcxyzabc")) + (assert (string= (substitute-if #\! (is-eql-p #\a) s :count 1 :from-end t) "xyzabcxyz!bc")) + (assert (string= s "xyzabcxyzabc"))) + nil) + +;;; More bit vector tests + +(deftest substitute-if-bit-vector.22 (let* ((orig #*00111001011010110) (x (copy-seq orig)) (result (substitute-if 1 (is-eql-p 1) x :key #'1+))) @@ -699,7 +730,7 @@ result)) #*11111111111111111) -(deftest substitute-if-bit-vector.27 +(deftest substitute-if-bit-vector.23 (let* ((orig #*00111001011010110) (x (copy-seq orig)) (result (substitute-if 1 (is-eql-p 1) x :key #'1+ :start 1 :end 10))) @@ -707,34 +738,36 @@ result)) #*01111111111010110) -(deftest substitute-if-bit-vector.30 +(deftest substitute-if-bit-vector.24 (let* ((x (make-array '(10) :initial-contents '(0 1 0 1 1 0 1 1 0 1) :fill-pointer 5 :element-type 'bit)) (result (substitute-if 1 #'zerop x))) result) #*11111) -(deftest substitute-if-bit-vector.31 +(deftest substitute-if-bit-vector.25 (let* ((x (make-array '(10) :initial-contents '(0 1 0 1 1 0 1 1 0 1) :fill-pointer 5 :element-type 'bit)) (result (substitute-if 1 #'zerop x :from-end t))) result) #*11111) -(deftest substitute-if-bit-vector.32 +(deftest substitute-if-bit-vector.26 (let* ((x (make-array '(10) :initial-contents '(0 1 0 1 1 0 1 1 0 1) :fill-pointer 5 :element-type 'bit)) (result (substitute-if 1 #'zerop x :count 1))) result) #*11011) -(deftest substitute-if-bit-vector.33 +(deftest substitute-if-bit-vector.27 (let* ((x (make-array '(10) :initial-contents '(0 1 0 1 1 0 1 1 0 1) :fill-pointer 5 :element-type 'bit)) (result (substitute-if 1 #'zerop x :from-end t :count 1))) result) #*01111) +;;; Order of evaluation tests + (deftest substitute-if.order.1 (let ((i 0) a b c d e f g h) (values diff --git a/ansi-tests/substitute.lsp b/ansi-tests/substitute.lsp index efd99b5d926b4d5cc1427ae8f75371011c89d6a8..7526f6de50d2fd9fef61f5042adf5f5608494617 100644 --- a/ansi-tests/substitute.lsp +++ b/ansi-tests/substitute.lsp @@ -435,6 +435,26 @@ result) #(a b z c b)) +(deftest substitute-vector.32 + (let* ((v1 (copy-seq #(a b c d a b c d a b c d a b c d))) + (v2 (make-array '(8) :displaced-to v1 + :displaced-index-offset 3))) + (values + (substitute 'x 'c v2 :count 1) + v1)) + #(d a b x d a b c) + #(a b c d a b c d a b c d a b c d)) + +(deftest substitute-vector.33 + (let* ((v1 (copy-seq #(a b c d a b c d a b c d a b c d))) + (v2 (make-array '(8) :displaced-to v1 + :displaced-index-offset 3))) + (values + (substitute 'x 'c v2 :count 1 :from-end t) + v1)) + #(d a b c d a b x) + #(a b c d a b c d a b c d a b c d)) + ;;; Tests on strings (deftest substitute-string.1 @@ -682,6 +702,15 @@ result) "abzcb") +(deftest substitute-string.32 + (do-special-strings + (s "xyzabcxyzabc" nil) + (assert (string= (substitute #\! #\a s) "xyz!bcxyz!bc")) + (assert (string= (substitute #\! #\a s :count 1) "xyz!bcxyzabc")) + (assert (string= (substitute #\! #\a s :count 1 :from-end t) "xyzabcxyz!bc")) + (assert (string= s "xyzabcxyzabc"))) + nil) + ;;; Tests on bit-vectors (deftest substitute-bit-vector.1