constantly.lsp 868 Bytes
Newer Older
1 2 3 4 5 6 7 8
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sun Oct  6 19:47:16 2002
;;;; Contains: Tests for CONSTANTLY

(in-package :cl-test)

(deftest constantly.1
9
  (let ((fn (cl:constantly 10))
sds's avatar
sds committed
10
        (x nil))
11
    (loop for i from 0 to (min 256 (1- call-arguments-limit))
sds's avatar
sds committed
12 13
          always (prog1 (eql (apply fn x) 10)
                   (push 'a x))))
14
  t)
15 16

(deftest constantly.2
17 18 19
  (notnot-mv (cl:constantly 1))
  t)

20 21 22 23 24 25 26 27 28
(deftest constantly.3
  (let ((i 0))
    (let ((fn (cl:constantly (progn (incf i) 'a))))
      (values
       i
       (mapcar fn '(1 2 3 4))
       i)))
  1 (a a a a) 1)

29
(deftest constantly.error.1
30 31
  (signals-error (cl:constantly) program-error)
  t)
32

33 34
;;; The next test fails in CMUCL, which has non-conformantly extended
;;; the syntax of constantly.
35
(deftest constantly.error.2
36 37
  (signals-error (cl:constantly 1 1) program-error)
  t)