@@ -440,11 +440,6 @@ output if a test fails.
440
440
(expand-macro-form , form nil )
441
441
' ,expansion , extras))
442
442
443
- (defmacro assert-false (form &rest extras)
444
- " Assert whether the form is false."
445
- (let ((extras ` (,@ (cdr form) ,@ extras)))
446
- ` (expand-assert :result , form , form nil , extras)))
447
-
448
443
(defmacro assert-equality (test expected form &rest extras)
449
444
" Assert whether expected and form are equal according to test."
450
445
` (expand-assert :equal , form , form , expected , extras :test , test))
@@ -454,10 +449,30 @@ output if a test fails.
454
449
` (expand-assert :output , form (expand-output-form , form)
455
450
, output , extras))
456
451
452
+ (defmacro assert-false (form &rest extras)
453
+ " Assert whether the form is false."
454
+ ` (expand-t-or-f nil , form , extras))
455
+
457
456
(defmacro assert-true (form &rest extras)
458
457
" Assert whether the form is true."
459
- (let ((extras ` (,@ (cdr form) ,@ extras)))
460
- ` (expand-assert :result , form , form t , extras)))
458
+ ` (expand-t-or-f t , form , extras))
459
+
460
+ (defmacro expand-t-or-f (t-or-f form extras)
461
+ " Expand the true/false assertions to report the arguments."
462
+ (let ((args (gensym ))
463
+ (fname (gensym )))
464
+ ` (let ((, args (list ,@ (cdr form)))
465
+ (, fname ' ,(car form)))
466
+ (internal-assert
467
+ :result ' ,form
468
+ (lambda () (apply , fname , args)) ; Evaluate the form
469
+ (lambda () , t-or-f)
470
+ ; ; Concatenate the args with the extras
471
+ (lambda ()
472
+ (nconc
473
+ (mapcan #' list ' ,(cdr form) , args)
474
+ (funcall (expand-extras , extras))))
475
+ #' eql ))))
461
476
462
477
(defmacro expand-assert (type form body expected extras &key (test ' #'eql ))
463
478
" Expand the assertion to the internal format."
0 commit comments