home *** CD-ROM | disk | FTP | other *** search
/ Ultra Pack / UltraComputing Partner Applications.iso / SunLabs / tclTK / src / tcl7.4 / tests / list.test < prev    next >
Encoding:
Text File  |  1994-12-18  |  2.8 KB  |  74 lines

  1. # Commands covered:  list
  2. #
  3. # This file contains a collection of tests for one or more of the Tcl
  4. # built-in commands.  Sourcing this file into Tcl runs the tests and
  5. # generates output for errors.  No output means no errors were found.
  6. #
  7. # Copyright (c) 1991-1993 The Regents of the University of California.
  8. # Copyright (c) 1994 Sun Microsystems, Inc.
  9. #
  10. # See the file "license.terms" for information on usage and redistribution
  11. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  12. #
  13. # @(#) list.test 1.19 94/12/17 16:20:08
  14.  
  15. if {[string compare test [info procs test]] == 1} then {source defs}
  16.  
  17. # First, a bunch of individual tests
  18.  
  19. test list-1.1 {basic tests} {list a b c} {a b c}
  20. test list-1.2 {basic tests} {list {a b} c} {{a b} c}
  21. test list-1.3 {basic tests} {list \{a b c} {\{a b c}
  22. test list-1.4 {basic tests} "list a{}} b{} c}" "a\\{\\}\\} b{} c\\}"
  23. test list-1.5 {basic tests} {list a\[ b\] } "{a\[} b\\]"
  24. test list-1.6 {basic tests} {list c\  d\t } "{c } {d\t}"
  25. test list-1.7 {basic tests} {list e\n f\$ } "{e\n} {f\$}"
  26. test list-1.8 {basic tests} {list g\; h\\} {{g;} h\\}
  27. test list-1.9 {basic tests} "list a\\\[} b\\\]} " "a\\\[\\\} b\\\]\\\}"
  28. test list-1.10 {basic tests} "list c\\\} d\\t} " "c\\} d\\t\\}"
  29. test list-1.11 {basic tests} "list e\\n} f\\$} " "e\\n\\} f\\$\\}"
  30. test list-1.12 {basic tests} "list g\\;} h\\\\} " "g\\;\\} {h\\}}"
  31. test list-1.13 {basic tests} {list a {{}} b} {a {{}} b}
  32. test list-1.14 {basic tests} {list a b xy\\} "a b xy\\\\"
  33. test list-1.15 {basic tests} "list a b\} e\\" "a b\\} e\\\\"
  34. test list-1.16 {basic tests} "list a b\}\\\$ e\\\$\\" "a b\\}\\\$ e\\\$\\\\"
  35. test list-1.17 {basic tests} {list a\f \{\f} "{a\f} \\\{\\f"
  36. test list-1.18 {basic tests} {list a\r \{\r} "{a\r} \\\{\\r"
  37. test list-1.19 {basic tests} {list a\v \{\v} "{a\v} \\\{\\v"
  38. test list-1.20 {basic tests} {list \"\}\{} "\\\"\\}\\{"
  39. test list-1.21 {basic tests} {list a b c\\\nd} "a b c\\\\\\nd"
  40. test list-1.22 {basic tests} {list "{ab}\\"} \\{ab\\}\\\\
  41. test list-1.23 {basic tests} {list \{} "\\{"
  42. test list-1.24 {basic tests} {list} {}
  43.  
  44. # For the next round of tests create a list and then pick it apart
  45. # with "index" to make sure that we get back exactly what went in.
  46.  
  47. set num 1
  48. proc lcheck {a b c} {
  49.     global num d
  50.     set d [list $a $b $c]
  51.     test list-2.$num {what goes in must come out} {lindex $d 0} $a
  52.     set num [expr $num+1]
  53.     test list-2.$num {what goes in must come out} {lindex $d 1} $b
  54.     set num [expr $num+1]
  55.     test list-2.$num {what goes in must come out} {lindex $d 2} $c
  56.     set num [expr $num+1]
  57. }
  58. lcheck a b c
  59. lcheck "a b" c\td e\nf
  60. lcheck {{a b}} {} {  }
  61. lcheck \$ \$ab ab\$
  62. lcheck \; \;ab ab\;
  63. lcheck \[ \[ab ab\[
  64. lcheck \\ \\ab ab\\
  65. lcheck {"} {"ab} {ab"}
  66. lcheck {a b} { ab} {ab }
  67. lcheck a{ a{b \{ab
  68. lcheck a} a}b }ab
  69. lcheck a\\} {a \}b} {a \{c}
  70. lcheck xyz \\ 1\\\n2
  71. lcheck "{ab}\\" "{ab}xy" abc
  72.  
  73. concat {}
  74.