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

  1. # Commands covered:  linsert
  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. # @(#) linsert.test 1.7 94/12/17 16:20:07
  14.  
  15. if {[string compare test [info procs test]] == 1} then {source defs}
  16.  
  17. test linsert-1.1 {linsert command} {
  18.     linsert {1 2 3 4 5} 0 a
  19. } {a 1 2 3 4 5}
  20. test linsert-1.2 {linsert command} {
  21.     linsert {1 2 3 4 5} 1 a
  22. } {1 a 2 3 4 5}
  23. test linsert-1.3 {linsert command} {
  24.     linsert {1 2 3 4 5} 2 a
  25. } {1 2 a 3 4 5}
  26. test linsert-1.4 {linsert command} {
  27.     linsert {1 2 3 4 5} 3 a
  28. } {1 2 3 a 4 5}
  29. test linsert-1.5 {linsert command} {
  30.     linsert {1 2 3 4 5} 4 a
  31. } {1 2 3 4 a 5}
  32. test linsert-1.6 {linsert command} {
  33.     linsert {1 2 3 4 5} 5 a
  34. } {1 2 3 4 5 a}
  35. test linsert-1.7 {linsert command} {
  36.     linsert {1 2 3 4 5} 2 one two \{three \$four
  37. } {1 2 one two \{three {$four} 3 4 5}
  38. test linsert-1.8 {linsert command} {
  39.     linsert {\{one \$two \{three \ four \ five} 2 a b c
  40. } {\{one \$two a b c \{three \ four \ five}
  41. test linsert-1.9 {linsert command} {
  42.     linsert {{1 2} {3 4} {5 6} {7 8}} 2 {x y} {a b}
  43. } {{1 2} {3 4} {x y} {a b} {5 6} {7 8}}
  44. test linsert-1.10 {linsert command} {
  45.     linsert {} 2 a b c
  46. } {a b c}
  47. test linsert-1.11 {linsert command} {
  48.     linsert {} 2 {}
  49. } {{}}
  50. test linsert-1.12 {linsert command} {
  51.     linsert {a b "c c" d e} 3 1
  52. } {a b "c c" 1 d e}
  53. test linsert-1.13 {linsert command} {
  54.     linsert { a b c d} 0 1 2
  55. } {1 2  a b c d}
  56. test linsert-1.14 {linsert command} {
  57.     linsert {a b c {d e f}} 4 1 2
  58. } {a b c {d e f} 1 2}
  59. test linsert-1.15 {linsert command} {
  60.     linsert {a b c \{\  abc} 4 q r
  61. } {a b c \{\  q r abc}
  62. test linsert-1.16 {linsert command} {
  63.     linsert {a b c \{ abc} 4 q r
  64. } {a b c \{ q r abc}
  65. test linsert-1.17 {linsert command} {
  66.     linsert {a b c} end q r
  67. } {a b c q r}
  68. test linsert-1.18 {linsert command} {
  69.     linsert {a} end q r
  70. } {a q r}
  71. test linsert-1.19 {linsert command} {
  72.     linsert {} end q r
  73. } {q r}
  74.  
  75. test linsert-2.1 {linsert errors} {
  76.     list [catch linsert msg] $msg
  77. } {1 {wrong # args: should be "linsert list index element ?element ...?"}}
  78. test linsert-2.2 {linsert errors} {
  79.     list [catch {linsert a b} msg] $msg
  80. } {1 {wrong # args: should be "linsert list index element ?element ...?"}}
  81. test linsert-2.3 {linsert errors} {
  82.     list [catch {linsert a 12x 2} msg] $msg
  83. } {1 {expected integer but got "12x"}}
  84. test linsert-2.4 {linsert errors} {
  85.     list [catch {linsert \{ 12 2} msg] $msg
  86. } {1 {unmatched open brace in list}}
  87.