;;;; condition-utils-test.scm -*- Scheme -*- ;;;; Kon Lovett, Jul '18 (import test) (test-begin "Condition Utils") ;;; (import (chicken condition) (chicken port)) (import condition-utils exn-condition) (define testc (make-exn-condition+ 'test "test" '(test) 'misc '(extra test 23))) (define testc? (make-condition-predicate exn misc extra)) (test-assert "composite of exn test extra" (testc? testc)) (test "test property of extra component of (exn test extra)" 23 ((condition-property-accessor 'extra 'test) testc)) (define testc-extra-test (make-condition-property-accessor extra test)) (define testc-extra-foo (make-condition-property-accessor extra foo 'foobar)) (test 23 (testc-extra-test testc)) (test 'foobar (testc-extra-foo testc)) (test-assert (call-chain? (get-call-chain 1))) (test-assert (call-chain? (get-call-chain 0))) (define testcc) (let ((chn (get-call-chain 1))) (set! testcc (make-exn-condition+ 'test "test" '(test) ;std chn ;+ 1 'misc '(extra test 23))) ) ;cnds (test-assert "composite of exn test extra (set!)" (testc? testcc)) ;C5 is a plist (define wr-exn-res "\nError: (test) test: test\n +: misc:\n +: extra: test 23\n") (test "may fail - order an issue" wr-exn-res (with-output-to-string (lambda () (write-exn-condition testc)))) (test-assert (exn-condition? testc)) (test 'test (exn-location testc)) (test "test" (exn-message testc)) (test '(test) (exn-arguments testc)) (test #f (exn-call-chain testc)) (import standard-conditions) (import http-client-conditions) (import intarweb-conditions) (define thttpc (make-exn-condition+ 'test "test" '(test) 'http '(extra test 23))) (test-assert (http-condition? thttpc)) ;C5 is a plist (define irr-res '(location test message "test" arguments (test) test 23)) (test irr-res (condition-irritants thttpc)) (print) (print "Writing exn condition") (print " (expect an \"error\")") (print "---------------------") (write-exn-condition testcc) (print) ;;; (test-end "Condition Utils") (test-exit)