|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-module (test-suite sxml-ssax) |
|
#:use-module (sxml ssax input-parse) |
|
#:use-module (test-suite lib) |
|
#:use-module (srfi srfi-1) |
|
#:use-module (srfi srfi-13) |
|
#:use-module (sxml ssax) |
|
#:use-module (ice-9 pretty-print)) |
|
|
|
(define pp pretty-print) |
|
|
|
(define-macro (import module . symbols) |
|
`(begin |
|
,@(map (lambda (sym) |
|
`(module-define! (current-module) ',sym (module-ref (resolve-module ',module) ',sym))) |
|
symbols))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(import (sxml ssax) |
|
ssax:read-NCName |
|
ssax:read-QName |
|
ssax:largest-unres-name |
|
ssax:Prefix-XML |
|
ssax:resolve-name |
|
ssax:scan-Misc |
|
ssax:assert-token |
|
ssax:handle-parsed-entity |
|
ssax:warn |
|
ssax:skip-pi |
|
ssax:S-chars |
|
ssax:skip-S |
|
ssax:ncname-starting-char? |
|
ssax:define-labeled-arg-macro |
|
let*-values |
|
ssax:make-parser/positional-args |
|
when |
|
make-xml-token |
|
nl |
|
|
|
parser-error |
|
ascii->char |
|
char->ascii |
|
char-newline |
|
char-return |
|
char-tab |
|
name-compare) |
|
|
|
(define (cout . args) |
|
"Similar to @code{cout << arguments << args}, where @var{argument} can |
|
be any Scheme object. If it's a procedure (e.g. @code{newline}), it's |
|
called without args rather than printed." |
|
(for-each (lambda (x) |
|
(if (procedure? x) (x) (display x))) |
|
args)) |
|
|
|
(define (cerr . args) |
|
"Similar to @code{cerr << arguments << args}, where @var{argument} can |
|
be any Scheme object. If it's a procedure (e.g. @code{newline}), it's |
|
called without args rather than printed." |
|
(format (current-ssax-error-port) |
|
";;; SSAX warning: ~a\n" args)) |
|
|
|
(define (list-intersperse src-l elem) |
|
(if (null? src-l) src-l |
|
(let loop ((l (cdr src-l)) (dest (cons (car src-l) '()))) |
|
(if (null? l) (reverse dest) |
|
(loop (cdr l) (cons (car l) (cons elem dest))))))) |
|
|
|
(define-syntax failed? |
|
(syntax-rules () |
|
((_ e ...) |
|
(not (false-if-exception (begin e ... #t)))))) |
|
|
|
(define *saved-port* (current-output-port)) |
|
|
|
(define-syntax assert |
|
(syntax-rules () |
|
((assert expr ...) |
|
(with-output-to-port *saved-port* |
|
(lambda () |
|
(pass-if '(and expr ...) |
|
(let* ((out (open-output-string)) |
|
(res (with-output-to-port out |
|
(lambda () |
|
(with-ssax-error-to-port (current-output-port) |
|
(lambda () |
|
(and expr ...))))))) |
|
|
|
res))))))) |
|
|
|
(define (load-tests file) |
|
(with-input-from-file (%search-load-path file) |
|
(lambda () |
|
(let loop ((sexp (read))) |
|
(cond |
|
((eof-object? sexp)) |
|
((and (pair? sexp) (pair? (cdr sexp)) |
|
(eq? (cadr sexp) 'run-test)) |
|
(primitive-eval sexp) |
|
(loop (read))) |
|
((and (pair? sexp) (eq? (car sexp) 'run-test)) |
|
(primitive-eval sexp) |
|
(loop (read))) |
|
(else |
|
(loop (read)))))))) |
|
|
|
(with-output-to-string |
|
(lambda () |
|
(load-tests "sxml/upstream/SSAX.scm"))) |
|
|