eval.lsp 992 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Thu Nov 21 10:43:15 2002
;;;; Contains: Tests of EVAL

(in-package :cl-test)

(deftest eval.1
  (eval 1)
  1)

(deftest eval.2
  (loop for x being the symbols of "KEYWORD"
sds's avatar
sds committed
14
        always (eq (eval x) x))
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
  t)

(deftest eval.3
  (let ((s "abcd"))
    (eqlt (eval s) s))
  t)

(deftest eval.4
  (eval '(car '(a . b)))
  a)

(deftest eval.5
  (eval '(let ((x 0)) x))
  0)

(deftest eval.6
  (funcall #'eval 1)
  1)

34 35 36 37 38
(deftest eval.order.1
  (let ((i 0))
    (values (eval (progn (incf i) 10)) i))
  10 1)

39 40 41
;;; Error cases

(deftest eval.error.1
42 43
  (signals-error (eval) program-error)
  t)
44 45

(deftest eval.error.2
46 47
  (signals-error (eval nil nil) program-error)
  t)
48 49

(deftest eval.error.3
50 51
  (let ((v (gensym)))
    (eval `(signals-error (eval (list ',v)) undefined-function
sds's avatar
sds committed
52
                          :name ,v)))
53
  t)
54 55 56 57

(deftest eval.error.4
  (let ((v (gensym)))
    (eval `(signals-error (eval ',v) unbound-variable :name ,v)))
sds's avatar
sds committed
58
  t)