multiple-value-list.lsp 1.89 KB
Newer Older
1 2 3 4 5
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Mon Feb 17 06:38:07 2003
;;;; Contains: Tests of MULTIPLE-VALUE-LIST

6

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23

(deftest multiple-value-list.1
  (multiple-value-list 'a)
  (a))

(deftest multiple-value-list.2
  (multiple-value-list (values))
  nil)

(deftest multiple-value-list.3
  (multiple-value-list (values 'a 'b 'c 'd 'e))
  (a b c d e))

(deftest multiple-value-list.4
  (multiple-value-list (values (values 'a 'b 'c 'd 'e)))
  (a))

24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
(deftest multiple-value-list.5
  (multiple-value-list (values 'a))
  (a))

(deftest multiple-value-list.6
  (multiple-value-list (values 'a 'b))
  (a b))

(deftest multiple-value-list.7
  (not
   (loop
    for i from 0 below (min multiple-values-limit 100)
    for x = (make-list i :initial-element 'a)
    always (equal x (multiple-value-list (values-list x)))))
  nil)

40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
;;; Test that explicit calls to macroexpand in subforms
;;; are done in the correct environment

(deftest multiple-value-list.8
  (macrolet
   ((%m (z) z))
   (multiple-value-list (expand-in-current-env (%m 1))))
  (1))

(deftest multiple-value-list.9
  (macrolet
   ((%m (z) z))
   (multiple-value-list (expand-in-current-env (%m (values 1 2 3)))))
  (1 2 3))

;;; Test that the argument is evaluated just once
56

57 58 59 60 61
(deftest multiple-value-list.order.1
  (let ((i 0))
    (values (multiple-value-list (incf i)) i))
  (1) 1)

62 63
;;; Error tests

64
(deftest multiple-value-list.error.1
65
  (signals-error (funcall (macro-function 'multiple-value-list))
sds's avatar
sds committed
66
                 program-error)
67
  t)
sds's avatar
sds committed
68

69
(deftest multiple-value-list.error.2
70
  (signals-error (funcall (macro-function 'multiple-value-list)
sds's avatar
sds committed
71 72
                           '(multiple-value-list nil))
                 program-error)
73
  t)
74 75

(deftest multiple-value-list.error.3
76
  (signals-error (funcall (macro-function 'multiple-value-list)
sds's avatar
sds committed
77 78 79
                           '(multiple-value-list nil)
                           nil nil)
                 program-error)
80
  t)