| 1 |
# Commands covered: regexp, regsub |
| 2 |
# |
| 3 |
# This file contains a collection of tests for one or more of the Tcl |
| 4 |
# built-in commands. Sourcing this file into Tcl runs the tests and |
| 5 |
# generates output for errors. No output means no errors were found. |
| 6 |
# |
| 7 |
# Copyright (c) 1991-1993 The Regents of the University of California. |
| 8 |
# Copyright (c) 1998 Sun Microsystems, Inc. |
| 9 |
# Copyright (c) 1998-1999 by Scriptics Corporation. |
| 10 |
# |
| 11 |
# See the file "license.terms" for information on usage and redistribution |
| 12 |
# of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 13 |
|
| 14 |
if {"::tcltest" ni [namespace children]} { |
| 15 |
package require tcltest 2.5 |
| 16 |
namespace import -force ::tcltest::* |
| 17 |
} |
| 18 |
|
| 19 |
# Procedure to evaluate a script within a proc, to test compilation |
| 20 |
# functionality |
| 21 |
|
| 22 |
proc evalInProc { script } { |
| 23 |
proc testProc {} $script |
| 24 |
set status [catch { |
| 25 |
testProc |
| 26 |
} result] |
| 27 |
rename testProc {} |
| 28 |
return $result |
| 29 |
#return [list $status $result] |
| 30 |
} |
| 31 |
|
| 32 |
unset -nocomplain foo |
| 33 |
|
| 34 |
test regexpComp-1.1 {basic regexp operation} { |
| 35 |
evalInProc { |
| 36 |
regexp ab*c abbbc |
| 37 |
} |
| 38 |
} 1 |
| 39 |
test regexpComp-1.2 {basic regexp operation} { |
| 40 |
evalInProc { |
| 41 |
regexp ab*c ac |
| 42 |
} |
| 43 |
} 1 |
| 44 |
test regexpComp-1.3 {basic regexp operation} { |
| 45 |
evalInProc { |
| 46 |
regexp ab*c ab |
| 47 |
} |
| 48 |
} 0 |
| 49 |
test regexpComp-1.4 {basic regexp operation} { |
| 50 |
evalInProc { |
| 51 |
regexp -- -gorp abc-gorpxxx |
| 52 |
} |
| 53 |
} 1 |
| 54 |
test regexpComp-1.5 {basic regexp operation} { |
| 55 |
evalInProc { |
| 56 |
regexp {^([^ ]*)[ ]*([^ ]*)} "" a |
| 57 |
} |
| 58 |
} 1 |
| 59 |
test regexpComp-1.6 {basic regexp operation} { |
| 60 |
list [catch {regexp {} abc} msg] $msg |
| 61 |
} {0 1} |
| 62 |
test regexpComp-1.7 {regexp utf compliance} { |
| 63 |
# if not UTF-8 aware, result is "0 1" |
| 64 |
evalInProc { |
| 65 |
set foo "\u4e4eb q" |
| 66 |
regexp "\u4e4eb q" "a\u4e4eb qw\u5e4e\x4e wq" bar |
| 67 |
list [string compare $foo $bar] [regexp 4 $bar] |
| 68 |
} |
| 69 |
} {0 0} |
| 70 |
|
| 71 |
test regexpComp-1.8 {regexp ***= metasyntax} { |
| 72 |
evalInProc { |
| 73 |
regexp -- "***=o" "aeiou" |
| 74 |
} |
| 75 |
} 1 |
| 76 |
test regexpComp-1.9 {regexp ***= metasyntax} { |
| 77 |
evalInProc { |
| 78 |
set string "aeiou" |
| 79 |
regexp -- "***=o" $string |
| 80 |
} |
| 81 |
} 1 |
| 82 |
test regexpComp-1.10 {regexp ***= metasyntax} { |
| 83 |
evalInProc { |
| 84 |
set string "aeiou" |
| 85 |
set re "***=o" |
| 86 |
regexp -- $re $string |
| 87 |
} |
| 88 |
} 1 |
| 89 |
test regexpComp-1.11 {regexp ***= metasyntax} { |
| 90 |
evalInProc { |
| 91 |
regexp -- "***=y" "aeiou" |
| 92 |
} |
| 93 |
} 0 |
| 94 |
test regexpComp-1.12 {regexp ***= metasyntax} { |
| 95 |
evalInProc { |
| 96 |
set string "aeiou" |
| 97 |
regexp -- "***=y" $string |
| 98 |
} |
| 99 |
} 0 |
| 100 |
test regexpComp-1.13 {regexp ***= metasyntax} { |
| 101 |
evalInProc { |
| 102 |
set string "aeiou" |
| 103 |
set re "***=y" |
| 104 |
regexp -- $re $string |
| 105 |
} |
| 106 |
} 0 |
| 107 |
test regexpComp-1.14 {regexp ***= metasyntax} { |
| 108 |
evalInProc { |
| 109 |
set string "aeiou" |
| 110 |
set re "***=e*o" |
| 111 |
regexp -- $re $string |
| 112 |
} |
| 113 |
} 0 |
| 114 |
test regexpComp-1.15 {regexp ***= metasyntax} { |
| 115 |
evalInProc { |
| 116 |
set string "ae*ou" |
| 117 |
set re "***=e*o" |
| 118 |
regexp -- $re $string |
| 119 |
} |
| 120 |
} 1 |
| 121 |
test regexpComp-1.16 {regexp ***= metasyntax} { |
| 122 |
evalInProc { |
| 123 |
set string {ae*[o]?ua} |
| 124 |
set re {***=e*[o]?u} |
| 125 |
regexp -- $re $string |
| 126 |
} |
| 127 |
} 1 |
| 128 |
|
| 129 |
test regexpComp-2.1 {getting substrings back from regexp} { |
| 130 |
evalInProc { |
| 131 |
set foo {} |
| 132 |
list [regexp ab*c abbbbc foo] $foo |
| 133 |
} |
| 134 |
} {1 abbbbc} |
| 135 |
test regexpComp-2.2 {getting substrings back from regexp} { |
| 136 |
evalInProc { |
| 137 |
set foo {} |
| 138 |
set f2 {} |
| 139 |
list [regexp a(b*)c abbbbc foo f2] $foo $f2 |
| 140 |
} |
| 141 |
} {1 abbbbc bbbb} |
| 142 |
test regexpComp-2.3 {getting substrings back from regexp} { |
| 143 |
evalInProc { |
| 144 |
set foo {} |
| 145 |
set f2 {} |
| 146 |
list [regexp a(b*)(c) abbbbc foo f2] $foo $f2 |
| 147 |
} |
| 148 |
} {1 abbbbc bbbb} |
| 149 |
test regexpComp-2.4 {getting substrings back from regexp} { |
| 150 |
evalInProc { |
| 151 |
set foo {} |
| 152 |
set f2 {} |
| 153 |
set f3 {} |
| 154 |
list [regexp a(b*)(c) abbbbc foo f2 f3] $foo $f2 $f3 |
| 155 |
} |
| 156 |
} {1 abbbbc bbbb c} |
| 157 |
test regexpComp-2.5 {getting substrings back from regexp} { |
| 158 |
evalInProc { |
| 159 |
set foo {}; set f1 {}; set f2 {}; set f3 {}; set f4 {}; set f5 {}; |
| 160 |
set f6 {}; set f7 {}; set f8 {}; set f9 {}; set fa {}; set fb {}; |
| 161 |
list [regexp (1*)(2*)(3*)(4*)(5*)(6*)(7*)(8*)(9*)(a*)(b*) \ |
| 162 |
12223345556789999aabbb \ |
| 163 |
foo f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb] $foo $f1 $f2 $f3 $f4 $f5 \ |
| 164 |
$f6 $f7 $f8 $f9 $fa $fb |
| 165 |
} |
| 166 |
} {1 12223345556789999aabbb 1 222 33 4 555 6 7 8 9999 aa bbb} |
| 167 |
test regexpComp-2.6 {getting substrings back from regexp} { |
| 168 |
evalInProc { |
| 169 |
set foo 2; set f2 2; set f3 2; set f4 2 |
| 170 |
list [regexp (a)(b)? xay foo f2 f3 f4] $foo $f2 $f3 $f4 |
| 171 |
} |
| 172 |
} {1 a a {} {}} |
| 173 |
test regexpComp-2.7 {getting substrings back from regexp} { |
| 174 |
evalInProc { |
| 175 |
set foo 1; set f2 1; set f3 1; set f4 1 |
| 176 |
list [regexp (a)(b)?(c) xacy foo f2 f3 f4] $foo $f2 $f3 $f4 |
| 177 |
} |
| 178 |
} {1 ac a {} c} |
| 179 |
test regexpComp-2.8 {getting substrings back from regexp} { |
| 180 |
evalInProc { |
| 181 |
set match {} |
| 182 |
list [regexp {^a*b} aaaab match] $match |
| 183 |
} |
| 184 |
} {1 aaaab} |
| 185 |
|
| 186 |
test regexpComp-3.1 {-indices option to regexp} { |
| 187 |
evalInProc { |
| 188 |
set foo {} |
| 189 |
list [regexp -indices ab*c abbbbc foo] $foo |
| 190 |
} |
| 191 |
} {1 {0 5}} |
| 192 |
test regexpComp-3.2 {-indices option to regexp} { |
| 193 |
evalInProc { |
| 194 |
set foo {} |
| 195 |
set f2 {} |
| 196 |
list [regexp -indices a(b*)c abbbbc foo f2] $foo $f2 |
| 197 |
} |
| 198 |
} {1 {0 5} {1 4}} |
| 199 |
test regexpComp-3.3 {-indices option to regexp} { |
| 200 |
evalInProc { |
| 201 |
set foo {} |
| 202 |
set f2 {} |
| 203 |
list [regexp -indices a(b*)(c) abbbbc foo f2] $foo $f2 |
| 204 |
} |
| 205 |
} {1 {0 5} {1 4}} |
| 206 |
test regexpComp-3.4 {-indices option to regexp} { |
| 207 |
evalInProc { |
| 208 |
set foo {} |
| 209 |
set f2 {} |
| 210 |
set f3 {} |
| 211 |
list [regexp -indices a(b*)(c) abbbbc foo f2 f3] $foo $f2 $f3 |
| 212 |
} |
| 213 |
} {1 {0 5} {1 4} {5 5}} |
| 214 |
test regexpComp-3.5 {-indices option to regexp} { |
| 215 |
evalInProc { |
| 216 |
set foo {}; set f1 {}; set f2 {}; set f3 {}; set f4 {}; set f5 {}; |
| 217 |
set f6 {}; set f7 {}; set f8 {}; set f9 {} |
| 218 |
list [regexp -indices (1*)(2*)(3*)(4*)(5*)(6*)(7*)(8*)(9*) \ |
| 219 |
12223345556789999 \ |
| 220 |
foo f1 f2 f3 f4 f5 f6 f7 f8 f9] $foo $f1 $f2 $f3 $f4 $f5 \ |
| 221 |
$f6 $f7 $f8 $f9 |
| 222 |
} |
| 223 |
} {1 {0 16} {0 0} {1 3} {4 5} {6 6} {7 9} {10 10} {11 11} {12 12} {13 16}} |
| 224 |
test regexpComp-3.6 {getting substrings back from regexp} { |
| 225 |
evalInProc { |
| 226 |
set foo 2; set f2 2; set f3 2; set f4 2 |
| 227 |
list [regexp -indices (a)(b)? xay foo f2 f3 f4] $foo $f2 $f3 $f4 |
| 228 |
} |
| 229 |
} {1 {1 1} {1 1} {-1 -1} {-1 -1}} |
| 230 |
test regexpComp-3.7 {getting substrings back from regexp} { |
| 231 |
evalInProc { |
| 232 |
set foo 1; set f2 1; set f3 1; set f4 1 |
| 233 |
list [regexp -indices (a)(b)?(c) xacy foo f2 f3 f4] $foo $f2 $f3 $f4 |
| 234 |
} |
| 235 |
} {1 {1 2} {1 1} {-1 -1} {2 2}} |
| 236 |
|
| 237 |
test regexpComp-4.1 {-nocase option to regexp} { |
| 238 |
evalInProc { |
| 239 |
regexp -nocase foo abcFOo |
| 240 |
} |
| 241 |
} 1 |
| 242 |
test regexpComp-4.2 {-nocase option to regexp} { |
| 243 |
evalInProc { |
| 244 |
set f1 22 |
| 245 |
set f2 33 |
| 246 |
set f3 44 |
| 247 |
list [regexp -nocase {a(b*)([xy]*)z} aBbbxYXxxZ22 f1 f2 f3] $f1 $f2 $f3 |
| 248 |
} |
| 249 |
} {1 aBbbxYXxxZ Bbb xYXxx} |
| 250 |
test regexpComp-4.3 {-nocase option to regexp} { |
| 251 |
evalInProc { |
| 252 |
regexp -nocase FOo abcFOo |
| 253 |
} |
| 254 |
} 1 |
| 255 |
set ::x abcdefghijklmnopqrstuvwxyz1234567890 |
| 256 |
set ::x $x$x$x$x$x$x$x$x$x$x$x$x |
| 257 |
test regexpComp-4.4 {case conversion in regexp} { |
| 258 |
evalInProc { |
| 259 |
list [regexp -nocase $::x $::x foo] $foo |
| 260 |
} |
| 261 |
} "1 $x" |
| 262 |
unset -nocomplain ::x |
| 263 |
|
| 264 |
test regexpComp-5.1 {exercise cache of compiled expressions} { |
| 265 |
evalInProc { |
| 266 |
regexp .*a b |
| 267 |
regexp .*b c |
| 268 |
regexp .*c d |
| 269 |
regexp .*d e |
| 270 |
regexp .*e f |
| 271 |
regexp .*a bbba |
| 272 |
} |
| 273 |
} 1 |
| 274 |
test regexpComp-5.2 {exercise cache of compiled expressions} { |
| 275 |
evalInProc { |
| 276 |
regexp .*a b |
| 277 |
regexp .*b c |
| 278 |
regexp .*c d |
| 279 |
regexp .*d e |
| 280 |
regexp .*e f |
| 281 |
regexp .*b xxxb |
| 282 |
} |
| 283 |
} 1 |
| 284 |
test regexpComp-5.3 {exercise cache of compiled expressions} { |
| 285 |
evalInProc { |
| 286 |
regexp .*a b |
| 287 |
regexp .*b c |
| 288 |
regexp .*c d |
| 289 |
regexp .*d e |
| 290 |
regexp .*e f |
| 291 |
regexp .*c yyyc |
| 292 |
} |
| 293 |
} 1 |
| 294 |
test regexpComp-5.4 {exercise cache of compiled expressions} { |
| 295 |
evalInProc { |
| 296 |
regexp .*a b |
| 297 |
regexp .*b c |
| 298 |
regexp .*c d |
| 299 |
regexp .*d e |
| 300 |
regexp .*e f |
| 301 |
regexp .*d 1d |
| 302 |
} |
| 303 |
} 1 |
| 304 |
test regexpComp-5.5 {exercise cache of compiled expressions} { |
| 305 |
evalInProc { |
| 306 |
regexp .*a b |
| 307 |
regexp .*b c |
| 308 |
regexp .*c d |
| 309 |
regexp .*d e |
| 310 |
regexp .*e f |
| 311 |
regexp .*e xe |
| 312 |
} |
| 313 |
} 1 |
| 314 |
|
| 315 |
test regexpComp-6.1 {regexp errors} { |
| 316 |
evalInProc { |
| 317 |
list [catch {regexp a} msg] $msg |
| 318 |
} |
| 319 |
} {1 {wrong # args: should be "regexp ?-option ...? exp string ?matchVar? ?subMatchVar ...?"}} |
| 320 |
test regexpComp-6.2 {regexp errors} { |
| 321 |
evalInProc { |
| 322 |
list [catch {regexp -nocase a} msg] $msg |
| 323 |
} |
| 324 |
} {1 {wrong # args: should be "regexp ?-option ...? exp string ?matchVar? ?subMatchVar ...?"}} |
| 325 |
test regexpComp-6.3 {regexp errors} { |
| 326 |
evalInProc { |
| 327 |
list [catch {regexp -gorp a} msg] $msg |
| 328 |
} |
| 329 |
} {1 {bad option "-gorp": must be -all, -about, -indices, -inline, -expanded, -line, -linestop, -lineanchor, -nocase, -start, or --}} |
| 330 |
test regexpComp-6.4 {regexp errors} { |
| 331 |
evalInProc { |
| 332 |
list [catch {regexp a( b} msg] $msg |
| 333 |
} |
| 334 |
} {1 {couldn't compile regular expression pattern: parentheses () not balanced}} |
| 335 |
test regexpComp-6.5 {regexp errors} { |
| 336 |
evalInProc { |
| 337 |
list [catch {regexp a( b} msg] $msg |
| 338 |
} |
| 339 |
} {1 {couldn't compile regular expression pattern: parentheses () not balanced}} |
| 340 |
test regexpComp-6.6 {regexp errors} { |
| 341 |
evalInProc { |
| 342 |
list [catch {regexp a a f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1} msg] $msg |
| 343 |
} |
| 344 |
} {0 1} |
| 345 |
test regexpComp-6.7 {regexp errors} { |
| 346 |
evalInProc { |
| 347 |
list [catch {regexp (x)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.) xyzzy} msg] $msg |
| 348 |
} |
| 349 |
} {0 0} |
| 350 |
test regexpComp-6.8 {regexp errors} { |
| 351 |
evalInProc { |
| 352 |
unset -nocomplain f1 |
| 353 |
set f1 44 |
| 354 |
list [catch {regexp abc abc f1(f2)} msg] $msg |
| 355 |
} |
| 356 |
} {1 {can't set "f1(f2)": variable isn't array}} |
| 357 |
test regexpComp-6.9 {regexp errors, -start bad int check} { |
| 358 |
evalInProc { |
| 359 |
list [catch {regexp -start bogus {^$} {}} msg] $msg |
| 360 |
} |
| 361 |
} {1 {bad index "bogus": must be integer?[+-]integer? or end?[+-]integer?}} |
| 362 |
|
| 363 |
test regexpComp-7.1 {basic regsub operation} { |
| 364 |
evalInProc { |
| 365 |
list [regsub aa+ xaxaaaxaa 111&222 foo] $foo |
| 366 |
} |
| 367 |
} {1 xax111aaa222xaa} |
| 368 |
test regexpComp-7.2 {basic regsub operation} { |
| 369 |
evalInProc { |
| 370 |
list [regsub aa+ aaaxaa &111 foo] $foo |
| 371 |
} |
| 372 |
} {1 aaa111xaa} |
| 373 |
test regexpComp-7.3 {basic regsub operation} { |
| 374 |
evalInProc { |
| 375 |
list [regsub aa+ xaxaaa 111& foo] $foo |
| 376 |
} |
| 377 |
} {1 xax111aaa} |
| 378 |
test regexpComp-7.4 {basic regsub operation} { |
| 379 |
evalInProc { |
| 380 |
list [regsub aa+ aaa 11&2&333 foo] $foo |
| 381 |
} |
| 382 |
} {1 11aaa2aaa333} |
| 383 |
test regexpComp-7.5 {basic regsub operation} { |
| 384 |
evalInProc { |
| 385 |
list [regsub aa+ xaxaaaxaa &2&333 foo] $foo |
| 386 |
} |
| 387 |
} {1 xaxaaa2aaa333xaa} |
| 388 |
test regexpComp-7.6 {basic regsub operation} { |
| 389 |
evalInProc { |
| 390 |
list [regsub aa+ xaxaaaxaa 1&22& foo] $foo |
| 391 |
} |
| 392 |
} {1 xax1aaa22aaaxaa} |
| 393 |
test regexpComp-7.7 {basic regsub operation} { |
| 394 |
evalInProc { |
| 395 |
list [regsub a(a+) xaxaaaxaa {1\122\1} foo] $foo |
| 396 |
} |
| 397 |
} {1 xax1aa22aaxaa} |
| 398 |
test regexpComp-7.8 {basic regsub operation} { |
| 399 |
evalInProc { |
| 400 |
list [regsub a(a+) xaxaaaxaa {1\\\122\1} foo] $foo |
| 401 |
} |
| 402 |
} "1 {xax1\\aa22aaxaa}" |
| 403 |
test regexpComp-7.9 {basic regsub operation} { |
| 404 |
evalInProc { |
| 405 |
list [regsub a(a+) xaxaaaxaa {1\\122\1} foo] $foo |
| 406 |
} |
| 407 |
} "1 {xax1\\122aaxaa}" |
| 408 |
test regexpComp-7.10 {basic regsub operation} { |
| 409 |
evalInProc { |
| 410 |
list [regsub a(a+) xaxaaaxaa {1\\&\1} foo] $foo |
| 411 |
} |
| 412 |
} "1 {xax1\\aaaaaxaa}" |
| 413 |
test regexpComp-7.11 {basic regsub operation} { |
| 414 |
evalInProc { |
| 415 |
list [regsub a(a+) xaxaaaxaa {1\&\1} foo] $foo |
| 416 |
} |
| 417 |
} {1 xax1&aaxaa} |
| 418 |
test regexpComp-7.12 {basic regsub operation} { |
| 419 |
evalInProc { |
| 420 |
list [regsub a(a+) xaxaaaxaa {\1\1\1\1&&} foo] $foo |
| 421 |
} |
| 422 |
} {1 xaxaaaaaaaaaaaaaaxaa} |
| 423 |
test regexpComp-7.13 {basic regsub operation} { |
| 424 |
evalInProc { |
| 425 |
set foo xxx |
| 426 |
list [regsub abc xyz 111 foo] $foo |
| 427 |
} |
| 428 |
} {0 xyz} |
| 429 |
test regexpComp-7.14 {basic regsub operation} { |
| 430 |
evalInProc { |
| 431 |
set foo xxx |
| 432 |
list [regsub ^ xyz "111 " foo] $foo |
| 433 |
} |
| 434 |
} {1 {111 xyz}} |
| 435 |
test regexpComp-7.15 {basic regsub operation} { |
| 436 |
evalInProc { |
| 437 |
set foo xxx |
| 438 |
list [regsub -- -foo abc-foodef "111 " foo] $foo |
| 439 |
} |
| 440 |
} {1 {abc111 def}} |
| 441 |
test regexpComp-7.16 {basic regsub operation} { |
| 442 |
evalInProc { |
| 443 |
set foo xxx |
| 444 |
list [regsub x "" y foo] $foo |
| 445 |
} |
| 446 |
} {0 {}} |
| 447 |
test regexpComp-7.17 {regsub utf compliance} { |
| 448 |
evalInProc { |
| 449 |
# if not UTF-8 aware, result is "0 1" |
| 450 |
set foo "xyz555ijka\u4e4ebpqr" |
| 451 |
regsub a\u4e4eb xyza\u4e4ebijka\u4e4ebpqr 555 bar |
| 452 |
list [string compare $foo $bar] [regexp 4 $bar] |
| 453 |
} |
| 454 |
} {0 0} |
| 455 |
|
| 456 |
test regexpComp-8.1 {case conversion in regsub} { |
| 457 |
evalInProc { |
| 458 |
list [regsub -nocase a(a+) xaAAaAAay & foo] $foo |
| 459 |
} |
| 460 |
} {1 xaAAaAAay} |
| 461 |
test regexpComp-8.2 {case conversion in regsub} { |
| 462 |
evalInProc { |
| 463 |
list [regsub -nocase a(a+) xaAAaAAay & foo] $foo |
| 464 |
} |
| 465 |
} {1 xaAAaAAay} |
| 466 |
test regexpComp-8.3 {case conversion in regsub} { |
| 467 |
evalInProc { |
| 468 |
set foo 123 |
| 469 |
list [regsub a(a+) xaAAaAAay & foo] $foo |
| 470 |
} |
| 471 |
} {0 xaAAaAAay} |
| 472 |
test regexpComp-8.4 {case conversion in regsub} { |
| 473 |
evalInProc { |
| 474 |
set foo 123 |
| 475 |
list [regsub -nocase a CaDE b foo] $foo |
| 476 |
} |
| 477 |
} {1 CbDE} |
| 478 |
test regexpComp-8.5 {case conversion in regsub} { |
| 479 |
evalInProc { |
| 480 |
set foo 123 |
| 481 |
list [regsub -nocase XYZ CxYzD b foo] $foo |
| 482 |
} |
| 483 |
} {1 CbD} |
| 484 |
test regexpComp-8.6 {case conversion in regsub} { |
| 485 |
evalInProc { |
| 486 |
set x abcdefghijklmnopqrstuvwxyz1234567890 |
| 487 |
set x $x$x$x$x$x$x$x$x$x$x$x$x |
| 488 |
set foo 123 |
| 489 |
list [regsub -nocase $x $x b foo] $foo |
| 490 |
} |
| 491 |
} {1 b} |
| 492 |
|
| 493 |
test regexpComp-9.1 {-all option to regsub} { |
| 494 |
evalInProc { |
| 495 |
set foo 86 |
| 496 |
list [regsub -all x+ axxxbxxcxdx |&| foo] $foo |
| 497 |
} |
| 498 |
} {4 a|xxx|b|xx|c|x|d|x|} |
| 499 |
test regexpComp-9.2 {-all option to regsub} { |
| 500 |
evalInProc { |
| 501 |
set foo 86 |
| 502 |
list [regsub -nocase -all x+ aXxXbxxcXdx |&| foo] $foo |
| 503 |
} |
| 504 |
} {4 a|XxX|b|xx|c|X|d|x|} |
| 505 |
test regexpComp-9.3 {-all option to regsub} { |
| 506 |
evalInProc { |
| 507 |
set foo 86 |
| 508 |
list [regsub x+ axxxbxxcxdx |&| foo] $foo |
| 509 |
} |
| 510 |
} {1 a|xxx|bxxcxdx} |
| 511 |
test regexpComp-9.4 {-all option to regsub} { |
| 512 |
evalInProc { |
| 513 |
set foo 86 |
| 514 |
list [regsub -all bc axxxbxxcxdx |&| foo] $foo |
| 515 |
} |
| 516 |
} {0 axxxbxxcxdx} |
| 517 |
test regexpComp-9.5 {-all option to regsub} { |
| 518 |
evalInProc { |
| 519 |
set foo xxx |
| 520 |
list [regsub -all node "node node more" yy foo] $foo |
| 521 |
} |
| 522 |
} {2 {yy yy more}} |
| 523 |
test regexpComp-9.6 {-all option to regsub} { |
| 524 |
evalInProc { |
| 525 |
set foo xxx |
| 526 |
list [regsub -all ^ xxx 123 foo] $foo |
| 527 |
} |
| 528 |
} {1 123xxx} |
| 529 |
test regexpComp-9.7 {Bug 84af1192f5: -all option to regsub} { |
| 530 |
evalInProc { |
| 531 |
regsub -all {\(.*} 123(qwe) "" |
| 532 |
} |
| 533 |
} 123 |
| 534 |
|
| 535 |
test regexpComp-10.1 {expanded syntax in regsub} { |
| 536 |
evalInProc { |
| 537 |
set foo xxx |
| 538 |
list [regsub -expanded ". \#comment\n . \#comment2" abc def foo] $foo |
| 539 |
} |
| 540 |
} {1 defc} |
| 541 |
test regexpComp-10.2 {newline sensitivity in regsub} { |
| 542 |
evalInProc { |
| 543 |
set foo xxx |
| 544 |
list [regsub -line {^a.*b$} "dabc\naxyb\n" 123 foo] $foo |
| 545 |
} |
| 546 |
} "1 {dabc\n123\n}" |
| 547 |
test regexpComp-10.3 {newline sensitivity in regsub} { |
| 548 |
evalInProc { |
| 549 |
set foo xxx |
| 550 |
list [regsub -line {^a.*b$} "dabc\naxyb\nxb" 123 foo] $foo |
| 551 |
} |
| 552 |
} "1 {dabc\n123\nxb}" |
| 553 |
test regexpComp-10.4 {partial newline sensitivity in regsub} { |
| 554 |
evalInProc { |
| 555 |
set foo xxx |
| 556 |
list [regsub -lineanchor {^a.*b$} "da\naxyb\nxb" 123 foo] $foo |
| 557 |
} |
| 558 |
} "1 {da\n123}" |
| 559 |
test regexpComp-10.5 {inverse partial newline sensitivity in regsub} { |
| 560 |
evalInProc { |
| 561 |
set foo xxx |
| 562 |
list [regsub -linestop {a.*b} "da\nbaxyb\nxb" 123 foo] $foo |
| 563 |
} |
| 564 |
} "1 {da\nb123\nxb}" |
| 565 |
|
| 566 |
test regexpComp-11.1 {regsub errors} { |
| 567 |
evalInProc { |
| 568 |
list [catch {regsub a b} msg] $msg |
| 569 |
} |
| 570 |
} {1 {wrong # args: should be "regsub ?-option ...? exp string subSpec ?varName?"}} |
| 571 |
test regexpComp-11.2 {regsub errors} { |
| 572 |
evalInProc { |
| 573 |
list [catch {regsub -nocase a b} msg] $msg |
| 574 |
} |
| 575 |
} {1 {wrong # args: should be "regsub ?-option ...? exp string subSpec ?varName?"}} |
| 576 |
test regexpComp-11.3 {regsub errors} { |
| 577 |
evalInProc { |
| 578 |
list [catch {regsub -nocase -all a b} msg] $msg |
| 579 |
} |
| 580 |
} {1 {wrong # args: should be "regsub ?-option ...? exp string subSpec ?varName?"}} |
| 581 |
test regexpComp-11.4 {regsub errors} { |
| 582 |
evalInProc { |
| 583 |
list [catch {regsub a b c d e f} msg] $msg |
| 584 |
} |
| 585 |
} {1 {wrong # args: should be "regsub ?-option ...? exp string subSpec ?varName?"}} |
| 586 |
test regexpComp-11.5 {regsub errors} { |
| 587 |
evalInProc { |
| 588 |
list [catch {regsub -gorp a b c} msg] $msg |
| 589 |
} |
| 590 |
} {1 {bad option "-gorp": must be -all, -nocase, -expanded, -line, -linestop, -lineanchor, -start, or --}} |
| 591 |
test regexpComp-11.6 {regsub errors} { |
| 592 |
evalInProc { |
| 593 |
list [catch {regsub -nocase a( b c d} msg] $msg |
| 594 |
} |
| 595 |
} {1 {couldn't compile regular expression pattern: parentheses () not balanced}} |
| 596 |
test regexpComp-11.7 {regsub errors} { |
| 597 |
evalInProc { |
| 598 |
unset -nocomplain f1 |
| 599 |
set f1 44 |
| 600 |
list [catch {regsub -nocase aaa aaa xxx f1(f2)} msg] $msg |
| 601 |
} |
| 602 |
} {1 {can't set "f1(f2)": variable isn't array}} |
| 603 |
test regexpComp-11.8 {regsub errors, -start bad int check} { |
| 604 |
evalInProc { |
| 605 |
list [catch {regsub -start bogus pattern string rep var} msg] $msg |
| 606 |
} |
| 607 |
} {1 {bad index "bogus": must be integer?[+-]integer? or end?[+-]integer?}} |
| 608 |
|
| 609 |
# This test crashes on the Mac unless you increase the Stack Space to about 1 |
| 610 |
# Meg. This is probably bigger than most users want... |
| 611 |
# 8.2.3 regexp reduced stack space requirements, but this should be |
| 612 |
# tested again |
| 613 |
test regexpComp-12.1 {Tcl_RegExpExec: large number of subexpressions} {macCrash} { |
| 614 |
evalInProc { |
| 615 |
list [regexp (.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.) abcdefghijklmnopqrstuvwxyz all a b c d e f g h i j k l m n o p q r s t u v w x y z] $all $a $b $c $d $e $f $g $h $i $j $k $l $m $n $o $p $q $r $s $t $u $v $w $x $y $z |
| 616 |
} |
| 617 |
} {1 abcdefghijklmnopqrstuvwxyz a b c d e f g h i j k l m n o p q r s t u v w x y z} |
| 618 |
|
| 619 |
test regexpComp-13.1 {regsub of a very large string} { |
| 620 |
# This test is designed to stress the memory subsystem in order |
| 621 |
# to catch Bug #933. It only fails if the Tcl memory allocator |
| 622 |
# is in use. |
| 623 |
|
| 624 |
set line {BEGIN_TABLE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; END_TABLE} |
| 625 |
set filedata [string repeat $line 200] |
| 626 |
for {set i 1} {$i<10} {incr i} { |
| 627 |
regsub -all "BEGIN_TABLE " $filedata "" newfiledata |
| 628 |
} |
| 629 |
set x done |
| 630 |
} {done} |
| 631 |
|
| 632 |
test regexpComp-14.1 {CompileRegexp: regexp cache} { |
| 633 |
evalInProc { |
| 634 |
regexp .*a b |
| 635 |
regexp .*b c |
| 636 |
regexp .*c d |
| 637 |
regexp .*d e |
| 638 |
regexp .*e f |
| 639 |
set x . |
| 640 |
append x *a |
| 641 |
regexp $x bbba |
| 642 |
} |
| 643 |
} 1 |
| 644 |
test regexpComp-14.2 {CompileRegexp: regexp cache, different flags} { |
| 645 |
evalInProc { |
| 646 |
regexp .*a b |
| 647 |
regexp .*b c |
| 648 |
regexp .*c d |
| 649 |
regexp .*d e |
| 650 |
regexp .*e f |
| 651 |
set x . |
| 652 |
append x *a |
| 653 |
regexp -nocase $x bbba |
| 654 |
} |
| 655 |
} 1 |
| 656 |
|
| 657 |
testConstraint exec [llength [info commands exec]] |
| 658 |
test regexpComp-14.3 {CompileRegexp: regexp cache, empty regexp and empty cache} -constraints { |
| 659 |
exec |
| 660 |
} -setup { |
| 661 |
set junk [makeFile {puts [regexp {} foo]} junk.tcl] |
| 662 |
} -body { |
| 663 |
exec [interpreter] $junk |
| 664 |
} -cleanup { |
| 665 |
removeFile junk.tcl |
| 666 |
} -result 1 |
| 667 |
|
| 668 |
test regexpComp-15.1 {regexp -start} { |
| 669 |
unset -nocomplain x |
| 670 |
list [regexp -start -10 {\d} 1abc2de3 x] $x |
| 671 |
} {1 1} |
| 672 |
test regexpComp-15.2 {regexp -start} { |
| 673 |
unset -nocomplain x |
| 674 |
list [regexp -start 2 {\d} 1abc2de3 x] $x |
| 675 |
} {1 2} |
| 676 |
test regexpComp-15.3 {regexp -start} { |
| 677 |
unset -nocomplain x |
| 678 |
list [regexp -start 4 {\d} 1abc2de3 x] $x |
| 679 |
} {1 2} |
| 680 |
test regexpComp-15.4 {regexp -start} { |
| 681 |
unset -nocomplain x |
| 682 |
list [regexp -start 5 {\d} 1abc2de3 x] $x |
| 683 |
} {1 3} |
| 684 |
test regexpComp-15.5 {regexp -start, over end of string} { |
| 685 |
unset -nocomplain x |
| 686 |
list [regexp -start [string length 1abc2de3] {\d} 1abc2de3 x] [info exists x] |
| 687 |
} {0 0} |
| 688 |
test regexpComp-15.6 {regexp -start, loss of ^$ behavior} { |
| 689 |
list [regexp -start 2 {^$} {}] |
| 690 |
} {0} |
| 691 |
|
| 692 |
test regexpComp-16.1 {regsub -start} { |
| 693 |
unset -nocomplain x |
| 694 |
list [regsub -all -start 2 {\d} a1b2c3d4e5 {/&} x] $x |
| 695 |
} {4 a1b/2c/3d/4e/5} |
| 696 |
test regexpComp-16.2 {regsub -start} { |
| 697 |
unset -nocomplain x |
| 698 |
list [regsub -all -start -25 {z} hello {/&} x] $x |
| 699 |
} {0 hello} |
| 700 |
test regexpComp-16.3 {regsub -start} { |
| 701 |
unset -nocomplain x |
| 702 |
list [regsub -all -start 3 {z} hello {/&} x] $x |
| 703 |
} {0 hello} |
| 704 |
test regexpComp-16.4 {regsub -start, \A behavior} { |
| 705 |
set out {} |
| 706 |
lappend out [regsub -start 0 -all {\A(\w)} {abcde} {/\1} x] $x |
| 707 |
lappend out [regsub -start 2 -all {\A(\w)} {abcde} {/\1} x] $x |
| 708 |
} {5 /a/b/c/d/e 3 ab/c/d/e} |
| 709 |
|
| 710 |
test regexpComp-17.1 {regexp -inline} { |
| 711 |
regexp -inline b ababa |
| 712 |
} {b} |
| 713 |
test regexpComp-17.2 {regexp -inline} { |
| 714 |
regexp -inline (b) ababa |
| 715 |
} {b b} |
| 716 |
test regexpComp-17.3 {regexp -inline -indices} { |
| 717 |
regexp -inline -indices (b) ababa |
| 718 |
} {{1 1} {1 1}} |
| 719 |
test regexpComp-17.4 {regexp -inline} { |
| 720 |
regexp -inline {\w(\d+)\w} " hello 23 there456def " |
| 721 |
} {e456d 456} |
| 722 |
test regexpComp-17.5 {regexp -inline no matches} { |
| 723 |
regexp -inline {\w(\d+)\w} "" |
| 724 |
} {} |
| 725 |
test regexpComp-17.6 {regexp -inline no matches} { |
| 726 |
regexp -inline hello goodbye |
| 727 |
} {} |
| 728 |
test regexpComp-17.7 {regexp -inline, no matchvars allowed} { |
| 729 |
list [catch {regexp -inline b abc match} msg] $msg |
| 730 |
} {1 {regexp match variables not allowed when using -inline}} |
| 731 |
|
| 732 |
test regexpComp-18.1 {regexp -all} { |
| 733 |
regexp -all b bbbbb |
| 734 |
} {5} |
| 735 |
test regexpComp-18.2 {regexp -all} { |
| 736 |
regexp -all b abababbabaaaaaaaaaab |
| 737 |
} {6} |
| 738 |
test regexpComp-18.3 {regexp -all -inline} { |
| 739 |
regexp -all -inline b abababbabaaaaaaaaaab |
| 740 |
} {b b b b b b} |
| 741 |
test regexpComp-18.4 {regexp -all -inline} { |
| 742 |
regexp -all -inline {\w(\w)} abcdefg |
| 743 |
} {ab b cd d ef f} |
| 744 |
test regexpComp-18.5 {regexp -all -inline} { |
| 745 |
regexp -all -inline {\w(\w)$} abcdefg |
| 746 |
} {fg g} |
| 747 |
test regexpComp-18.6 {regexp -all -inline} { |
| 748 |
regexp -all -inline {\d+} 10:20:30:40 |
| 749 |
} {10 20 30 40} |
| 750 |
test regexpComp-18.7 {regexp -all -inline} { |
| 751 |
list [catch {regexp -all -inline b abc match} msg] $msg |
| 752 |
} {1 {regexp match variables not allowed when using -inline}} |
| 753 |
test regexpComp-18.8 {regexp -all} { |
| 754 |
# This should not cause an infinite loop |
| 755 |
regexp -all -inline {a*} a |
| 756 |
} {a} |
| 757 |
test regexpComp-18.9 {regexp -all} { |
| 758 |
# Yes, the expected result is {a {}}. Here's why: |
| 759 |
# Start at index 0; a* matches the "a" there then stops. |
| 760 |
# Go to index 1; a* matches the lambda (or {}) there then stops. Recall |
| 761 |
# that a* matches zero or more "a"'s; thus it matches the string "b", as |
| 762 |
# there are zero or more "a"'s there. |
| 763 |
# Go to index 2; this is past the end of the string, so stop. |
| 764 |
regexp -all -inline {a*} ab |
| 765 |
} {a {}} |
| 766 |
test regexpComp-18.10 {regexp -all} { |
| 767 |
# Yes, the expected result is {a {} a}. Here's why: |
| 768 |
# Start at index 0; a* matches the "a" there then stops. |
| 769 |
# Go to index 1; a* matches the lambda (or {}) there then stops. Recall |
| 770 |
# that a* matches zero or more "a"'s; thus it matches the string "b", as |
| 771 |
# there are zero or more "a"'s there. |
| 772 |
# Go to index 2; a* matches the "a" there then stops. |
| 773 |
# Go to index 3; this is past the end of the string, so stop. |
| 774 |
regexp -all -inline {a*} aba |
| 775 |
} {a {} a} |
| 776 |
test regexpComp-18.11 {regexp -all} { |
| 777 |
evalInProc { |
| 778 |
regexp -all -inline {^a} aaaa |
| 779 |
} |
| 780 |
} {a} |
| 781 |
test regexpComp-18.12 {regexp -all -inline -indices} { |
| 782 |
evalInProc { |
| 783 |
regexp -all -inline -indices a(b(c)d|e(f)g)h abcdhaefgh |
| 784 |
} |
| 785 |
} {{0 4} {1 3} {2 2} {-1 -1} {5 9} {6 8} {-1 -1} {7 7}} |
| 786 |
|
| 787 |
test regexpComp-19.1 {regsub null replacement} { |
| 788 |
evalInProc { |
| 789 |
regsub -all {@} {@hel@lo@} "\0a\0" result |
| 790 |
list $result [string length $result] |
| 791 |
} |
| 792 |
} "\0a\0hel\0a\0lo\0a\0 14" |
| 793 |
|
| 794 |
test regexpComp-20.1 {regsub shared object shimmering} { |
| 795 |
evalInProc { |
| 796 |
# Bug #461322 |
| 797 |
set a abcdefghijklmnopqurstuvwxyz |
| 798 |
set b $a |
| 799 |
set c abcdefghijklmnopqurstuvwxyz0123456789 |
| 800 |
regsub $a $c $b d |
| 801 |
list $d [string length $d] [string bytelength $d] |
| 802 |
} |
| 803 |
} [list abcdefghijklmnopqurstuvwxyz0123456789 37 37] |
| 804 |
test regexpComp-20.2 {regsub shared object shimmering with -about} { |
| 805 |
evalInProc { |
| 806 |
eval regexp -about abc |
| 807 |
} |
| 808 |
} {0 {}} |
| 809 |
|
| 810 |
test regexpComp-21.1 {regexp command compiling tests} { |
| 811 |
evalInProc { |
| 812 |
regexp foo bar |
| 813 |
} |
| 814 |
} 0 |
| 815 |
test regexpComp-21.2 {regexp command compiling tests} { |
| 816 |
evalInProc { |
| 817 |
regexp {^foo$} dogfood |
| 818 |
} |
| 819 |
} 0 |
| 820 |
test regexpComp-21.3 {regexp command compiling tests} { |
| 821 |
evalInProc { |
| 822 |
set a foo |
| 823 |
regexp {^foo$} $a |
| 824 |
} |
| 825 |
} 1 |
| 826 |
test regexpComp-21.4 {regexp command compiling tests} { |
| 827 |
evalInProc { |
| 828 |
regexp foo dogfood |
| 829 |
} |
| 830 |
} 1 |
| 831 |
test regexpComp-21.5 {regexp command compiling tests} { |
| 832 |
evalInProc { |
| 833 |
regexp -nocase FOO dogfod |
| 834 |
} |
| 835 |
} 0 |
| 836 |
test regexpComp-21.6 {regexp command compiling tests} { |
| 837 |
evalInProc { |
| 838 |
regexp -n foo dogfoOd |
| 839 |
} |
| 840 |
} 1 |
| 841 |
test regexpComp-21.7 {regexp command compiling tests} { |
| 842 |
evalInProc { |
| 843 |
regexp -no -- FoO dogfood |
| 844 |
} |
| 845 |
} 1 |
| 846 |
test regexpComp-21.8 {regexp command compiling tests} { |
| 847 |
evalInProc { |
| 848 |
regexp -- foo dogfod |
| 849 |
} |
| 850 |
} 0 |
| 851 |
test regexpComp-21.9 {regexp command compiling tests} { |
| 852 |
evalInProc { |
| 853 |
list [catch {regexp -- -nocase foo dogfod} msg] $msg |
| 854 |
} |
| 855 |
} {0 0} |
| 856 |
test regexpComp-21.10 {regexp command compiling tests} { |
| 857 |
evalInProc { |
| 858 |
list [regsub -all "" foo bar str] $str |
| 859 |
} |
| 860 |
} {3 barfbarobaro} |
| 861 |
test regexpComp-21.11 {regexp command compiling tests} { |
| 862 |
evalInProc { |
| 863 |
list [regsub -all "" "" bar str] $str |
| 864 |
} |
| 865 |
} {0 {}} |
| 866 |
|
| 867 |
test regexpComp-22.0.1 {Bug 1810038} { |
| 868 |
evalInProc { |
| 869 |
regexp ($|^X)* {} |
| 870 |
} |
| 871 |
} 1 |
| 872 |
|
| 873 |
test regexpComp-22.0.2 {regexp compile and backrefs, Bug 1857126} { |
| 874 |
evalInProc { |
| 875 |
regexp -- {([bc])\1} bb |
| 876 |
} |
| 877 |
} 1 |
| 878 |
|
| 879 |
set i 0 |
| 880 |
foreach {str exp result} { |
| 881 |
foo ^foo 1 |
| 882 |
foobar ^foobar$ 1 |
| 883 |
foobar bar$ 1 |
| 884 |
foobar ^$ 0 |
| 885 |
"" ^$ 1 |
| 886 |
anything $ 1 |
| 887 |
anything ^.*$ 1 |
| 888 |
anything ^.*a$ 0 |
| 889 |
anything ^.*a.*$ 1 |
| 890 |
anything ^.*.*$ 1 |
| 891 |
anything ^.*..*$ 1 |
| 892 |
anything ^.*b$ 0 |
| 893 |
anything ^a.*$ 1 |
| 894 |
} { |
| 895 |
test regexpComp-22.[incr i] {regexp command compiling tests} \ |
| 896 |
[subst {evalInProc {set a "$str"; regexp {$exp} \$a}}] $result |
| 897 |
} |
| 898 |
|
| 899 |
set i 0 |
| 900 |
foreach {str exp result} { |
| 901 |
foo ^foo 1 |
| 902 |
foobar ^foobar$ 1 |
| 903 |
foobar bar$ 1 |
| 904 |
foobar ^$ 0 |
| 905 |
"" ^$ 1 |
| 906 |
anything $ 1 |
| 907 |
anything ^.*$ 1 |
| 908 |
anything ^.*a$ 0 |
| 909 |
anything ^.*a.*$ 1 |
| 910 |
anything ^.*.*$ 1 |
| 911 |
anything ^.*..*$ 1 |
| 912 |
anything ^.*b$ 0 |
| 913 |
anything ^a.*$ 1 |
| 914 |
} { |
| 915 |
test regexpComp-23.[incr i] {regexp command compiling tests INST_REGEXP} \ |
| 916 |
[subst {evalInProc {set a "$str"; set re "$exp"; regexp \$re \$a}}] $result |
| 917 |
} |
| 918 |
|
| 919 |
test regexpComp-24.1 {regexp command compiling tests} { |
| 920 |
evalInProc { |
| 921 |
set re foo |
| 922 |
regexp -nocase $re bar |
| 923 |
} |
| 924 |
} 0 |
| 925 |
test regexpComp-24.2 {regexp command compiling tests} { |
| 926 |
evalInProc { |
| 927 |
set re {^foo$} |
| 928 |
regexp $re dogfood |
| 929 |
} |
| 930 |
} 0 |
| 931 |
test regexpComp-24.3 {regexp command compiling tests} { |
| 932 |
evalInProc { |
| 933 |
set a foo |
| 934 |
set re {^foo$} |
| 935 |
regexp $re $a |
| 936 |
} |
| 937 |
} 1 |
| 938 |
test regexpComp-24.4 {regexp command compiling tests} { |
| 939 |
evalInProc { |
| 940 |
set re foo |
| 941 |
regexp $re dogfood |
| 942 |
} |
| 943 |
} 1 |
| 944 |
test regexpComp-24.5 {regexp command compiling tests} { |
| 945 |
evalInProc { |
| 946 |
set re FOO |
| 947 |
regexp -nocase $re dogfod |
| 948 |
} |
| 949 |
} 0 |
| 950 |
test regexpComp-24.6 {regexp command compiling tests} { |
| 951 |
evalInProc { |
| 952 |
set re foo |
| 953 |
regexp -n $re dogfoOd |
| 954 |
} |
| 955 |
} 1 |
| 956 |
test regexpComp-24.7 {regexp command compiling tests} { |
| 957 |
evalInProc { |
| 958 |
set re FoO |
| 959 |
regexp -no -- $re dogfood |
| 960 |
} |
| 961 |
} 1 |
| 962 |
test regexpComp-24.8 {regexp command compiling tests} { |
| 963 |
evalInProc { |
| 964 |
set re foo |
| 965 |
regexp -- $re dogfod |
| 966 |
} |
| 967 |
} 0 |
| 968 |
test regexpComp-24.9 {regexp command compiling tests} { |
| 969 |
evalInProc { |
| 970 |
set re "(" |
| 971 |
list [catch {regexp -- $re dogfod} msg] $msg |
| 972 |
} |
| 973 |
} {1 {couldn't compile regular expression pattern: parentheses () not balanced}} |
| 974 |
test regexpComp-24.10 {regexp command compiling tests} { |
| 975 |
# Bug 1902436 - last * escaped |
| 976 |
evalInProc { |
| 977 |
set text {this is *bold* !} |
| 978 |
set re {\*bold\*} |
| 979 |
regexp -- $re $text |
| 980 |
} |
| 981 |
} 1 |
| 982 |
test regexpComp-24.11 {regexp command compiling tests} { |
| 983 |
# Bug 1902436 - last * escaped |
| 984 |
evalInProc { |
| 985 |
set text {this is *bold* !} |
| 986 |
set re {\*bold\*.*!} |
| 987 |
regexp -- $re $text |
| 988 |
} |
| 989 |
} 1 |
| 990 |
|
| 991 |
# cleanup |
| 992 |
::tcltest::cleanupTests |
| 993 |
return |
| 994 |
|
| 995 |
# Local Variables: |
| 996 |
# mode: tcl |
| 997 |
# End: |