• [^] # Re: Exemple de test d'un code retour erreur en Lisp ?

    Posté par . En réponse à la dépêche Peter Seibel : Practical Common Lisp. Évalué à 3.

    CL-USER 34 > (defun test (f)
     (case (apply f nil)
     ((ok-1 ok-2 ok-3) "OK...")
     ((nok-1 nok-2 nok-3) "NOK...")
     (failed "Failed...")
     (t "unknown")))
    TEST
    CL-USER 35 > (test (defun ma-function () 'ok-1))
    "OK..."
    CL-USER 36 > (test (defun ma-function () 'nok-1))
    "NOK..."
    CL-USER 37 > (test (defun ma-function () 'failed))
    "Failed..."
    CL-USER 38 > (test (defun ma-function () 'quoi))
    "unknown"
    CL-USER 39 > (test #'(lambda () 'nok-3))
    "NOK..."