Commit 8f40459a authored by pfdietz's avatar pfdietz

Finish vector printing tests.

parent 9aef3bce
......@@ -1627,4 +1627,32 @@ the condition to go uncaught if it cannot be classified."
(* significand (expt radix (- limit)) sign))
((> exponent limit)
(* significand (expt radix limit) sign))
(t (rational x))))))
\ No newline at end of file
(t (rational x))))))
(defun random-partition (n p)
"Partition n into p numbers, each >= 1. Return list of numbers."
(assert (<= 1 p))
#|
(cond
((= p 1) (list n))
((< n p) (make-list p :initial-element 1))
(t
(let ((n1 (1+ (random (floor n p)))))
(cons n1 (random-partition (- n n1) (1- p)))))))
|#
(cond
((= p 1) (list n))
((= n 0) (make-list p :initial-element 0))
(t (let* ((r (random p))
(n1 (random (1+ n))))
(cond
((= r 0)
(cons n1 (random-partition (- n n1) (1- p))))
((= r (1- p))
(append (random-partition (- n n1) (1- p)) (list n1)))
(t
(let* ((n2 (random (1+ (- n n1))))
(n3 (- n n1 n2)))
(append (random-partition n2 r)
(list n1)
(random-partition n3 (- p 1 r))))))))))
......@@ -279,6 +279,12 @@
:can-fail t)))
nil)
(deftest print.vector.random.4
(loop for v = (make-random-vector (1+ (random 100)))
repeat 1000
nconc (randomly-check-readability v :test #'equalp))
nil)
;;; *print-length* checks
(deftest print.vector.length.1
......@@ -407,5 +413,3 @@
(write-to-string '#(#(a)) :level 1 :readably nil :pretty nil))
"#(#)")
......@@ -159,5 +159,13 @@
(cons (make-random-cons-tree s1)
(make-random-cons-tree (- size s1))))))
\ No newline at end of file
(defun make-random-vector (size)
(if (> size 1)
(let* ((nelems (min (1- size) (1+ (random (max 2 (floor size 4))))))
(sizes (mapcar #'1+ (random-partition (- size nelems 1) nelems))))
(make-array nelems :initial-contents (mapcar #'make-random-vector sizes)))
(rcase
(1 (random-from-seq #(a b c d e f g)))
(1 (- (random 2001) 1000))
(1 (random 1000.0))
)))
......@@ -889,36 +889,6 @@
(integer (let ((x (ash 1 (random *maximum-random-int-bits*))))
(random-from-interval (1+ x) (- x))))
))))
(defun random-partition (n p)
"Partition n into p numbers, each >= 1. Return list of numbers."
(assert (<= 1 p))
#|
(cond
((= p 1) (list n))
((< n p) (make-list p :initial-element 1))
(t
(let ((n1 (1+ (random (floor n p)))))
(cons n1 (random-partition (- n n1) (1- p)))))))
|#
(cond
((= p 1) (list n))
((= n 0) (make-list p :initial-element 0))
(t (let* ((r (random p))
(n1 (random (1+ n))))
(cond
((= r 0)
(cons n1 (random-partition (- n n1) (1- p))))
((= r (1- p))
(append (random-partition (- n n1) (1- p)) (list n1)))
(t
(let* ((n2 (random (1+ (- n n1))))
(n3 (- n n1 n2)))
(append (random-partition n2 r)
(list n1)
(random-partition n3 (- p 1 r))))))))))
(defun make-optimized-lambda-form (form vars var-types opt-decls)
`(lambda ,vars
......
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