source: trunk/source/tests/ansi-tests/truncate-aux.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: 2.8 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Wed Aug 20 05:15:17 2003
4;;;; Contains: Aux. functions associated with tests of TRUNCATE
5
6(in-package :cl-test)
7
8(defun truncate.1-fn ()
9  (loop for n = (- (random 2000000000)
10                   1000000000)
11        for d = (1+ (random 10000))
12        for vals = (multiple-value-list (truncate n d))
13        for (q r) = vals
14        for n2 = (+ (* q d) r)
15        repeat 1000
16        unless (and (eql (length vals) 2)
17                    (integerp q)
18                    (= n n2)
19                    (integerp r)
20                    (if (>= n 0) (< -1 r d)
21                      (< (- d) r 1)))
22        collect (list n d q r n2)))
23
24(defun truncate.2-fn ()
25  (loop for num = (random 1000000000)
26        for denom = (1+ (random 1000))
27        for n = (/ num denom)
28        for d = (1+ (random 10000))
29        for vals = (multiple-value-list (truncate n d))
30        for (q r) = vals
31        for n2 = (+ (* q d) r)
32        repeat 1000
33        unless (and (eql (length vals) 2)
34                    (integerp q)
35                    (<= 0 r)
36                    (< r d)
37                    (= n n2))
38        collect (list n d q r n2)))
39
40(defun truncate.3-fn (width)
41  (loop for n = (- (random width) (/ width 2))
42        for vals = (multiple-value-list (truncate n))
43        for (q r) = vals
44        for n2 = (+ q r)
45        repeat 1000
46        unless (and (eql (length vals) 2)
47                    (integerp q)
48                    (= n n2)
49                    (if (>= n 0)
50                        (and (<= 0 r) (< r 1))
51                      (and (< -1 r) (<= r 0)))
52                    )
53        collect (list n q r n2)))
54
55(defun truncate.7-fn ()
56  (loop for numerator = (- (random 10000000000) 5000000000)
57        for denominator = (1+ (random 100000))
58        for n = (/ numerator denominator)
59        for vals = (multiple-value-list (truncate n))
60        for (q r) = vals
61        for n2 = (+ q r)
62        repeat 1000
63        unless (and (eql (length vals) 2)
64                    (integerp q)
65                    (rationalp r)
66                    (= n n2)
67                    (if (>= n 0)
68                        (and (<= 0 r) (< r 1))
69                      (and (< -1 r) (<= r 0)))
70                    )
71        collect (list n q r n2)))
72
73(defun truncate.8-fn ()
74  (loop for num1 = (- (random 10000000000) 5000000000)
75        for den1 = (1+ (random 100000))
76        for n = (/ num1 den1)
77        for num2 = (- (1+ (random 1000000)))
78        for den2 = (1+ (random 1000000))
79        for d = (/ num2 den2)
80        for vals = (multiple-value-list (truncate n d))
81        for (q r) = vals
82        for n2 = (+ (* q d) r)
83        repeat 1000
84        unless (and (eql (length vals) 2)
85                    (integerp q)
86                    (rationalp r)
87                    (if (> n 0)
88                        (and (<= 0 r) (< r (- d)))
89                      (and (>= 0 r) (> r d)))
90                    (= n n2))
91        collect (list n q d r n2)))
92
93(defun truncate.9-fn ()
94  (loop for num1 = (- (random 1000000000000000) 500000000000000)
95        for den1 = (1+ (random 10000000000))
96        for n = (/ num1 den1)
97        for num2 = (- (1+ (random 1000000000)))
98        for den2 = (1+ (random 10000000))
99        for d = (/ num2 den2)
100        for vals = (multiple-value-list (truncate n d))
101        for (q r) = vals
102        for n2 = (+ (* q d) r)
103        repeat 1000
104        unless (and (eql (length vals) 2)
105                    (integerp q)
106                    (rationalp r)
107                    (if (> n 0)
108                        (and (<= 0 r) (< r (- d)))
109                      (and (>= 0 r) (> r d)))
110                    (= n n2))
111        collect (list n q d r n2)))
112
113
Note: See TracBrowser for help on using the repository browser.