- (assert (string= (concatenate 'string "foo" " " "bar") "foo bar"))
- (assert (string= (concatenate '(string 7) "foo" " " "bar") "foo bar"))
- (assert-type-error (concatenate '(string 6) "foo" " " "bar"))
- (assert (string= (concatenate '(string 6) "foo" #(#\b #\a #\r)) "foobar"))
- (assert-type-error (concatenate '(string 7) "foo" #(#\b #\a #\r))))
- ;; Non-VECTOR ARRAY types aren't allowed as vector type specifiers.
- (locally
- (declare (optimize safety))
- (assert-type-error (concatenate 'simple-array "foo" "bar"))
- (assert-type-error (map 'simple-array #'identity '(1 2 3)))
- (assert (equalp #(11 13)
- (map '(simple-array fixnum (*)) #'+ '(1 2 3) '(10 11))))
- (assert-type-error (coerce '(1 2 3) 'simple-array))
- (assert-type-error (merge 'simple-array '(1 3) '(2 4) '<))
- (assert (equalp #(3 2 1) (coerce '(3 2 1) '(vector fixnum))))
- (assert-type-error (map 'array #'identity '(1 2 3)))
- (assert-type-error (map '(array fixnum) #'identity '(1 2 3)))
- (assert (equalp #(1 2 3) (coerce '(1 2 3) '(vector fixnum))))
- ;; but COERCE has an exemption clause:
- (assert (string= "foo" (coerce "foo" 'simple-array)))
- ;; ... though not in all cases.
- (assert-type-error (coerce '(#\f #\o #\o) 'simple-array))))
+ (format t "~&~S~%" type-stub)
+ ;; MAKE-SEQUENCE
+ (assert (= (length (make-sequence `(,@type-stub) 10)) 10))
+ (assert (= (length (make-sequence `(,@type-stub 10) 10)) 10))
+ (assert-type-error (make-sequence `(,@type-stub 10) 11))
+ ;; COERCE
+ (assert (= (length (coerce '(0 0 0) `(,@type-stub))) 3))
+ (assert (= (length (coerce #(0 0 0) `(,@type-stub 3))) 3))
+ (assert-type-error (coerce #*111 `(,@type-stub 4)))
+ ;; CONCATENATE
+ (assert (= (length (concatenate `(,@type-stub) #(0 0 0) #*111)) 6))
+ (assert (equalp (concatenate `(,@type-stub) #(0 0 0) #*111)
+ (coerce #(0 0 0 1 1 1) `(,@type-stub))))
+ (assert (= (length (concatenate `(,@type-stub 6) #(0 0 0) #*111)) 6))
+ (assert (equalp (concatenate `(,@type-stub 6) #(0 0 0) #*111)
+ (coerce #(0 0 0 1 1 1) `(,@type-stub 6))))
+ (assert-type-error (concatenate `(,@type-stub 5) #(0 0 0) #*111))
+ ;; MERGE
+ (macrolet ((test (type)
+ `(merge ,type (copy-seq #(0 1 0)) (copy-seq #*111) #'>)))
+ (assert (= (length (test `(,@type-stub))) 6))
+ (assert (equalp (test `(,@type-stub))
+ (coerce #(1 1 1 0 1 0) `(,@type-stub))))
+ (assert (= (length (test `(,@type-stub 6))) 6))
+ (assert (equalp (test `(,@type-stub 6))
+ (coerce #(1 1 1 0 1 0) `(,@type-stub 6))))
+ (assert-type-error (test `(,@type-stub 4))))
+ ;; MAP
+ (assert (= (length (map `(,@type-stub) #'logxor #(0 0 1 1) '(0 1 0 1))) 4))
+ (assert (equalp (map `(,@type-stub) #'logxor #(0 0 1 1) '(0 1 0 1))
+ (coerce #(0 1 1 0) `(,@type-stub))))
+ (assert (= (length (map `(,@type-stub 4) #'logxor #(0 0 1 1) '(0 1 0 1)))
+ 4))
+ (assert (equalp (map `(,@type-stub 4) #'logxor #(0 0 1 1) '(0 1 0 1))
+ (coerce #(0 1 1 0) `(,@type-stub 4))))
+ (assert-type-error (map `(,@type-stub 5) #'logxor #(0 0 1 1) '(0 1 0 1))))
+ ;; some more CONCATENATE tests for strings
+ (locally
+ (declare (optimize safety))
+ (assert (string= (concatenate 'string "foo" " " "bar") "foo bar"))
+ (assert (string= (concatenate '(string 7) "foo" " " "bar") "foo bar"))
+ (assert-type-error (concatenate '(string 6) "foo" " " "bar"))
+ (assert (string= (concatenate '(string 6) "foo" #(#\b #\a #\r)) "foobar"))
+ (assert (string= (concatenate '(string 6) #(#\b #\a #\r) "foo") "barfoo"))
+ (assert-type-error (concatenate '(string 7) "foo" #(#\b #\a #\r))))
+ ;; Non-VECTOR ARRAY types aren't allowed as vector type specifiers.
+ (locally
+ (declare (optimize safety))
+ (assert-type-error (concatenate 'simple-array "foo" "bar"))
+ (assert-type-error (map 'simple-array #'identity '(1 2 3)))
+ (assert (equalp #(11 13)
+ (map '(simple-array fixnum (*)) #'+ '(1 2 3) '(10 11))))
+ (assert-type-error (coerce '(1 2 3) 'simple-array))
+ (assert-type-error (merge 'simple-array (list 1 3) (list 2 4) '<))
+ (assert (equalp #(3 2 1) (coerce '(3 2 1) '(vector fixnum))))
+ (assert-type-error (map 'array #'identity '(1 2 3)))
+ (assert-type-error (map '(array fixnum) #'identity '(1 2 3)))
+ (assert (equalp #(1 2 3) (coerce '(1 2 3) '(vector fixnum))))
+ ;; but COERCE has an exemption clause:
+ (assert (string= "foo" (coerce "foo" 'simple-array)))
+ ;; ... though not in all cases.
+ (assert-type-error (coerce '(#\f #\o #\o) 'simple-array)))))
+
+;; CONCATENATE used to fail for generic sequences for result-type NULL.
+(with-test (:name (concatenate :result-type-null :bug-1162301))
+ (assert (sequence:emptyp (concatenate 'null)))
+
+ (for-every-seq #()
+ '((sequence:emptyp (concatenate 'null seq))
+ (sequence:emptyp (concatenate 'null seq seq))
+ (sequence:emptyp (concatenate 'null seq #()))
+ (sequence:emptyp (concatenate 'null seq ""))))
+
+ (for-every-seq #(1)
+ (mapcar (lambda (form)
+ `(typep (nth-value 1 (ignore-errors ,form)) 'type-error))
+ '((concatenate 'null seq)
+ (concatenate 'null seq seq)
+ (concatenate 'null seq #())
+ (concatenate 'null seq "2")))))