GOOPS cosmetics
[bpt/guile.git] / test-suite / tests / random.test
CommitLineData
d7473131
DL
1;;;; random.test --- tests guile's uniform arrays -*- scheme -*-
2;;;;
3;;;; Copyright 2013 Free Software Foundation, Inc.
4;;;;
5;;;; This library is free software; you can redistribute it and/or
6;;;; modify it under the terms of the GNU Lesser General Public
7;;;; License as published by the Free Software Foundation; either
8;;;; version 3 of the License, or (at your option) any later version.
9;;;;
10;;;; This library is distributed in the hope that it will be useful,
11;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13;;;; Lesser General Public License for more details.
14;;;;
15;;;; You should have received a copy of the GNU Lesser General Public
16;;;; License along with this library; if not, write to the Free Software
17;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
19(define-module (test-suite test-random)
20 #:use-module ((system base compile) #:select (compile))
21 #:use-module (test-suite lib)
22 #:use-module (srfi srfi-4)
23 #:use-module (srfi srfi-4 gnu))
24
25; see strings.test, arrays.test.
26(define exception:wrong-type-arg
27 (cons #t "Wrong type"))
28
29;;;
30;;; random:normal-vector!
31;;;
32
33(with-test-prefix "random:normal-vector!"
34
35 ;; FIXME need proper function test.
36
37 (pass-if "non uniform"
38 (let ((a (make-vector 4 0))
39 (b (make-vector 4 0))
40 (c (make-shared-array (make-vector 8 0)
41 (lambda (i) (list (+ 1 (* 2 i)))) 4)))
42 (begin
43 (random:normal-vector! b (random-state-from-platform))
44 (random:normal-vector! c (random-state-from-platform))
45 (and (not (equal? a b)) (not (equal? a c))))))
46
47 (pass-if "uniform (f64)"
48 (let ((a (make-f64vector 4 0))
49 (b (make-f64vector 4 0))
50 (c (make-shared-array (make-f64vector 8 0)
51 (lambda (i) (list (+ 1 (* 2 i)))) 4)))
52 (begin
53 (random:normal-vector! b (random-state-from-platform))
54 (random:normal-vector! c (random-state-from-platform))
55 (and (not (equal? a b)) (not (equal? a c)))))))