OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [start/] [insight/] [tk/] [tests/] [textIndex.test] - Blame information for rev 1780

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# This file is a Tcl script to test the code in the file tkTextIndex.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: textIndex.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
.t insert 1.0 "Line 1
35
abcdefghijklm
36
12345
37
Line 4
38
bOy GIrl .#@? x_yz
39
!@#$%
40
Line 7"
41
 
42
test textIndex-1.1 {TkTextMakeIndex} {
43
    .t index -1.3
44
} 1.0
45
test textIndex-1.2 {TkTextMakeIndex} {
46
    .t index 0.3
47
} 1.0
48
test textIndex-1.3 {TkTextMakeIndex} {
49
    .t index 1.3
50
} 1.3
51
test textIndex-1.4 {TkTextMakeIndex} {
52
    .t index 3.-1
53
} 3.0
54
test textIndex-1.5 {TkTextMakeIndex} {
55
    .t index 3.3
56
} 3.3
57
test textIndex-1.6 {TkTextMakeIndex} {
58
    .t index 3.5
59
} 3.5
60
test textIndex-1.7 {TkTextMakeIndex} {
61
    .t index 3.6
62
} 3.5
63
test textIndex-1.8 {TkTextMakeIndex} {
64
    .t index 3.7
65
} 3.5
66
test textIndex-1.9 {TkTextMakeIndex} {
67
    .t index 7.2
68
} 7.2
69
test textIndex-1.10 {TkTextMakeIndex} {
70
    .t index 8.0
71
} 8.0
72
test textIndex-1.11 {TkTextMakeIndex} {
73
    .t index 8.1
74
} 8.0
75
test textIndex-1.12 {TkTextMakeIndex} {
76
    .t index 9.0
77
} 8.0
78
 
79
.t tag add x 2.3 2.6
80
test textIndex-2.1 {TkTextIndexToSeg} {
81
    .t get 2.0
82
} a
83
test textIndex-2.2 {TkTextIndexToSeg} {
84
    .t get 2.2
85
} c
86
test textIndex-2.3 {TkTextIndexToSeg} {
87
    .t get 2.3
88
} d
89
test textIndex-2.4 {TkTextIndexToSeg} {
90
    .t get 2.6
91
} g
92
test textIndex-2.5 {TkTextIndexToSeg} {
93
    .t get 2.7
94
} h
95
test textIndex-2.6 {TkTextIndexToSeg} {
96
    .t get 2.12
97
} m
98
test textIndex-2.7 {TkTextIndexToSeg} {
99
    .t get 2.13
100
} \n
101
test textIndex-2.8 {TkTextIndexToSeg} {
102
    .t get 2.14
103
} \n
104
.t tag delete x
105
 
106
.t mark set foo 3.2
107
.t tag add x 2.8 2.11
108
.t tag add x 6.0 6.2
109
set weirdTag "funny . +- 22.1\n\t{"
110
.t tag add $weirdTag 2.1  2.6
111
set weirdMark "asdf \n{-+ 66.2\t"
112
.t mark set $weirdMark 4.0
113
.t tag config y -relief raised
114
test textIndex-3.1 {TkTextGetIndex, weird mark names} {
115
    list [catch {.t index $weirdMark} msg] $msg
116
} {0 4.0}
117
 
