summaryrefslogtreecommitdiffstats
path: root/tests/word.test
blob: c141abad8ab91f0306465b1877036d2cf0f14de6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# This file is a Tcl script to test the [tcl_startOf|endOf]* functions in
# word.tcl.  It is organized in the standard fashion for Tcl tests.
#
# Copyright (c) 2024 Jan Nijtmans
# All rights reserved.

if {"::tcltest" ni [namespace children]} {
    package require tcltest 2.5
    namespace import -force ::tcltest::*
}

::tcltest::loadTestedCommands
catch [list package require -exact tcl::test [info patchlevel]]

test word-1.0 {tcl_endOfWord} -body {
    tcl_endOfWord "ab cd" -1
} -result 2
test word-1.1 {tcl_endOfWord} -body {
    tcl_endOfWord "ab cd" 0
} -result 2
test word-1.2 {tcl_endOfWord} -body {
    tcl_endOfWord "ab cd" 1
} -result 2
test word-1.3 {tcl_endOfWord} -body {
    tcl_endOfWord "ab cd" 2
} -result -1
test word-1.4 {tcl_endOfWord} -body {
    tcl_endOfWord "ab cd" 3
} -result -1
test word-1.5 {tcl_endOfWord} -body {
    tcl_endOfWord "ab cd" 4
} -result -1
test word-1.6 {tcl_endOfWord} -body {
    tcl_endOfWord "ab cd" 5
} -result -1
test word-1.7 {tcl_endOfWord} -body {
    tcl_endOfWord "ab cd" end
} -result -1
test word-1.8 {tcl_endOfWord} -body {
    tcl_endOfWord "ab cd" end-1
} -result -1

test word-2.0 {tcl_startOfPreviousWord} -body {
    tcl_startOfPreviousWord "ab cd" -1
} -result -1
test word-2.1 {tcl_startOfPreviousWord} -body {
    tcl_startOfPreviousWord "ab cd" 0
} -result -1
test word-2.2 {tcl_startOfPreviousWord} -body {
    tcl_startOfPreviousWord "ab cd" 1
} -result 0
test word-2.3 {tcl_startOfPreviousWord} -body {
    tcl_startOfPreviousWord "ab cd" 2
} -result 0
test word-2.4 {tcl_startOfPreviousWord} -body {
    tcl_startOfPreviousWord "ab cd" 3
} -result 0
test word-2.5 {tcl_startOfPreviousWord} -body {
    tcl_startOfPreviousWord "ab cd" 4
} -result 3
test word-2.6 {tcl_startOfPreviousWord} -body {
    tcl_startOfPreviousWord "ab cd" 5
} -result 3
test word-2.7 {tcl_startOfPreviousWord} -body {
    tcl_startOfPreviousWord "ab cd" end
} -result 3
test word-2.8 {tcl_startOfPreviousWord, bug [16e25e1402]} -body {
    tcl_startOfPreviousWord "ab cd" end-1
} -result 0

test word-3.0 {tcl_startOfNextWord} -body {
    tcl_startOfNextWord "ab cd" -1
} -result 3
test word-3.1 {tcl_startOfNextWord} -body {
    tcl_startOfNextWord "ab cd" 0
} -result 3
test word-3.2 {tcl_startOfNextWord} -body {
    tcl_startOfNextWord "ab cd" 1
} -result 3
test word-3.3 {tcl_startOfNextWord} -body {
    tcl_startOfNextWord "ab cd" 2
} -result 3
test word-3.4 {tcl_startOfNextWord} -body {
    tcl_startOfNextWord "ab cd" 3
} -result -1
test word-3.5 {tcl_startOfNextWord} -body {
    tcl_startOfNextWord "ab cd" 4
} -result -1
test word-3.6 {tcl_startOfNextWord} -body {
    tcl_startOfNextWord "ab cd" 5
} -result -1
test word-3.7 {tcl_startOfNextWord} -body {
    tcl_startOfNextWord "ab cd" end
} -result -1
test word-3.8 {tcl_startOfNextWord} -body {
    tcl_startOfNextWord "ab cd" end-1
} -result -1

test word-4.0 {tcl_wordBreakBefore} -body {
    tcl_wordBreakBefore "ab cd" -1
} -result -1
test word-4.1 {tcl_wordBreakBefore} -body {
    tcl_wordBreakBefore "ab cd" 0
} -result -1
test word-4.2 {tcl_wordBreakBefore} -body {
    tcl_wordBreakBefore "ab cd" 1
} -result -1
test word-4.3 {tcl_wordBreakBefore} -body {
    tcl_wordBreakBefore "ab cd" 2
} -result 2
test word-4.4 {tcl_wordBreakBefore} -body {
    tcl_wordBreakBefore "ab cd" 3
} -result 3
test word-4.5 {tcl_wordBreakBefore} -body {
    tcl_wordBreakBefore "ab cd" 4
} -result 3
test word-4.6 {tcl_wordBreakBefore} -body {
    tcl_wordBreakBefore "ab cd" 5
} -result 3
test word-4.7 {tcl_wordBreakBefore} -body {
    tcl_wordBreakBefore "ab cd" end
} -result 3
test word-4.8 {tcl_wordBreakBefore} -body {
    tcl_startOfNextWord "ab cd" end-1
} -result -1

test word-5.0 {tcl_wordBreakAfter} -body {
    tcl_wordBreakAfter "ab cd" -1
} -result 2
test word-5.1 {tcl_wordBreakAfter} -body {
    tcl_wordBreakAfter "ab cd" 0
} -result 2
test word-5.2 {tcl_wordBreakAfter} -body {
    tcl_wordBreakAfter "ab cd" 1
} -result 2
test word-5.3 {tcl_wordBreakAfter} -body {
    tcl_wordBreakAfter "ab cd" 2
} -result 3
test word-5.4 {tcl_wordBreakAfter} -body {
    tcl_wordBreakAfter "ab cd" 3
} -result -1
test word-5.5 {tcl_wordBreakAfter} -body {
    tcl_wordBreakAfter "ab cd" 4
} -result -1
test word-5.6 {tcl_wordBreakAfter} -body {
    tcl_wordBreakAfter "ab cd" 5
} -result -1
test word-5.7 {tcl_wordBreakAfter} -body {
    tcl_wordBreakAfter "ab cd" end
} -result -1
test word-5.8 {tcl_wordBreakAfter} -body {
    tcl_wordBreakAfter "ab cd" end-1
} -result -1

test word-6.0 {tcl_startOfPreviousWord} -body {
    tcl_startOfPreviousWord a b c d
} -returnCodes 1 -result {wrong # args: should be "tcl_startOfPreviousWord str start"}
test word-6.1 {tcl_startOfNextWord} -body {
    tcl_startOfNextWord a b c d
} -returnCodes 1 -result {wrong # args: should be "tcl_startOfNextWord str start"}
test word-6.2 {tcl_endOfWord} -body {
    tcl_endOfWord a b c d
} -returnCodes 1 -result {wrong # args: should be "tcl_endOfWord str start"}
test word-6.3 {tcl_wordBreakBefore} -body {
    tcl_wordBreakBefore a b c d
} -returnCodes 1 -result {wrong # args: should be "tcl_wordBreakBefore str start"}
test word-6.4 {tcl_wordBreakAfter} -body {
    tcl_wordBreakAfter a b c d
} -returnCodes 1 -result {wrong # args: should be "tcl_wordBreakAfter str start"}

# cleanup
::tcltest::cleanupTests
return

# Local Variables:
# mode: tcl
# End: