~ubuntu-branches/ubuntu/intrepid/mit-scheme/intrepid-updates

« back to all changes in this revision

Viewing changes to src/xml/test-parser.scm

  • Committer: Bazaar Package Importer
  • Author(s): Chris Hanson
  • Date: 2005-01-18 00:33:57 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20050118003357-pv3i8iqlm5m80tl5
Tags: 7.7.90-5
* Add "libx11-dev" to build-depends.  (closes: Bug#290845)
* Fix debian/control and debian/menu to eliminate some lintian errors
  and warnings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
;;; -*-Scheme-*-
2
 
;;;
3
 
;;; $Id: test-parser.scm,v 1.5 2001/07/16 20:40:25 cph Exp $
4
 
;;;
5
 
;;; Copyright (c) 2001 Massachusetts Institute of Technology
6
 
;;;
7
 
;;; This program is free software; you can redistribute it and/or
8
 
;;; modify it under the terms of the GNU General Public License as
9
 
;;; published by the Free Software Foundation; either version 2 of the
10
 
;;; License, or (at your option) any later version.
11
 
;;;
12
 
;;; This program is distributed in the hope that it will be useful,
13
 
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 
;;; General Public License for more details.
16
 
;;;
17
 
;;; You should have received a copy of the GNU General Public License
18
 
;;; along with this program; if not, write to the Free Software
19
 
;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20
 
;;; 02111-1307, USA.
21
 
 
22
 
(define (test-parser pathname)
23
 
  (call-with-input-file pathname
24
 
    (lambda (port)
25
 
      (parse-xml-document (input-port->parser-buffer port)))))
 
1
#| -*-Scheme-*-
 
2
 
 
3
$Id: test-parser.scm,v 1.10 2003/03/01 16:52:10 cph Exp $
 
4
 
 
5
Copyright 2001 Massachusetts Institute of Technology
 
6
 
 
7
This file is part of MIT/GNU Scheme.
 
8
 
 
9
MIT/GNU Scheme is free software; you can redistribute it and/or modify
 
10
it under the terms of the GNU General Public License as published by
 
11
the Free Software Foundation; either version 2 of the License, or (at
 
12
your option) any later version.
 
13
 
 
14
MIT/GNU Scheme is distributed in the hope that it will be useful, but
 
15
WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
17
General Public License for more details.
 
18
 
 
19
You should have received a copy of the GNU General Public License
 
20
along with MIT/GNU Scheme; if not, write to the Free Software
 
21
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
 
22
USA.
 
23
 
 
24
|#
 
25
 
 
26
(define (run-xml-tests #!optional root)
 
27
  (let ((root
 
28
         (merge-pathnames "xmlconf/xmltest/"
 
29
                          (if (default-object? root)
 
30
                              "~/xml/"
 
31
                              (pathname-as-directory root)))))
 
32
    (for-each (lambda (dir)
 
33
                (newline)
 
34
                (write-string ";")
 
35
                (write-string dir)
 
36
                (newline)
 
37
                (test-directory (merge-pathnames dir root)))
 
38
              '("valid/sa" "valid/ext-sa" "valid/not-sa"
 
39
                           "invalid"
 
40
                           "not-wf/sa" "not-wf/ext-sa" "not-wf/not-sa"))))
26
41
 
27
42
(define (test-directory directory)
28
43
  (map (lambda (pathname)
29
44
         (write-string ";")
30
45
         (write-string (file-namestring pathname))
31
46
         (write-string ":\t")
32
 
         (let ((v (ignore-errors (lambda () (test-parser pathname)))))
 
47
         (let ((v (ignore-errors (lambda () (read-xml-file pathname)))))
33
48
           (cond ((not v)
34
49
                  (write-string "No match."))
35
50
                 ((condition? v)
36
51
                  (write-condition-report v (current-output-port)))
37
52
                 (else
38
 
                  (write-string "Parsed: ")
39
 
                  (write v)))
 
53
                  (let ((s (ignore-errors (lambda () (xml->string v)))))
 
54
                    (if (condition? s)
 
55
                        (begin
 
56
                          (write-string "Can't write: ")
 
57
                          (write-condition-report s (current-output-port)))
 
58
                        (let ((x (ignore-errors (lambda () (string->xml s)))))
 
59
                          (if (condition? x)
 
60
                              (begin
 
61
                                (write-string "Can't re-read: ")
 
62
                                (write-condition-report x
 
63
                                                        (current-output-port)))
 
64
                              (begin
 
65
                                (write-string "Parsed: ")
 
66
                                (write v))))))))
40
67
           (newline)
41
68
           v))
42
69
       (directory-read
43
70
        (merge-pathnames "*.xml" (pathname-as-directory directory)))))
44
71
 
45
 
(define (run-xml-tests root)
46
 
  (let ((root
47
 
         (merge-pathnames "xmlconf/xmltest/"
48
 
                          (pathname-as-directory root))))
49
 
    (for-each (lambda (dir)
50
 
                (newline)
51
 
                (write-string ";")
52
 
                (write-string dir)
53
 
                (newline)
54
 
                (test-directory (merge-pathnames dir root)))
55
 
              '("valid/sa" "valid/ext-sa" "valid/not-sa"
56
 
                           "invalid"
57
 
                           "not-wf/sa" "not-wf/ext-sa" "not-wf/not-sa"))))
58
 
 
59
 
(define (run-output-tests root output)
60
 
  (let ((root
61
 
         (merge-pathnames "xmlconf/xmltest/"
62
 
                          (pathname-as-directory root)))
 
72
(define (run-output-tests output #!optional root)
 
73
  (let ((root
 
74
         (merge-pathnames "xmlconf/xmltest/"
 
75
                          (if (default-object? root)
 
76
                              "~/xml/"
 
77
                              (pathname-as-directory root))))
63
78
        (output (pathname-as-directory output)))
64
79
    (for-each (lambda (pathname)
65
80
                (write-string ";")
66
81
                (write-string (file-namestring pathname))
67
82
                (write-string ":\t")
68
 
                (let ((v (ignore-errors (lambda () (test-parser pathname)))))
 
83
                (let ((v (ignore-errors (lambda () (read-xml-file pathname)))))
69
84
                  (cond ((not v)
70
85
                         (write-string "No match.")
71
86
                         (newline))