svref.lsp 1.17 KB
Newer Older
pfdietz's avatar
pfdietz committed
1 2 3 4 5
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Wed Jan 22 21:39:30 2003
;;;; Contains: Tests of SVREF

6

pfdietz's avatar
pfdietz committed
7 8 9 10 11 12 13 14 15 16

(deftest svref.1
  (let ((a (vector 1 2 3 4)))
    (loop for i below 4 collect (svref a i)))
  (1 2 3 4))

(deftest svref.2
  (let ((a (vector 1 2 3 4)))
    (values
     (loop for i below 4
sds's avatar
sds committed
17
           collect (setf (svref a i) (+ i 10)))
pfdietz's avatar
pfdietz committed
18 19 20 21
     a))
  (10 11 12 13)
  #(10 11 12 13))

22 23
(deftest svref.order.1
  (let ((v (vector 'a 'b 'c 'd))
sds's avatar
sds committed
24
        (i 0) a b)
25 26
    (values
     (svref (progn (setf a (incf i)) v)
sds's avatar
sds committed
27
            (progn (setf b (incf i)) 2))
28 29 30 31 32
     i a b))
  c 2 1 2)

(deftest svref.order.2
  (let ((v (vector 'a 'b 'c 'd))
sds's avatar
sds committed
33
        (i 0) a b c)
34 35 36
    (values
     (setf
      (svref (progn (setf a (incf i)) v)
sds's avatar
sds committed
37
             (progn (setf b (incf i)) 2))
38 39 40 41 42
      (progn (setf c (incf i)) 'w))
     v i a b c))
  w #(a b w d) 3 1 2 3)


pfdietz's avatar
pfdietz committed
43 44 45
;;; Error tests

(deftest svref.error.1
46 47
  (signals-error (svref) program-error)
  t)
pfdietz's avatar
pfdietz committed
48 49

(deftest svref.error.2
50 51
  (signals-error (svref (vector 1)) program-error)
  t)
52 53

(deftest svref.error.3
54 55
  (signals-error (svref (vector 1) 0 0) program-error)
  t)
56 57

(deftest svref.error.4
58 59
  (signals-error (svref (vector 1) 0 nil) program-error)
  t)