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

  1. # Commands covered:  split
  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. # @(#) split.test 1.7 94/12/17 16:20:25
  14.  
  15. if {[string compare test [info procs test]] == 1} then {source defs}
  16.  
  17. test split-1.1 {basic split commands} {
  18.     split "a\n b\t\r c\n "
  19. } {a {} b {} {} c {} {}}
  20. test split-1.2 {basic split commands} {
  21.     split "word 1xyzword 2zword 3" xyz
  22. } {{word 1} {} {} {word 2} {word 3}}
  23. test split-1.3 {basic split commands} {
  24.     split "12345" {}
  25. } {1 2 3 4 5}
  26. test split-1.4 {basic split commands} {
  27.     split "a\}b\[c\{\]\$"
  28. } "a\\}b\\\[c\\{\\\]\\\$"
  29. test split-1.5 {basic split commands} {
  30.     split {} {}
  31. } {}
  32. test split-1.6 {basic split commands} {
  33.     split {}
  34. } {}
  35. test split-1.7 {basic split commands} {
  36.     split {   }
  37. } {{} {} {} {}}
  38.  
  39. test split-2.1 {split errors} {
  40.     list [catch split msg] $msg $errorCode
  41. } {1 {wrong # args: should be "split string ?splitChars?"} NONE}
  42. test split-2.2 {split errors} {
  43.     list [catch {split a b c} msg] $msg $errorCode
  44. } {1 {wrong # args: should be "split string ?splitChars?"} NONE}
  45.