1 |
578 |
markom |
# 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 |
|
|
# RCS: @(#) $Id: textMark.test,v 1.1.1.1 2002-01-16 10:26:00 markom Exp $
|
11 |
|
|
|
12 |
|
|
if {[string compare test [info procs test]] == 1} then \
|
13 |
|
|
{source defs}
|
14 |
|
|
|
15 |
|
|
catch {destroy .t}
|
16 |
|
|
if [catch {text .t -font {Courier 12} -width 20 -height 10}] {
|
17 |
|
|
puts "The font needed by these tests isn't available, so I'm"
|
18 |
|
|
puts "going to skip the tests."
|
19 |
|
|
return
|
20 |
|
|
}
|
21 |
|
|
pack append . .t {top expand fill}
|
22 |
|
|
update
|
23 |
|
|
.t debug on
|
24 |
|
|
wm geometry . {}
|
25 |
|
|
|
26 |
|
|
# The statements below reset the main window; it's needed if the window
|
27 |
|
|
# manager is mwm to make mwm forget about a previous minimum size setting.
|
28 |
|
|
|
29 |
|
|
wm withdraw .
|
30 |
|
|
wm minsize . 1 1
|
31 |
|
|
wm positionfrom . user
|
32 |
|
|
wm deiconify .
|
33 |
|
|
|
34 |
|
|
entry .t.e
|
35 |
|
|
.t insert 1.0 "Line 1
|
36 |
|
|
abcdefghijklm
|
37 |
|
|
12345
|
38 |
|
|
Line 4
|
39 |
|
|
bOy GIrl .#@? x_yz
|
40 |
|
|
!@#$%
|
41 |
|
|
Line 7"
|
42 |
|
|
|
43 |
|
|
test textMark-1.1 {TkTextMarkCmd - missing option} {
|
44 |
|
|
list [catch {.t mark} msg] $msg
|
45 |
|
|
} {1 {wrong # args: should be ".t mark option ?arg arg ...?"}}
|
46 |
|
|
test textMark-1.2 {TkTextMarkCmd - bogus option} {
|
47 |
|
|
list [catch {.t mark gorp} msg] $msg
|
48 |
|
|
} {1 {bad mark option "gorp": must be gravity, names, next, previous, set, or unset}}
|
49 |
|
|
test textMark-1.3 {TkTextMarkCmd - "gravity" option} {
|
50 |
|
|
list [catch {.t mark gravity foo} msg] $msg
|
51 |
|
|
} {1 {there is no mark named "foo"}}
|
52 |
|
|
test textMark-1.4 {TkTextMarkCmd - "gravity" option} {
|
53 |
|
|
.t mark unset x
|
54 |
|
|
.t mark set x 1.3
|
55 |
|
|
.t insert 1.3 x
|
56 |
|
|
list [.t mark gravity x] [.t index x]
|
57 |
|
|
} {right 1.4}
|
58 |
|
|
test textMark-1.5 {TkTextMarkCmd - "gravity" option} {
|
59 |
|
|
.t mark unset x
|
60 |
|
|
.t mark set x 1.3
|
61 |
|
|
.t mark g x left
|
62 |
|
|
.t insert 1.3 x
|
63 |
|
|
list [.t mark gravity x] [.t index x]
|
64 |
|
|
} {left 1.3}
|
65 |
|
|
test textMark-1.6 {TkTextMarkCmd - "gravity" option} {
|
66 |
|
|
.t mark unset x
|
67 |
|
|
.t mark set x 1.3
|
68 |
|
|
.t mark gravity x right
|
69 |
|
|
.t insert 1.3 x
|
70 |
|
|
list [.t mark gravity x] [.t index x]
|
71 |
|
|
} {right 1.4}
|
72 |
|
|
test textMark-1.7 {TkTextMarkCmd - "gravity" option} {
|
73 |
|
|
list [catch {.t mark gravity x gorp} msg] $msg
|
74 |
|
|
} {1 {bad mark gravity "gorp": must be left or right}}
|
75 |
|
|
test textMark-1.8 {TkTextMarkCmd - "gravity" option} {
|
76 |
|
|
list [catch {.t mark gravity} msg] $msg
|
77 |
|
|
} {1 {wrong # args: should be ".t mark gravity markName ?gravity?"}}
|
78 |
|
|
|
79 |
|
|
test textMark-2.1 {TkTextMarkCmd - "names" option} {
|
80 |
|
|
list [catch {.t mark names 2} msg] $msg
|
81 |
|
|
} {1 {wrong # args: should be ".t mark names"}}
|
82 |
|
|
.t mark unset x
|
83 |
|
|
test textMark-2.2 {TkTextMarkCmd - "names" option} {
|
84 |
|
|
lsort [.t mark n]
|
85 |
|
|
} {current insert}
|
86 |
|
|
test textMark-2.3 {TkTextMarkCmd - "names" option} {
|
87 |
|
|
.t mark set a 1.1
|
88 |
|
|
.t mark set "b c" 2.3
|
89 |
|
|
lsort [.t mark names]
|
90 |
|
|
} {a {b c} current insert}
|
91 |
|
|
|
92 |
|
|
test textMark-3.1 {TkTextMarkCmd - "set" option} {
|
93 |
|
|
list [catch {.t mark set a} msg] $msg
|
94 |
|
|
} {1 {wrong # args: should be ".t mark set markName index"}}
|
95 |
|
|
test textMark-3.2 {TkTextMarkCmd - "set" option} {
|
96 |
|
|
list [catch {.t mark s a b c} msg] $msg
|
97 |
|
|
} {1 {wrong # args: should be ".t mark set markName index"}}
|
98 |
|
|
test textMark-3.3 {TkTextMarkCmd - "set" option} {
|
99 |
|
|
list [catch {.t mark set a @x} msg] $msg
|
100 |
|
|
} {1 {bad text index "@x"}}
|
101 |
|
|
test textMark-3.4 {TkTextMarkCmd - "set" option} {
|
102 |
|
|
.t mark set a 1.2
|
103 |
|
|
.t index a
|
104 |
|
|
} 1.2
|
105 |
|
|
test textMark-3.5 {TkTextMarkCmd - "set" option} {
|
106 |
|
|
.t mark set a end
|
107 |
|
|
.t index a
|
108 |
|
|
} {8.0}
|
109 |
|
|
|
110 |
|
|
test textMark-4.1 {TkTextMarkCmd - "unset" option} {
|
111 |
|
|
list [catch {.t mark unset} msg] $msg
|
112 |
|
|
} {0 {}}
|
113 |
|
|
test textMark-4.2 {TkTextMarkCmd - "unset" option} {
|
114 |
|
|
.t mark set a 1.2
|
115 |
|
|
.t mark set b 2.3
|
116 |
|
|
.t mark unset a b
|
117 |
|
|
list [catch {.t index a} msg] $msg [catch {.t index b} msg2] $msg2
|
118 |
|
|
} {1 {bad text index "a"} 1 {bad text index "b"}}
|
119 |
|
|
test textMark-4.3 {TkTextMarkCmd - "unset" option} {
|
120 |
|
|
.t mark set a 1.2
|
121 |
|
|
.t mark set b 2.3
|
122 |
|
|
.t mark set 49ers 3.1
|
123 |
|
|
eval .t mark unset [.t mark names]
|
124 |
|
|
lsort [.t mark names]
|
125 |
|
|
} {current insert}
|
126 |
|
|
|
127 |
|
|
test textMark-5.1 {TkTextMarkCmd - miscellaneous} {
|
128 |
|
|
list [catch {.t mark} msg] $msg
|
129 |
|
|
} {1 {wrong # args: should be ".t mark option ?arg arg ...?"}}
|
130 |
|
|
test textMark-5.2 {TkTextMarkCmd - miscellaneous} {
|
131 |
|
|
list [catch {.t mark foo} msg] $msg
|
132 |
|
|
} {1 {bad mark option "foo": must be gravity, names, next, previous, set, or unset}}
|
133 |
|
|
|
134 |
|
|
test textMark-6.1 {TkTextMarkSegToIndex} {
|
135 |
|
|
.t mark set a 1.2
|
136 |
|
|
.t mark set b 1.2
|
137 |
|
|
.t mark set c 1.2
|
138 |
|
|
.t mark set d 1.4
|
139 |
|
|
list [.t index a] [.t index b] [.t index c ] [.t index d]
|
140 |
|
|
} {1.2 1.2 1.2 1.4}
|
141 |
|
|
|
142 |
|
|
catch {eval {.t mark unset} [.t mark names]}
|
143 |
|
|
test textMark-7.1 {MarkFindNext - invalid mark name} {
|
144 |
|
|
catch {.t mark next bogus} x
|
145 |
|
|
set x
|
146 |
|
|
} {bad text index "bogus"}
|
147 |
|
|
test textMark-7.2 {MarkFindNext - marks at same location} {
|
148 |
|
|
.t mark set insert 2.0
|
149 |
|
|
.t mark set current 2.0
|
150 |
|
|
.t mark next current
|
151 |
|
|
} {insert}
|
152 |
|
|
test textMark-7.3 {MarkFindNext - numerical starting mark} {
|
153 |
|
|
.t mark set current 1.0
|
154 |
|
|
.t mark set insert 1.0
|
155 |
|
|
.t mark next 1.0
|
156 |
|
|
} {insert}
|
157 |
|
|
test textMark-7.4 {MarkFindNext - mark on the same line} {
|
158 |
|
|
.t mark set current 1.0
|
159 |
|
|
.t mark set insert 1.1
|
160 |
|
|
.t mark next current
|
161 |
|
|
} {insert}
|
162 |
|
|
test textMark-7.5 {MarkFindNext - mark on the next line} {
|
163 |
|
|
.t mark set current 1.end
|
164 |
|
|
.t mark set insert 2.0
|
165 |
|
|
.t mark next current
|
166 |
|
|
} {insert}
|
167 |
|
|
test textMark-7.6 {MarkFindNext - mark far away} {
|
168 |
|
|
.t mark set current 1.2
|
169 |
|
|
.t mark set insert 7.0
|
170 |
|
|
.t mark next current
|
171 |
|
|
} {insert}
|
172 |
|
|
test textMark-7.7 {MarkFindNext - mark on top of end} {
|
173 |
|
|
.t mark set current end
|
174 |
|
|
.t mark next end
|
175 |
|
|
} {current}
|
176 |
|
|
test textMark-7.8 {MarkFindNext - no next mark} {
|
177 |
|
|
.t mark set current 1.0
|
178 |
|
|
.t mark set insert 3.0
|
179 |
|
|
.t mark next insert
|
180 |
|
|
} {}
|
181 |
|
|
test textMark-8.1 {MarkFindPrev - invalid mark name} {
|
182 |
|
|
catch {.t mark prev bogus} x
|
183 |
|
|
set x
|
184 |
|
|
} {bad text index "bogus"}
|
185 |
|
|
test textMark-8.2 {MarkFindPrev - marks at same location} {
|
186 |
|
|
.t mark set insert 2.0
|
187 |
|
|
.t mark set current 2.0
|
188 |
|
|
.t mark prev insert
|
189 |
|
|
} {current}
|
190 |
|
|
test textMark-8.3 {MarkFindPrev - numerical starting mark} {
|
191 |
|
|
.t mark set current 1.0
|
192 |
|
|
.t mark set insert 1.0
|
193 |
|
|
.t mark prev 1.1
|
194 |
|
|
} {current}
|
195 |
|
|
test textMark-8.4 {MarkFindPrev - mark on the same line} {
|
196 |
|
|
.t mark set current 1.0
|
197 |
|
|
.t mark set insert 1.1
|
198 |
|
|
.t mark prev insert
|
199 |
|
|
} {current}
|
200 |
|
|
test textMark-8.5 {MarkFindPrev - mark on the previous line} {
|
201 |
|
|
.t mark set current 1.end
|
202 |
|
|
.t mark set insert 2.0
|
203 |
|
|
.t mark prev insert
|
204 |
|
|
} {current}
|
205 |
|
|
test textMark-8.6 {MarkFindPrev - mark far away} {
|
206 |
|
|
.t mark set current 1.2
|
207 |
|
|
.t mark set insert 7.0
|
208 |
|
|
.t mark prev insert
|
209 |
|
|
} {current}
|
210 |
|
|
test textMark-8.7 {MarkFindPrev - mark on top of end} {
|
211 |
|
|
.t mark set insert 3.0
|
212 |
|
|
.t mark set current end
|
213 |
|
|
.t mark prev end
|
214 |
|
|
} {insert}
|
215 |
|
|
test textMark-8.8 {MarkFindPrev - no previous mark} {
|
216 |
|
|
.t mark set current 1.0
|
217 |
|
|
.t mark set insert 3.0
|
218 |
|
|
.t mark prev current
|
219 |
|
|
} {}
|
220 |
|
|
|
221 |
|
|
catch {destroy .t}
|
222 |
|
|
concat {}
|