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

  1. # Features covered:  Processing Instructions
  2. #
  3. # This file contains a collection of tests for the TclXML parser.
  4. # This file tests the parser's performance on Processing Instructions.
  5. # Sourcing this file into Tcl runs the tests and generates output
  6. # for errors.  No output means no errors were found.
  7. #
  8. # Copyright (c) 1998 Zveno Pty Ltd.
  9. #
  10. # $Id: PI.test,v 1.1.1.1 1996/02/22 06:06:15 daniel Exp $
  11.  
  12. if {[string compare test [info procs test]] == 1} then {source defs}
  13.  
  14. if {[catch {package require xml 1.6}]} {
  15.     catch {puts stderr "Cannot load xml 1.6 package"}
  16.     return
  17. }
  18.  
  19. catch {unset result}
  20. proc PI {target data args} {
  21.     lappend ::result $target $data
  22. }
  23.  
  24. test pi-1.1 {PI} {
  25.     set ::result {}
  26.  
  27.     catch {rename xml::pi-1.1 {}}
  28.     set parser [xml::parser pi-1.1 \
  29.     -processinginstructioncommand PI]
  30.     $parser parse {<?xml version="1.0"?>
  31. <!DOCTYPE Test>
  32. <Test><?Test This is a processing instruction?></Test>
  33. }
  34.     set ::result
  35. } {Test {This is a processing instruction}}
  36.  
  37. test pi-1.2 {PI: missing trailing ?} {
  38.     set ::result {}
  39.  
  40.     catch {rename xml::pi-1.2 {}}
  41.     set parser [xml::parser pi-1.2 \
  42.     -processinginstructioncommand PI]
  43.     set returncode [catch {$parser parse {<?xml version="1.0"?>
  44. <!DOCTYPE Test>
  45. <Test><?Test This is a syntax error></Test>
  46. }} msg]
  47.  
  48.     list $returncode [regexp {PI: expected '\?' character.+} $msg]
  49. } {1 1}
  50.  
  51. test pi-2.1 {PI with special characters} {
  52.     set ::result {}
  53.  
  54.     catch {rename xml::pi-2.1 {}}
  55.     set parser [xml::parser pi-2.1 \
  56.     -processinginstructioncommand PI]
  57.     $parser parse {<?xml version="1.0"?>
  58. <!DOCTYPE Test>
  59. <Test><?[if !VMLRender]?></Test>
  60. }
  61.     set ::result
  62. } {{[if} !VMLRender\]}
  63.