Last active
January 1, 2019 13:49
-
-
Save informatimago/4afdb7021c69a049d15672055e2512c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun foo (a b) | |
(zerop (mod (- a b) 100))) | |
(defun bar (a b) | |
(zerop (mod (- a b) 33))) | |
(loop :for (specifiedp expected test) | |
:in '( | |
(:specified (test eql) ()) | |
(:specified (test foo) (:test foo)) | |
(:specified (test-not foo) (:test-not foo)) | |
(:specified type-error (:test nil)) | |
(:specified type-error (:test-not nil)) | |
(:unspecified (test foo) (:test foo :test-not nil)) | |
(:unspecified (test-not foo) (:test nil :test-not foo)) | |
(:unspecified error (:test foo :test-not bar)) | |
(:unspecified error (:test nil :test-not nil)) | |
) | |
:collect (if (member expected '(type-error error)) | |
(handler-case | |
(list specifiedp :failure | |
(apply (function find) 102 '(1 2 3 4 101 102 103 104) test)) | |
(type-error (err) | |
(if (eql expected 'type-error) | |
(list specifiedp :success err) | |
(list specifiedp :failure err))) | |
(error (err) | |
(if (eql expected 'error) | |
(list specifiedp :success err) | |
(list specifiedp :failure err)))) | |
(handler-case | |
(let ((result (apply (function find) 102 '(1 2 3 4 101 102 103 104) test))) | |
(list specifiedp :success result)) | |
(error (err) | |
(list specifiedp :failure err)))))) | |
#-(and) | |
( | |
#+abcl | |
((:SPECIFIED :SUCCESS 102) | |
(:SPECIFIED :SUCCESS 2) | |
(:SPECIFIED :SUCCESS 1) | |
(:SPECIFIED :FAILURE 102) | |
(:SPECIFIED :FAILURE 102) | |
(:UNSPECIFIED :SUCCESS 2) | |
(:UNSPECIFIED :SUCCESS 1) | |
(:UNSPECIFIED :FAILURE 1) | |
(:UNSPECIFIED :FAILURE 102)) | |
#+ccl | |
((:SPECIFIED :SUCCESS 102) | |
(:SPECIFIED :SUCCESS 2) | |
(:SPECIFIED :SUCCESS 1) | |
(:SPECIFIED :FAILURE 102) | |
(:SPECIFIED :FAILURE 102) | |
(:UNSPECIFIED :SUCCESS 2) | |
(:UNSPECIFIED :SUCCESS 1) | |
(:UNSPECIFIED :SUCCESS #<SIMPLE-ERROR #x30200063213D>) | |
(:UNSPECIFIED :FAILURE 102)) | |
#+clisp | |
((:SPECIFIED :SUCCESS 102) | |
(:SPECIFIED :SUCCESS 2) | |
(:SPECIFIED :SUCCESS 1) | |
(:SPECIFIED :FAILURE 102) | |
(:SPECIFIED :FAILURE 102) | |
(:UNSPECIFIED :SUCCESS 2) | |
(:UNSPECIFIED :SUCCESS 1) | |
(:UNSPECIFIED :SUCCESS #<SIMPLE-ERROR #x0000000000033150>) | |
(:UNSPECIFIED :FAILURE 102)) | |
#+ecl | |
((:SPECIFIED :SUCCESS 102) | |
(:SPECIFIED :SUCCESS 2) | |
(:SPECIFIED :SUCCESS 1) | |
(:SPECIFIED :FAILURE 102) | |
(:SPECIFIED :FAILURE 102) | |
(:UNSPECIFIED :SUCCESS 2) | |
(:UNSPECIFIED :SUCCESS 1) | |
(:UNSPECIFIED :SUCCESS #<a SIMPLE-ERROR>) | |
(:UNSPECIFIED :FAILURE 102)) | |
#+sbcl | |
((:SPECIFIED :SUCCESS 102) | |
(:SPECIFIED :SUCCESS 2) | |
(:SPECIFIED :SUCCESS 1) | |
(:SPECIFIED :FAILURE 102) | |
(:SPECIFIED :FAILURE 102) | |
(:UNSPECIFIED :SUCCESS 2) | |
(:UNSPECIFIED :SUCCESS 1) | |
(:UNSPECIFIED :SUCCESS #<SIMPLE-ERROR "can't specify both :TEST and :TEST-NOT" {10027425D3}>) | |
(:UNSPECIFIED :FAILURE 102)) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment