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:
1.4 KB

Line  

1  ;* Mode: Lisp * 

2  ;;;; Author: Paul Dietz 

3  ;;;; Created: Mon Sep 1 14:00:45 2003 

4  ;;;; Contains: Tests of RATIONALIZE 

5  

6  (inpackage :cltest) 

7  

8  (deftest rationalize.error.1 

9  (signalserror (rationalize) programerror) 

10  t) 

11  

12  (deftest rationalize.error.2 

13  (signalserror (rationalize 0 nil) programerror) 

14  t) 

15  

16  (deftest rationalize.error.3 

17  (signalserror (rationalize 0 0) programerror) 

18  t) 

19  

20  (deftest rationalize.error.4 

21  (checktypeerror #'rationalize #'realp) 

22  nil) 

23  

24  (deftest rationalize.1 

25  (loop for x in (loop for r in *reals* 

26  when (or (not (floatp r)) 

27  (<= 1000 (nthvalue 1 (integerdecodefloat r)) 1000)) 

28  collect r) 

29  for r = (rationalize x) 

30  unless (and (rationalp r) 

31  (if (floatp x) 

32  (= (float r x) x) 

33  (eql x r))) 

34  collect (list x r)) 

35  nil) 

36  

37  (deftest rationalize.2 

38  (loop for type in '(shortfloat singlefloat doublefloat longfloat) 

39  collect 

40  (loop for i from 10000 to 10000 

41  for x = (coerce i type) 

42  for r = (rationalize x) 

43  count (not (eql r i)))) 

44  (0 0 0 0)) 

45  

46  (deftest rationalize.3 

47  (loop for type in '(shortfloat singlefloat doublefloat longfloat) 

48  for bound in '(1.0s5 1.0f10 1.0d20 1.0l30) 

49  nconc 

50  (loop for x = (randomfrominterval bound) 

51  for r = (rationalize x) 

52  for x2 = (float r x) 

53  repeat 1000 

54  unless (and (rationalp r) (= x x2)) 

55  collect (list x r x2))) 

56  nil) 

Note: See
TracBrowser
for help on using the repository browser.