home *** CD-ROM | disk | FTP | other *** search
/ PC World 2000 December / PCWorld_2000-12_cd.bin / Komunikace / Comanche / xuibuilder / TclXML-1.1.1 / tests / xmltest.test < prev   
Text File  |  2000-11-02  |  2KB  |  55 lines

  1. # Features covered:  Conformance
  2. #
  3. # This file contains a collection of tests for the TclXML parser.
  4. # This file tests the parser's performance on conformance to the 
  5. # XML specification.  As such it is crude and does not test callback
  6. # features.
  7. #
  8. # Sourcing this file into Tcl runs the tests and generates output
  9. # for errors.  No output means no errors were found.
  10. #
  11. # Copyright (c) 1999 Zveno Pty Ltd.
  12. #
  13. # $Id: xmltest.test,v 1.1.1.1 1996/02/22 06:06:15 daniel Exp $
  14.  
  15. if {[string compare test [info procs test]] == 1} then {source defs}
  16.  
  17. if {[catch {package require xml 1.7}]} {
  18.     catch {puts stderr "Cannot load xml 1.7 package"}
  19.     return
  20. }
  21.  
  22. proc xmltest {expect dir subdir f} {
  23.  
  24.     set ch [open $f]
  25.     set data [read $ch]
  26.     close $ch
  27.  
  28.     test xmltest-$dir-$subdir-[file rootname [file tail $f]] "Document $dir $subdir [file tail $f]" {
  29.     set parser [xml::parser xmltest]
  30.     set code [catch {$parser parse $data}]
  31.     rename $parser {}
  32.     set code
  33.     } $expect
  34. }
  35.  
  36. # NB. Uses James Clark's test suite for WFF checking.
  37. # Need a framework to test against each file: it's too time-
  38. # consuming to setup a test proc for each one.
  39.  
  40. set testDir [file join [pwd] xmltest]
  41.  
  42. # These documents should fail
  43. foreach dir {not-wf} {
  44.     foreach file [glob -nocomplain [file join $testDir $dir sa *.xml]] {
  45.     xmltest 1 $dir sa $file
  46.     }
  47. }
  48.  
  49. # These documents should pass
  50. foreach dir {invalid valid} {
  51.     foreach file [glob -nocomplain [file join $testDir $dir sa *.xml]] {
  52.     xmltest 0 $dir sa $file
  53.     }
  54. }
  55.