source: trunk/source/tests/ansi-tests/lcm.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.1 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Thu Sep  4 22:03:21 2003
4;;;; Contains: Tests of LCM
5
6(in-package :cl-test)
7
8(compile-and-load "numbers-aux.lsp")
9(compile-and-load "gcd-aux.lsp")
10
11(deftest lcm.error.1
12  (check-type-error #'lcm #'integerp)
13  nil)
14
15(deftest lcm.1
16  (lcm)
17  1)
18
19(deftest lcm.2
20  (loop for i = (random-fixnum)
21        for a = (abs i)
22        repeat 1000
23        unless (and (eql a (lcm i))
24                    (eql a (lcm 1 i)))
25        collect i)
26  nil)
27
28(deftest lcm.3
29  (loop for i = (random-from-interval 10000000000000000)
30        for a = (abs i)
31        repeat 1000
32        unless (and (eql a (lcm i))
33                    (eql a (lcm i 1)))
34        collect i)
35  nil)
36
37(deftest lcm.4
38  (loop for i = (random-fixnum)
39        for j = (random-fixnum)
40        repeat 1000
41        unless (eql (my-lcm i j) (lcm i j))
42        collect (list i j))
43  nil)
44
45(deftest lcm.5
46  (let ((bound (ash 1 200)))
47    (loop for i = (random-from-interval bound)
48          for j = (random-from-interval bound)
49          repeat 1000
50          unless (eql (my-lcm i j) (lcm i j))
51          collect (list i j)))
52  nil)
53
54(deftest lcm.6
55  (loop for i = (random-fixnum)
56        for j = (random-fixnum)
57        for k = (random-fixnum)
58        repeat 1000
59        unless (eql (my-lcm i (my-lcm j k)) (lcm i j k))
60        collect (list i j k))
61  nil)
62
63(deftest lcm.7
64  (loop for i = (random-fixnum)
65        for j = (random-fixnum)
66        for k = (random-fixnum)
67        for n = (random-fixnum)
68        repeat 1000
69        unless (eql (my-lcm (my-lcm i j) (my-lcm k n)) (lcm i j k n))
70        collect (list i j k n))
71  nil)
72
73(deftest lcm.8
74  (loop for i from 1 to (min 256 (1- call-arguments-limit))
75        always (eql (apply #'lcm (make-list i :initial-element 1)) 1))
76  t)
77
78(deftest lcm.9
79  (lcm 0 0)
80  0)
81
82(deftest lcm.10
83  (lcm 1 0 0)
84  0)
85
86(deftest lcm.11
87  (lcm 0 1 0)
88  0)
89
90(deftest lcm.12
91  (lcm 0 0 1)
92  0)
93
94
95(deftest lcm.order.1
96  (let ((i 0) x y)
97    (values
98     (lcm (progn (setf x (incf i)) 15)
99          (progn (setf y (incf i)) 25))
100     i x y))
101  75 2 1 2)
102
103(deftest lcm.order.2
104  (let ((i 0) x y)
105    (values
106     (lcm (progn (setf x (incf i)) 0)
107          (progn (setf y (incf i)) 10))
108     i x y))
109  0 2 1 2)
110
111(deftest lcm.order.3
112  (let ((i 0))
113    (values
114     (lcm (progn (incf i) 0))
115     i))
116  0 1)
117
118
Note: See TracBrowser for help on using the repository browser.