home *** CD-ROM | disk | FTP | other *** search
/ Ultra Pack / UltraComputing Partner Applications.iso / SunLabs / tclTK / src / tk4.0 / tests / textMark.test < prev    next >
Encoding:
Text File  |  1994-12-17  |  4.4 KB  |  143 lines

  1. # This file is a Tcl script to test the code in the file tkTextMark.c.
  2. # This file is organized in the standard fashion for Tcl tests.
  3. #
  4. # Copyright (c) 1994 The Regents of the University of California.
  5. # Copyright (c) 1994 Sun Microsystems, Inc.
  6. #
  7. # See the file "license.terms" for information on usage and redistribution
  8. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  9. #
  10. # @(#) textMark.test 1.3 94/12/17 15:54:54
  11.  
  12. if {[string compare test [info procs test]] == 1} then \
  13.   {source defs}
  14.  
  15. catch {destroy .t}
  16. if [catch {text .t \
  17.     -font -adobe-courier-medium-r-normal--12-120-75-75-m-70-iso8859-1 \
  18.     -width 20 -height 10}] {
  19.     puts "The font needed by these tests isn't available, so I'm"
  20.     puts "going to skip the tests."
  21.     return
  22. }
  23. pack append . .t {top expand fill}
  24. update
  25. .t debug on
  26. wm geometry . {}
  27.   
  28. # The statements below reset the main window;  it's needed if the window
  29. # manager is mwm to make mwm forget about a previous minimum size setting.
  30.  
  31. wm withdraw .
  32. wm minsize . 1 1
  33. wm positionfrom . user
  34. wm deiconify .
  35.  
  36. entry .t.e
  37. .t insert 1.0 "Line 1
  38. abcdefghijklm
  39. 12345
  40. Line 4
  41. bOy GIrl .#@? x_yz
  42. !@#$%
  43. Line 7"
  44.  
  45. test textMark-1.1 {TkTextMarkCmd - "gravity" option} {
  46.     list [catch {.t mark} msg] $msg
  47. } {1 {wrong # args: should be ".t mark option ?arg arg ...?"}}
  48. test textMark-1.2 {TkTextMarkCmd - "gravity" option} {
  49.     list [catch {.t mark gorp} msg] $msg
  50. } {1 {bad mark option "gorp":  must be gravity, names, set, or unset}}
  51. test textMark-1.3 {TkTextMarkCmd - "gravity" option} {
  52.     list [catch {.t mark gravity foo} msg] $msg
  53. } {1 {there is no mark named "foo"}}
  54. test textMark-1.4 {TkTextMarkCmd - "gravity" option} {
  55.     .t mark unset x
  56.     .t mark set x 1.3
  57.     .t insert 1.3 x
  58.     list [.t mark gravity x] [.t index x]
  59. } {right 1.4}
  60. test textMark-1.5 {TkTextMarkCmd - "gravity" option} {
  61.     .t mark unset x
  62.     .t mark set x 1.3
  63.     .t mark g x left
  64.     .t insert 1.3 x
  65.     list [.t mark gravity x] [.t index x]
  66. } {left 1.3}
  67. test textMark-1.6 {TkTextMarkCmd - "gravity" option} {
  68.     .t mark unset x
  69.     .t mark set x 1.3
  70.     .t mark gravity x right
  71.     .t insert 1.3 x
  72.     list [.t mark gravity x] [.t index x]
  73. } {right 1.4}
  74. test textMark-1.7 {TkTextMarkCmd - "gravity" option} {
  75.     list [catch {.t mark gravity x gorp} msg] $msg
  76. } {1 {bad mark gravity "gorp": must be left or right}}
  77.  
  78. test textMark-2.1 {TkTextMarkCmd - "names" option} {
  79.     list [catch {.t mark names 2} msg] $msg
  80. } {1 {wrong # args: should be ".t mark names"}}
  81. .t mark unset x
  82. test textMark-2.2 {TkTextMarkCmd - "names" option} {
  83.     lsort [.t mark n]
  84. } {current insert}
  85. test textMark-2.3 {TkTextMarkCmd - "names" option} {
  86.     .t mark set a 1.1
  87.     .t mark set "b c" 2.3
  88.     lsort [.t mark names]
  89. } {a {b c} current insert}
  90.  
  91. test textMark-3.1 {TkTextMarkCmd - "set" option} {
  92.     list [catch {.t mark set a} msg] $msg
  93. } {1 {wrong # args: should be ".t mark set markName index"}}
  94. test textMark-3.2 {TkTextMarkCmd - "set" option} {
  95.     list [catch {.t mark s a b c} msg] $msg
  96. } {1 {wrong # args: should be ".t mark set markName index"}}
  97. test textMark-3.3 {TkTextMarkCmd - "set" option} {
  98.     list [catch {.t mark set a @x} msg] $msg
  99. } {1 {bad text index "@x"}}
  100. test textMark-3.4 {TkTextMarkCmd - "set" option} {
  101.     .t mark set a 1.2
  102.     .t index a
  103. } 1.2
  104. test textMark-3.5 {TkTextMarkCmd - "set" option} {
  105.     .t mark set a end
  106.     .t index a
  107. } {8.0}
  108.  
  109. test textMark-4.1 {TkTextMarkCmd - "unset" option} {
  110.     list [catch {.t mark unset} msg] $msg
  111. } {0 {}}
  112. test textMark-4.2 {TkTextMarkCmd - "unset" option} {
  113.     .t mark set a 1.2
  114.     .t mark set b 2.3
  115.     .t mark unset a b
  116.         list [catch {.t index a} msg] $msg [catch {.t index b} msg2] $msg2
  117. } {1 {bad text index "a"} 1 {bad text index "b"}}
  118. test textMark-4.3 {TkTextMarkCmd - "unset" option} {
  119.     .t mark set a 1.2
  120.     .t mark set b 2.3
  121.     .t mark set 49ers 3.1
  122.     eval .t mark unset [.t mark names]
  123.     lsort [.t mark names]
  124. } {current insert}
  125.  
  126. test textMark-5.1 {TkTextMarkCmd - miscellaneous} {
  127.     list [catch {.t mark} msg] $msg
  128. } {1 {wrong # args: should be ".t mark option ?arg arg ...?"}}
  129. test textMark-5.2 {TkTextMarkCmd - miscellaneous} {
  130.     list [catch {.t mark foo} msg] $msg
  131. } {1 {bad mark option "foo":  must be gravity, names, set, or unset}}
  132.  
  133. test textMark-6.1 {TkTextMarkSegToIndex} {
  134.     .t mark set a 1.2
  135.     .t mark set b 1.2
  136.     .t mark set c 1.2
  137.     .t mark set d 1.4
  138.     list [.t index a] [.t index b] [.t index c ] [.t index d]
  139. } {1.2 1.2 1.2 1.4}
  140.  
  141. catch {destroy .t}
  142. concat {}
  143.