source: trunk/source/tests/ansi-tests/complex.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 11 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 1.2 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sat Sep  6 19:56:29 2003
4;;;; Contains: Tests of COMPLEX
5
6(in-package :cl-test)
7
8;;; Error tests
9
10(deftest complex.error.1
11  (signals-error (complex) program-error)
12  t)
13
14(deftest complex.error.2
15  (signals-error (complex 1 1 nil) program-error)
16  t)
17
18;;; Non-error tests
19
20(deftest complex.1
21  (loop for x in *rationals*
22        for c = (complex x)
23        always (eql c x))
24  t)
25
26(deftest complex.2
27  (loop for x in *floats*
28        for c = (complex x)
29        always (and (complexp c)
30                    (eql x (realpart c))
31                    (eql (float 0 x) (imagpart c))))
32  t)
33
34(deftest complex.3
35  (loop for x in *rationals*
36        for c = (complex 0 x)
37        unless (or (zerop x)
38                   (and (complexp c)
39                        (eql (realpart c) 0)
40                        (eql (imagpart c) x)))
41        collect (list c x))
42  nil)
43
44(deftest complex.4
45  (loop for x in *floats*
46        for c = (complex 0 x)
47        always (and (complexp c)
48                    (eql (float 0 x) (realpart c))
49                    (eql x (imagpart c))))
50  t)
51
52;;; Tests of some properties of complex numbers
53
54(deftest complex.5
55  (loop for c in *complexes*
56        unless (loop for type in '(short-float single-float double-float long-float)
57                     always (if (typep (realpart c) type)
58                                (typep (imagpart c) type)
59                              (not (typep (imagpart c) type))))
60        collect c)
61  nil)
Note: See TracBrowser for help on using the repository browser.