Commit 48f51b0f authored by pfdietz's avatar pfdietz

Added tests for MULTIPLE-VALUE-SETQ, MULTIPLE-VALUE-PROG1

parent 1f5ade69
......@@ -46,6 +46,8 @@
(load "macrolet.lsp")
(load "multiple-value-bind.lsp")
(load "multiple-value-call.lsp") ;; include multiple-value-list
(load "multiple-value-prog1.lsp")
(load "multiple-value-setq.lsp")
(load "nil.lsp")
(load "not-and-null.lsp")
(load "notany.lsp")
......
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sat Oct 19 06:48:02 2002
;;;; Contains: Tests for MULTIPLE-VALUE-PROG1
(in-package :cl-test)
(deftest multiple-value-prog1.1
(multiple-value-prog1 nil)
nil)
(deftest multiple-value-prog1.2
(multiple-value-prog1 '(a b c))
(a b c))
(deftest multiple-value-prog1.3
(multiple-value-prog1 (values-list '(a b c)))
a b c)
(deftest multiple-value-prog1.4
(multiple-value-prog1 (values)))
(deftest multiple-value-prog1.5
(let ((x 0) (y 0))
(multiple-value-prog1 (values x y)
(incf x) (incf y 2)))
0 0)
(deftest multiple-value-prog1.6
(let ((x 0) (y 0))
(multiple-value-call
#'list
(multiple-value-prog1 (values x y)
(incf x) (incf y 2))
x y))
(0 0 1 2))
(deftest multiple-value-prog1.7
(let ((x 0) (y 0))
(multiple-value-call
#'list
(multiple-value-prog1 (values (incf x) y)
(incf x x)
(incf y 10))
x y))
(1 0 2 10))
#|
(deftest multiple-value-prog1.8
(let* ((n (min 100 multiple-values-limit)))
(not
(loop for i from 0 below n
for x = (make-int-list i)
always
(equalt
(multiple-value-list
(eval `(multiple-value-prog1 (values-list (quote ,(copy-seq x)))
nil)))
x))))
nil)
|#
(deftest multiple-value-prog1.9
(let ((x 0) (y 0))
(values
(block foo
(multiple-value-prog1
(values (incf x) (incf y 2))
(return-from foo 'a)))
x y))
a 1 2)
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sat Oct 19 07:00:57 2002
;;;; Contains: Tests of MULTIPLE-VALUE-SETQ
(in-package :cl-test)
(deftest multiple-value-setq.1
(let ((x 1) (y 2))
(values
(multiple-value-list
(multiple-value-setq (x y) (values 3 4)))
x y))
(3) 3 4)
(deftest multiple-value-setq.2
(let (x)
(multiple-value-setq (x) (values 1 2))
x)
1)
(deftest multiple-value-setq.3
(let (x)
(symbol-macrolet ((y x))
(multiple-value-setq (y) (values 1 2))
x))
1)
(deftest multiple-value-setq.4
(let ((x (list nil)))
(symbol-macrolet ((y (car x)))
(multiple-value-setq (y) (values 1 2))
x))
(1))
;;; test of order of evaluation
;;; The (INCF I) should be evaluated before the assigned form I.
(deftest multiple-value-setq.5
(let ((i 0) (x (list nil)))
(symbol-macrolet ((y (car (progn (incf i) x))))
(multiple-value-setq (y) i))
x)
(1))
(deftest multiple-value-setq.6
(let ((x (list nil)) z)
(symbol-macrolet ((y (car x)))
(multiple-value-setq (y z) (values 1 2)))
(values x z))
(1) 2)
(deftest multiple-value-setq.7
(let ((x (list nil)) (z (list nil)))
(symbol-macrolet ((y (car x))
(w (car z)))
(multiple-value-setq (y w) (values 1 2)))
(values x z))
(1) (2))
;;; Another order of evaluation tests, this time with two
;;; symbol macro arguments
(deftest multiple-value-setq.8
(let ((x (list nil)) (z (list nil)) (i 0))
(symbol-macrolet ((y (car (progn (incf i 3) x)))
(w (car (progn (incf i i) z))))
(multiple-value-setq (y w) (values i 10)))
(values x z))
(6) (10))
(deftest multiple-value-setq.9
(let (x)
(values
(multiple-value-setq (x x) (values 1 2))
x))
1 2)
(deftest multiple-value-setq.10
(let (x)
(values
(multiple-value-setq (x x) (values 1))
x))
1 nil)
(deftest multiple-value-setq.11
(let ((x 1) (y 2) (z 3))
(multiple-value-setq (x y z) (values))
(values x y z))
nil nil nil)
#|
(deftest multiple-value-setq.12
(let ((n (min 100 multiple-values-limit))
(vars nil)
(result nil))
(loop
for i from 1 below n
for form =
(progn
(push (gensym) vars)
(push i result)
`(let ,vars
(and (eql (multiple-value-setq ,vars (values-list (quote ,result)))
,(car result))
(equal (list ,@vars) (quote ,result)))))
unless (eval form)
collect (list i form)))
nil)
|#
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment