zerop.lsp 2.29 KB
Newer Older
pfdietz's avatar
pfdietz committed
1 2 3 4 5 6 7 8
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Mon Aug  4 21:47:34 2003
;;;; Contains: Tests of ZEROP

(in-package :cl-test)

(deftest zerop.error.1
9 10
  (signals-error (zerop) program-error)
  t)
pfdietz's avatar
pfdietz committed
11 12

(deftest zerop.error.2
13 14
  (signals-error (zerop 0 1) program-error)
  t)
pfdietz's avatar
pfdietz committed
15 16

(deftest zerop.error.3
17 18
  (signals-error (zerop 1 0) program-error)
  t)
pfdietz's avatar
pfdietz committed
19 20

(deftest zerop.error.4
21
  (check-type-error #'zerop #'numberp)
pfdietz's avatar
pfdietz committed
22 23 24 25
  nil)

(deftest zerop.1
  (loop for x in *numbers*
sds's avatar
sds committed
26 27
        when (if (zerop x) (/= x 0) (= x 0))
        collect x)
pfdietz's avatar
pfdietz committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
  nil)

(deftest zerop.2
  (zerop 1)
  nil)

(deftest zerop.3
  (zerop -1)
  nil)

(deftest zerop.4
  (notnot-mv (zerop 0))
  t)

(deftest zerop.5
  (notnot-mv (zerop 0.0s0))
  t)

(deftest zerop.6
  (notnot-mv (zerop 0.0f0))
  t)

(deftest zerop.7
  (notnot-mv (zerop 0.0d0))
  t)

54
(deftest zerop.7a
pfdietz's avatar
pfdietz committed
55 56 57 58 59
  (notnot-mv (zerop 0.0l0))
  t)

(deftest zerop.8
  (remove-if-not #'zerop
sds's avatar
sds committed
60 61 62 63 64 65 66 67 68 69 70 71
                 (list least-negative-short-float
                       least-negative-normalized-short-float
                       least-negative-single-float
                       least-negative-normalized-single-float
                       least-negative-double-float
                       least-negative-normalized-double-float
                       least-negative-long-float
                       least-negative-normalized-long-float
                       most-negative-short-float
                       most-negative-single-float
                       most-negative-double-float
                       most-negative-long-float))
pfdietz's avatar
pfdietz committed
72 73 74 75
  nil)

(deftest zerop.9
  (remove-if-not #'zerop
sds's avatar
sds committed
76 77 78 79 80 81 82 83 84 85 86 87
                 (list least-positive-short-float
                       least-positive-normalized-short-float
                       least-positive-single-float
                       least-positive-normalized-single-float
                       least-positive-double-float
                       least-positive-normalized-double-float
                       least-positive-long-float
                       least-positive-normalized-long-float
                       most-positive-short-float
                       most-positive-single-float
                       most-positive-double-float
                       most-positive-long-float))
pfdietz's avatar
pfdietz committed
88 89 90 91 92 93
  nil)

(deftest zerop.10
  (notevery #'zerop (list -0.0s0 -0.0f0 -0.0d0 -0.0l0))
  nil)