| 1 |
# This file is a Tcl script to test the [tcl_startOf|endOf]* functions in |
| 2 |
# word.tcl. It is organized in the standard fashion for Tcl tests. |
| 3 |
# |
| 4 |
# Copyright (c) 2024 Jan Nijtmans |
| 5 |
# All rights reserved. |
| 6 |
|
| 7 |
if {"::tcltest" ni [namespace children]} { |
| 8 |
package require tcltest 2.5 |
| 9 |
namespace import -force ::tcltest::* |
| 10 |
} |
| 11 |
|
| 12 |
::tcltest::loadTestedCommands |
| 13 |
catch [list package require -exact tcl::test [info patchlevel]] |
| 14 |
|
| 15 |
test word-1.0 {tcl_endOfWord} -body { |
| 16 |
tcl_endOfWord "ab cd" -1 |
| 17 |
} -result 2 |
| 18 |
test word-1.1 {tcl_endOfWord} -body { |
| 19 |
tcl_endOfWord "ab cd" 0 |
| 20 |
} -result 2 |
| 21 |
test word-1.2 {tcl_endOfWord} -body { |
| 22 |
tcl_endOfWord "ab cd" 1 |
| 23 |
} -result 2 |
| 24 |
test word-1.3 {tcl_endOfWord} -body { |
| 25 |
tcl_endOfWord "ab cd" 2 |
| 26 |
} -result -1 |
| 27 |
test word-1.4 {tcl_endOfWord} -body { |
| 28 |
tcl_endOfWord "ab cd" 3 |
| 29 |
} -result -1 |
| 30 |
test word-1.5 {tcl_endOfWord} -body { |
| 31 |
tcl_endOfWord "ab cd" 4 |
| 32 |
} -result -1 |
| 33 |
test word-1.6 {tcl_endOfWord} -body { |
| 34 |
tcl_endOfWord "ab cd" 5 |
| 35 |
} -result -1 |
| 36 |
test word-1.7 {tcl_endOfWord} -body { |
| 37 |
tcl_endOfWord "ab cd" end |
| 38 |
} -result -1 |
| 39 |
test word-1.8 {tcl_endOfWord} -body { |
| 40 |
tcl_endOfWord "ab cd" end-1 |
| 41 |
} -result -1 |
| 42 |
|
| 43 |
test word-2.0 {tcl_startOfPreviousWord} -body { |
| 44 |
tcl_startOfPreviousWord "ab cd" -1 |
| 45 |
} -result -1 |
| 46 |
test word-2.1 {tcl_startOfPreviousWord} -body { |
| 47 |
tcl_startOfPreviousWord "ab cd" 0 |
| 48 |
} -result -1 |
| 49 |
test word-2.2 {tcl_startOfPreviousWord} -body { |
| 50 |
tcl_startOfPreviousWord "ab cd" 1 |
| 51 |
} -result 0 |
| 52 |
test word-2.3 {tcl_startOfPreviousWord} -body { |
| 53 |
tcl_startOfPreviousWord "ab cd" 2 |
| 54 |
} -result 0 |
| 55 |
test word-2.4 {tcl_startOfPreviousWord} -body { |
| 56 |
tcl_startOfPreviousWord "ab cd" 3 |
| 57 |
} -result 0 |
| 58 |
test word-2.5 {tcl_startOfPreviousWord} -body { |
| 59 |
tcl_startOfPreviousWord "ab cd" 4 |
| 60 |
} -result 3 |
| 61 |
test word-2.6 {tcl_startOfPreviousWord} -body { |
| 62 |
tcl_startOfPreviousWord "ab cd" 5 |
| 63 |
} -result 3 |
| 64 |
test word-2.7 {tcl_startOfPreviousWord} -body { |
| 65 |
tcl_startOfPreviousWord "ab cd" end |
| 66 |
} -result 3 |
| 67 |
test word-2.8 {tcl_startOfPreviousWord, bug [16e25e1402]} -body { |
| 68 |
tcl_startOfPreviousWord "ab cd" end-1 |
| 69 |
} -result 0 |
| 70 |
|
| 71 |
test word-3.0 {tcl_startOfNextWord} -body { |
| 72 |
tcl_startOfNextWord "ab cd" -1 |
| 73 |
} -result 3 |
| 74 |
test word-3.1 {tcl_startOfNextWord} -body { |
| 75 |
tcl_startOfNextWord "ab cd" 0 |
| 76 |
} -result 3 |
| 77 |
test word-3.2 {tcl_startOfNextWord} -body { |
| 78 |
tcl_startOfNextWord "ab cd" 1 |
| 79 |
} -result 3 |
| 80 |
test word-3.3 {tcl_startOfNextWord} -body { |
| 81 |
tcl_startOfNextWord "ab cd" 2 |
| 82 |
} -result 3 |
| 83 |
test word-3.4 {tcl_startOfNextWord} -body { |
| 84 |
tcl_startOfNextWord "ab cd" 3 |
| 85 |
} -result -1 |
| 86 |
test word-3.5 {tcl_startOfNextWord} -body { |
| 87 |
tcl_startOfNextWord "ab cd" 4 |
| 88 |
} -result -1 |
| 89 |
test word-3.6 {tcl_startOfNextWord} -body { |
| 90 |
tcl_startOfNextWord "ab cd" 5 |
| 91 |
} -result -1 |
| 92 |
test word-3.7 {tcl_startOfNextWord} -body { |
| 93 |
tcl_startOfNextWord "ab cd" end |
| 94 |
} -result -1 |
| 95 |
test word-3.8 {tcl_startOfNextWord} -body { |
| 96 |
tcl_startOfNextWord "ab cd" end-1 |
| 97 |
} -result -1 |
| 98 |
|
| 99 |
test word-4.0 {tcl_wordBreakBefore} -body { |
| 100 |
tcl_wordBreakBefore "ab cd" -1 |
| 101 |
} -result -1 |
| 102 |
test word-4.1 {tcl_wordBreakBefore} -body { |
| 103 |
tcl_wordBreakBefore "ab cd" 0 |
| 104 |
} -result -1 |
| 105 |
test word-4.2 {tcl_wordBreakBefore} -body { |
| 106 |
tcl_wordBreakBefore "ab cd" 1 |
| 107 |
} -result -1 |
| 108 |
test word-4.3 {tcl_wordBreakBefore} -body { |
| 109 |
tcl_wordBreakBefore "ab cd" 2 |
| 110 |
} -result 2 |
| 111 |
test word-4.4 {tcl_wordBreakBefore} -body { |
| 112 |
tcl_wordBreakBefore "ab cd" 3 |
| 113 |
} -result 3 |
| 114 |
test word-4.5 {tcl_wordBreakBefore} -body { |
| 115 |
tcl_wordBreakBefore "ab cd" 4 |
| 116 |
} -result 3 |
| 117 |
test word-4.6 {tcl_wordBreakBefore} -body { |
| 118 |
tcl_wordBreakBefore "ab cd" 5 |
| 119 |
} -result 3 |
| 120 |
test word-4.7 {tcl_wordBreakBefore} -body { |
| 121 |
tcl_wordBreakBefore "ab cd" end |
| 122 |
} -result 3 |
| 123 |
test word-4.8 {tcl_wordBreakBefore} -body { |
| 124 |
tcl_startOfNextWord "ab cd" end-1 |
| 125 |
} -result -1 |
| 126 |
|
| 127 |
test word-5.0 {tcl_wordBreakAfter} -body { |
| 128 |
tcl_wordBreakAfter "ab cd" -1 |
| 129 |
} -result 2 |
| 130 |
test word-5.1 {tcl_wordBreakAfter} -body { |
| 131 |
tcl_wordBreakAfter "ab cd" 0 |
| 132 |
} -result 2 |
| 133 |
test word-5.2 {tcl_wordBreakAfter} -body { |
| 134 |
tcl_wordBreakAfter "ab cd" 1 |
| 135 |
} -result 2 |
| 136 |
test word-5.3 {tcl_wordBreakAfter} -body { |
| 137 |
tcl_wordBreakAfter "ab cd" 2 |
| 138 |
} -result 3 |
| 139 |
test word-5.4 {tcl_wordBreakAfter} -body { |
| 140 |
tcl_wordBreakAfter "ab cd" 3 |
| 141 |
} -result -1 |
| 142 |
test word-5.5 {tcl_wordBreakAfter} -body { |
| 143 |
tcl_wordBreakAfter "ab cd" 4 |
| 144 |
} -result -1 |
| 145 |
test word-5.6 {tcl_wordBreakAfter} -body { |
| 146 |
tcl_wordBreakAfter "ab cd" 5 |
| 147 |
} -result -1 |
| 148 |
test word-5.7 {tcl_wordBreakAfter} -body { |
| 149 |
tcl_wordBreakAfter "ab cd" end |
| 150 |
} -result -1 |
| 151 |
test word-5.8 {tcl_wordBreakAfter} -body { |
| 152 |
tcl_wordBreakAfter "ab cd" end-1 |
| 153 |
} -result -1 |
| 154 |
|
| 155 |
test word-6.0 {tcl_startOfPreviousWord} -body { |
| 156 |
tcl_startOfPreviousWord a b c d |
| 157 |
} -returnCodes 1 -result {wrong # args: should be "tcl_startOfPreviousWord str start"} |
| 158 |
test word-6.1 {tcl_startOfNextWord} -body { |
| 159 |
tcl_startOfNextWord a b c d |
| 160 |
} -returnCodes 1 -result {wrong # args: should be "tcl_startOfNextWord str start"} |
| 161 |
test word-6.2 {tcl_endOfWord} -body { |
| 162 |
tcl_endOfWord a b c d |
| 163 |
} -returnCodes 1 -result {wrong # args: should be "tcl_endOfWord str start"} |
| 164 |
test word-6.3 {tcl_wordBreakBefore} -body { |
| 165 |
tcl_wordBreakBefore a b c d |
| 166 |
} -returnCodes 1 -result {wrong # args: should be "tcl_wordBreakBefore str start"} |
| 167 |
test word-6.4 {tcl_wordBreakAfter} -body { |
| 168 |
tcl_wordBreakAfter a b c d |
| 169 |
} -returnCodes 1 -result {wrong # args: should be "tcl_wordBreakAfter str start"} |
| 170 |
|
| 171 |
# cleanup |
| 172 |
::tcltest::cleanupTests |
| 173 |
return |
| 174 |
|
| 175 |
# Local Variables: |
| 176 |
# mode: tcl |
| 177 |
# End: |