source: trunk/source/tests/ansi-tests/nth-value.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 11 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 1.5 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sat Oct 19 08:24:14 2002
4;;;; Contains: Tests of NTH-VALUE
5
6(in-package :cl-test)
7
8(deftest nth-value.1
9  (nth-value 0 'a)
10  a)
11
12(deftest nth-value.2
13  (nth-value 1 'a)
14  nil)
15
16(deftest nth-value.3
17  (nth-value 0 (values))
18  nil)
19
20(deftest nth-value.4
21  (loop for i from 0 to 19
22        collect (nth-value i (values 'a 'b 'c 'd 'e 'f 'g 'h 'i 'j 'k
23                                     'l 'm 'n 'o 'p 'q 'r 's)))
24  (a b c d e f g h i j k l m n o p q r s nil))
25
26(deftest nth-value.5
27  (nth-value 100 'a)
28  nil)
29
30;;; Test that explicit calls to macroexpand in subforms
31;;; are done in the correct environment
32
33(deftest nth-value.6
34  (macrolet
35   ((%m (z) z))
36   (nth-value (expand-in-current-env (%m 1)) (values 'a 'b 'c)))
37  b)
38
39(deftest nth-value.7
40  (macrolet
41   ((%m (z) z))
42   (nth-value 1 (expand-in-current-env (%m (values 'a 'b 'c)))))
43  b)
44
45;;; Order of evaluation test
46
47(deftest nth-value.order.1
48  (let ((i 0) x y)
49    (values
50     (nth-value (progn (setf x (incf i)) 3)
51                (progn (setf y (incf i)) (values 'a 'b 'c 'd 'e 'f 'g)))
52     i x y))
53  d 2 1 2)
54
55;;; Error tests
56
57(deftest nth-value.error.1
58  (signals-error (funcall (macro-function 'nth-value))
59                 program-error)
60  t)
61 
62(deftest nth-value.error.2
63  (signals-error (funcall (macro-function 'nth-value)
64                           '(nth-value 1 '(a b c)))
65                 program-error)
66  t)
67
68(deftest nth-value.error.3
69  (signals-error (funcall (macro-function 'nth-value)
70                           '(nth-value 1 '(a b c))
71                           nil nil)
72                 program-error)
73  t)
Note: See TracBrowser for help on using the repository browser.