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

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

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

File size: 2.2 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Thu Sep  4 22:29:09 2003
4;;;; Contains: Tests of SIGNUM
5
6(in-package :cl-test)
7
8(deftest signum.error.1
9  (signals-error (signum) program-error)
10  t)
11
12(deftest signum.error.2
13  (signals-error (signum 1 1) program-error)
14  t)
15
16(deftest signum.error.3
17  (signals-error (signum 1 nil) program-error)
18  t)
19
20(deftest signum.1
21  (signum 0)
22  0)
23
24(deftest signum.2
25  (signum 123)
26  1)
27
28(deftest signum.3
29  (signum -123123)
30  -1)
31
32(deftest signum.4
33  (loop for i in *rationals*
34        for s = (signum i)
35        unless (cond
36                ((zerop i) (eql s 0))
37                ((plusp i) (eql s 1))
38                (t (eql s -1)))
39        collect (list i s))
40  nil)
41
42(deftest signum.5
43  (loop for x in '(0.0s0 0.0f0 0.0d0 0.0l0)
44        for one = (float 1 x)
45        for y = (float 13122 x)
46        for s1 = (signum x)
47        for s2 = (signum y)
48        for s3 = (signum (- y))
49        unless (and (eql s1 x)
50                    (eql s2 one)
51                    (eql s3 (- one)))
52        collect (list x one y s1 s2 s3))
53  nil)
54
55(deftest signum.6
56  (loop
57   for tp in '(short-float single-float double-float long-float)
58   for z = (coerce 0 tp)
59   for mz = (- z)
60   nconc
61   (loop for x in (list z mz)
62         nconc
63         (loop for y in (list z mz)
64               for c = (complex z mz)
65               for s = (signum c)
66               unless (eql c s)
67               collect (list c s))))
68  nil)
69
70(deftest signum.7
71  (loop
72   for tp in '(short-float single-float double-float long-float)
73   for z = (coerce 0 tp)
74   for one = (coerce 1 tp)
75   for onem = (coerce -1 tp)
76   for c1 = (complex one z)
77   for c2 = (complex onem z)
78   for c3 = (complex z one)
79   for c4 = (complex z onem)
80   unless (eql c1 (signum c1))
81   collect (list c1 (signum c1))
82   unless (eql c2 (signum c2))
83   collect (list c2 (signum c2))
84   unless (eql c3 (signum c3))
85   collect (list c3 (signum c3))
86   unless (eql c4 (signum c4))
87   collect (list c4 (signum c4)))
88  nil)
89
90(deftest signum.8
91  (let* ((c (complex 0 1))
92         (s (signum c)))
93    (or (eqlt c s)
94        (eqlt s #c(0.0 1.0))))
95  t)
96
97(deftest signum.9
98  (let* ((c (complex 0 -1))
99         (s (signum c)))
100    (or (eqlt c s)
101        (eqlt s #c(0.0 -1.0))))
102  t)
103
104(deftest signum.10
105  (let* ((c (complex 3/5 4/5))
106         (s (signum c)))
107    (or (eqlt c s)
108        (eqlt s (complex (float 3/5) (float 4/5)))))
109  t)
110
111(deftest signum.11
112  (let ((i 0)) (values (signum (the (integer 1 1) (incf i))) i))
113  1 1)
114
Note: See TracBrowser for help on using the repository browser.