| 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 {"::tcltest" ni [namespace children]} { |
| 13 |
package require tcltest 2.5 |
| 14 |
} |
| 15 |
|
| 16 |
::tcltest::loadTestedCommands |
| 17 |
catch [list package require -exact Tcltest [info patchlevel]] |
| 18 |
|
| 19 |
# All tests require the testregexp command, return if this |
| 20 |
# command doesn't exist |
| 21 |
|
| 22 |
::tcltest::testConstraint testregexp [llength [info commands testregexp]] |
| 23 |
::tcltest::testConstraint localeRegexp 0 |
| 24 |
|
| 25 |
# This file uses some custom procedures, defined below, for regexp regression |
| 26 |
# testing. The name of the procedure indicates the general nature of the |
| 27 |
# test: |
| 28 |
# expectError compile error expected |
| 29 |
# expectNomatch match failure expected |
| 30 |
# expectMatch successful match |
| 31 |
# expectIndices successful match with -indices (used in checking things |
| 32 |
# like nonparticipating subexpressions) |
| 33 |
# expectPartial unsuccessful match with -indices (!!) (used in checking |
| 34 |
# partial-match reporting) |
| 35 |
# There is also "doing" which sets up title and major test number for each |
| 36 |
# block of tests. |
| 37 |
|
| 38 |
# The first 3 arguments are constant: a minor number (which often gets |
| 39 |
# a letter or two suffixed to it internally), some flags, and the RE |
| 40 |
# itself. For expectError, the remaining argument is the name of the |
| 41 |
# compile error expected, less the leading "REG_". For the rest, the |
| 42 |
# next argument is the string to try the match against. Remaining |
| 43 |
# arguments are the substring expected to be matched, and any |
| 44 |
# substrings expected to be matched by subexpressions. (For |
| 45 |
# expectNomatch, these arguments are optional, and if present are |
| 46 |
# ignored except that they indicate how many subexpressions should be |
| 47 |
# present in the RE.) It is an error for the number of subexpression |
| 48 |
# arguments to be wrong. Cases involving nonparticipating |
| 49 |
# subexpressions, checking where empty substrings are located, |
| 50 |
# etc. should be done using expectIndices and expectPartial. |
| 51 |
|
| 52 |
# The flag characters are complex and a bit eclectic. Generally speaking, |
| 53 |
# lowercase letters are compile options, uppercase are expected re_info |
| 54 |
# bits, and nonalphabetics are match options, controls for how the test is |
| 55 |
# run, or testing options. The one small surprise is that AREs are the |
| 56 |
# default, and you must explicitly request lesser flavors of RE. The flags |
| 57 |
# are as follows. It is admitted that some are not very mnemonic. |
| 58 |
# There are some others which are purely debugging tools and are not |
| 59 |
# useful in this file. |
| 60 |
# |
| 61 |
# - no-op (placeholder) |
| 62 |
# + provide fake xy equivalence class and ch collating element |
| 63 |
# % force small state-set cache in matcher (to test cache replace) |
| 64 |
# ^ beginning of string is not beginning of line |
| 65 |
# $ end of string is not end of line |
| 66 |
# * test is Unicode-specific, needs big character set |
| 67 |
# |
| 68 |
# & test as both ARE and BRE |
| 69 |
# b BRE |
| 70 |
# e ERE |
| 71 |
# a turn advanced-features bit on (error unless ERE already) |
| 72 |
# q literal string, no metacharacters at all |
| 73 |
# |
| 74 |
# i case-independent matching |
| 75 |
# o ("opaque") no subexpression capture |
| 76 |
# p newlines are half-magic, excluded from . and [^ only |
| 77 |
# w newlines are half-magic, significant to ^ and $ only |
| 78 |
# n newlines are fully magic, both effects |
| 79 |
# x expanded RE syntax |
| 80 |
# t incomplete-match reporting |
| 81 |
# |
| 82 |
# A backslash-_a_lphanumeric seen |
| 83 |
# B ERE/ARE literal-_b_race heuristic used |
| 84 |
# E backslash (_e_scape) seen within [] |
| 85 |
# H looka_h_ead constraint seen |
| 86 |
# I _i_mpossible to match |
| 87 |
# L _l_ocale-specific construct seen |
| 88 |
# M unportable (_m_achine-specific) construct seen |
| 89 |
# N RE can match empty (_n_ull) string |
| 90 |
# P non-_P_OSIX construct seen |
| 91 |
# Q {} _q_uantifier seen |
| 92 |
# R back _r_eference seen |
| 93 |
# S POSIX-un_s_pecified syntax seen |
| 94 |
# T prefers shortest (_t_iny) |
| 95 |
# U saw original-POSIX botch: unmatched right paren in ERE (_u_gh) |
| 96 |
|
| 97 |
# The one area we can't easily test is memory-allocation failures (which |
| 98 |
# are hard to provoke on command). Embedded NULs also are not tested at |
| 99 |
# the moment, but this is a historical accident which should be fixed. |
| 100 |
|
| 101 |
|
| 102 |
# test procedures and related |
| 103 |
namespace eval RETest { |
| 104 |
namespace export doing expect* knownBug |
| 105 |
|
| 106 |
variable regBug 0 |
| 107 |
|
| 108 |
# re_info abbreviation mapping table |
| 109 |
variable infonames |
| 110 |
array set infonames { |
| 111 |
A REG_UBSALNUM |
| 112 |
B REG_UBRACES |
| 113 |
E REG_UBBS |
| 114 |
H REG_ULOOKAHEAD |
| 115 |
I REG_UIMPOSSIBLE |
| 116 |
L REG_ULOCALE |
| 117 |
M REG_UUNPORT |
| 118 |
N REG_UEMPTYMATCH |
| 119 |
P REG_UNONPOSIX |
| 120 |
Q REG_UBOUNDS |
| 121 |
R REG_UBACKREF |
| 122 |
S REG_UUNSPEC |
| 123 |
T REG_USHORTEST |
| 124 |
U REG_UPBOTCH |
| 125 |
} |
| 126 |
variable infonameorder "RHQBAUEPSMLNIT" ;# must match bit order, lsb first |
| 127 |
|
| 128 |
# build test number (internal) |
| 129 |
proc TestNum {args} { |
| 130 |
return reg-[join [concat $args] .] |
| 131 |
} |
| 132 |
|
| 133 |
# build description, with possible modifiers (internal) |
| 134 |
proc TestDesc {args} { |
| 135 |
variable description |
| 136 |
|
| 137 |
set testid [concat $args] |
| 138 |
set d $description |
| 139 |
if {[llength $testid] > 1} { |
| 140 |
set d "$d ([lrange $testid 1 end])" |
| 141 |
} |
| 142 |
return $d |
| 143 |
} |
| 144 |
|
| 145 |
# build trailing options and flags argument from a flags string (internal) |
| 146 |
proc TestFlags {fl} { |
| 147 |
set args [list] |
| 148 |
set flags "" |
| 149 |
foreach f [split $fl ""] { |
| 150 |
switch -exact -- $f { |
| 151 |
"i" { lappend args "-nocase" } |
| 152 |
"x" { lappend args "-expanded" } |
| 153 |
"n" { lappend args "-line" } |
| 154 |
"p" { lappend args "-linestop" } |
| 155 |
"w" { lappend args "-lineanchor" } |
| 156 |
"-" { } |
| 157 |
default { append flags $f } |
| 158 |
} |
| 159 |
} |
| 160 |
if {$flags ne ""} { |
| 161 |
lappend args -xflags $flags |
| 162 |
} |
| 163 |
return $args |
| 164 |
} |
| 165 |
|
| 166 |
# build info-flags list from a flags string (internal) |
| 167 |
proc TestInfoFlags {fl} { |
| 168 |
variable infonames |
| 169 |
variable infonameorder |
| 170 |
|
| 171 |
set ret [list] |
| 172 |
foreach f [split $infonameorder ""] { |
| 173 |
if {[string match *$f* $fl]} { |
| 174 |
lappend ret $infonames($f) |
| 175 |
} |
| 176 |
} |
| 177 |
return $ret |
| 178 |
} |
| 179 |
|
| 180 |
# Share the generation of the list of test constraints so it is |
| 181 |
# done the same on all routes. |
| 182 |
proc TestConstraints {flags} { |
| 183 |
set constraints [list testregexp] |
| 184 |
|
| 185 |
variable regBug |
| 186 |
if {$regBug} { |
| 187 |
# This will trigger registration as a skipped test |
| 188 |
lappend constraints knownBug |
| 189 |
} |
| 190 |
|
| 191 |
# Tcl locale stuff doesn't do the ch/xy test fakery yet |
| 192 |
if {[string match *+* $flags]} { |
| 193 |
# This will trigger registration as a skipped test |
| 194 |
lappend constraints localeRegexp |
| 195 |
} |
| 196 |
|
| 197 |
return $constraints |
| 198 |
} |
| 199 |
|
| 200 |
# match expected, internal routine that does the work |
| 201 |
# parameters like the "real" routines except they don't have "opts", |
| 202 |
# which is a possibly-empty list of switches for the regexp match attempt |
| 203 |
# The ! flag is used to indicate expected match failure (for REG_EXPECT, |
| 204 |
# which wants argument testing even in the event of failure). |
| 205 |
proc MatchExpected {opts testid flags re target args} { |
| 206 |
# if &, test as both BRE and ARE |
| 207 |
if {[string match *&* $flags]} { |
| 208 |
set f [string map {& {}} $flags] |
| 209 |
MatchExpected $opts "$testid ARE" ${f} $re $target {*}$args |
| 210 |
MatchExpected $opts "$testid BRE" ${f}b $re $target {*}$args |
| 211 |
return |
| 212 |
} |
| 213 |
|
| 214 |
set constraints [TestConstraints $flags] |
| 215 |
|
| 216 |
set f [TestFlags $flags] |
| 217 |
set infoflags [TestInfoFlags $flags] |
| 218 |
set ccmd [list testregexp -about {*}$f $re] |
| 219 |
set ecmd [list testregexp {*}$opts {*}$f $re $target] |
| 220 |
|
| 221 |
set nsub [expr {[llength $args] - 1}] |
| 222 |
set names [list] |
| 223 |
set refs "" |
| 224 |
for {set i 0} {$i < [llength $args]} {incr i} { |
| 225 |
if {$i == 0} { |
| 226 |
set name match |
| 227 |
} else { |
| 228 |
set name sub$i |
| 229 |
} |
| 230 |
lappend names $name |
| 231 |
append refs " \$$name" |
| 232 |
set $name "" |
| 233 |
} |
| 234 |
if {[string match *o* $flags]} { ;# REG_NOSUB kludge |
| 235 |
set nsub 0 ;# unsigned value cannot be -1 |
| 236 |
} |
| 237 |
if {[string match *t* $flags]} { ;# REG_EXPECT |
| 238 |
incr nsub -1 ;# the extra does not count |
| 239 |
} |
| 240 |
set erun "list \[[concat $ecmd $names]\] $refs" |
| 241 |
set result [list [expr {![string match *!* $flags]}] {*}$args] |
| 242 |
set info [list $nsub $infoflags] |
| 243 |
|
| 244 |
::tcltest::test [TestNum $testid compile] [TestDesc $testid compile] \ |
| 245 |
-constraints $constraints -body $ccmd -result $info |
| 246 |
::tcltest::test [TestNum $testid execute] [TestDesc $testid execute] \ |
| 247 |
-constraints $constraints -body $erun -result $result |
| 248 |
} |
| 249 |
|
| 250 |
# set major test number and description |
| 251 |
proc doing {major desc} { |
| 252 |
variable description "RE engine $desc" |
| 253 |
} |
| 254 |
|
| 255 |
# compilation error expected |
| 256 |
proc expectError {testid flags re err} { |
| 257 |
# if &, test as both ARE and BRE |
| 258 |
if {[string match *&* $flags]} { |
| 259 |
set f [string map {& {}} $flags] |
| 260 |
expectError "$testid ARE" ${f} $re $err |
| 261 |
expectError "$testid BRE" ${f}b $re $err |
| 262 |
return |
| 263 |
} |
| 264 |
|
| 265 |
set constraints [TestConstraints $flags] |
| 266 |
|
| 267 |
set cmd [list testregexp -about {*}[TestFlags $flags] $re] |
| 268 |
::tcltest::test [TestNum $testid error] [TestDesc $testid error] \ |
| 269 |
-constraints $constraints -result [list 1 REG_$err] -body \ |
| 270 |
"list \[catch \{$cmd\}\] \[lindex \$::errorCode 1\]" |
| 271 |
} |
| 272 |
|
| 273 |
# match failure expected |
| 274 |
proc expectNomatch {testid flags re target args} { |
| 275 |
variable regBug |
| 276 |
# if &, test as both ARE and BRE |
| 277 |
if {[string match *&* $flags]} { |
| 278 |
set f [string map {& {}} $flags] |
| 279 |
expectNomatch "$testid ARE" ${f} $re $target {*}$args |
| 280 |
expectNomatch "$testid BRE" ${f}b $re $target {*}$args |
| 281 |
return |
| 282 |
} |
| 283 |
|
| 284 |
set constraints [TestConstraints $flags] |
| 285 |
|
| 286 |
set f [TestFlags $flags] |
| 287 |
set infoflags [TestInfoFlags $flags] |
| 288 |
set ccmd [list testregexp -about {*}$f $re] |
| 289 |
set nsub [expr {[llength $args] - 1}] |
| 290 |
if {$nsub < 0} { |
| 291 |
# didn't tell us number of subexps |
| 292 |
set ccmd "lreplace \[$ccmd\] 0 0" |
| 293 |
set info [list $infoflags] |
| 294 |
} else { |
| 295 |
set info [list $nsub $infoflags] |
| 296 |
} |
| 297 |
set ecmd [list testregexp {*}$f $re $target] |
| 298 |
|
| 299 |
::tcltest::test [TestNum $testid compile] [TestDesc $testid compile] \ |
| 300 |
-constraints $constraints -body $ccmd -result $info |
| 301 |
::tcltest::test [TestNum $testid execute] [TestDesc $testid execute] \ |
| 302 |
-constraints $constraints -body $ecmd -result 0 |
| 303 |
} |
| 304 |
|
| 305 |
# match expected (no missing, empty, or ambiguous submatches) |
| 306 |
# expectMatch testno flags re target mat submat ... |
| 307 |
proc expectMatch {args} { |
| 308 |
MatchExpected {} {*}$args |
| 309 |
} |
| 310 |
|
| 311 |
# match expected (full fanciness) |
| 312 |
# expectIndices testno flags re target mat submat ... |
| 313 |
proc expectIndices {args} { |
| 314 |
MatchExpected -indices {*}$args |
| 315 |
} |
| 316 |
|
| 317 |
# partial match expected |
| 318 |
# expectPartial testno flags re target mat "" ... |
| 319 |
# Quirk: number of ""s must be one more than number of subREs. |
| 320 |
proc expectPartial {args} { |
| 321 |
lset args 1 ![lindex $args 1] ;# add ! flag |
| 322 |
MatchExpected -indices {*}$args |
| 323 |
} |
| 324 |
|
| 325 |
# test is a knownBug |
| 326 |
proc knownBug {args} { |
| 327 |
variable regBug 1 |
| 328 |
uplevel \#0 $args |
| 329 |
set regBug 0 |
| 330 |
} |
| 331 |
} |
| 332 |
namespace import RETest::* |
| 333 |
|
| 334 |
######## the tests themselves ######## |
| 335 |
|
| 336 |
# support functions and preliminary misc. |
| 337 |
# This is sensitive to changes in message wording, but we really have to |
| 338 |
# test the code->message expansion at least once. |
| 339 |
::tcltest::test reg-0.1 "regexp error reporting" { |
| 340 |
list [catch {regexp (*) ign} msg] $msg |
| 341 |
} {1 {couldn't compile regular expression pattern: quantifier operand invalid}} |
| 342 |
|
| 343 |
|
| 344 |
doing 1 "basic sanity checks" |
| 345 |
expectMatch 1.1 & abc abc abc |
| 346 |
expectNomatch 1.2 & abc def |
| 347 |
expectMatch 1.3 & abc xyabxabce abc |
| 348 |
|
| 349 |
|
| 350 |
doing 2 "invalid option combinations" |
| 351 |
expectError 2.1 qe a INVARG |
| 352 |
expectError 2.2 qa a INVARG |
| 353 |
expectError 2.3 qx a INVARG |
| 354 |
expectError 2.4 qn a INVARG |
| 355 |
expectError 2.5 ba a INVARG |
| 356 |
|
| 357 |
|
| 358 |
doing 3 "basic syntax" |
| 359 |
expectIndices 3.1 &NS "" a {0 -1} |
| 360 |
expectMatch 3.2 NS a| a a |
| 361 |
expectMatch 3.3 - a|b a a |
| 362 |
expectMatch 3.4 - a|b b b |
| 363 |
expectMatch 3.5 NS a||b b b |
| 364 |
expectMatch 3.6 & ab ab ab |
| 365 |
|
| 366 |
|
| 367 |
doing 4 "parentheses" |
| 368 |
expectMatch 4.1 - (a)e ae ae a |
| 369 |
expectMatch 4.2 o (a)e ae |
| 370 |
expectMatch 4.3 b {\(a\)b} ab ab a |
| 371 |
expectMatch 4.4 - a((b)c) abc abc bc b |
| 372 |
expectMatch 4.5 - a(b)(c) abc abc b c |
| 373 |
expectError 4.6 - a(b EPAREN |
| 374 |
expectError 4.7 b {a\(b} EPAREN |
| 375 |
# sigh, we blew it on the specs here... someday this will be fixed in POSIX, |
| 376 |
# but meanwhile, it's fixed in AREs |
| 377 |
expectMatch 4.8 eU a)b a)b a)b |
| 378 |
expectError 4.9 - a)b EPAREN |
| 379 |
expectError 4.10 b {a\)b} EPAREN |
| 380 |
expectMatch 4.11 P a(?:b)c abc abc |
| 381 |
expectError 4.12 e a(?:b)c BADRPT |
| 382 |
expectIndices 4.13 S a()b ab {0 1} {1 0} |
| 383 |
expectMatch 4.14 SP a(?:)b ab ab |
| 384 |
expectIndices 4.15 S a(|b)c ac {0 1} {1 0} |
| 385 |
expectMatch 4.16 S a(b|)c abc abc b |
| 386 |
|
| 387 |
|
| 388 |
doing 5 "simple one-char matching" |
| 389 |
# general case of brackets done later |
| 390 |
expectMatch 5.1 & a.b axb axb |
| 391 |
expectNomatch 5.2 &n "a.b" "a\nb" |
| 392 |
expectMatch 5.3 & {a[bc]d} abd abd |
| 393 |
expectMatch 5.4 & {a[bc]d} acd acd |
| 394 |
expectNomatch 5.5 & {a[bc]d} aed |
| 395 |
expectNomatch 5.6 & {a[^bc]d} abd |
| 396 |
expectMatch 5.7 & {a[^bc]d} aed aed |
| 397 |
expectNomatch 5.8 &p "a\[^bc]d" "a\nd" |
| 398 |
|
| 399 |
|
| 400 |
doing 6 "context-dependent syntax" |
| 401 |
# plus odds and ends |
| 402 |
expectError 6.1 - * BADRPT |
| 403 |
expectMatch 6.2 b * * * |
| 404 |
expectMatch 6.3 b {\(*\)} * * * |
| 405 |
expectError 6.4 - (*) BADRPT |
| 406 |
expectMatch 6.5 b ^* * * |
| 407 |
expectError 6.6 - ^* BADRPT |
| 408 |
expectNomatch 6.7 & ^b ^b |
| 409 |
expectMatch 6.8 b x^ x^ x^ |
| 410 |
expectNomatch 6.9 I x^ x |
| 411 |
expectMatch 6.10 n "\n^" "x\nb" "\n" |
| 412 |
expectNomatch 6.11 bS {\(^b\)} ^b |
| 413 |
expectMatch 6.12 - (^b) b b b |
| 414 |
expectMatch 6.13 & {x$} x x |
| 415 |
expectMatch 6.14 bS {\(x$\)} x x x |
| 416 |
expectMatch 6.15 - {(x$)} x x x |
| 417 |
expectMatch 6.16 b {x$y} "x\$y" "x\$y" |
| 418 |
expectNomatch 6.17 I {x$y} xy |
| 419 |
expectMatch 6.18 n "x\$\n" "x\n" "x\n" |
| 420 |
expectError 6.19 - + BADRPT |
| 421 |
expectError 6.20 - ? BADRPT |
| 422 |
|
| 423 |
|
| 424 |
doing 7 "simple quantifiers" |
| 425 |
expectMatch 7.1 &N a* aa aa |
| 426 |
expectIndices 7.2 &N a* b {0 -1} |
| 427 |
expectMatch 7.3 - a+ aa aa |
| 428 |
expectMatch 7.4 - a?b ab ab |
| 429 |
expectMatch 7.5 - a?b b b |
| 430 |
expectError 7.6 - ** BADRPT |
| 431 |
expectMatch 7.7 bN ** *** *** |
| 432 |
expectError 7.8 & a** BADRPT |
| 433 |
expectError 7.9 & a**b BADRPT |
| 434 |
expectError 7.10 & *** BADRPT |
| 435 |
expectError 7.11 - a++ BADRPT |
| 436 |
expectError 7.12 - a?+ BADRPT |
| 437 |
expectError 7.13 - a?* BADRPT |
| 438 |
expectError 7.14 - a+* BADRPT |
| 439 |
expectError 7.15 - a*+ BADRPT |
| 440 |
|
| 441 |
|
| 442 |
doing 8 "braces" |
| 443 |
expectMatch 8.1 NQ "a{0,1}" "" "" |
| 444 |
expectMatch 8.2 NQ "a{0,1}" ac a |
| 445 |
expectError 8.3 - "a{1,0}" BADBR |
| 446 |
expectError 8.4 - "a{1,2,3}" BADBR |
| 447 |
expectError 8.5 - "a{257}" BADBR |
| 448 |
expectError 8.6 - "a{1000}" BADBR |
| 449 |
expectError 8.7 - "a{1" EBRACE |
| 450 |
expectError 8.8 - "a{1n}" BADBR |
| 451 |
expectMatch 8.9 BS "a{b" "a\{b" "a\{b" |
| 452 |
expectMatch 8.10 BS "a{" "a\{" "a\{" |
| 453 |
expectMatch 8.11 bQ "a\\{0,1\\}b" cb b |
| 454 |
expectError 8.12 b "a\\{0,1" EBRACE |
| 455 |
expectError 8.13 - "a{0,1\\" BADBR |
| 456 |
expectMatch 8.14 Q "a{0}b" ab b |
| 457 |
expectMatch 8.15 Q "a{0,0}b" ab b |
| 458 |
expectMatch 8.16 Q "a{0,1}b" ab ab |
| 459 |
expectMatch 8.17 Q "a{0,2}b" b b |
| 460 |
expectMatch 8.18 Q "a{0,2}b" aab aab |
| 461 |
expectMatch 8.19 Q "a{0,}b" aab aab |
| 462 |
expectMatch 8.20 Q "a{1,1}b" aab ab |
| 463 |
expectMatch 8.21 Q "a{1,3}b" aaaab aaab |
| 464 |
expectNomatch 8.22 Q "a{1,3}b" b |
| 465 |
expectMatch 8.23 Q "a{1,}b" aab aab |
| 466 |
expectNomatch 8.24 Q "a{2,3}b" ab |
| 467 |
expectMatch 8.25 Q "a{2,3}b" aaaab aaab |
| 468 |
expectNomatch 8.26 Q "a{2,}b" ab |
| 469 |
expectMatch 8.27 Q "a{2,}b" aaaab aaaab |
| 470 |
|
| 471 |
|
| 472 |
doing 9 "brackets" |
| 473 |
expectMatch 9.1 & {a[bc]} ac ac |
| 474 |
expectMatch 9.2 & {a[-]} a- a- |
| 475 |
expectMatch 9.3 & {a[[.-.]]} a- a- |
| 476 |
expectMatch 9.4 &L {a[[.zero.]]} a0 a0 |
| 477 |
expectMatch 9.5 &LM {a[[.zero.]-9]} a2 a2 |
| 478 |
expectMatch 9.6 &M {a[0-[.9.]]} a2 a2 |
| 479 |
expectMatch 9.7 &+L {a[[=x=]]} ax ax |
| 480 |
expectMatch 9.8 &+L {a[[=x=]]} ay ay |
| 481 |
expectNomatch 9.9 &+L {a[[=x=]]} az |
| 482 |
expectError 9.10 & {a[0-[=x=]]} ERANGE |
| 483 |
expectMatch 9.11 &L {a[[:digit:]]} a0 a0 |
| 484 |
expectError 9.12 & {a[[:woopsie:]]} ECTYPE |
| 485 |
expectNomatch 9.13 &L {a[[:digit:]]} ab |
| 486 |
expectError 9.14 & {a[0-[:digit:]]} ERANGE |
| 487 |
expectMatch 9.15 &LP {[[:<:]]a} a a |
| 488 |
expectMatch 9.16 &LP {a[[:>:]]} a a |
| 489 |
expectError 9.17 & {a[[..]]b} ECOLLATE |
| 490 |
expectError 9.18 & {a[[==]]b} ECOLLATE |
| 491 |
expectError 9.19 & {a[[::]]b} ECTYPE |
| 492 |
expectError 9.20 & {a[[.a} EBRACK |
| 493 |
expectError 9.21 & {a[[=a} EBRACK |
| 494 |
expectError 9.22 & {a[[:a} EBRACK |
| 495 |
expectError 9.23 & {a[} EBRACK |
| 496 |
expectError 9.24 & {a[b} EBRACK |
| 497 |
expectError 9.25 & {a[b-} EBRACK |
| 498 |
expectError 9.26 & {a[b-c} EBRACK |
| 499 |
expectMatch 9.27 &M {a[b-c]} ab ab |
| 500 |
expectMatch 9.28 & {a[b-b]} ab ab |
| 501 |
expectMatch 9.29 &M {a[1-2]} a2 a2 |
| 502 |
expectError 9.30 & {a[c-b]} ERANGE |
| 503 |
expectError 9.31 & {a[a-b-c]} ERANGE |
| 504 |
expectMatch 9.32 &M {a[--?]b} a?b a?b |
| 505 |
expectMatch 9.33 & {a[---]b} a-b a-b |
| 506 |
expectMatch 9.34 & {a[]b]c} a]c a]c |
| 507 |
expectMatch 9.35 EP {a[\]]b} a]b a]b |
| 508 |
expectNomatch 9.36 bE {a[\]]b} a]b |
| 509 |
expectMatch 9.37 bE {a[\]]b} "a\\]b" "a\\]b" |
| 510 |
expectMatch 9.38 eE {a[\]]b} "a\\]b" "a\\]b" |
| 511 |
expectMatch 9.39 EP {a[\\]b} "a\\b" "a\\b" |
| 512 |
expectMatch 9.40 eE {a[\\]b} "a\\b" "a\\b" |
| 513 |
expectMatch 9.41 bE {a[\\]b} "a\\b" "a\\b" |
| 514 |
expectError 9.42 - {a[\Z]b} EESCAPE |
| 515 |
expectMatch 9.43 & {a[[b]c} "a\[c" "a\[c" |
| 516 |
expectMatch 9.44 EMP* {a[\u00fe-\u0507][\u00ff-\u0300]b} \ |
| 517 |
"a\u0102\u02ffb" "a\u0102\u02ffb" |
| 518 |
|
| 519 |
|
| 520 |
doing 10 "anchors and newlines" |
| 521 |
expectMatch 10.1 & ^a a a |
| 522 |
expectNomatch 10.2 &^ ^a a |
| 523 |
expectIndices 10.3 &N ^ a {0 -1} |
| 524 |
expectIndices 10.4 & {a$} aba {2 2} |
| 525 |
expectNomatch 10.5 {&$} {a$} a |
| 526 |
expectIndices 10.6 &N {$} ab {2 1} |
| 527 |
expectMatch 10.7 &n ^a a a |
| 528 |
expectMatch 10.8 &n "^a" "b\na" "a" |
| 529 |
expectIndices 10.9 &w "^a" "a\na" {0 0} |
| 530 |
expectIndices 10.10 &n^ "^a" "a\na" {2 2} |
| 531 |
expectMatch 10.11 &n {a$} a a |
| 532 |
expectMatch 10.12 &n "a\$" "a\nb" "a" |
| 533 |
expectIndices 10.13 &n "a\$" "a\na" {0 0} |
| 534 |
expectIndices 10.14 N ^^ a {0 -1} |
| 535 |
expectMatch 10.15 b ^^ ^ ^ |
| 536 |
expectIndices 10.16 N {$$} a {1 0} |
| 537 |
expectMatch 10.17 b {$$} "\$" "\$" |
| 538 |
expectMatch 10.18 &N {^$} "" "" |
| 539 |
expectNomatch 10.19 &N {^$} a |
| 540 |
expectIndices 10.20 &nN "^\$" a\n\nb {2 1} |
| 541 |
expectMatch 10.21 N {$^} "" "" |
| 542 |
expectMatch 10.22 b {$^} "\$^" "\$^" |
| 543 |
expectMatch 10.23 P {\Aa} a a |
| 544 |
expectMatch 10.24 ^P {\Aa} a a |
| 545 |
expectNomatch 10.25 ^nP {\Aa} "b\na" |
| 546 |
expectMatch 10.26 P {a\Z} a a |
| 547 |
expectMatch 10.27 \$P {a\Z} a a |
| 548 |
expectNomatch 10.28 \$nP {a\Z} "a\nb" |
| 549 |
expectError 10.29 - ^* BADRPT |
| 550 |
expectError 10.30 - {$*} BADRPT |
| 551 |
expectError 10.31 - {\A*} BADRPT |
| 552 |
expectError 10.32 - {\Z*} BADRPT |
| 553 |
|
| 554 |
|
| 555 |
doing 11 "boundary constraints" |
| 556 |
expectMatch 11.1 &LP {[[:<:]]a} a a |
| 557 |
expectMatch 11.2 &LP {[[:<:]]a} -a a |
| 558 |
expectNomatch 11.3 &LP {[[:<:]]a} ba |
| 559 |
expectMatch 11.4 &LP {a[[:>:]]} a a |
| 560 |
expectMatch 11.5 &LP {a[[:>:]]} a- a |
| 561 |
expectNomatch 11.6 &LP {a[[:>:]]} ab |
| 562 |
expectMatch 11.7 bLP {\<a} a a |
| 563 |
expectNomatch 11.8 bLP {\<a} ba |
| 564 |
expectMatch 11.9 bLP {a\>} a a |
| 565 |
expectNomatch 11.10 bLP {a\>} ab |
| 566 |
expectMatch 11.11 LP {\ya} a a |
| 567 |
expectNomatch 11.12 LP {\ya} ba |
| 568 |
expectMatch 11.13 LP {a\y} a a |
| 569 |
expectNomatch 11.14 LP {a\y} ab |
| 570 |
expectMatch 11.15 LP {a\Y} ab a |
| 571 |
expectNomatch 11.16 LP {a\Y} a- |
| 572 |
expectNomatch 11.17 LP {a\Y} a |
| 573 |
expectNomatch 11.18 LP {-\Y} -a |
| 574 |
expectMatch 11.19 LP {-\Y} -% - |
| 575 |
expectNomatch 11.20 LP {\Y-} a- |
| 576 |
expectError 11.21 - {[[:<:]]*} BADRPT |
| 577 |
expectError 11.22 - {[[:>:]]*} BADRPT |
| 578 |
expectError 11.23 b {\<*} BADRPT |
| 579 |
expectError 11.24 b {\>*} BADRPT |
| 580 |
expectError 11.25 - {\y*} BADRPT |
| 581 |
expectError 11.26 - {\Y*} BADRPT |
| 582 |
expectMatch 11.27 LP {\ma} a a |
| 583 |
expectNomatch 11.28 LP {\ma} ba |
| 584 |
expectMatch 11.29 LP {a\M} a a |
| 585 |
expectNomatch 11.30 LP {a\M} ab |
| 586 |
expectNomatch 11.31 ILP {\Ma} a |
| 587 |
expectNomatch 11.32 ILP {a\m} a |
| 588 |
|
| 589 |
|
| 590 |
doing 12 "character classes" |
| 591 |
expectMatch 12.1 LP {a\db} a0b a0b |
| 592 |
expectNomatch 12.2 LP {a\db} axb |
| 593 |
expectNomatch 12.3 LP {a\Db} a0b |
| 594 |
expectMatch 12.4 LP {a\Db} axb axb |
| 595 |
expectMatch 12.5 LP "a\\sb" "a b" "a b" |
| 596 |
expectMatch 12.6 LP "a\\sb" "a\tb" "a\tb" |
| 597 |
expectMatch 12.7 LP "a\\sb" "a\nb" "a\nb" |
| 598 |
expectNomatch 12.8 LP {a\sb} axb |
| 599 |
expectMatch 12.9 LP {a\Sb} axb axb |
| 600 |
expectNomatch 12.10 LP "a\\Sb" "a b" |
| 601 |
expectMatch 12.11 LP {a\wb} axb axb |
| 602 |
expectNomatch 12.12 LP {a\wb} a-b |
| 603 |
expectNomatch 12.13 LP {a\Wb} axb |
| 604 |
expectMatch 12.14 LP {a\Wb} a-b a-b |
| 605 |
expectMatch 12.15 LP {\y\w+z\y} adze-guz guz |
| 606 |
expectMatch 12.16 LPE {a[\d]b} a1b a1b |
| 607 |
expectMatch 12.17 LPE "a\[\\s]b" "a b" "a b" |
| 608 |
expectMatch 12.18 LPE {a[\w]b} axb axb |
| 609 |
|
| 610 |
|
| 611 |
doing 13 "escapes" |
| 612 |
expectError 13.1 & "a\\" EESCAPE |
| 613 |
expectMatch 13.2 - {a\<b} a<b a<b |
| 614 |
expectMatch 13.3 e {a\<b} a<b a<b |
| 615 |
expectMatch 13.4 bAS {a\wb} awb awb |
| 616 |
expectMatch 13.5 eAS {a\wb} awb awb |
| 617 |
expectMatch 13.6 PL "a\\ab" "a\007b" "a\007b" |
| 618 |
expectMatch 13.7 P "a\\bb" "a\bb" "a\bb" |
| 619 |
expectMatch 13.8 P {a\Bb} "a\\b" "a\\b" |
| 620 |
expectMatch 13.9 MP "a\\chb" "a\bb" "a\bb" |
| 621 |
expectMatch 13.10 MP "a\\cHb" "a\bb" "a\bb" |
| 622 |
expectMatch 13.11 LMP "a\\e" "a\033" "a\033" |
| 623 |
expectMatch 13.12 P "a\\fb" "a\fb" "a\fb" |
| 624 |
expectMatch 13.13 P "a\\nb" "a\nb" "a\nb" |
| 625 |
expectMatch 13.14 P "a\\rb" "a\rb" "a\rb" |
| 626 |
expectMatch 13.15 P "a\\tb" "a\tb" "a\tb" |
| 627 |
expectMatch 13.16 P "a\\u0008x" "a\bx" "a\bx" |
| 628 |
expectMatch 13.17 P {a\u008x} "a\bx" "a\bx" |
| 629 |
expectError 13.17.1 - {a\ux} EESCAPE |
| 630 |
expectMatch 13.18 P "a\\u00088x" "a\b8x" "a\b8x" |
| 631 |
expectMatch 13.19 P "a\\U00000008x" "a\bx" "a\bx" |
| 632 |
expectMatch 13.20 P {a\U0000008x} "a\bx" "a\bx" |
| 633 |
expectMatch 13.21 P "a\\vb" "a\vb" "a\vb" |
| 634 |
expectMatch 13.22 MP "a\\x08x" "a\bx" "a\bx" |
| 635 |
expectError 13.23 - {a\xq} EESCAPE |
| 636 |
expectMatch 13.24 MP "a\\x08x" "a\bx" "a\bx" |
| 637 |
expectError 13.25 - {a\z} EESCAPE |
| 638 |
expectMatch 13.26 MP "a\\010b" "a\bb" "a\bb" |
| 639 |
expectMatch 13.27 P "a\\U00001234x" "a\u1234x" "a\u1234x" |
| 640 |
expectMatch 13.28 P {a\U00001234x} "a\u1234x" "a\u1234x" |
| 641 |
expectMatch 13.29 P "a\\U0001234x" "a\u1234x" "a\u1234x" |
| 642 |
expectMatch 13.30 P {a\U0001234x} "a\u1234x" "a\u1234x" |
| 643 |
expectMatch 13.31 P "a\\U000012345x" "a\u12345x" "a\u12345x" |
| 644 |
expectMatch 13.32 P {a\U000012345x} "a\u12345x" "a\u12345x" |
| 645 |
expectMatch 13.33 P "a\\U1000000x" "a\ufffd0x" "a\ufffd0x" |
| 646 |
expectMatch 13.34 P {a\U1000000x} "a\ufffd0x" "a\ufffd0x" |
| 647 |
|
| 648 |
|
| 649 |
doing 14 "back references" |
| 650 |
# ugh |
| 651 |
expectMatch 14.1 RP {a(b*)c\1} abbcbb abbcbb bb |
| 652 |
expectMatch 14.2 RP {a(b*)c\1} ac ac "" |
| 653 |
expectNomatch 14.3 RP {a(b*)c\1} abbcb |
| 654 |
expectMatch 14.4 RP {a(b*)\1} abbcbb abb b |
| 655 |
expectMatch 14.5 RP {a(b|bb)\1} abbcbb abb b |
| 656 |
expectMatch 14.6 RP {a([bc])\1} abb abb b |
| 657 |
expectNomatch 14.7 RP {a([bc])\1} abc |
| 658 |
expectMatch 14.8 RP {a([bc])\1} abcabb abb b |
| 659 |
expectNomatch 14.9 RP {a([bc])*\1} abc |
| 660 |
expectNomatch 14.10 RP {a([bc])\1} abB |
| 661 |
expectMatch 14.11 iRP {a([bc])\1} abB abB b |
| 662 |
expectMatch 14.12 RP {a([bc])\1+} abbb abbb b |
| 663 |
expectMatch 14.13 QRP "a(\[bc])\\1{3,4}" abbbb abbbb b |
| 664 |
expectNomatch 14.14 QRP "a(\[bc])\\1{3,4}" abbb |
| 665 |
expectMatch 14.15 RP {a([bc])\1*} abbb abbb b |
| 666 |
expectMatch 14.16 RP {a([bc])\1*} ab ab b |
| 667 |
expectMatch 14.17 RP {a([bc])(\1*)} ab ab b "" |
| 668 |
expectError 14.18 - {a((b)\1)} ESUBREG |
| 669 |
expectError 14.19 - {a(b)c\2} ESUBREG |
| 670 |
expectMatch 14.20 bR {a\(b*\)c\1} abbcbb abbcbb bb |
| 671 |
expectMatch 14.21 RP {^([bc])\1*$} bbb bbb b |
| 672 |
expectMatch 14.22 RP {^([bc])\1*$} ccc ccc c |
| 673 |
expectNomatch 14.23 RP {^([bc])\1*$} bcb |
| 674 |
expectMatch 14.24 LRP {^(\w+)( \1)+$} {abc abc abc} {abc abc abc} abc { abc} |
| 675 |
expectNomatch 14.25 LRP {^(\w+)( \1)+$} {abc abd abc} |
| 676 |
expectNomatch 14.26 LRP {^(\w+)( \1)+$} {abc abc abd} |
| 677 |
expectMatch 14.27 RP {^(.+)( \1)+$} {abc abc abc} {abc abc abc} abc { abc} |
| 678 |
expectNomatch 14.28 RP {^(.+)( \1)+$} {abc abd abc} |
| 679 |
expectNomatch 14.29 RP {^(.+)( \1)+$} {abc abc abd} |
| 680 |
|
| 681 |
|
| 682 |
doing 15 "octal escapes vs back references" |
| 683 |
# initial zero is always octal |
| 684 |
expectMatch 15.1 MP "a\\010b" "a\bb" "a\bb" |
| 685 |
expectMatch 15.2 MP "a\\0070b" "a\0070b" "a\0070b" |
| 686 |
expectMatch 15.3 MP "a\\07b" "a\007b" "a\007b" |
| 687 |
expectMatch 15.4 MP "a(b)(b)(b)(b)(b)(b)(b)(b)(b)(b)\\07c" \ |
| 688 |
"abbbbbbbbbb\007c" abbbbbbbbbb\007c b b b b b b b b b b |
| 689 |
# a single digit is always a backref |
| 690 |
expectError 15.5 - {a\7b} ESUBREG |
| 691 |
# otherwise it's a backref only if within range (barf!) |
| 692 |
expectMatch 15.6 MP "a\\10b" "a\bb" "a\bb" |
| 693 |
expectMatch 15.7 MP {a\101b} aAb aAb |
| 694 |
expectMatch 15.8 RP {a(b)(b)(b)(b)(b)(b)(b)(b)(b)(b)\10c} \ |
| 695 |
"abbbbbbbbbbbc" abbbbbbbbbbbc b b b b b b b b b b |
| 696 |
# but we're fussy about border cases -- guys who want octal should use the zero |
| 697 |
expectError 15.9 - {a((((((((((b\10))))))))))c} ESUBREG |
| 698 |
# BREs don't have octal, EREs don't have backrefs |
| 699 |
expectMatch 15.10 MP "a\\12b" "a\nb" "a\nb" |
| 700 |
expectError 15.11 b {a\12b} ESUBREG |
| 701 |
expectMatch 15.12 eAS {a\12b} a12b a12b |
| 702 |
expectMatch 15.13 MP {a\701b} a\u00381b a\u00381b |
| 703 |
|
| 704 |
|
| 705 |
doing 16 "expanded syntax" |
| 706 |
expectMatch 16.1 xP "a b c" "abc" "abc" |
| 707 |
expectMatch 16.2 xP "a b #oops\nc\td" "abcd" "abcd" |
| 708 |
expectMatch 16.3 x "a\\ b\\\tc" "a b\tc" "a b\tc" |
| 709 |
expectMatch 16.4 xP "a b\\#c" "ab#c" "ab#c" |
| 710 |
expectMatch 16.5 xP "a b\[c d]e" "ab e" "ab e" |
| 711 |
expectMatch 16.6 xP "a b\[c#d]e" "ab#e" "ab#e" |
| 712 |
expectMatch 16.7 xP "a b\[c#d]e" "abde" "abde" |
| 713 |
expectMatch 16.8 xSPB "ab{ d" "ab\{d" "ab\{d" |
| 714 |
expectMatch 16.9 xPQ "ab{ 1 , 2 }c" "abc" "abc" |
| 715 |
|
| 716 |
|
| 717 |
doing 17 "misc syntax" |
| 718 |
expectMatch 17.1 P a(?#comment)b ab ab |
| 719 |
|
| 720 |
|
| 721 |
doing 18 "unmatchable REs" |
| 722 |
expectNomatch 18.1 I a^b ab |
| 723 |
|
| 724 |
|
| 725 |
doing 19 "case independence" |
| 726 |
expectMatch 19.1 &i ab Ab Ab |
| 727 |
expectMatch 19.2 &i {a[bc]} aC aC |
| 728 |
expectNomatch 19.3 &i {a[^bc]} aB |
| 729 |
expectMatch 19.4 &iM {a[b-d]} aC aC |
| 730 |
expectNomatch 19.5 &iM {a[^b-d]} aC |
| 731 |
|
| 732 |
|
| 733 |
doing 20 "directors and embedded options" |
| 734 |
expectError 20.1 & ***? BADPAT |
| 735 |
expectMatch 20.2 q ***? ***? ***? |
| 736 |
expectMatch 20.3 &P ***=a*b a*b a*b |
| 737 |
expectMatch 20.4 q ***=a*b ***=a*b ***=a*b |
| 738 |
expectMatch 20.5 bLP {***:\w+} ab ab |
| 739 |
expectMatch 20.6 eLP {***:\w+} ab ab |
| 740 |
expectError 20.7 & ***:***=a*b BADRPT |
| 741 |
expectMatch 20.8 &P ***:(?b)a+b a+b a+b |
| 742 |
expectMatch 20.9 P (?b)a+b a+b a+b |
| 743 |
expectError 20.10 e {(?b)\w+} BADRPT |
| 744 |
expectMatch 20.11 bAS {(?b)\w+} (?b)w+ (?b)w+ |
| 745 |
expectMatch 20.12 iP (?c)a a a |
| 746 |
expectNomatch 20.13 iP (?c)a A |
| 747 |
expectMatch 20.14 APS {(?e)\W+} WW WW |
| 748 |
expectMatch 20.15 P (?i)a+ Aa Aa |
| 749 |
expectNomatch 20.16 P "(?m)a.b" "a\nb" |
| 750 |
expectMatch 20.17 P "(?m)^b" "a\nb" "b" |
| 751 |
expectNomatch 20.18 P "(?n)a.b" "a\nb" |
| 752 |
expectMatch 20.19 P "(?n)^b" "a\nb" "b" |
| 753 |
expectNomatch 20.20 P "(?p)a.b" "a\nb" |
| 754 |
expectNomatch 20.21 P "(?p)^b" "a\nb" |
| 755 |
expectMatch 20.22 P (?q)a+b a+b a+b |
| 756 |
expectMatch 20.23 nP "(?s)a.b" "a\nb" "a\nb" |
| 757 |
expectMatch 20.24 xP "(?t)a b" "a b" "a b" |
| 758 |
expectMatch 20.25 P "(?w)a.b" "a\nb" "a\nb" |
| 759 |
expectMatch 20.26 P "(?w)^b" "a\nb" "b" |
| 760 |
expectMatch 20.27 P "(?x)a b" "ab" "ab" |
| 761 |
expectError 20.28 - (?z)ab BADOPT |
| 762 |
expectMatch 20.29 P (?ici)a+ Aa Aa |
| 763 |
expectError 20.30 P (?i)(?q)a+ BADRPT |
| 764 |
expectMatch 20.31 P (?q)(?i)a+ (?i)a+ (?i)a+ |
| 765 |
expectMatch 20.32 P (?qe)a+ a a |
| 766 |
expectMatch 20.33 xP "(?q)a b" "a b" "a b" |
| 767 |
expectMatch 20.34 P "(?qx)a b" "a b" "a b" |
| 768 |
expectMatch 20.35 P (?qi)ab Ab Ab |
| 769 |
|
| 770 |
|
| 771 |
doing 21 "capturing" |
| 772 |
expectMatch 21.1 - a(b)c abc abc b |
| 773 |
expectMatch 21.2 P a(?:b)c xabc abc |
| 774 |
expectMatch 21.3 - a((b))c xabcy abc b b |
| 775 |
expectMatch 21.4 P a(?:(b))c abcy abc b |
| 776 |
expectMatch 21.5 P a((?:b))c abc abc b |
| 777 |
expectMatch 21.6 P a(?:(?:b))c abc abc |
| 778 |
expectIndices 21.7 Q "a(b){0}c" ac {0 1} {-1 -1} |
| 779 |
expectMatch 21.8 - a(b)c(d)e abcde abcde b d |
| 780 |
expectMatch 21.9 - (b)c(d)e bcde bcde b d |
| 781 |
expectMatch 21.10 - a(b)(d)e abde abde b d |
| 782 |
expectMatch 21.11 - a(b)c(d) abcd abcd b d |
| 783 |
expectMatch 21.12 - (ab)(cd) xabcdy abcd ab cd |
| 784 |
expectMatch 21.13 - a(b)?c xabcy abc b |
| 785 |
expectIndices 21.14 - a(b)?c xacy {1 2} {-1 -1} |
| 786 |
expectMatch 21.15 - a(b)?c(d)?e xabcdey abcde b d |
| 787 |
expectIndices 21.16 - a(b)?c(d)?e xacdey {1 4} {-1 -1} {3 3} |
| 788 |
expectIndices 21.17 - a(b)?c(d)?e xabcey {1 4} {2 2} {-1 -1} |
| 789 |
expectIndices 21.18 - a(b)?c(d)?e xacey {1 3} {-1 -1} {-1 -1} |
| 790 |
expectMatch 21.19 - a(b)*c xabcy abc b |
| 791 |
expectIndices 21.20 - a(b)*c xabbbcy {1 5} {4 4} |
| 792 |
expectIndices 21.21 - a(b)*c xacy {1 2} {-1 -1} |
| 793 |
expectMatch 21.22 - a(b*)c xabbbcy abbbc bbb |
| 794 |
expectMatch 21.23 - a(b*)c xacy ac "" |
| 795 |
expectNomatch 21.24 - a(b)+c xacy |
| 796 |
expectMatch 21.25 - a(b)+c xabcy abc b |
| 797 |
expectIndices 21.26 - a(b)+c xabbbcy {1 5} {4 4} |
| 798 |
expectMatch 21.27 - a(b+)c xabbbcy abbbc bbb |
| 799 |
expectIndices 21.28 Q "a(b){2,3}c" xabbbcy {1 5} {4 4} |
| 800 |
expectIndices 21.29 Q "a(b){2,3}c" xabbcy {1 4} {3 3} |
| 801 |
expectNomatch 21.30 Q "a(b){2,3}c" xabcy |
| 802 |
expectMatch 21.31 LP "\\y(\\w+)\\y" "-- abc-" "abc" "abc" |
| 803 |
expectMatch 21.32 - a((b|c)d+)+ abacdbd acdbd bd b |
| 804 |
expectMatch 21.33 N (.*).* abc abc abc |
| 805 |
expectMatch 21.34 N (a*)* bc "" "" |
| 806 |
expectMatch 21.35 M { TO (([a-z0-9._]+|"([^"]+|"")+")+)} {asd TO foo} { TO foo} foo o {} |
| 807 |
|
| 808 |
|
| 809 |
doing 22 "multicharacter collating elements" |
| 810 |
# again ugh |
| 811 |
expectMatch 22.1 &+L {a[c]e} ace ace |
| 812 |
expectNomatch 22.2 &+IL {a[c]h} ach |
| 813 |
expectMatch 22.3 &+L {a[[.ch.]]} ach ach |
| 814 |
expectNomatch 22.4 &+L {a[[.ch.]]} ace |
| 815 |
expectMatch 22.5 &+L {a[c[.ch.]]} ac ac |
| 816 |
expectMatch 22.6 &+L {a[c[.ch.]]} ace ac |
| 817 |
expectMatch 22.7 &+L {a[c[.ch.]]} ache ach |
| 818 |
expectNomatch 22.8 &+L {a[^c]e} ace |
| 819 |
expectMatch 22.9 &+L {a[^c]e} abe abe |
| 820 |
expectMatch 22.10 &+L {a[^c]e} ache ache |
| 821 |
expectNomatch 22.11 &+L {a[^[.ch.]]} ach |
| 822 |
expectMatch 22.12 &+L {a[^[.ch.]]} ace ac |
| 823 |
expectMatch 22.13 &+L {a[^[.ch.]]} ac ac |
| 824 |
expectMatch 22.14 &+L {a[^[.ch.]]} abe ab |
| 825 |
expectNomatch 22.15 &+L {a[^c[.ch.]]} ach |
| 826 |
expectNomatch 22.16 &+L {a[^c[.ch.]]} ace |
| 827 |
expectNomatch 22.17 &+L {a[^c[.ch.]]} ac |
| 828 |
expectMatch 22.18 &+L {a[^c[.ch.]]} abe ab |
| 829 |
expectMatch 22.19 &+L {a[^b]} ac ac |
| 830 |
expectMatch 22.20 &+L {a[^b]} ace ac |
| 831 |
expectMatch 22.21 &+L {a[^b]} ach ach |
| 832 |
expectNomatch 22.22 &+L {a[^b]} abe |
| 833 |
|
| 834 |
|
| 835 |
doing 23 "lookahead constraints" |
| 836 |
expectMatch 23.1 HP a(?=b)b* ab ab |
| 837 |
expectNomatch 23.2 HP a(?=b)b* a |
| 838 |
expectMatch 23.3 HP a(?=b)b*(?=c)c* abc abc |
| 839 |
expectNomatch 23.4 HP a(?=b)b*(?=c)c* ab |
| 840 |
expectNomatch 23.5 HP a(?!b)b* ab |
| 841 |
expectMatch 23.6 HP a(?!b)b* a a |
| 842 |
expectMatch 23.7 HP (?=b)b b b |
| 843 |
expectNomatch 23.8 HP (?=b)b a |
| 844 |
|
| 845 |
|
| 846 |
doing 24 "non-greedy quantifiers" |
| 847 |
expectMatch 24.1 PT ab+? abb ab |
| 848 |
expectMatch 24.2 PT ab+?c abbc abbc |
| 849 |
expectMatch 24.3 PT ab*? abb a |
| 850 |
expectMatch 24.4 PT ab*?c abbc abbc |
| 851 |
expectMatch 24.5 PT ab?? ab a |
| 852 |
expectMatch 24.6 PT ab??c abc abc |
| 853 |
expectMatch 24.7 PQT "ab{2,4}?" abbbb abb |
| 854 |
expectMatch 24.8 PQT "ab{2,4}?c" abbbbc abbbbc |
| 855 |
expectMatch 24.9 - 3z* 123zzzz456 3zzzz |
| 856 |
expectMatch 24.10 PT 3z*? 123zzzz456 3 |
| 857 |
expectMatch 24.11 - z*4 123zzzz456 zzzz4 |
| 858 |
expectMatch 24.12 PT z*?4 123zzzz456 zzzz4 |
| 859 |
expectMatch 24.13 PT {^([^/]+?)(?:/([^/]+?))(?:/([^/]+?))?$} {foo/bar/baz} {foo/bar/baz} {foo} {bar} {baz} |
| 860 |
|
| 861 |
|
| 862 |
doing 25 "mixed quantifiers" |
| 863 |
# this is very incomplete as yet |
| 864 |
# should include | |
| 865 |
expectMatch 25.1 PNT {^(.*?)(a*)$} "xyza" xyza xyz a |
| 866 |
expectMatch 25.2 PNT {^(.*?)(a*)$} "xyzaa" xyzaa xyz aa |
| 867 |
expectMatch 25.3 PNT {^(.*?)(a*)$} "xyz" xyz xyz "" |
| 868 |
|
| 869 |
|
| 870 |
doing 26 "tricky cases" |
| 871 |
# attempts to trick the matcher into accepting a short match |
| 872 |
expectMatch 26.1 - (week|wee)(night|knights) \ |
| 873 |
"weeknights" weeknights wee knights |
| 874 |
expectMatch 26.2 RP {a(bc*).*\1} abccbccb abccbccb b |
| 875 |
expectMatch 26.3 - {a(b.[bc]*)+} abcbd abcbd bd |
| 876 |
|
| 877 |
|
| 878 |
doing 27 "implementation misc." |
| 879 |
# duplicate arcs are suppressed |
| 880 |
expectMatch 27.1 P a(?:b|b)c abc abc |
| 881 |
# make color/subcolor relationship go back and forth |
| 882 |
expectMatch 27.2 & {[ab][ab][ab]} aba aba |
| 883 |
expectMatch 27.3 & {[ab][ab][ab][ab][ab][ab][ab]} \ |
| 884 |
"abababa" abababa |
| 885 |
|
| 886 |
|
| 887 |
doing 28 "boundary busters etc." |
| 888 |
# color-descriptor allocation changes at 10 |
| 889 |
expectMatch 28.1 & abcdefghijkl "abcdefghijkl" abcdefghijkl |
| 890 |
# so does arc allocation |
| 891 |
expectMatch 28.2 P a(?:b|c|d|e|f|g|h|i|j|k|l|m)n "agn" agn |
| 892 |
# subexpression tracking also at 10 |
| 893 |
expectMatch 28.3 - a(((((((((((((b)))))))))))))c \ |
| 894 |
"abc" abc b b b b b b b b b b b b b |
| 895 |
# state-set handling changes slightly at unsigned size (might be 64...) |
| 896 |
# (also stresses arc allocation) |
| 897 |
expectMatch 28.4 Q "ab{1,100}c" abbc abbc |
| 898 |
expectMatch 28.5 Q "ab{1,100}c" \ |
| 899 |
"abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc" \ |
| 900 |
abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc |
| 901 |
expectMatch 28.6 Q "ab{1,100}c" \ |
| 902 |
"abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc"\ |
| 903 |
abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc |
| 904 |
# force small cache and bust it, several ways |
| 905 |
expectMatch 28.7 LP {\w+abcdefgh} xyzabcdefgh xyzabcdefgh |
| 906 |
expectMatch 28.8 %LP {\w+abcdefgh} xyzabcdefgh xyzabcdefgh |
| 907 |
expectMatch 28.9 %LP {\w+abcdefghijklmnopqrst} \ |
| 908 |
"xyzabcdefghijklmnopqrst" xyzabcdefghijklmnopqrst |
| 909 |
expectIndices 28.10 %LP {\w+(abcdefgh)?} xyz {0 2} {-1 -1} |
| 910 |
expectIndices 28.11 %LP {\w+(abcdefgh)?} xyzabcdefg {0 9} {-1 -1} |
| 911 |
expectIndices 28.12 %LP {\w+(abcdefghijklmnopqrst)?} \ |
| 912 |
"xyzabcdefghijklmnopqrs" {0 21} {-1 -1} |
| 913 |
|
| 914 |
|
| 915 |
doing 29 "incomplete matches" |
| 916 |
expectPartial 29.1 t def abc {3 2} "" |
| 917 |
expectPartial 29.2 t bcd abc {1 2} "" |
| 918 |
expectPartial 29.3 t abc abab {0 3} "" |
| 919 |
expectPartial 29.4 t abc abdab {3 4} "" |
| 920 |
expectIndices 29.5 t abc abc {0 2} {0 2} |
| 921 |
expectIndices 29.6 t abc xyabc {2 4} {2 4} |
| 922 |
expectPartial 29.7 t abc+ xyab {2 3} "" |
| 923 |
expectIndices 29.8 t abc+ xyabc {2 4} {2 4} |
| 924 |
knownBug expectIndices 29.9 t abc+ xyabcd {2 4} {6 5} |
| 925 |
expectIndices 29.10 t abc+ xyabcdd {2 4} {7 6} |
| 926 |
expectPartial 29.11 tPT abc+? xyab {2 3} "" |
| 927 |
# the retain numbers in these two may look wrong, but they aren't |
| 928 |
expectIndices 29.12 tPT abc+? xyabc {2 4} {5 4} |
| 929 |
expectIndices 29.13 tPT abc+? xyabcc {2 4} {6 5} |
| 930 |
expectIndices 29.14 tPT abc+? xyabcd {2 4} {6 5} |
| 931 |
expectIndices 29.15 tPT abc+? xyabcdd {2 4} {7 6} |
| 932 |
expectIndices 29.16 t abcd|bc xyabc {3 4} {2 4} |
| 933 |
expectPartial 29.17 tn .*k "xx\nyyy" {3 5} "" |
| 934 |
|
| 935 |
|
| 936 |
doing 30 "misc. oddities and old bugs" |
| 937 |
expectError 30.1 & *** BADRPT |
| 938 |
expectMatch 30.2 N a?b* abb abb |
| 939 |
expectMatch 30.3 N a?b* bb bb |
| 940 |
expectMatch 30.4 & a*b aab aab |
| 941 |
expectMatch 30.5 & ^a*b aaaab aaaab |
| 942 |
expectMatch 30.6 &M {[0-6][1-2][0-3][0-6][1-6][0-6]} \ |
| 943 |
"010010" 010010 |
| 944 |
# temporary REG_BOSONLY kludge |
| 945 |
expectMatch 30.7 s abc abcd abc |
| 946 |
expectNomatch 30.8 s abc xabcd |
| 947 |
# back to normal stuff |
| 948 |
expectMatch 30.9 HLP {(?n)^(?![t#])\S+} \ |
| 949 |
"tk\n\n#\n#\nit0" it0 |
| 950 |
|
| 951 |
|
| 952 |
# Now for tests *not* written by Henry Spencer |
| 953 |
|
| 954 |
namespace import -force ::tcltest::test |
| 955 |
|
| 956 |
# Tests resulting from bugs reported by users |
| 957 |
test reg-31.1 {[[:xdigit:]] behaves correctly when followed by [[:space:]]} { |
| 958 |
set str {2:::DebugWin32} |
| 959 |
set re {([[:xdigit:]])([[:space:]]*)} |
| 960 |
list [regexp $re $str match xdigit spaces] $match $xdigit $spaces |
| 961 |
# Code used to produce {1 2:::DebugWin32 2 :::DebugWin32} !!! |
| 962 |
} {1 2 2 {}} |
| 963 |
|
| 964 |
test reg-32.1 {canmatch functionality -- at end} testregexp { |
| 965 |
set pat {blah} |
| 966 |
set line "asd asd" |
| 967 |
# can match at the final d, if '%' follows |
| 968 |
set res [testregexp -xflags -- c $pat $line resvar] |
| 969 |
lappend res $resvar |
| 970 |
} {0 7} |
| 971 |
test reg-32.2 {canmatch functionality -- at end} testregexp { |
| 972 |
set pat {s%$} |
| 973 |
set line "asd asd" |
| 974 |
# can only match after the end of the string |
| 975 |
set res [testregexp -xflags -- c $pat $line resvar] |
| 976 |
lappend res $resvar |
| 977 |
} {0 7} |
| 978 |
test reg-32.3 {canmatch functionality -- not last char} testregexp { |
| 979 |
set pat {[^d]%$} |
| 980 |
set line "asd asd" |
| 981 |
# can only match after the end of the string |
| 982 |
set res [testregexp -xflags -- c $pat $line resvar] |
| 983 |
lappend res $resvar |
| 984 |
} {0 7} |
| 985 |
test reg-32.3.1 {canmatch functionality -- no match} testregexp { |
| 986 |
set pat {\Zx} |
| 987 |
set line "asd asd" |
| 988 |
# can match the last char, if followed by x |
| 989 |
set res [testregexp -xflags -- c $pat $line resvar] |
| 990 |
lappend res $resvar |
| 991 |
} {0 -1} |
| 992 |
test reg-32.4 {canmatch functionality -- last char} {knownBug testregexp} { |
| 993 |
set pat {.x} |
| 994 |
set line "asd asd" |
| 995 |
# can match the last char, if followed by x |
| 996 |
set res [testregexp -xflags -- c $pat $line resvar] |
| 997 |
lappend res $resvar |
| 998 |
} {0 6} |
| 999 |
test reg-32.4.1 {canmatch functionality -- last char} {knownBug testregexp} { |
| 1000 |
set pat {.x$} |
| 1001 |
set line "asd asd" |
| 1002 |
# can match the last char, if followed by x |
| 1003 |
set res [testregexp -xflags -- c $pat $line resvar] |
| 1004 |
lappend res $resvar |
| 1005 |
} {0 6} |
| 1006 |
test reg-32.5 {canmatch functionality -- last char} {knownBug testregexp} { |
| 1007 |
set pat {.[^d]x$} |
| 1008 |
set line "asd asd" |
| 1009 |
# can match the last char, if followed by not-d and x. |
| 1010 |
set res [testregexp -xflags -- c $pat $line resvar] |
| 1011 |
lappend res $resvar |
| 1012 |
} {0 6} |
| 1013 |
test reg-32.6 {canmatch functionality -- last char} {knownBug testregexp} { |
| 1014 |
set pat {[^a]%[^\r\n]*$} |
| 1015 |
set line "asd asd" |
| 1016 |
# can match at the final d, if '%' follows |
| 1017 |
set res [testregexp -xflags -- c $pat $line resvar] |
| 1018 |
lappend res $resvar |
| 1019 |
} {0 6} |
| 1020 |
test reg-32.7 {canmatch functionality -- last char} {knownBug testregexp} { |
| 1021 |
set pat {[^a]%$} |
| 1022 |
set line "asd asd" |
| 1023 |
# can match at the final d, if '%' follows |
| 1024 |
set res [testregexp -xflags -- c $pat $line resvar] |
| 1025 |
lappend res $resvar |
| 1026 |
} {0 6} |
| 1027 |
test reg-32.8 {canmatch functionality -- last char} {knownBug testregexp} { |
| 1028 |
set pat {[^x]%$} |
| 1029 |
set line "asd asd" |
| 1030 |
# can match at the final d, if '%' follows |
| 1031 |
set res [testregexp -xflags -- c $pat $line resvar] |
| 1032 |
lappend res $resvar |
| 1033 |
} {0 6} |
| 1034 |
test reg-32.9 {canmatch functionality -- more complex case} {knownBug testregexp} { |
| 1035 |
set pat {((\B\B|\Bh+line)[ \t]*|[^\B]%[^\r\n]*)$} |
| 1036 |
set line "asd asd" |
| 1037 |
# can match at the final d, if '%' follows |
| 1038 |
set res [testregexp -xflags -- c $pat $line resvar] |
| 1039 |
lappend res $resvar |
| 1040 |
} {0 6} |
| 1041 |
|
| 1042 |
# Tests reg-33.*: Checks for bug fixes |
| 1043 |
|
| 1044 |
test reg-33.1 {Bug 230589} { |
| 1045 |
regexp {[ ]*(^|[^%])%V} "*%V2" m s |
| 1046 |
} 1 |
| 1047 |
test reg-33.2 {Bug 504785} { |
| 1048 |
regexp -inline {([^_.]*)([^.]*)\.(..)(.).*} bbcos_001_c01.q1la |
| 1049 |
} {bbcos_001_c01.q1la bbcos _001_c01 q1 l} |
| 1050 |
test reg-33.3 {Bug 505048} { |
| 1051 |
regexp {\A\s*[^<]*\s*<([^>]+)>} a<a> |
| 1052 |
} 1 |
| 1053 |
test reg-33.4 {Bug 505048} { |
| 1054 |
regexp {\A\s*([^b]*)b} ab |
| 1055 |
} 1 |
| 1056 |
test reg-33.5 {Bug 505048} { |
| 1057 |
regexp {\A\s*[^b]*(b)} ab |
| 1058 |
} 1 |
| 1059 |
test reg-33.6 {Bug 505048} { |
| 1060 |
regexp {\A(\s*)[^b]*(b)} ab |
| 1061 |
} 1 |
| 1062 |
test reg-33.7 {Bug 505048} { |
| 1063 |
regexp {\A\s*[^b]*b} ab |
| 1064 |
} 1 |
| 1065 |
test reg-33.8 {Bug 505048} { |
| 1066 |
regexp -inline {\A\s*[^b]*b} ab |
| 1067 |
} ab |
| 1068 |
test reg-33.9 {Bug 505048} { |
| 1069 |
regexp -indices -inline {\A\s*[^b]*b} ab |
| 1070 |
} {{0 1}} |
| 1071 |
test reg-33.10 {Bug 840258} -body { |
| 1072 |
regsub {(^|\n)+\.*b} \n.b {} tmp |
| 1073 |
} -cleanup { |
| 1074 |
unset tmp |
| 1075 |
} -result 1 |
| 1076 |
test reg-33.11 {Bug 840258} -body { |
| 1077 |
regsub {(^|[\n\r]+)\.*\?<.*?(\n|\r)+} \ |
| 1078 |
"TQ\r\n.?<5000267>Test already stopped\r\n" {} tmp |
| 1079 |
} -cleanup { |
| 1080 |
unset tmp |
| 1081 |
} -result 1 |
| 1082 |
test reg-33.12 {Bug 1810264 - bad read} { |
| 1083 |
regexp {\3161573148} {\3161573148} |
| 1084 |
} 0 |
| 1085 |
test reg-33.13 {Bug 1810264 - infinite loop} { |
| 1086 |
regexp {($|^)*} {x} |
| 1087 |
} 1 |
| 1088 |
# Some environments have small default stack sizes. [Bug 1905562] |
| 1089 |
test reg-33.14 {Bug 1810264 - super-expensive expression} nonPortable { |
| 1090 |
regexp {(x{200}){200}$y} {x} |
| 1091 |
} 0 |
| 1092 |
|
| 1093 |
test reg-33.15.1 {Bug 3603557 - an "in the wild" RE} { |
| 1094 |
lindex [regexp -expanded -about { |
| 1095 |
^TETRA_MODE_CMD # Message Type |
| 1096 |
([[:blank:]]+) # Pad |
| 1097 |
(ETS_1_1|ETS_1_2|ETS_2_2) # SystemCode |
| 1098 |
([[:blank:]]+) # Pad |
| 1099 |
(CONTINUOUS|CARRIER|MCCH|TRAFFIC) # SharingMode |
| 1100 |
([[:blank:]]+) # Pad |
| 1101 |
([[:digit:]]{1,2}) # ColourCode |
| 1102 |
([[:blank:]]+) # Pad |
| 1103 |
(1|2|3|4|6|9|12|18) # TSReservedFrames |
| 1104 |
([[:blank:]]+) # Pad |
| 1105 |
(PASS|TRUE|FAIL|FALSE) # UPlaneDTX |
| 1106 |
([[:blank:]]+) # Pad |
| 1107 |
(PASS|TRUE|FAIL|FALSE) # Frame18Extension |
| 1108 |
([[:blank:]]+) # Pad |
| 1109 |
([[:digit:]]{1,4}) # MCC |
| 1110 |
([[:blank:]]+) # Pad |
| 1111 |
([[:digit:]]{1,5}) # MNC |
| 1112 |
([[:blank:]]+) # Pad |
| 1113 |
(BOTH|BCAST|ENQRY|NONE) # NbrCellBcast |
| 1114 |
([[:blank:]]+) # Pad |
| 1115 |
(UNKNOWN|LOW|MEDIUM|HIGH) # CellServiceLevel |
| 1116 |
([[:blank:]]+) # Pad |
| 1117 |
(PASS|TRUE|FAIL|FALSE) # LateEntryInfo |
| 1118 |
([[:blank:]]+) # Pad |
| 1119 |
(300|400) # FrequencyBand |
| 1120 |
([[:blank:]]+) # Pad |
| 1121 |
(NORMAL|REVERSE) # ReverseOperation |
| 1122 |
([[:blank:]]+) # Pad |
| 1123 |
(NONE|\+6\.25|\-6\.25|\+12\.5) # Offset |
| 1124 |
([[:blank:]]+) # Pad |
| 1125 |
(10) # DuplexSpacing |
| 1126 |
([[:blank:]]+) # Pad |
| 1127 |
([[:digit:]]{1,4}) # MainCarrierNr |
| 1128 |
([[:blank:]]+) # Pad |
| 1129 |
(0|1|2|3) # NrCSCCH |
| 1130 |
([[:blank:]]+) # Pad |
| 1131 |
(15|20|25|30|35|40|45) # MSTxPwrMax |
| 1132 |
([[:blank:]]+) # Pad |
| 1133 |
(\-125|\-120|\-115|\-110|\-105|\-100|\-95|\-90|\-85|\-80|\-75|\-70|\-65|\-60|\-55|\-50) |
| 1134 |
# RxLevAccessMin |
| 1135 |
([[:blank:]]+) # Pad |
| 1136 |
(\-53|\-51|\-49|\-47|\-45|\-43|\-41|\-39|\-37|\-35|\-33|\-31|\-29|\-27|\-25|\-23) |
| 1137 |
# AccessParameter |
| 1138 |
([[:blank:]]+) # Pad |
| 1139 |
(DISABLE|[[:digit:]]{3,4}) # RadioDLTimeout |
| 1140 |
([[:blank:]]+) # Pad |
| 1141 |
(\-[[:digit:]]{2,3}) # RSSIThreshold |
| 1142 |
([[:blank:]]+) # Pad |
| 1143 |
([[:digit:]]{1,5}) # CCKIdSCKVerNr |
| 1144 |
([[:blank:]]+) # Pad |
| 1145 |
([[:digit:]]{1,5}) # LocationArea |
| 1146 |
([[:blank:]]+) # Pad |
| 1147 |
([(1|0)]{16}) # SubscriberClass |
| 1148 |
([[:blank:]]+) # Pad |
| 1149 |
([(1|0)]{12}) # BSServiceDetails |
| 1150 |
([[:blank:]]+) # Pad |
| 1151 |
(RANDOMIZE|IMMEDIATE|[[:digit:]]{1,2}) # IMM |
| 1152 |
([[:blank:]]+) # Pad |
| 1153 |
([[:digit:]]{1,2}) # WT |
| 1154 |
([[:blank:]]+) # Pad |
| 1155 |
([[:digit:]]{1,2}) # Nu |
| 1156 |
([[:blank:]]+) # Pad |
| 1157 |
([0-1]) # FrameLngFctr |
| 1158 |
([[:blank:]]+) # Pad |
| 1159 |
([[:digit:]]{1,2}) # TSPtr |
| 1160 |
([[:blank:]]+) # Pad |
| 1161 |
([0-7]) # MinPriority |
| 1162 |
([[:blank:]]+) # Pad |
| 1163 |
(PASS|TRUE|FAIL|FALSE) # ExtdSrvcsEnabled |
| 1164 |
([[:blank:]]+) # Pad |
| 1165 |
(.*) # ConditionalFields |
| 1166 |
}] 0 |
| 1167 |
} 68 |
| 1168 |
test reg-33.16.1 {Bug [8d2c0da36d]- another "in the wild" RE} { |
| 1169 |
lindex [regexp -about "^MRK:client1: =1339 14HKelly Talisman 10011000 (\[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]*) \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 8 0 8 0 0 0 77 77 1 1 2 0 11 { 1 3 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 1 13HC6 My Creator 2 3 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 1 31HC7 Slightly offensive name, huh 3 8 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 1 23HE-mail:[email protected] 4 9 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 1 17Hcompface must die 5 10 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 0 3HAir 6 12 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 1 14HPGP public key 7 13 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 1 [email protected] 8 30 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 0 12H2 text/plain 9 30 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 0 13H2 x-kom/basic 10 33 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 1 1H0 11 14 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 1 1H3 }\r?"] 0 |
| 1170 |
} 1 |
| 1171 |
|
| 1172 |
test reg-33.15 {constraint fixes} { |
| 1173 |
regexp {(^)+^} x |
| 1174 |
} 1 |
| 1175 |
test reg-33.16 {constraint fixes} { |
| 1176 |
regexp {($^)+} x |
| 1177 |
} 0 |
| 1178 |
test reg-33.17 {constraint fixes} { |
| 1179 |
regexp {(^$)*} x |
| 1180 |
} 1 |
| 1181 |
test reg-33.18 {constraint fixes} { |
| 1182 |
regexp {(^(?!aa))+} {aa bb cc} |
| 1183 |
} 0 |
| 1184 |
test reg-33.19 {constraint fixes} { |
| 1185 |
regexp {(^(?!aa)(?!bb)(?!cc))+} {aa x} |
| 1186 |
} 0 |
| 1187 |
test reg-33.20 {constraint fixes} { |
| 1188 |
regexp {(^(?!aa)(?!bb)(?!cc))+} {bb x} |
| 1189 |
} 0 |
| 1190 |
test reg-33.21 {constraint fixes} { |
| 1191 |
regexp {(^(?!aa)(?!bb)(?!cc))+} {cc x} |
| 1192 |
} 0 |
| 1193 |
test reg-33.22 {constraint fixes} { |
| 1194 |
regexp {(^(?!aa)(?!bb)(?!cc))+} {dd x} |
| 1195 |
} 1 |
| 1196 |
|
| 1197 |
test reg-33.23 {} { |
| 1198 |
regexp {abcd(\m)+xyz} x |
| 1199 |
} 0 |
| 1200 |
test reg-33.24 {} { |
| 1201 |
regexp {abcd(\m)+xyz} a |
| 1202 |
} 0 |
| 1203 |
test reg-33.25 {} { |
| 1204 |
regexp {^abcd*(((((^(a c(e?d)a+|)+|)+|)+|)+|a)+|)} x |
| 1205 |
} 0 |
| 1206 |
test reg-33.26 {} { |
| 1207 |
regexp {a^(^)bcd*xy(((((($a+|)+|)+|)+$|)+|)+|)^$} x |
| 1208 |
} 0 |
| 1209 |
test reg-33.27 {} { |
| 1210 |
regexp {xyz(\Y\Y)+} x |
| 1211 |
} 0 |
| 1212 |
test reg-33.28 {} { |
| 1213 |
regexp {x|(?:\M)+} x |
| 1214 |
} 1 |
| 1215 |
test reg-33.29 {} { |
| 1216 |
# This is near the limits of the RE engine |
| 1217 |
regexp [string repeat x*y*z* 480] x |
| 1218 |
} 1 |
| 1219 |
|
| 1220 |
test reg-33.30 {Bug 1080042} { |
| 1221 |
regexp {(\Y)+} foo |
| 1222 |
} 1 |
| 1223 |
test reg-33.31 {Bug 7c64aa5e1a} { |
| 1224 |
regexp -inline {(?b).\{1,10\}} {abcdef} |
| 1225 |
} abcdef |
| 1226 |
|
| 1227 |
|
| 1228 |
# cleanup |
| 1229 |
::tcltest::cleanupTests |
| 1230 |
return |
| 1231 |
|
| 1232 |
# Local Variables: |
| 1233 |
# mode: tcl |
| 1234 |
# End: |