Skip to content
Snippets Groups Projects
Commit 0c4b44c5 authored by pfdietz's avatar pfdietz
Browse files

More const fold tests

parent d31bd2e6
No related branches found
No related tags found
No related merge requests found
Showing
with 84 additions and 6 deletions
...@@ -47,6 +47,11 @@ ...@@ -47,6 +47,11 @@
((a . b)(c . d)) ((a . b)(c . d))
3 1 2 3) 3 1 2 3)
(def-fold-test acons.fold.1 (acons 'x 'y nil))
(def-fold-test acons.fold.2 (acons 1 2 '((3 . 4) (5 . 6))))
;;; Error tests
(deftest acons.error.1 (deftest acons.error.1
(signals-error (acons) program-error) (signals-error (acons) program-error)
t) t)
......
...@@ -133,6 +133,8 @@ ...@@ -133,6 +133,8 @@
(a b c d e) (a b c d e)
5 1 2 3 4 5) 5 1 2 3 4 5)
(def-fold-test adjoin.fold.1 (adjoin 'x '(a b c nil d)))
(deftest adjoin.allow-other-keys.1 (deftest adjoin.allow-other-keys.1
(adjoin 'a '(b c) :bad t :allow-other-keys t) (adjoin 'a '(b c) :bad t :allow-other-keys t)
(a b c)) (a b c))
......
...@@ -62,6 +62,11 @@ ...@@ -62,6 +62,11 @@
(let ((i 0)) (values (append (incf i)) i)) (let ((i 0)) (values (append (incf i)) i))
1 1) 1 1)
(def-fold-test append.fold.1 (append '(a b c) nil))
(def-fold-test append.fold.2 (append nil '(x) nil))
;;; Error tests
(deftest append.error.1 (deftest append.error.1
(signals-error (append '(a . b) '(z)) (signals-error (append '(a . b) '(z))
type-error) type-error)
......
...@@ -76,6 +76,12 @@ ...@@ -76,6 +76,12 @@
i)) i))
(a b c) 1) (a b c) 1)
(def-fold-test butlast.fold.1 (butlast '(a b) 1))
(def-fold-test butlast.fold.2 (butlast '(a b c d e f) 3))
(def-fold-test butlast.fold.3 (butlast '(a b c d e f g h i) 7))
;;; Error tests
(deftest butlast.error.1 (deftest butlast.error.1
(signals-error (butlast (copy-tree '(a b c d)) 'a) (signals-error (butlast (copy-tree '(a b c d)) 'a)
type-error) type-error)
......
...@@ -617,3 +617,8 @@ ...@@ -617,3 +617,8 @@
(cons nil (rev-assoc-list (cdr x)))) (cons nil (rev-assoc-list (cdr x))))
(t (t
(acons (cdar x) (caar x) (rev-assoc-list (cdr x)))))) (acons (cdar x) (caar x) (rev-assoc-list (cdr x))))))
(defvar *mapc.6-var* nil)
(defun mapc.6-fun (x)
(push x *mapc.6-var*)
x)
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
(let ((i 0)) (values (cons (incf i) (incf i)) i)) (let ((i 0)) (values (cons (incf i) (incf i)) i))
(1 . 2) 2) (1 . 2) 2)
(def-fold-test cons.fold.1 (cons 'a 'b))
;;; Error tests ;;; Error tests
(deftest cons.error.1 (deftest cons.error.1
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
t)) t))
t) t)
(def-fold-test copy-alist.1 (copy-alist '((a . b) nil (c . d))))
(def-fold-test copy-alist.2 (car (copy-alist '((a . b) nil (c . d)))))
(def-fold-test copy-alist.3 (caddr (copy-alist '((a . b) nil (c . d)))))
;;; Error tests ;;; Error tests
(deftest copy-alist.error.1 (deftest copy-alist.error.1
......
...@@ -34,6 +34,10 @@ ...@@ -34,6 +34,10 @@
i)) i))
(a b c) 1) (a b c) 1)
(def-fold-test copy-tree.fold.1 (copy-tree '(a . b)))
(def-fold-test copy-tree.fold.2 (copy-tree '(a)))
(def-fold-test copy-tree.fold.3 (copy-tree '(a b c d e)))
;;; Error tests ;;; Error tests
(deftest copy-tree.error.1 (deftest copy-tree.error.1
......
...@@ -349,6 +349,8 @@ ...@@ -349,6 +349,8 @@
#'<) #'<)
(3 4)) (3 4))
(def-fold-test intersection.fold.1 (intersection '(a b c d e f) '(d w a x b y)))
;;; Error tests ;;; Error tests
(deftest intersection.error.1 (deftest intersection.error.1
......
...@@ -105,7 +105,10 @@ ...@@ -105,7 +105,10 @@
(progn (setf y (incf i)) (progn (setf y (incf i))
'd)) 'd))
i x y)) i x y))
(a b c) 2 1 2) (a b c) 2 1 2)
(def-fold-test ldiff.fold.1 (ldiff '(a b c) 'x))
(def-fold-test ldiff.fold.2 (let ((x '(a b c))) (ldiff x (cddr x))))
;; Error checking ;; Error checking
......
...@@ -34,6 +34,12 @@ ...@@ -34,6 +34,12 @@
(incf i) (incf i) (incf i) (incf i))) (incf i) (incf i) (incf i) (incf i)))
(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16)) (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16))
(def-fold-test list.fold.1 (list 'a))
(def-fold-test list.fold.2 (list 'a 'b))
(def-fold-test list.fold.3 (list 'a 'b 'c 'd 'e 'f))
;;; LIST* tests
(deftest list*.1 (deftest list*.1
(list* 1 2 3) (list* 1 2 3)
(1 2 . 3)) (1 2 . 3))
...@@ -62,3 +68,7 @@ ...@@ -62,3 +68,7 @@
(incf i) (incf i) (incf i) (incf i) (incf i) (incf i) (incf i) (incf i)
(incf i) (incf i) (incf i) (incf i))) (incf i) (incf i) (incf i) (incf i)))
(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 . 16)) (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 . 16))
(def-fold-test list*.fold.1 (list* 'a 'b))
(def-fold-test list*.fold.2 (list* 'a 'b 'c))
(def-fold-test list*.fold.3 (list* 'a 'b 'c 'd 'e 'f))
...@@ -69,6 +69,10 @@ ...@@ -69,6 +69,10 @@
(a a a a a) (a a a a a)
3 1 2 3) 3 1 2 3)
(def-fold-test make-list.fold.1 (make-list 1))
(def-fold-test make-list.fold.2 (make-list 10 :initial-element 'x))
;;; Error tests
(deftest make-list.error.1 (deftest make-list.error.1
(check-type-error #'make-list (typef 'unsigned-byte)) (check-type-error #'make-list (typef 'unsigned-byte))
......
...@@ -46,11 +46,6 @@ ...@@ -46,11 +46,6 @@
x)) x))
((a a a a a) 3)) ((a a a a a) 3))
(defvar *mapc.6-var* nil)
(defun mapc.6-fun (x)
(push x *mapc.6-var*)
x)
(deftest mapc.6 (deftest mapc.6
(let* ((x (copy-list '(a b c d e f g h))) (let* ((x (copy-list '(a b c d e f g h)))
(xcopy (make-scaffold-copy x))) (xcopy (make-scaffold-copy x)))
...@@ -73,6 +68,8 @@ ...@@ -73,6 +68,8 @@
i x y z)) i x y z))
(a b c) 3 1 2 3) (a b c) 3 1 2 3)
;;; Error tests
(deftest mapc.error.1 (deftest mapc.error.1
(check-type-error #'(lambda (x) (mapc #'identity x)) #'listp) (check-type-error #'(lambda (x) (mapc #'identity x)) #'listp)
nil) nil)
......
...@@ -80,6 +80,11 @@ ...@@ -80,6 +80,11 @@
((a 1) (b 2) (c 3)) ((a 1) (b 2) (c 3))
3 1 2 3) 3 1 2 3)
(def-fold-test mapcar.fold.1 (mapcar 'identity '(a b c d)))
(def-fold-test mapcar.fold.2 (mapcar 'not '(t nil nil t t)))
;;; Error tests
(deftest mapcar.error.1 (deftest mapcar.error.1
(check-type-error #'(lambda (x) (mapcar #'identity x)) #'listp) (check-type-error #'(lambda (x) (mapcar #'identity x)) #'listp)
nil) nil)
......
...@@ -94,6 +94,11 @@ ...@@ -94,6 +94,11 @@
i x y z)) i x y z))
(1 2 3) 3 1 2 3) (1 2 3) 3 1 2 3)
(def-fold-test maplist.fold.1 (maplist 'car '(a b c d e)))
(def-fold-test maplist.fold.2 (maplist #'cadr '(a b c d e)))
;;; Error tests
(deftest maplist.error.1 (deftest maplist.error.1
(check-type-error #'(lambda (x) (maplist #'identity x)) #'listp) (check-type-error #'(lambda (x) (maplist #'identity x)) #'listp)
nil) nil)
......
...@@ -63,6 +63,10 @@ ...@@ -63,6 +63,10 @@
t)) t))
t) t)
(def-fold-test pairlis.fold.1 (pairlis '(a b) '(c d)))
;;; Error tests
(deftest pairlis.error.1 (deftest pairlis.error.1
(signals-error (pairlis) program-error) (signals-error (pairlis) program-error)
t) t)
......
...@@ -41,6 +41,11 @@ ...@@ -41,6 +41,11 @@
i x y)) i x y))
(c b a d e f) 2 1 2) (c b a d e f) 2 1 2)
(def-fold-test revappend.fold.1 (revappend '(x) nil))
(def-fold-test revappend.fold.2 (revappend '(x y z) nil))
;;; Error tests
(deftest revappend.error.1 (deftest revappend.error.1
(signals-error (revappend) program-error) (signals-error (revappend) program-error)
t) t)
......
...@@ -270,6 +270,8 @@ ...@@ -270,6 +270,8 @@
#'<) #'<)
nil) nil)
(def-fold-test set-difference.fold.1 (set-difference '(a b c d e f g h) '(b w h x e y)))
;;; Error tests ;;; Error tests
......
...@@ -313,6 +313,10 @@ ...@@ -313,6 +313,10 @@
#'<) #'<)
nil) nil)
(def-fold-test set-exclusive-or.fold.1 (set-exclusive-or '(a b c d e f) '(b x e y z c)))
;;; Error tests
(deftest set-exclusive-or.error.1 (deftest set-exclusive-or.error.1
(signals-error (set-exclusive-or) program-error) (signals-error (set-exclusive-or) program-error)
t) t)
......
...@@ -116,6 +116,10 @@ ...@@ -116,6 +116,10 @@
(z b c d) (z b c d)
4 1 2 3 4) 4 1 2 3 4)
;;; Const fold tests
(def-fold-test sublis.fold.1 (sublis '((a . b)) '(a x y . a)))
;;; Keyword tests ;;; Keyword tests
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment