; Validate processing of MIME entities, headers and fields ; ; IMPORT ; appropriate prelude: myenv.scm, myenv-bigloo.scm, myenv-scm.scm ; depending on your system ; catch-error.scm -- for procedure, for-syntax ; util.scm ; input-parse.scm ; mime.scm ; ; $Id: vmime.scm,v 1.4 2004/07/31 01:33:25 oleg Exp oleg $ ; This function is imported into the input-parse.scm module (define (parser-error port msg . specializing-msgs) (apply error (cons msg specializing-msgs))) ; make sure that the 'FORM' gave upon evaluation the ; EXPECTED-RESULT (cond-expand ((or bigloo gambit) (define-macro (expect form expected-result-exp) (let ((expected-result (gensym))) `(begin (let ((,expected-result ,expected-result-exp)) (display "evaluating ") (write ',form) (let ((real-result ,form)) (if (equal? real-result ,expected-result) (cout "... gave the expected result: " (lambda () (write real-result)) nl) (error "... yielded: " real-result " which differs from the expected result: " ,expected-result) ))))))) (else (define-syntax expect (syntax-rules () ((expect form expected-result-exp) (begin (let ((expected-result expected-result-exp)) (display "evaluating ") (write 'form) (let ((real-result form)) (if (equal? real-result expected-result) (cout "... gave the expected result: " (lambda () (write real-result)) nl) (error "... yielded: " real-result " which differs from the expected result: " expected-result) )))))))) ) (cerr nl "Verifying MIME:parse-content-type ..." nl) (let () (expect (MIME:parse-content-type "text/html") '((=mime-type . "text/html"))) (expect (MIME:parse-content-type "text/html; cid=10") `((,(string->symbol "cid") . "10") (=mime-type . "text/html"))) (expect (MIME:parse-content-type "text/html ; cid=10 ") `((,(string->symbol "cid") . "10") (=mime-type . "text/html"))) (expect (MIME:parse-content-type "text/html ; cid='12' ") `((,(string->symbol "cid") . "'12'") (=mime-type . "text/html"))) (assert (failed? (MIME:parse-content-type "text/html ; cid="))) (assert (failed? (MIME:parse-content-type "text/html ; cid= "))) (assert (failed? (MIME:parse-content-type "text/html ; = "))) (assert (failed? (MIME:parse-content-type "text html ; cid= "))) (assert (failed? (MIME:parse-content-type "text/html ; cid='1 2'"))) (assert (failed? (MIME:parse-content-type "text/html ; cid= ;attr="))) (expect (MIME:parse-content-type "text/html ; cid=10; name=val ; name1=\" val \" ;name3=\" va\\\\ lu\\\"e \" ") (list (cons (string->symbol "name3") " va\\ lu\"e ") (cons (string->symbol "name1") " val ") (cons (string->symbol "name") "val") (cons (string->symbol "cid") "10") (cons '=mime-type "text/html"))) ) (cerr nl nl "All tests passed" nl)