source: trunk/source/tests/ansi-tests/isqrt.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 15:40:09 2003
4;;;; Contains: Tests of ISQRT
5
6(in-package :cl-test)
7
8(compile-and-load "numbers-aux.lsp")
9
10;;; Error tests
11
12(deftest isqrt.error.1
13  (signals-error (isqrt) program-error)
14  t)
15
16(deftest isqrt.error.2
17  (signals-error (isqrt 0 0) program-error)
18  t)
19
20(deftest isqrt.error.3
21  (signals-error (isqrt 0 nil) program-error)
22  t)
23
24(deftest isqrt.error.4
25  (signals-error (isqrt 0 0 0) program-error)
26  t)
27
28(deftest isqrt.error.5
29  (loop for x in *mini-universe*
30        unless (or (and (integerp x) (>= x 0))
31                   (eval `(signals-type-error x ',x (isqrt x))))
32        collect x)
33  nil)
34
35;;; Non-error tests
36
37(deftest isqrt.1
38  (loop for i from 0 to 10000
39        for i2 = (* i i)
40        for s = (isqrt i2)
41        unless (eql s i)
42        collect i)
43  nil)
44
45(deftest isqrt.2
46  (loop for i = (random-from-interval most-positive-fixnum 0)
47        for s = (isqrt i)
48        repeat 1000
49        unless (and (integerp s)
50                    (>= s 0)
51                    (<= (* s s) i)
52                    (> (* (1+ s) (1+ s)) i))
53        collect (list i s))
54  nil)
55
56(deftest isqrt.3
57  (loop for i = (random-from-interval 1000000000000000 0)
58        for s = (isqrt i)
59        repeat 1000
60        unless (and (integerp s)
61                    (>= s 0)
62                    (<= (* s s) i)
63                    (> (* (1+ s) (1+ s)) i))
64        collect (list i s))
65  nil)
Note: See TracBrowser for help on using the repository browser.