Commit 686f9c63 authored by pfdietz's avatar pfdietz

More tests for PHASE, initial checkin of tests for REALPART, IMAGPART.

parent 3c2e6b25
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sun Sep 7 07:47:43 2003
;;;; Contains: Tests of IMAGPART
(in-package :cl-test)
(deftest imagpart.error.1
(classify-error (imagpart))
program-error)
(deftest imagpart.error.2
(classify-error (imagpart #c(1.0 2.0) nil))
program-error)
(deftest imagpart.error.3
(loop for x in *mini-universe*
unless (or (numberp x)
(eq (eval `(classify-error (imagpart ',x))) 'type-error))
collect x)
nil)
(deftest imagpart.1
(loop for x in *reals*
for c = (complex 0 x)
for ip = (imagpart c)
unless (eql x ip)
collect (list x c ip))
nil)
(deftest imagpart.2
(loop for x in *reals*
for c = (complex 1 x)
for ip = (imagpart c)
unless (eql x ip)
collect (list x c ip))
nil)
(deftest imagpart.3
(loop for x in *reals*
for c = (complex x x)
for ip = (imagpart c)
unless (eql x ip)
collect (list x c ip))
nil)
(deftest imagpart.4
(loop for x in *reals*
for ip = (imagpart x)
unless (eql (* 0 x) ip)
collect (list x ip (* 0 x)))
nil)
......@@ -48,6 +48,8 @@
(load "complexp.lsp")
(load "conjugate.lsp")
(load "phase.lsp")
(load "realpart.lsp")
(load "imagpart.lsp")
(load "rational.lsp")
(load "rationalize.lsp")
......
......@@ -99,3 +99,24 @@
(let ((p (phase #c(1.0l0 1.0l0))))
(approx= p (/ pi 4)))
t)
;;; Negative zeros
(deftest phase.18
(or (eqlt -0.0s0 0.0s0)
(approx= (phase #c(-1.0 -0.0)) (coerce (- pi) 'short-float)))
t)
(deftest phase.19
(or (eqlt -0.0f0 0.0f0)
(approx= (phase #c(-1.0 -0.0)) (coerce (- pi) 'single-float)))
t)
(deftest phase.20
(or (eqlt -0.0d0 0.0d0)
(approx= (phase #c(-1.0 -0.0)) (coerce (- pi) 'double-float)))
t)
(deftest phase.21
(or (eqlt -0.0l0 0.0l0)
(approx= (phase #c(-1.0 -0.0)) (coerce (- pi) 'long-float)))
t)
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sun Sep 7 07:41:15 2003
;;;; Contains: Tests of REALPART
(in-package :cl-test)
(deftest realpart.error.1
(classify-error (realpart))
program-error)
(deftest realpart.error.2
(classify-error (realpart #c(1.0 2.0) nil))
program-error)
(deftest realpart.error.3
(loop for x in *mini-universe*
unless (or (numberp x)
(eq (eval `(classify-error (realpart ',x))) 'type-error))
collect x)
nil)
(deftest realpart.1
(loop for x in *reals*
for c = (complex x 0)
for rp = (realpart c)
unless (eql x rp)
collect (list x c rp))
nil)
(deftest realpart.2
(loop for x in *reals*
for c = (complex x 1)
for rp = (realpart c)
unless (eql x rp)
collect (list x c rp))
nil)
(deftest realpart.3
(loop for x in *reals*
for c = (complex x x)
for rp = (realpart c)
unless (eql x rp)
collect (list x c rp))
nil)
;;; Should move this to complex.lsp
(deftest realpart.4
(loop for c in *complexes*
for rp = (realpart c)
for ip = (imagpart c)
for c2 = (complex rp ip)
unless (eql c c2)
collect (list c rp ip c2))
nil)
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