previous koans, conditions
complex stuff, unpleasant for now
This commit is contained in:
parent
b4fe711abb
commit
586f06fbf2
|
@ -230,14 +230,15 @@
|
||||||
#-abcl
|
#-abcl
|
||||||
(assert-equal 3 (funcall operation 12 4)))))
|
(assert-equal 3 (funcall operation 12 4)))))
|
||||||
|
|
||||||
|
(setq my-condition (handler-case (divide 6 :zero) (type-error (c) c)))
|
||||||
(define-test accessors-type-error
|
(define-test accessors-type-error
|
||||||
(let ((condition (handler-case (divide 6 :zero) (type-error (c) c))))
|
(let ((condition (handler-case (divide 6 :zero) (type-error (c) c))))
|
||||||
(assert-equal ____ (type-error-datum condition))
|
(assert-equal :zero (type-error-datum my-condition))
|
||||||
(let ((expected-type (type-error-expected-type condition)))
|
(let ((expected-type (type-error-expected-type my-condition)))
|
||||||
(true-or-false? ____ (typep :zero expected-type))
|
(true-or-false? nil (typep :zero expected-type))
|
||||||
(true-or-false? ____ (typep 0 expected-type))
|
(true-or-false? t (typep 0 expected-type))
|
||||||
(true-or-false? ____ (typep "zero" expected-type))
|
(true-or-false? nil (typep "zero" expected-type))
|
||||||
(true-or-false? ____ (typep 0.0 expected-type)))))
|
(true-or-false? t (typep 0.0 expected-type)))))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
@ -265,12 +266,12 @@
|
||||||
(flet ((try-log-line-type (line)
|
(flet ((try-log-line-type (line)
|
||||||
(handler-case (log-line-type line)
|
(handler-case (log-line-type line)
|
||||||
(error (condition) condition))))
|
(error (condition) condition))))
|
||||||
(assert-equal ____ (try-log-line-type "TIMESTAMP 2020-05-08 16:59:39"))
|
(assert-equal :timestamp (try-log-line-type "TIMESTAMP 2020-05-08 16:59:39"))
|
||||||
(assert-equal ____ (try-log-line-type "HTTP GET / from 127.0.0.1"))
|
(assert-equal :http (try-log-line-type "HTTP GET / from 127.0.0.1"))
|
||||||
(assert-equal ____ (try-log-line-type "LOGIN administrator:hunter2"))
|
(assert-equal :login (try-log-line-type "LOGIN administrator:hunter2"))
|
||||||
(let ((condition (try-log-line-type "WARNING: 95% of disk space used")))
|
(let ((condition (try-log-line-type "WARNING: 95% of disk space used")))
|
||||||
(assert-equal ____ (line condition))
|
(assert-equal "WARNING: 95% of disk space used" (line condition))
|
||||||
(assert-equal ____ (reason condition)))
|
(assert-equal :unknown-log-line-type (reason condition)))
|
||||||
(let ((condition (try-log-line-type 5555)))
|
(let ((condition (try-log-line-type 5555)))
|
||||||
(assert-equal 'string (____ condition))
|
(assert-equal 'string (type-error-expected-type condition))
|
||||||
(assert-equal 5555 (____ condition)))))
|
(assert-equal 5555 (type-error-datum condition)))))
|
||||||
|
|
Loading…
Reference in New Issue