source: trunk/source/tests/ansi-tests/make-random-state.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.6 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sat Sep  6 17:53:30 2003
4;;;; Contains: Tests of MAKE-RANDOM-STATE
5
6(in-package :cl-test)
7
8;;; Error tests
9
10(deftest make-random-state.error.1
11  (signals-error (make-random-state nil nil) program-error)
12  t)
13
14(deftest make-random-state.error.2
15  (signals-error (make-random-state t nil) program-error)
16  t)
17
18(deftest make-random-state.error.3
19  (signals-error (make-random-state *random-state* nil) program-error)
20  t)
21
22(deftest make-random-state.error.4
23  (check-type-error #'make-random-state (typef '(or (member nil t) random-state)))
24  nil)
25
26;;; Non-error tests
27
28(deftest make-random-state.1
29  (let ((rs (make-random-state)))
30    (and (not (eq rs *random-state*))
31         (random-state-p rs)
32         (eqlt (random 1000000) (random 1000000 rs))))
33  t)
34
35(deftest make-random-state.2
36  (let ((rs (make-random-state *random-state*)))
37    (and (not (eq rs *random-state*))
38         (random-state-p rs)
39         (eqlt (random 1000000) (random 1000000 rs))))
40  t)
41
42(deftest make-random-state.3
43  (let ((rs (make-random-state)))
44    (random 10)
45    (let ((rs2 (make-random-state rs)))
46      (and (not (eq rs *random-state*))
47           (not (eq rs rs2))
48           (not (eq rs2 *random-state*))
49           (random-state-p rs)
50           (random-state-p rs2)
51           (eqlt (random 1.0 rs) (random 1.0 rs2)))))
52  t)
53
54(deftest make-random-state.4
55  (let ((rs (make-random-state t))
56        (rs2 (make-random-state t)))
57    (and (random-state-p rs)
58         (not (eq rs *random-state*))
59         (random-state-p rs2)
60         (not (eq rs2 *random-state*))
61         (not (eq rs rs2))
62         (integerp (random 10 rs))
63         (floatp (random 1.0 rs2))
64         t))
65  t)
66
67 
Note: See TracBrowser for help on using the repository browser.