118
test textIndex-4.1 {TkTextGetIndex, tags} {
119
    list [catch {.t index x.first} msg] $msg
120
} {0 2.8}
121
test textIndex-4.2 {TkTextGetIndex, tags} {
122
    list [catch {.t index x.last} msg] $msg
123
} {0 6.2}
124
test textIndex-4.3 {TkTextGetIndex, weird tags} {
125
    list [.t index $weirdTag.first+1c] [.t index $weirdTag.last+2c]
126
} {2.2 2.8}
127
test textIndex-4.4 {TkTextGetIndex, tags} {
128
    list [catch {.t index x.gorp} msg] $msg
129
} {1 {bad text index "x.gorp"}}
130
test textIndex-4.5 {TkTextGetIndex, tags} {
131
    list [catch {.t index foo.last} msg] $msg
132
} {1 {bad text index "foo.last"}}
133
test textIndex-4.6 {TkTextGetIndex, tags} {
134
    list [catch {.t index y.first} msg] $msg
135
} {1 {text doesn't contain any characters tagged with "y"}}
136
test textIndex-4.7 {TkTextGetIndex, tags} {
137
    list [catch {.t index x.last,} msg] $msg
138
} {1 {bad text index "x.last,"}}
139
test textIndex-4.8 {TkTextGetIndex, tags} {
140
    .t tag add z 1.0
141
    set result [list [.t index z.first] [.t index z.last]]
142
    .t tag delete z
143
    set result
144
} {1.0 1.1}
145
 
146
test textIndex-5.1 {TkTextGetIndex, "@"} {fonts} {
147
    .t index @12,9
148
} 1.1
149
test textIndex-5.2 {TkTextGetIndex, "@"} {fonts} {
150
    .t index @-2,7
151
} 1.0
152
test textIndex-5.3 {TkTextGetIndex, "@"} {fonts} {
153
    .t index @10,-7
154
} 1.0
155
test textIndex-5.4 {TkTextGetIndex, "@"} {fonts} {
156
    list [catch {.t index @x} msg] $msg
157
} {1 {bad text index "@x"}}
158
test textIndex-5.5 {TkTextGetIndex, "@"} {fonts} {
159
    list [catch {.t index @10q} msg] $msg
160
} {1 {bad text index "@10q"}}
161
test textIndex-5.6 {TkTextGetIndex, "@"} {fonts} {
162
    list [catch {.t index @10,} msg] $msg
163
} {1 {bad text index "@10,"}}
164
test textIndex-5.7 {TkTextGetIndex, "@"} {fonts} {
165
    list [catch {.t index @10,a} msg] $msg
166
} {1 {bad text index "@10,a"}}
167
test textIndex-5.8 {TkTextGetIndex, "@"} {fonts} {
168
    list [catch {.t index @10,9,} msg] $msg
169
} {1 {bad text index "@10,9,"}}
170
 
171
test textIndex-6.1 {TkTextGetIndex, numeric} {
172
    list [catch {.t index 2.3} msg] $msg
173
} {0 2.3}
174
test textIndex-6.2 {TkTextGetIndex, numeric} {
175
    list [catch {.t index -} msg] $msg
176
} {1 {bad text index "-"}}
177
test textIndex-6.3 {TkTextGetIndex, numeric} {
178
    list [catch {.t index 2.end} msg] $msg
179
} {0 2.13}
180
test textIndex-6.4 {TkTextGetIndex, numeric} {
181
    list [catch {.t index 2.x} msg] $msg
182
} {1 {bad text index "2.x"}}
183
test textIndex-6.5 {TkTextGetIndex, numeric} {
184
    list [catch {.t index 2.3x} msg] $msg
185
} {1 {bad text index "2.3x"}}
186
 
187
test textIndex-7.1 {TkTextGetIndex, miscellaneous other bases} {
188
    list [catch {.t index end} msg] $msg
189
} {0 8.0}
190
test textIndex-7.2 {TkTextGetIndex, miscellaneous other bases} {
191
    list [catch {.t index foo} msg] $msg
192
} {0 3.2}
193
test textIndex-7.3 {TkTextGetIndex, miscellaneous other bases} {
194
    list [catch {.t index foo+1c} msg] $msg
195
} {0 3.3}
196
 
197
test textIndex-8.1 {TkTextGetIndex, modifiers} {
198
    list [catch {.t index 2.1+1char} msg] $msg
199
} {0 2.2}
200
test textIndex-8.2 {TkTextGetIndex, modifiers} {
201
    list [catch {.t index "2.1          +1char"} msg] $msg
202
} {0 2.2}
203
test textIndex-8.3 {TkTextGetIndex, modifiers} {
204
    list [catch {.t index 2.1-1char} msg] $msg
205
} {0 2.0}
206
test textIndex-8.4 {TkTextGetIndex, modifiers} {
207
    list [catch {.t index {2.1  }} msg] $msg
208
} {0 2.1}
209
test textIndex-8.5 {TkTextGetIndex, modifiers} {
210
    list [catch {.t index {2.1+foo bar}} msg] $msg
211
} {1 {bad text index "2.1+foo bar"}}
212
test textIndex-8.6 {TkTextGetIndex, modifiers} {
213
    list [catch {.t index {2.1 foo bar}} msg] $msg
214
} {1 {bad text index "2.1 foo bar"}}
215
 
216
test textIndex-9.1 {TkTextIndexCmp} {
217
    list [.t compare 3.1 < 3.2] [.t compare 3.1 == 3.2]
218
} {1 0}
219
test textIndex-9.2 {TkTextIndexCmp} {
220
    list [.t compare 3.2 < 3.2] [.t compare 3.2 == 3.2]
221
} {0 1}
222
test textIndex-9.3 {TkTextIndexCmp} {
223
    list [.t compare 3.3 < 3.2] [.t compare 3.3 == 3.2]
224
} {0 0}
225
test textIndex-9.4 {TkTextIndexCmp} {
226
    list [.t compare 2.1 < 3.2] [.t compare 2.1 == 3.2]
227
} {1 0}
228
test textIndex-9.5 {TkTextIndexCmp} {
229
    list [.t compare 4.1 < 3.2] [.t compare 4.1 == 3.2]
230
} {0 0}
231
 
232
test textIndex-10.1 {ForwBack} {
233
    list [catch {.t index {2.3 + x}} msg] $msg
234
} {1 {bad text index "2.3 + x"}}
235
test textIndex-10.2 {ForwBack} {
236
    list [catch {.t index {2.3 + 2 chars}} msg] $msg
237
} {0 2.5}
238
test textIndex-10.3 {ForwBack} {
239
    list [catch {.t index {2.3 + 2c}} msg] $msg
240
} {0 2.5}
241
test textIndex-10.4 {ForwBack} {
242
    list [catch {.t index {2.3 - 3ch}} msg] $msg
243
} {0 2.0}
244
test textIndex-10.5 {ForwBack} {
245
    list [catch {.t index {2.3 + 3 lines}} msg] $msg
246
} {0 5.3}
247
test textIndex-10.6 {ForwBack} {
248
    list [catch {.t index {2.3 -1l}} msg] $msg
249
} {0 1.3}
250
test textIndex-10.7 {ForwBack} {
251
    list [catch {.t index {2.3 -1 gorp}} msg] $msg
252
} {1 {bad text index "2.3 -1 gorp"}}
253
test textIndex-10.8 {ForwBack} {
254
    list [catch {.t index {2.3 - 4 lines}} msg] $msg
255
} {0 1.3}
256
 
257
test textIndex-11.1 {TkTextIndexForwChars} {
258
    .t index {2.3 + -7 chars}
259
} 1.3
260
test textIndex-11.2 {TkTextIndexForwChars} {
261
    .t index {2.3 + 5 chars}
262
} 2.8
263
test textIndex-11.3 {TkTextIndexForwChars} {
264
    .t index {2.3 + 10 chars}
265
} 2.13
266
test textIndex-11.4 {TkTextIndexForwChars} {
267
    .t index {2.3 + 11 chars}
268
} 3.0
269
test textIndex-11.5 {TkTextIndexForwChars} {
270
    .t index {2.3 + 55 chars}
271
} 7.6
272
test textIndex-11.6 {TkTextIndexForwChars} {
273
    .t index {2.3 + 56 chars}
274
} 8.0
275
test textIndex-11.7 {TkTextIndexForwChars} {
276
    .t index {2.3 + 57 chars}
277
} 8.0
278
 
279
test textIndex-12.1 {TkTextIndexBackChars} {
280
    .t index {3.2 - -10 chars}
281
} 4.6
282
test textIndex-12.2 {TkTextIndexBackChars} {
283
    .t index {3.2 - 2 chars}
284
} 3.0
285
test textIndex-12.3 {TkTextIndexBackChars} {
286
    .t index {3.2 - 3 chars}
287
} 2.13
288
test textIndex-12.4 {TkTextIndexBackChars} {
289
    .t index {3.2 - 22 chars}
290
} 1.1
291
test textIndex-12.5 {TkTextIndexBackChars} {
292
    .t index {3.2 - 23 chars}
293
} 1.0
294
test textIndex-12.6 {TkTextIndexBackChars} {
295
    .t index {3.2 - 24 chars}
296
} 1.0
297
 
298
proc getword index {
299
    .t get [.t index "$index wordstart"] [.t index "$index wordend"]
300
}
301
test textIndex-13.1 {StartEnd} {
302
    list [catch {.t index {2.3 lineend}} msg] $msg
303
} {0 2.13}
304
test textIndex-13.2 {StartEnd} {
305
    list [catch {.t index {2.3 linee}} msg] $msg
306
} {0 2.13}
307
test textIndex-13.3 {StartEnd} {
308
    list [catch {.t index {2.3 line}} msg] $msg
309
} {1 {bad text index "2.3 line"}}
310
test textIndex-13.4 {StartEnd} {
311
    list [catch {.t index {2.3 linestart}} msg] $msg
312
} {0 2.0}
313
test textIndex-13.5 {StartEnd} {
314
    list [catch {.t index {2.3 lines}} msg] $msg
315
} {0 2.0}
316
test textIndex-13.6 {StartEnd} {
317
    getword 5.3
318
} { }
319
test textIndex-13.7 {StartEnd} {
320
    getword 5.4
321
} GIrl
322
test textIndex-13.8 {StartEnd} {
323
    getword 5.7
324
} GIrl
325
test textIndex-13.9 {StartEnd} {
326
    getword 5.8
327
} { }
328
test textIndex-13.10 {StartEnd} {
329
    getword 5.14
330
} x_yz
331
test textIndex-13.11 {StartEnd} {
332
    getword 6.2
333
} #
334
test textIndex-13.12 {StartEnd} {
335
    getword 3.4
336
} 12345
337
.t tag add x 2.8 2.11
338
test textIndex-13.13 {StartEnd} {
339
    list [catch {.t index {2.2 worde}} msg] $msg
340
} {0 2.13}
341
test textIndex-13.14 {StartEnd} {
342
    list [catch {.t index {2.12 words}} msg] $msg
343
} {0 2.0}
344
test textIndex-13.15 {StartEnd} {
345
    list [catch {.t index {2.12 word}} msg] $msg
346
} {1 {bad text index "2.12 word"}}
347
 
348
catch {destroy .t}
349
concat

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.