Commit 3ccb26a9 authored by pfdietz's avatar pfdietz
Browse files

Refactor fold tests using a convenient macro.

parent 5463b7bf
......@@ -842,20 +842,11 @@
;;; Constant folding tests
(deftest substitute-if.fold.1
(flet ((%f () (substitute-if 'z 'null '(a nil b))))
(values (%f) (let ((seq (%f))) (setf (elt seq 0) 'd) seq) (%f)))
(a z b) (d z b) (a z b))
(deftest substitute-if.fold.2
(flet ((%f () (substitute-if 'z 'null #(a nil b))))
(values (%f) (let ((seq (%f))) (setf (elt seq 0) 'd) seq) (%f)))
#(a z b) #(d z b) #(a z b))
(deftest substitute-if.fold.3
(flet ((%f () (substitute-if 0 'plusp #*100110)))
(values (%f) (let ((seq (%f))) (setf (elt seq 0) 1) seq) (%f)))
#*000000 #*100000 #*000000)
(def-fold-test substitute-if.fold.1 (substitute-if 'z 'null '(a nil b)))
(def-fold-test substitute-if.fold.2 (substitute-if 'z 'null #(a nil b)))
(def-fold-test substitute-if.fold.3 (substitute-if 0 'plusp #*100110))
(def-fold-test substitute-if.fold.4 (substitute-if #\x 'digit-char-p
"asdf8234n123f"))
;;; Error cases
......
......@@ -1094,35 +1094,10 @@
;;; Constant folding tests
(deftest substitute.fold.1
(flet ((%f () (substitute 'z 'b '(a b c))))
(values
(%f)
(let ((seq (%f))) (setf (elt seq 0) 'd) seq)
(%f)))
(a z c)
(d z c)
(a z c))
(deftest substitute.fold.2
(flet ((%f () (substitute 'z 'b #(a b c))))
(values
(%f)
(let ((seq (%f))) (setf (elt seq 0) 'd) seq)
(%f)))
#(a z c)
#(d z c)
#(a z c))
(deftest substitute.fold.3
(flet ((%f () (substitute 0 1 #*001101)))
(values
(%f)
(let ((seq (%f))) (setf (elt seq 0) 1) seq)
(%f)))
#*000000
#*100000
#*000000)
(def-fold-test substitute.fold.1 (substitute 'z 'b '(a b c)))
(def-fold-test substitute.fold.2 (substitute 'z 'b #(a b c)))
(def-fold-test substitute.fold.3 (substitute 0 1 #*001101))
(def-fold-test substitute.fold.4 (substitute #\a #\b "abcebadfke"))
;;; Error cases
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment