Raymond Toy pushed to branch issue-291-pprint-handler-case at cmucl / cmucl
Commits: ac5dde80 by Raymond Toy at 2024-03-29T08:25:47-07:00 Add a several smaller test cases for handler-case as requested
- - - - -
1 changed file:
- tests/pprint.lisp
Changes:
===================================== tests/pprint.lisp ===================================== @@ -27,26 +27,97 @@ (print "Hello")) s))))
-(define-test pprint.handler-case +(define-test pprint.handler-case.1 (:tag :issues) + ;; Just an expression (assert-equal -" + " +(HANDLER-CASE (SIGNAL CONDITION))" + (with-output-to-string (s) + (pprint '(handler-case (signal condition)) + s)))) + +(define-test pprint.handler-case.2 + (:tag :issues) + ;; One error clause + (assert-equal + " (HANDLER-CASE (SIGNAL CONDITION) (WARNING NIL - "Lots of smoke, but no fire.") - ((OR ARITHMETIC-ERROR CONTROL-ERROR CELL-ERROR STREAM-ERROR) (CONDITION) - (FORMAT NIL "~S looks especially bad." CONDITION)) - (SERIOUS-CONDITION (CONDITION) - (FORMAT NIL "~S looks serious." CONDITION)) - (CONDITION NIL - "Hardly worth mentioning."))" + "Lots of smoke, but no fire."))" (with-output-to-string (s) (pprint '(handler-case (signal condition) - (warning () "Lots of smoke, but no fire.") - ((or arithmetic-error control-error cell-error stream-error) - (condition) - (format nil "~S looks especially bad." condition)) - (serious-condition (condition) - (format nil "~S looks serious." condition)) - (condition () "Hardly worth mentioning.")) + (warning () "Lots of smoke, but no fire.")) s)))) + +(define-test pprint.handler-case.3 + (:tag :issues) + ;; More than one error clause + (assert-equal + " +(HANDLER-CASE (SIGNAL CONDITION) + (WARNING NIL + "Lots of smoke, but no fire.") + ((OR ARITHMETIC-ERROR CONTROL-ERROR CELL-ERROR STREAM-ERROR) (CONDITION) + (FORMAT NIL "~S looks especially bad." CONDITION)))" + (with-output-to-string (s) + (pprint '(handler-case (signal condition) + (warning () "Lots of smoke, but no fire.") + ((or arithmetic-error control-error cell-error stream-error) + (condition) + (format nil "~S looks especially bad." condition))) + s)))) + +(define-test pprint.handler-case.4 + (:tag :issues) + ;; An expression and a no-error clause + (assert-equal + " +(HANDLER-CASE (SIGNAL CONDITION) + (:NO-ERROR NIL + (FORMAT NIL "Nothing bad happened.")))" + (with-output-to-string (s) + (pprint '(handler-case (signal condition) + (:no-error () + (format nil "Nothing bad happened."))) + s)))) + + +(define-test pprint.handler-case.5 + (:tag :issues) + ;; One error clause and a no-error clause + (assert-equal + " +(HANDLER-CASE (SIGNAL CONDITION) + (WARNING NIL + "Lots of smoke, but no fire.") + (:NO-ERROR NIL + (FORMAT NIL "Nothing bad happened.")))" + (with-output-to-string (s) + (pprint '(handler-case (signal condition) + (warning () "Lots of smoke, but no fire.") + (:no-error () + (format nil "Nothing bad happened."))) + s)))) + +(define-test pprint.handler-case.6 + (:tag :issues) + ;; More than one error clause and a no-error clause + (assert-equal + " +(HANDLER-CASE (SIGNAL CONDITION) + (WARNING NIL + "Lots of smoke, but no fire.") + ((OR ARITHMETIC-ERROR CONTROL-ERROR CELL-ERROR STREAM-ERROR) (CONDITION) + (FORMAT NIL "~S looks especially bad." CONDITION)) + (:NO-ERROR NIL + (FORMAT NIL "Nothing bad happened.")))" + (with-output-to-string (s) + (pprint '(handler-case (signal condition) + (warning () "Lots of smoke, but no fire.") + ((or arithmetic-error control-error cell-error stream-error) + (condition) + (format nil "~S looks especially bad." condition)) + (:no-error () + (format nil "Nothing bad happened."))) + s))))
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/ac5dde808d1f1332da7268dc...