reg.test 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134
  1. # reg.test --
  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. # (Don't panic if you are seeing this as part of the reg distribution
  7. # and aren't using Tcl -- reg's own regression tester also knows how
  8. # to read this file, ignoring the Tcl-isms.)
  9. #
  10. # Copyright (c) 1998, 1999 Henry Spencer. All rights reserved.
  11. #
  12. if {[lsearch [namespace children] ::tcltest] == -1} {
  13. package require tcltest 2
  14. namespace import -force ::tcltest::*
  15. }
  16. # All tests require the testregexp command, return if this
  17. # command doesn't exist
  18. ::tcltest::testConstraint testregexp \
  19. [expr {[info commands testregexp] != {}}]
  20. ::tcltest::testConstraint localeRegexp 0
  21. # This file uses some custom procedures, defined below, for regexp regression
  22. # testing. The name of the procedure indicates the general nature of the
  23. # test:
  24. # e compile error expected
  25. # f match failure expected
  26. # m successful match
  27. # i successful match with -indices (used in checking things like
  28. # nonparticipating subexpressions)
  29. # p unsuccessful match with -indices (!!) (used in checking
  30. # partial-match reporting)
  31. # There is also "doing" which sets up title and major test number for each
  32. # block of tests.
  33. # The first 3 arguments are constant: a minor number (which often gets
  34. # a letter or two suffixed to it internally), some flags, and the RE itself.
  35. # For e, the remaining argument is the name of the compile error expected,
  36. # less the leading "REG_". For the rest, the next argument is the string
  37. # to try the match against. Remaining arguments are the substring expected
  38. # to be matched, and any substrings expected to be matched by subexpressions.
  39. # (For f, these arguments are optional, and if present are ignored except
  40. # that they indicate how many subexpressions should be present in the RE.)
  41. # It is an error for the number of subexpression arguments to be wrong.
  42. # Cases involving nonparticipating subexpressions, checking where empty
  43. # substrings are located, etc. should be done using i and p.
  44. # The flag characters are complex and a bit eclectic. Generally speaking,
  45. # lowercase letters are compile options, uppercase are expected re_info
  46. # bits, and nonalphabetics are match options, controls for how the test is
  47. # run, or testing options. The one small surprise is that AREs are the
  48. # default, and you must explicitly request lesser flavors of RE. The flags
  49. # are as follows. It is admitted that some are not very mnemonic.
  50. # There are some others which are purely debugging tools and are not
  51. # useful in this file.
  52. #
  53. # - no-op (placeholder)
  54. # + provide fake xy equivalence class and ch collating element
  55. # % force small state-set cache in matcher (to test cache replace)
  56. # ^ beginning of string is not beginning of line
  57. # $ end of string is not end of line
  58. # * test is Unicode-specific, needs big character set
  59. #
  60. # & test as both ARE and BRE
  61. # b BRE
  62. # e ERE
  63. # a turn advanced-features bit on (error unless ERE already)
  64. # q literal string, no metacharacters at all
  65. #
  66. # i case-independent matching
  67. # o ("opaque") no subexpression capture
  68. # p newlines are half-magic, excluded from . and [^ only
  69. # w newlines are half-magic, significant to ^ and $ only
  70. # n newlines are fully magic, both effects
  71. # x expanded RE syntax
  72. # t incomplete-match reporting
  73. #
  74. # A backslash-_a_lphanumeric seen
  75. # B ERE/ARE literal-_b_race heuristic used
  76. # E backslash (_e_scape) seen within []
  77. # H looka_h_ead constraint seen
  78. # I _i_mpossible to match
  79. # L _l_ocale-specific construct seen
  80. # M unportable (_m_achine-specific) construct seen
  81. # N RE can match empty (_n_ull) string
  82. # P non-_P_OSIX construct seen
  83. # Q {} _q_uantifier seen
  84. # R back _r_eference seen
  85. # S POSIX-un_s_pecified syntax seen
  86. # T prefers shortest (_t_iny)
  87. # U saw original-POSIX botch: unmatched right paren in ERE (_u_gh)
  88. # The one area we can't easily test is memory-allocation failures (which
  89. # are hard to provoke on command). Embedded NULs also are not tested at
  90. # the moment, but this is a historical accident which should be fixed.
  91. # test procedures and related
  92. set ask "about"
  93. set xflags "xflags"
  94. set testbypassed 0
  95. # re_info abbreviation mapping table
  96. set infonames(A) "REG_UBSALNUM"
  97. set infonames(B) "REG_UBRACES"
  98. set infonames(E) "REG_UBBS"
  99. set infonames(H) "REG_ULOOKAHEAD"
  100. set infonames(I) "REG_UIMPOSSIBLE"
  101. set infonames(L) "REG_ULOCALE"
  102. set infonames(M) "REG_UUNPORT"
  103. set infonames(N) "REG_UEMPTYMATCH"
  104. set infonames(P) "REG_UNONPOSIX"
  105. set infonames(Q) "REG_UBOUNDS"
  106. set infonames(R) "REG_UBACKREF"
  107. set infonames(S) "REG_UUNSPEC"
  108. set infonames(T) "REG_USHORTEST"
  109. set infonames(U) "REG_UPBOTCH"
  110. set infonameorder "RHQBAUEPSMLNIT" ;# must match bit order, lsb first
  111. # set major test number and description
  112. proc doing {major desc} {
  113. global prefix description testbypassed
  114. if {$testbypassed != 0} {
  115. puts stdout "!!! bypassed $testbypassed tests in\
  116. $prefix, `$description'"
  117. }
  118. set prefix reg-$major
  119. set description "reg $desc"
  120. set testbypassed 0
  121. }
  122. # build test number (internal)
  123. proc tno {testid} {
  124. return [join $testid .]
  125. }
  126. # build description, with possible modifiers (internal)
  127. proc desc {testid} {
  128. global description
  129. set d $description
  130. if {[llength $testid] > 1} {
  131. set d "([lreplace $testid 0 0]) $d"
  132. }
  133. return $d
  134. }
  135. # build trailing options and flags argument from a flags string (internal)
  136. proc flags {fl} {
  137. global xflags
  138. set args [list]
  139. set flags ""
  140. foreach f [split $fl ""] {
  141. switch -exact -- $f {
  142. "i" { lappend args "-nocase" }
  143. "x" { lappend args "-expanded" }
  144. "n" { lappend args "-line" }
  145. "p" { lappend args "-linestop" }
  146. "w" { lappend args "-lineanchor" }
  147. "-" { }
  148. default { append flags $f }
  149. }
  150. }
  151. if {[string compare $flags ""] != 0} {
  152. lappend args -$xflags $flags
  153. }
  154. return $args
  155. }
  156. # build info-flags list from a flags string (internal)
  157. proc infoflags {fl} {
  158. global infonames infonameorder
  159. set ret [list]
  160. foreach f [split $infonameorder ""] {
  161. if {[string first $f $fl] >= 0} {
  162. lappend ret $infonames($f)
  163. }
  164. }
  165. return $ret
  166. }
  167. # compilation error expected
  168. proc e {testid flags re err} {
  169. global prefix ask errorCode
  170. # Tcl locale stuff doesn't do the ch/xy test fakery yet
  171. if {[string first "+" $flags] >= 0} {
  172. # This will register as a skipped test
  173. test $prefix.[tno $testid] [desc $testid] localeRegexp {} {}
  174. return
  175. }
  176. # if &, test as both ARE and BRE
  177. set amp [string first "&" $flags]
  178. if {$amp >= 0} {
  179. set f [string range $flags 0 [expr $amp - 1]]
  180. append f [string range $flags [expr $amp + 1] end]
  181. e [linsert $testid end ARE] ${f} $re $err
  182. e [linsert $testid end BRE] ${f}b $re $err
  183. return
  184. }
  185. set cmd [concat [list testregexp -$ask] [flags $flags] [list $re]]
  186. set run "list \[catch \{$cmd\}\] \[lindex \$errorCode 1\]"
  187. test $prefix.[tno $testid] [desc $testid] \
  188. {testregexp} $run [list 1 REG_$err]
  189. }
  190. # match failure expected
  191. proc f {testid flags re target args} {
  192. global prefix description ask
  193. # Tcl locale stuff doesn't do the ch/xy test fakery yet
  194. if {[string first "+" $flags] >= 0} {
  195. # This will register as a skipped test
  196. test $prefix.[tno $testid] [desc $testid] localeRegexp {} {}
  197. return
  198. }
  199. # if &, test as both ARE and BRE
  200. set amp [string first "&" $flags]
  201. if {$amp >= 0} {
  202. set f [string range $flags 0 [expr $amp - 1]]
  203. append f [string range $flags [expr $amp + 1] end]
  204. eval [linsert $args 0 f [linsert $testid end ARE] ${f} $re \
  205. $target]
  206. eval [linsert $args 0 f [linsert $testid end BRE] ${f}b $re \
  207. $target]
  208. return
  209. }
  210. set f [flags $flags]
  211. set infoflags [infoflags $flags]
  212. set ccmd [concat [list testregexp -$ask] $f [list $re]]
  213. set nsub [expr [llength $args] - 1]
  214. if {$nsub == -1} {
  215. # didn't tell us number of subexps
  216. set ccmd "lreplace \[$ccmd\] 0 0"
  217. set info [list $infoflags]
  218. } else {
  219. set info [list $nsub $infoflags]
  220. }
  221. lappend testid "compile"
  222. test $prefix.[tno $testid] [desc $testid] {testregexp} $ccmd $info
  223. set testid [lreplace $testid end end "execute"]
  224. set ecmd [concat [list testregexp] $f [list $re $target]]
  225. test $prefix.[tno $testid] [desc $testid] {testregexp} $ecmd 0
  226. }
  227. # match expected, internal routine that does the work
  228. # parameters like the "real" routines except they don't have "opts",
  229. # which is a possibly-empty list of switches for the regexp match attempt
  230. # The ! flag is used to indicate expected match failure (for REG_EXPECT,
  231. # which wants argument testing even in the event of failure).
  232. proc matchexpected {opts testid flags re target args} {
  233. global prefix description ask regBug
  234. if {[info exists regBug] && $regBug} {
  235. # This will register as a skipped test
  236. test $prefix.[tno $testid] [desc $testid] knownBug {format 0} {1}
  237. return
  238. }
  239. # Tcl locale stuff doesn't do the ch/xy test fakery yet
  240. if {[string first "+" $flags] >= 0} {
  241. # This will register as a skipped test
  242. test $prefix.[tno $testid] [desc $testid] localeRegexp {} {}
  243. return
  244. }
  245. # if &, test as both BRE and ARE
  246. set amp [string first "&" $flags]
  247. if {$amp >= 0} {
  248. set f [string range $flags 0 [expr $amp - 1]]
  249. append f [string range $flags [expr $amp + 1] end]
  250. eval [concat [list matchexpected $opts \
  251. [linsert $testid end ARE] ${f} $re $target] $args]
  252. eval [concat [list matchexpected $opts \
  253. [linsert $testid end BRE] ${f}b $re $target] $args]
  254. return
  255. }
  256. set f [flags $flags]
  257. set infoflags [infoflags $flags]
  258. set ccmd [concat [list testregexp -$ask] $f [list $re]]
  259. set ecmd [concat [list testregexp] $opts $f [list $re $target]]
  260. set nsub [expr [llength $args] - 1]
  261. set names [list]
  262. set refs ""
  263. for {set i 0} {$i <= $nsub} {incr i} {
  264. if {$i == 0} {
  265. set name match
  266. } else {
  267. set name sub$i
  268. }
  269. lappend names $name
  270. append refs " \$$name"
  271. set $name ""
  272. }
  273. if {[string first "o" $flags] >= 0} { ;# REG_NOSUB kludge
  274. set nsub 0 ;# unsigned value cannot be -1
  275. }
  276. if {[string first "t" $flags] >= 0} { ;# REG_EXPECT
  277. incr nsub -1 ;# the extra does not count
  278. }
  279. set ecmd [concat $ecmd $names]
  280. set erun "list \[$ecmd\] $refs"
  281. set retcode [list 1]
  282. if {[string first "!" $flags] >= 0} {
  283. set retcode [list 0]
  284. }
  285. set result [concat $retcode $args]
  286. set info [list $nsub $infoflags]
  287. lappend testid "compile"
  288. test $prefix.[tno $testid] [desc $testid] {testregexp} $ccmd $info
  289. set testid [lreplace $testid end end "execute"]
  290. test $prefix.[tno $testid] [desc $testid] {testregexp} $erun $result
  291. }
  292. # match expected (no missing, empty, or ambiguous submatches)
  293. # m testno flags re target mat submat ...
  294. proc m {args} {
  295. eval matchexpected [linsert $args 0 [list]]
  296. }
  297. # match expected (full fanciness)
  298. # i testno flags re target mat submat ...
  299. proc i {args} {
  300. eval matchexpected [linsert $args 0 [list "-indices"]]
  301. }
  302. # partial match expected
  303. # p testno flags re target mat "" ...
  304. # Quirk: number of ""s must be one more than number of subREs.
  305. proc p {args} {
  306. set f [lindex $args 1] ;# add ! flag
  307. set args [lreplace $args 1 1 "!$f"]
  308. eval matchexpected [linsert $args 0 [list "-indices"]]
  309. }
  310. # test is a knownBug
  311. proc knownBug {args} {
  312. set ::regBug 1
  313. uplevel #0 $args
  314. set ::regBug 0
  315. }
  316. # the tests themselves
  317. # support functions and preliminary misc.
  318. # This is sensitive to changes in message wording, but we really have to
  319. # test the code->message expansion at least once.
  320. test reg-0.1 "regexp error reporting" {
  321. list [catch {regexp (*) ign} msg] $msg
  322. } {1 {couldn't compile regular expression pattern: quantifier operand invalid}}
  323. doing 1 "basic sanity checks"
  324. m 1 & abc abc abc
  325. f 2 & abc def
  326. m 3 & abc xyabxabce abc
  327. doing 2 "invalid option combinations"
  328. e 1 qe a INVARG
  329. e 2 qa a INVARG
  330. e 3 qx a INVARG
  331. e 4 qn a INVARG
  332. e 5 ba a INVARG
  333. doing 3 "basic syntax"
  334. i 1 &NS "" a {0 -1}
  335. m 2 NS a| a a
  336. m 3 - a|b a a
  337. m 4 - a|b b b
  338. m 5 NS a||b b b
  339. m 6 & ab ab ab
  340. doing 4 "parentheses"
  341. m 1 - (a)e ae ae a
  342. m 2 o (a)e ae
  343. m 3 b {\(a\)b} ab ab a
  344. m 4 - a((b)c) abc abc bc b
  345. m 5 - a(b)(c) abc abc b c
  346. e 6 - a(b EPAREN
  347. e 7 b {a\(b} EPAREN
  348. # sigh, we blew it on the specs here... someday this will be fixed in POSIX,
  349. # but meanwhile, it's fixed in AREs
  350. m 8 eU a)b a)b a)b
  351. e 9 - a)b EPAREN
  352. e 10 b {a\)b} EPAREN
  353. m 11 P a(?:b)c abc abc
  354. e 12 e a(?:b)c BADRPT
  355. i 13 S a()b ab {0 1} {1 0}
  356. m 14 SP a(?:)b ab ab
  357. i 15 S a(|b)c ac {0 1} {1 0}
  358. m 16 S a(b|)c abc abc b
  359. doing 5 "simple one-char matching"
  360. # general case of brackets done later
  361. m 1 & a.b axb axb
  362. f 2 &n "a.b" "a\nb"
  363. m 3 & {a[bc]d} abd abd
  364. m 4 & {a[bc]d} acd acd
  365. f 5 & {a[bc]d} aed
  366. f 6 & {a[^bc]d} abd
  367. m 7 & {a[^bc]d} aed aed
  368. f 8 &p "a\[^bc]d" "a\nd"
  369. doing 6 "context-dependent syntax"
  370. # plus odds and ends
  371. e 1 - * BADRPT
  372. m 2 b * * *
  373. m 3 b {\(*\)} * * *
  374. e 4 - (*) BADRPT
  375. m 5 b ^* * *
  376. e 6 - ^* BADRPT
  377. f 7 & ^b ^b
  378. m 8 b x^ x^ x^
  379. f 9 I x^ x
  380. m 10 n "\n^" "x\nb" "\n"
  381. f 11 bS {\(^b\)} ^b
  382. m 12 - (^b) b b b
  383. m 13 & {x$} x x
  384. m 14 bS {\(x$\)} x x x
  385. m 15 - {(x$)} x x x
  386. m 16 b {x$y} "x\$y" "x\$y"
  387. f 17 I {x$y} xy
  388. m 18 n "x\$\n" "x\n" "x\n"
  389. e 19 - + BADRPT
  390. e 20 - ? BADRPT
  391. doing 7 "simple quantifiers"
  392. m 1 &N a* aa aa
  393. i 2 &N a* b {0 -1}
  394. m 3 - a+ aa aa
  395. m 4 - a?b ab ab
  396. m 5 - a?b b b
  397. e 6 - ** BADRPT
  398. m 7 bN ** *** ***
  399. e 8 & a** BADRPT
  400. e 9 & a**b BADRPT
  401. e 10 & *** BADRPT
  402. e 11 - a++ BADRPT
  403. e 12 - a?+ BADRPT
  404. e 13 - a?* BADRPT
  405. e 14 - a+* BADRPT
  406. e 15 - a*+ BADRPT
  407. doing 8 "braces"
  408. m 1 NQ "a{0,1}" "" ""
  409. m 2 NQ "a{0,1}" ac a
  410. e 3 - "a{1,0}" BADBR
  411. e 4 - "a{1,2,3}" BADBR
  412. e 5 - "a{257}" BADBR
  413. e 6 - "a{1000}" BADBR
  414. e 7 - "a{1" EBRACE
  415. e 8 - "a{1n}" BADBR
  416. m 9 BS "a{b" "a\{b" "a\{b"
  417. m 10 BS "a{" "a\{" "a\{"
  418. m 11 bQ "a\\{0,1\\}b" cb b
  419. e 12 b "a\\{0,1" EBRACE
  420. e 13 - "a{0,1\\" BADBR
  421. m 14 Q "a{0}b" ab b
  422. m 15 Q "a{0,0}b" ab b
  423. m 16 Q "a{0,1}b" ab ab
  424. m 17 Q "a{0,2}b" b b
  425. m 18 Q "a{0,2}b" aab aab
  426. m 19 Q "a{0,}b" aab aab
  427. m 20 Q "a{1,1}b" aab ab
  428. m 21 Q "a{1,3}b" aaaab aaab
  429. f 22 Q "a{1,3}b" b
  430. m 23 Q "a{1,}b" aab aab
  431. f 24 Q "a{2,3}b" ab
  432. m 25 Q "a{2,3}b" aaaab aaab
  433. f 26 Q "a{2,}b" ab
  434. m 27 Q "a{2,}b" aaaab aaaab
  435. doing 9 "brackets"
  436. m 1 & {a[bc]} ac ac
  437. m 2 & {a[-]} a- a-
  438. m 3 & {a[[.-.]]} a- a-
  439. m 4 &L {a[[.zero.]]} a0 a0
  440. m 5 &LM {a[[.zero.]-9]} a2 a2
  441. m 6 &M {a[0-[.9.]]} a2 a2
  442. m 7 &+L {a[[=x=]]} ax ax
  443. m 8 &+L {a[[=x=]]} ay ay
  444. f 9 &+L {a[[=x=]]} az
  445. e 10 & {a[0-[=x=]]} ERANGE
  446. m 11 &L {a[[:digit:]]} a0 a0
  447. e 12 & {a[[:woopsie:]]} ECTYPE
  448. f 13 &L {a[[:digit:]]} ab
  449. e 14 & {a[0-[:digit:]]} ERANGE
  450. m 15 &LP {[[:<:]]a} a a
  451. m 16 &LP {a[[:>:]]} a a
  452. e 17 & {a[[..]]b} ECOLLATE
  453. e 18 & {a[[==]]b} ECOLLATE
  454. e 19 & {a[[::]]b} ECTYPE
  455. e 20 & {a[[.a} EBRACK
  456. e 21 & {a[[=a} EBRACK
  457. e 22 & {a[[:a} EBRACK
  458. e 23 & {a[} EBRACK
  459. e 24 & {a[b} EBRACK
  460. e 25 & {a[b-} EBRACK
  461. e 26 & {a[b-c} EBRACK
  462. m 27 &M {a[b-c]} ab ab
  463. m 28 & {a[b-b]} ab ab
  464. m 29 &M {a[1-2]} a2 a2
  465. e 30 & {a[c-b]} ERANGE
  466. e 31 & {a[a-b-c]} ERANGE
  467. m 32 &M {a[--?]b} a?b a?b
  468. m 33 & {a[---]b} a-b a-b
  469. m 34 & {a[]b]c} a]c a]c
  470. m 35 EP {a[\]]b} a]b a]b
  471. f 36 bE {a[\]]b} a]b
  472. m 37 bE {a[\]]b} "a\\]b" "a\\]b"
  473. m 38 eE {a[\]]b} "a\\]b" "a\\]b"
  474. m 39 EP {a[\\]b} "a\\b" "a\\b"
  475. m 40 eE {a[\\]b} "a\\b" "a\\b"
  476. m 41 bE {a[\\]b} "a\\b" "a\\b"
  477. e 42 - {a[\Z]b} EESCAPE
  478. m 43 & {a[[b]c} "a\[c" "a\[c"
  479. m 44 EMP* {a[\u00fe-\u0507][\u00ff-\u0300]b} \
  480. "a\u0102\u02ffb" "a\u0102\u02ffb"
  481. doing 10 "anchors and newlines"
  482. m 1 & ^a a a
  483. f 2 &^ ^a a
  484. i 3 &N ^ a {0 -1}
  485. i 4 & {a$} aba {2 2}
  486. f 5 {&$} {a$} a
  487. i 6 &N {$} ab {2 1}
  488. m 7 &n ^a a a
  489. m 8 &n "^a" "b\na" "a"
  490. i 9 &w "^a" "a\na" {0 0}
  491. i 10 &n^ "^a" "a\na" {2 2}
  492. m 11 &n {a$} a a
  493. m 12 &n "a\$" "a\nb" "a"
  494. i 13 &n "a\$" "a\na" {0 0}
  495. i 14 N ^^ a {0 -1}
  496. m 15 b ^^ ^ ^
  497. i 16 N {$$} a {1 0}
  498. m 17 b {$$} "\$" "\$"
  499. m 18 &N {^$} "" ""
  500. f 19 &N {^$} a
  501. i 20 &nN "^\$" "a\n\nb" {2 1}
  502. m 21 N {$^} "" ""
  503. m 22 b {$^} "\$^" "\$^"
  504. m 23 P {\Aa} a a
  505. m 24 ^P {\Aa} a a
  506. f 25 ^nP {\Aa} "b\na"
  507. m 26 P {a\Z} a a
  508. m 27 {$P} {a\Z} a a
  509. f 28 {$nP} {a\Z} "a\nb"
  510. e 29 - ^* BADRPT
  511. e 30 - {$*} BADRPT
  512. e 31 - {\A*} BADRPT
  513. e 32 - {\Z*} BADRPT
  514. doing 11 "boundary constraints"
  515. m 1 &LP {[[:<:]]a} a a
  516. m 2 &LP {[[:<:]]a} -a a
  517. f 3 &LP {[[:<:]]a} ba
  518. m 4 &LP {a[[:>:]]} a a
  519. m 5 &LP {a[[:>:]]} a- a
  520. f 6 &LP {a[[:>:]]} ab
  521. m 7 bLP {\<a} a a
  522. f 8 bLP {\<a} ba
  523. m 9 bLP {a\>} a a
  524. f 10 bLP {a\>} ab
  525. m 11 LP {\ya} a a
  526. f 12 LP {\ya} ba
  527. m 13 LP {a\y} a a
  528. f 14 LP {a\y} ab
  529. m 15 LP {a\Y} ab a
  530. f 16 LP {a\Y} a-
  531. f 17 LP {a\Y} a
  532. f 18 LP {-\Y} -a
  533. m 19 LP {-\Y} -% -
  534. f 20 LP {\Y-} a-
  535. e 21 - {[[:<:]]*} BADRPT
  536. e 22 - {[[:>:]]*} BADRPT
  537. e 23 b {\<*} BADRPT
  538. e 24 b {\>*} BADRPT
  539. e 25 - {\y*} BADRPT
  540. e 26 - {\Y*} BADRPT
  541. m 27 LP {\ma} a a
  542. f 28 LP {\ma} ba
  543. m 29 LP {a\M} a a
  544. f 30 LP {a\M} ab
  545. f 31 ILP {\Ma} a
  546. f 32 ILP {a\m} a
  547. doing 12 "character classes"
  548. m 1 LP {a\db} a0b a0b
  549. f 2 LP {a\db} axb
  550. f 3 LP {a\Db} a0b
  551. m 4 LP {a\Db} axb axb
  552. m 5 LP "a\\sb" "a b" "a b"
  553. m 6 LP "a\\sb" "a\tb" "a\tb"
  554. m 7 LP "a\\sb" "a\nb" "a\nb"
  555. f 8 LP {a\sb} axb
  556. m 9 LP {a\Sb} axb axb
  557. f 10 LP "a\\Sb" "a b"
  558. m 11 LP {a\wb} axb axb
  559. f 12 LP {a\wb} a-b
  560. f 13 LP {a\Wb} axb
  561. m 14 LP {a\Wb} a-b a-b
  562. m 15 LP {\y\w+z\y} adze-guz guz
  563. m 16 LPE {a[\d]b} a1b a1b
  564. m 17 LPE "a\[\\s]b" "a b" "a b"
  565. m 18 LPE {a[\w]b} axb axb
  566. doing 13 "escapes"
  567. e 1 & "a\\" EESCAPE
  568. m 2 - {a\<b} a<b a<b
  569. m 3 e {a\<b} a<b a<b
  570. m 4 bAS {a\wb} awb awb
  571. m 5 eAS {a\wb} awb awb
  572. m 6 PL "a\\ab" "a\007b" "a\007b"
  573. m 7 P "a\\bb" "a\bb" "a\bb"
  574. m 8 P {a\Bb} "a\\b" "a\\b"
  575. m 9 MP "a\\chb" "a\bb" "a\bb"
  576. m 10 MP "a\\cHb" "a\bb" "a\bb"
  577. m 11 LMP "a\\e" "a\033" "a\033"
  578. m 12 P "a\\fb" "a\fb" "a\fb"
  579. m 13 P "a\\nb" "a\nb" "a\nb"
  580. m 14 P "a\\rb" "a\rb" "a\rb"
  581. m 15 P "a\\tb" "a\tb" "a\tb"
  582. m 16 P "a\\u0008x" "a\bx" "a\bx"
  583. e 17 - {a\u008x} EESCAPE
  584. m 18 P "a\\u00088x" "a\b8x" "a\b8x"
  585. m 19 P "a\\U00000008x" "a\bx" "a\bx"
  586. e 20 - {a\U0000008x} EESCAPE
  587. m 21 P "a\\vb" "a\vb" "a\vb"
  588. m 22 MP "a\\x08x" "a\bx" "a\bx"
  589. e 23 - {a\xq} EESCAPE
  590. m 24 MP "a\\x0008x" "a\bx" "a\bx"
  591. e 25 - {a\z} EESCAPE
  592. m 26 MP "a\\010b" "a\bb" "a\bb"
  593. doing 14 "back references"
  594. # ugh
  595. m 1 RP {a(b*)c\1} abbcbb abbcbb bb
  596. m 2 RP {a(b*)c\1} ac ac ""
  597. f 3 RP {a(b*)c\1} abbcb
  598. m 4 RP {a(b*)\1} abbcbb abb b
  599. m 5 RP {a(b|bb)\1} abbcbb abb b
  600. m 6 RP {a([bc])\1} abb abb b
  601. f 7 RP {a([bc])\1} abc
  602. m 8 RP {a([bc])\1} abcabb abb b
  603. f 9 RP {a([bc])*\1} abc
  604. f 10 RP {a([bc])\1} abB
  605. m 11 iRP {a([bc])\1} abB abB b
  606. m 12 RP {a([bc])\1+} abbb abbb b
  607. m 13 QRP "a(\[bc])\\1{3,4}" abbbb abbbb b
  608. f 14 QRP "a(\[bc])\\1{3,4}" abbb
  609. m 15 RP {a([bc])\1*} abbb abbb b
  610. m 16 RP {a([bc])\1*} ab ab b
  611. m 17 RP {a([bc])(\1*)} ab ab b ""
  612. e 18 - {a((b)\1)} ESUBREG
  613. e 19 - {a(b)c\2} ESUBREG
  614. m 20 bR {a\(b*\)c\1} abbcbb abbcbb bb
  615. doing 15 "octal escapes vs back references"
  616. # initial zero is always octal
  617. m 1 MP "a\\010b" "a\bb" "a\bb"
  618. m 2 MP "a\\0070b" "a\0070b" "a\0070b"
  619. m 3 MP "a\\07b" "a\007b" "a\007b"
  620. m 4 MP "a(b)(b)(b)(b)(b)(b)(b)(b)(b)(b)\\07c" "abbbbbbbbbb\007c" \
  621. "abbbbbbbbbb\007c" "b" "b" "b" "b" "b" "b" \
  622. "b" "b" "b" "b"
  623. # a single digit is always a backref
  624. e 5 - {a\7b} ESUBREG
  625. # otherwise it's a backref only if within range (barf!)
  626. m 6 MP "a\\10b" "a\bb" "a\bb"
  627. m 7 MP {a\101b} aAb aAb
  628. m 8 RP {a(b)(b)(b)(b)(b)(b)(b)(b)(b)(b)\10c} abbbbbbbbbbbc \
  629. abbbbbbbbbbbc b b b b b b b \
  630. b b b
  631. # but we're fussy about border cases -- guys who want octal should use the zero
  632. e 9 - {a((((((((((b\10))))))))))c} ESUBREG
  633. # BREs don't have octal, EREs don't have backrefs
  634. m 10 MP "a\\12b" "a\nb" "a\nb"
  635. e 11 b {a\12b} ESUBREG
  636. m 12 eAS {a\12b} a12b a12b
  637. doing 16 "expanded syntax"
  638. m 1 xP "a b c" "abc" "abc"
  639. m 2 xP "a b #oops\nc\td" "abcd" "abcd"
  640. m 3 x "a\\ b\\\tc" "a b\tc" "a b\tc"
  641. m 4 xP "a b\\#c" "ab#c" "ab#c"
  642. m 5 xP "a b\[c d]e" "ab e" "ab e"
  643. m 6 xP "a b\[c#d]e" "ab#e" "ab#e"
  644. m 7 xP "a b\[c#d]e" "abde" "abde"
  645. m 8 xSPB "ab{ d" "ab\{d" "ab\{d"
  646. m 9 xPQ "ab{ 1 , 2 }c" "abc" "abc"
  647. doing 17 "misc syntax"
  648. m 1 P a(?#comment)b ab ab
  649. doing 18 "unmatchable REs"
  650. f 1 I a^b ab
  651. doing 19 "case independence"
  652. m 1 &i ab Ab Ab
  653. m 2 &i {a[bc]} aC aC
  654. f 3 &i {a[^bc]} aB
  655. m 4 &iM {a[b-d]} aC aC
  656. f 5 &iM {a[^b-d]} aC
  657. doing 20 "directors and embedded options"
  658. e 1 & ***? BADPAT
  659. m 2 q ***? ***? ***?
  660. m 3 &P ***=a*b a*b a*b
  661. m 4 q ***=a*b ***=a*b ***=a*b
  662. m 5 bLP {***:\w+} ab ab
  663. m 6 eLP {***:\w+} ab ab
  664. e 7 & ***:***=a*b BADRPT
  665. m 8 &P ***:(?b)a+b a+b a+b
  666. m 9 P (?b)a+b a+b a+b
  667. e 10 e {(?b)\w+} BADRPT
  668. m 11 bAS {(?b)\w+} (?b)w+ (?b)w+
  669. m 12 iP (?c)a a a
  670. f 13 iP (?c)a A
  671. m 14 APS {(?e)\W+} WW WW
  672. m 15 P (?i)a+ Aa Aa
  673. f 16 P "(?m)a.b" "a\nb"
  674. m 17 P "(?m)^b" "a\nb" "b"
  675. f 18 P "(?n)a.b" "a\nb"
  676. m 19 P "(?n)^b" "a\nb" "b"
  677. f 20 P "(?p)a.b" "a\nb"
  678. f 21 P "(?p)^b" "a\nb"
  679. m 22 P (?q)a+b a+b a+b
  680. m 23 nP "(?s)a.b" "a\nb" "a\nb"
  681. m 24 xP "(?t)a b" "a b" "a b"
  682. m 25 P "(?w)a.b" "a\nb" "a\nb"
  683. m 26 P "(?w)^b" "a\nb" "b"
  684. m 27 P "(?x)a b" "ab" "ab"
  685. e 28 - (?z)ab BADOPT
  686. m 29 P (?ici)a+ Aa Aa
  687. e 30 P (?i)(?q)a+ BADRPT
  688. m 31 P (?q)(?i)a+ (?i)a+ (?i)a+
  689. m 32 P (?qe)a+ a a
  690. m 33 xP "(?q)a b" "a b" "a b"
  691. m 34 P "(?qx)a b" "a b" "a b"
  692. m 35 P (?qi)ab Ab Ab
  693. doing 21 "capturing"
  694. m 1 - a(b)c abc abc b
  695. m 2 P a(?:b)c xabc abc
  696. m 3 - a((b))c xabcy abc b b
  697. m 4 P a(?:(b))c abcy abc b
  698. m 5 P a((?:b))c abc abc b
  699. m 6 P a(?:(?:b))c abc abc
  700. i 7 Q "a(b){0}c" ac {0 1} {-1 -1}
  701. m 8 - a(b)c(d)e abcde abcde b d
  702. m 9 - (b)c(d)e bcde bcde b d
  703. m 10 - a(b)(d)e abde abde b d
  704. m 11 - a(b)c(d) abcd abcd b d
  705. m 12 - (ab)(cd) xabcdy abcd ab cd
  706. m 13 - a(b)?c xabcy abc b
  707. i 14 - a(b)?c xacy {1 2} {-1 -1}
  708. m 15 - a(b)?c(d)?e xabcdey abcde b d
  709. i 16 - a(b)?c(d)?e xacdey {1 4} {-1 -1} {3 3}
  710. i 17 - a(b)?c(d)?e xabcey {1 4} {2 2} {-1 -1}
  711. i 18 - a(b)?c(d)?e xacey {1 3} {-1 -1} {-1 -1}
  712. m 19 - a(b)*c xabcy abc b
  713. i 20 - a(b)*c xabbbcy {1 5} {4 4}
  714. i 21 - a(b)*c xacy {1 2} {-1 -1}
  715. m 22 - a(b*)c xabbbcy abbbc bbb
  716. m 23 - a(b*)c xacy ac ""
  717. f 24 - a(b)+c xacy
  718. m 25 - a(b)+c xabcy abc b
  719. i 26 - a(b)+c xabbbcy {1 5} {4 4}
  720. m 27 - a(b+)c xabbbcy abbbc bbb
  721. i 28 Q "a(b){2,3}c" xabbbcy {1 5} {4 4}
  722. i 29 Q "a(b){2,3}c" xabbcy {1 4} {3 3}
  723. f 30 Q "a(b){2,3}c" xabcy
  724. m 31 LP "\\y(\\w+)\\y" "-- abc-" "abc" "abc"
  725. m 32 - a((b|c)d+)+ abacdbd acdbd bd b
  726. m 33 N (.*).* abc abc abc
  727. m 34 N (a*)* bc "" ""
  728. doing 22 "multicharacter collating elements"
  729. # again ugh
  730. m 1 &+L {a[c]e} ace ace
  731. f 2 &+IL {a[c]h} ach
  732. m 3 &+L {a[[.ch.]]} ach ach
  733. f 4 &+L {a[[.ch.]]} ace
  734. m 5 &+L {a[c[.ch.]]} ac ac
  735. m 6 &+L {a[c[.ch.]]} ace ac
  736. m 7 &+L {a[c[.ch.]]} ache ach
  737. f 8 &+L {a[^c]e} ace
  738. m 9 &+L {a[^c]e} abe abe
  739. m 10 &+L {a[^c]e} ache ache
  740. f 11 &+L {a[^[.ch.]]} ach
  741. m 12 &+L {a[^[.ch.]]} ace ac
  742. m 13 &+L {a[^[.ch.]]} ac ac
  743. m 14 &+L {a[^[.ch.]]} abe ab
  744. f 15 &+L {a[^c[.ch.]]} ach
  745. f 16 &+L {a[^c[.ch.]]} ace
  746. f 17 &+L {a[^c[.ch.]]} ac
  747. m 18 &+L {a[^c[.ch.]]} abe ab
  748. m 19 &+L {a[^b]} ac ac
  749. m 20 &+L {a[^b]} ace ac
  750. m 21 &+L {a[^b]} ach ach
  751. f 22 &+L {a[^b]} abe
  752. doing 23 "lookahead constraints"
  753. m 1 HP a(?=b)b* ab ab
  754. f 2 HP a(?=b)b* a
  755. m 3 HP a(?=b)b*(?=c)c* abc abc
  756. f 4 HP a(?=b)b*(?=c)c* ab
  757. f 5 HP a(?!b)b* ab
  758. m 6 HP a(?!b)b* a a
  759. m 7 HP (?=b)b b b
  760. f 8 HP (?=b)b a
  761. doing 24 "non-greedy quantifiers"
  762. m 1 PT ab+? abb ab
  763. m 2 PT ab+?c abbc abbc
  764. m 3 PT ab*? abb a
  765. m 4 PT ab*?c abbc abbc
  766. m 5 PT ab?? ab a
  767. m 6 PT ab??c abc abc
  768. m 7 PQT "ab{2,4}?" abbbb abb
  769. m 8 PQT "ab{2,4}?c" abbbbc abbbbc
  770. m 9 - 3z* 123zzzz456 3zzzz
  771. m 10 PT 3z*? 123zzzz456 3
  772. m 11 - z*4 123zzzz456 zzzz4
  773. m 12 PT z*?4 123zzzz456 zzzz4
  774. doing 25 "mixed quantifiers"
  775. # this is very incomplete as yet
  776. # should include |
  777. m 1 PNT {^(.*?)(a*)$} xyza xyza xyz a
  778. m 2 PNT {^(.*?)(a*)$} xyzaa xyzaa xyz aa
  779. m 3 PNT {^(.*?)(a*)$} xyz xyz xyz ""
  780. doing 26 "tricky cases"
  781. # attempts to trick the matcher into accepting a short match
  782. m 1 - (week|wee)(night|knights) weeknights weeknights \
  783. wee knights
  784. m 2 RP {a(bc*).*\1} abccbccb abccbccb b
  785. m 3 - {a(b.[bc]*)+} abcbd abcbd bd
  786. doing 27 "implementation misc."
  787. # duplicate arcs are suppressed
  788. m 1 P a(?:b|b)c abc abc
  789. # make color/subcolor relationship go back and forth
  790. m 2 & {[ab][ab][ab]} aba aba
  791. m 3 & {[ab][ab][ab][ab][ab][ab][ab]} abababa abababa
  792. doing 28 "boundary busters etc."
  793. # color-descriptor allocation changes at 10
  794. m 1 & abcdefghijkl abcdefghijkl abcdefghijkl
  795. # so does arc allocation
  796. m 2 P a(?:b|c|d|e|f|g|h|i|j|k|l|m)n agn agn
  797. # subexpression tracking also at 10
  798. m 3 - a(((((((((((((b)))))))))))))c abc abc b b b b b b b b b b b b b
  799. # state-set handling changes slightly at unsigned size (might be 64...)
  800. # (also stresses arc allocation)
  801. m 4 Q "ab{1,100}c" abbc abbc
  802. m 5 Q "ab{1,100}c" abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc \
  803. abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc
  804. m 6 Q "ab{1,100}c" \
  805. abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc \
  806. abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc
  807. # force small cache and bust it, several ways
  808. m 7 LP {\w+abcdefgh} xyzabcdefgh xyzabcdefgh
  809. m 8 %LP {\w+abcdefgh} xyzabcdefgh xyzabcdefgh
  810. m 9 %LP {\w+abcdefghijklmnopqrst} xyzabcdefghijklmnopqrst \
  811. xyzabcdefghijklmnopqrst
  812. i 10 %LP {\w+(abcdefgh)?} xyz {0 2} {-1 -1}
  813. i 11 %LP {\w+(abcdefgh)?} xyzabcdefg {0 9} {-1 -1}
  814. i 12 %LP {\w+(abcdefghijklmnopqrst)?} xyzabcdefghijklmnopqrs \
  815. {0 21} {-1 -1}
  816. doing 29 "incomplete matches"
  817. p 1 t def abc {3 2} ""
  818. p 2 t bcd abc {1 2} ""
  819. p 3 t abc abab {0 3} ""
  820. p 4 t abc abdab {3 4} ""
  821. i 5 t abc abc {0 2} {0 2}
  822. i 6 t abc xyabc {2 4} {2 4}
  823. p 7 t abc+ xyab {2 3} ""
  824. i 8 t abc+ xyabc {2 4} {2 4}
  825. knownBug i 9 t abc+ xyabcd {2 4} {6 5}
  826. i 10 t abc+ xyabcdd {2 4} {7 6}
  827. p 11 tPT abc+? xyab {2 3} ""
  828. # the retain numbers in these two may look wrong, but they aren't
  829. i 12 tPT abc+? xyabc {2 4} {5 4}
  830. i 13 tPT abc+? xyabcc {2 4} {6 5}
  831. i 14 tPT abc+? xyabcd {2 4} {6 5}
  832. i 15 tPT abc+? xyabcdd {2 4} {7 6}
  833. i 16 t abcd|bc xyabc {3 4} {2 4}
  834. p 17 tn .*k "xx\nyyy" {3 5} ""
  835. doing 30 "misc. oddities and old bugs"
  836. e 1 & *** BADRPT
  837. m 2 N a?b* abb abb
  838. m 3 N a?b* bb bb
  839. m 4 & a*b aab aab
  840. m 5 & ^a*b aaaab aaaab
  841. m 6 &M {[0-6][1-2][0-3][0-6][1-6][0-6]} 010010 010010
  842. # temporary REG_BOSONLY kludge
  843. m 7 s abc abcd abc
  844. f 8 s abc xabcd
  845. # back to normal stuff
  846. m 9 HLP {(?n)^(?![t#])\S+} "tk\n\n#\n#\nit0" it0
  847. # flush any leftover complaints
  848. doing 0 "flush"
  849. # Tests resulting from bugs reported by users
  850. test reg-31.1 {[[:xdigit:]] behaves correctly when followed by [[:space:]]} {
  851. set str {2:::DebugWin32}
  852. set re {([[:xdigit:]])([[:space:]]*)}
  853. list [regexp $re $str match xdigit spaces] $match $xdigit $spaces
  854. # Code used to produce {1 2:::DebugWin32 2 :::DebugWin32} !!!
  855. } {1 2 2 {}}
  856. test reg-32.1 {canmatch functionality -- at end} {
  857. set pat {blah}
  858. set line "asd asd"
  859. # can match at the final d, if '%' follows
  860. set res [testregexp -xflags -- c $pat $line resvar]
  861. lappend res $resvar
  862. } {0 7}
  863. test reg-32.2 {canmatch functionality -- at end} {
  864. set pat {s%$}
  865. set line "asd asd"
  866. # can only match after the end of the string
  867. set res [testregexp -xflags -- c $pat $line resvar]
  868. lappend res $resvar
  869. } {0 7}
  870. test reg-32.3 {canmatch functionality -- not last char} {
  871. set pat {[^d]%$}
  872. set line "asd asd"
  873. # can only match after the end of the string
  874. set res [testregexp -xflags -- c $pat $line resvar]
  875. lappend res $resvar
  876. } {0 7}
  877. test reg-32.3.1 {canmatch functionality -- no match} {
  878. set pat {\Zx}
  879. set line "asd asd"
  880. # can match the last char, if followed by x
  881. set res [testregexp -xflags -- c $pat $line resvar]
  882. lappend res $resvar
  883. } {0 -1}
  884. test reg-32.4 {canmatch functionality -- last char} {knownBug} {
  885. set pat {.x}
  886. set line "asd asd"
  887. # can match the last char, if followed by x
  888. set res [testregexp -xflags -- c $pat $line resvar]
  889. lappend res $resvar
  890. } {0 6}
  891. test reg-32.4.1 {canmatch functionality -- last char} {knownBug} {
  892. set pat {.x$}
  893. set line "asd asd"
  894. # can match the last char, if followed by x
  895. set res [testregexp -xflags -- c $pat $line resvar]
  896. lappend res $resvar
  897. } {0 6}
  898. test reg-32.5 {canmatch functionality -- last char} {knownBug} {
  899. set pat {.[^d]x$}
  900. set line "asd asd"
  901. # can match the last char, if followed by not-d and x.
  902. set res [testregexp -xflags -- c $pat $line resvar]
  903. lappend res $resvar
  904. } {0 6}
  905. test reg-32.6 {canmatch functionality -- last char} {knownBug} {
  906. set pat {[^a]%[^\r\n]*$}
  907. set line "asd asd"
  908. # can match at the final d, if '%' follows
  909. set res [testregexp -xflags -- c $pat $line resvar]
  910. lappend res $resvar
  911. } {0 6}
  912. test reg-32.7 {canmatch functionality -- last char} {knownBug} {
  913. set pat {[^a]%$}
  914. set line "asd asd"
  915. # can match at the final d, if '%' follows
  916. set res [testregexp -xflags -- c $pat $line resvar]
  917. lappend res $resvar
  918. } {0 6}
  919. test reg-32.8 {canmatch functionality -- last char} {knownBug} {
  920. set pat {[^x]%$}
  921. set line "asd asd"
  922. # can match at the final d, if '%' follows
  923. set res [testregexp -xflags -- c $pat $line resvar]
  924. lappend res $resvar
  925. } {0 6}
  926. test reg-32.9 {canmatch functionality -- more complex case} {knownBug} {
  927. set pat {((\B\B|\Bh+line)[ \t]*|[^\B]%[^\r\n]*)$}
  928. set line "asd asd"
  929. # can match at the final d, if '%' follows
  930. set res [testregexp -xflags -- c $pat $line resvar]
  931. lappend res $resvar
  932. } {0 6}
  933. # Tests reg-33.*: Checks for bug fixes
  934. test reg-33.1 {Bug 230589} {
  935. regexp {[ ]*(^|[^%])%V} "*%V2" m s
  936. } 1
  937. test reg-33.2 {Bug 504785} {
  938. regexp -inline {([^_.]*)([^.]*)\.(..)(.).*} bbcos_001_c01.q1la
  939. } {bbcos_001_c01.q1la bbcos _001_c01 q1 l}
  940. test reg-33.3 {Bug 505048} {
  941. regexp {\A\s*[^<]*\s*<([^>]+)>} a<a>
  942. } 1
  943. test reg-33.4 {Bug 505048} {
  944. regexp {\A\s*([^b]*)b} ab
  945. } 1
  946. test reg-33.5 {Bug 505048} {
  947. regexp {\A\s*[^b]*(b)} ab
  948. } 1
  949. test reg-33.6 {Bug 505048} {
  950. regexp {\A(\s*)[^b]*(b)} ab
  951. } 1
  952. test reg-33.7 {Bug 505048} {
  953. regexp {\A\s*[^b]*b} ab
  954. } 1
  955. test reg-33.8 {Bug 505048} {
  956. regexp -inline {\A\s*[^b]*b} ab
  957. } ab
  958. test reg-33.9 {Bug 505048} {
  959. regexp -indices -inline {\A\s*[^b]*b} ab
  960. } {{0 1}}
  961. test reg-33.10 {Bug 840258} {
  962. regsub {(^|\n)+\.*b} \n.b {} tmp
  963. } 1
  964. test reg-33.11 {Bug 840258} {
  965. regsub {(^|[\n\r]+)\.*\?<.*?(\n|\r)+} \
  966. "TQ\r\n.?<5000267>Test already stopped\r\n" {} tmp
  967. } 1
  968. # cleanup
  969. ::tcltest::cleanupTests
  970. return