16
20
(defmacro assert! (&whole whole-form
17
21
assertion &optional form)
23
; Note that assertion should evaluate to a single non-stobj value. See also
18
26
(list 'make-event (assert!-body assertion form)
19
27
:on-behalf-of whole-form))
52
60
(assert! (equal (access-command-tuple-form
53
61
(cddr (car (scan-to-command (w state)))))
54
62
'(exit-boot-strap-mode)))
64
; We turn now to developing an extension of assert! that works with stobjs, in
65
; this case for assertions that return (mv val st) where val is an ordinary
66
; value and st is a stobj. Our intention is to illustrate how to write other
67
; versions of assert!. If you understand this extension, you can then write
68
; your own extensions that can similarly handle other signatures for the
71
(defun assert!-stobj-body (assertion st form)
73
; Assertion should evaluate to (mv val st), where val is an ordinary value and
74
; st is a stobj. See also assert!-body.
79
(mv nil ',(or form '(value-triple nil)) state ,st)
80
(mv-let (erp val state)
82
"Assertion failed:~%~x0"
84
(declare (ignore erp val))
85
(mv t nil state ,st)))))
87
(defmacro assert!-stobj (&whole whole-form
88
assertion st &optional form)
90
; Assertion should evaluate to (mv val st), where val is an ordinary value and
91
; st is a stobj. See also assert!.
93
(list 'make-event (assert!-stobj-body assertion st form)
94
:on-behalf-of whole-form))
96
; Test-stobj example from David Rager.
101
(defstobj foo field1 field2)
103
(defun test-stobj (x foo)
104
(declare (xargs :stobjs foo))
105
(let ((foo (update-field1 17 foo)))
106
(update-field2 x foo)))
109
(assert!-stobj (let* ((foo (test-stobj 14 foo)))
110
(mv (equal (field1 foo)
116
(assert!-stobj (let* ((foo (test-stobj 14 foo)))
117
(mv (equal (field1 foo)