store-value.lsp 1.27 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sun Mar 23 09:10:22 2003
;;;; Contains: Tests for STORE-VALUE restart and function

(in-package :cl-test)

(deftest store-value.1
  (restart-case
   (progn (store-value 10) 'bad)
   (store-value (x) (list x 'good)))
  (10 good))

(deftest store-value.2
  (let ((c1 (make-condition 'error))
sds's avatar
sds committed
16
        (c2 (make-condition 'error)))
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
    (restart-case
     (with-condition-restarts
      c1
      (list (first (compute-restarts)))
      (store-value 17 c2))
     (store-value (x) (list x 'bad))
     (store-value (x) (list x 'good))))
  (17 good))

(deftest store-value.3
  (restart-case
   (progn (store-value 11 nil) 'bad)
   (store-value (x) (list x 'good)))
  (11 good))

(deftest store-value.4
  (let ((c1 (make-condition 'error))
sds's avatar
sds committed
34
        (c2 (make-condition 'error)))
35 36 37 38 39 40 41 42 43 44 45
    (restart-case
     (with-condition-restarts
      c1
      (list (first (compute-restarts)))
      (store-value 18 nil))
     (store-value (x) (list x 'good))
     (store-value (x) (list x 'bad))))
  (18 good))

(deftest store-value.5
  (let ((c1 (make-condition 'error))
sds's avatar
sds committed
46
        (c2 (make-condition 'error)))
47 48 49 50 51 52
     (with-condition-restarts
      c1
      (compute-restarts)
      ;; All conditions are now associated with c1
      (store-value 21 c2)))
  nil)