Change Guile license to LGPLv3+
[bpt/guile.git] / test-suite / tests / vectors.test
1 ;;;; vectors.test --- test suite for Guile's vector functions -*- scheme -*-
2 ;;;;
3 ;;;; Copyright (C) 2003, 2006 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 vectors)
20 :use-module (test-suite lib))
21
22 ;; FIXME: As soon as guile supports immutable vectors, this has to be
23 ;; replaced with the appropriate error type and message.
24 (define exception:immutable-vector
25 (cons 'some-error-type "^trying to modify an immutable vector"))
26
27
28 (with-test-prefix "vector-set!"
29
30 (expect-fail-exception "vector constant"
31 exception:immutable-vector
32 (vector-set! '#(1 2 3) 0 4)))
33
34 (with-test-prefix "vector->list"
35
36 (pass-if "simple vector"
37 (equal? '(1 2 3) (vector->list #(1 2 3))))
38
39 (pass-if "shared array"
40 (let ((b (make-shared-array #(1) (lambda (x) '(0)) 2)))
41 (equal? b (list->vector (vector->list b))))))
42