accessors.
* module/rnrs/conditions.scm (define-condition-type): The generated
accessors should be condition accessors, which know how to unpack a
compound condition; these can then delegate to the appropriate record
accessors.
* test-suite/tests/r6rs-conditions.test: New test case to verify above.
(generate-accessors
(syntax-rules ()
((_ counter (f a) . rest)
- (begin (define a (record-accessor condition-type counter))
+ (begin (define a
+ (condition-accessor
+ condition-type
+ (record-accessor condition-type counter)))
(generate-accessors (+ counter 1) rest)))
((_ counter ((f a)))
- (define a (record-accessor condition-type counter)))
+ (define a
+ (condition-accessor
+ condition-type (record-accessor condition-type counter))))
((_ counter ()) (begin))
((_ counter) (begin)))))
(begin
:use-module ((rnrs conditions) :version (6))
:use-module (test-suite lib))
+(define-condition-type &a &condition make-a-condition a-condition? (foo a-foo))
+(define-condition-type &b &condition make-b-condition b-condition? (bar b-bar))
+
(with-test-prefix "condition?"
(pass-if "condition? is #t for simple conditions"
(condition? (make-error)))
(vc (make-violation))
(c (condition vc mc)))
(equal? (ma c) "foo"))))
+
+(with-test-prefix "define-condition-type"
+ (pass-if "define-condition-type produces proper accessors"
+ (let ((c (condition (make-a-condition 'foo) (make-b-condition 'bar))))
+ (and (eq? (a-foo c) 'foo) (eq? (b-bar c) 'bar)))))