print-complex.lsp 1.38 KB
Newer Older
1 2 3 4 5 6 7
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Wed Mar  3 06:44:04 2004
;;;; Contains: Tests of printing complex numbers

(in-package :cl-test)

pfdietz's avatar
pfdietz committed
8 9
(compile-and-load "printer-aux.lsp")

10
(deftest print.complex.1
11 12
  (equalt
   (with-standard-io-syntax
13 14
     (let ((*print-readably* nil))
       (with-output-to-string (s) (prin1 (complex 1 2) s))))
15 16 17
   "#C(1 2)")
  t)

18
(deftest print.complex.2
19 20
  (equalt
   (with-standard-io-syntax
21 22
     (let ((*print-readably* nil))
       (with-output-to-string (s) (prin1 (complex 1.0 2.0) s))))
23 24 25
   "#C(1.0 2.0)")
  t)

26
(deftest print.complex.random.1
27
  (loop for numbits = (random 40)
sds's avatar
sds committed
28 29 30 31 32 33
        for bound = (ash 1 numbits)
        for r = (- (random (+ bound bound)) bound)
        for i = (- (random (+ bound bound)) bound)
        repeat 1000
        unless (= i 0)
        nconc (randomly-check-readability (complex r i)))
34 35
  nil)

36
(deftest print.complex.random.2
37
  (loop for numbits = (random 40)
sds's avatar
sds committed
38 39 40 41 42 43 44 45 46 47
        for bound = (ash 1 numbits)
        for num1 = (- (random (+ bound bound)) bound)
        for num2 = (- (random (+ bound bound)) bound)
        for denom1 = (1+ (random bound))
        for denom2 = (1+ (random bound))
        for r = (/ num1 denom1)
        for i = (/ num2 denom2)
        repeat 1000
        unless (= i 0)
        nconc (randomly-check-readability (complex r i)))
48 49 50
  nil)

;; General floating point complex printing tests will go here
sds's avatar
sds committed
51

52 53 54 55 56