os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/reg.test
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/reg.test	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1135 @@
     1.4 +# reg.test --
     1.5 +#
     1.6 +# This file contains a collection of tests for one or more of the Tcl
     1.7 +# built-in commands.  Sourcing this file into Tcl runs the tests and
     1.8 +# generates output for errors.  No output means no errors were found.
     1.9 +# (Don't panic if you are seeing this as part of the reg distribution
    1.10 +# and aren't using Tcl -- reg's own regression tester also knows how
    1.11 +# to read this file, ignoring the Tcl-isms.)
    1.12 +#
    1.13 +# Copyright (c) 1998, 1999 Henry Spencer.  All rights reserved.
    1.14 +#
    1.15 +# RCS: @(#) $Id: reg.test,v 1.16.2.3 2004/11/27 05:44:13 dgp Exp $
    1.16 +
    1.17 +if {[lsearch [namespace children] ::tcltest] == -1} {
    1.18 +    package require tcltest 2
    1.19 +    namespace import -force ::tcltest::*
    1.20 +}
    1.21 +
    1.22 +# All tests require the testregexp command, return if this
    1.23 +# command doesn't exist
    1.24 +
    1.25 +::tcltest::testConstraint testregexp \
    1.26 +	[expr {[info commands testregexp] != {}}]
    1.27 +::tcltest::testConstraint localeRegexp 0
    1.28 +
    1.29 +# This file uses some custom procedures, defined below, for regexp regression
    1.30 +# testing.  The name of the procedure indicates the general nature of the
    1.31 +# test:
    1.32 +#	e	compile error expected
    1.33 +#	f	match failure expected
    1.34 +#	m	successful match
    1.35 +#	i	successful match with -indices (used in checking things like
    1.36 +#		nonparticipating subexpressions)
    1.37 +#	p	unsuccessful match with -indices (!!) (used in checking
    1.38 +#		partial-match reporting)
    1.39 +# There is also "doing" which sets up title and major test number for each
    1.40 +# block of tests.
    1.41 +
    1.42 +# The first 3 arguments are constant:  a minor number (which often gets
    1.43 +# a letter or two suffixed to it internally), some flags, and the RE itself.
    1.44 +# For e, the remaining argument is the name of the compile error expected,
    1.45 +# less the leading "REG_".  For the rest, the next argument is the string
    1.46 +# to try the match against.  Remaining arguments are the substring expected
    1.47 +# to be matched, and any substrings expected to be matched by subexpressions.
    1.48 +# (For f, these arguments are optional, and if present are ignored except
    1.49 +# that they indicate how many subexpressions should be present in the RE.)
    1.50 +# It is an error for the number of subexpression arguments to be wrong.
    1.51 +# Cases involving nonparticipating subexpressions, checking where empty
    1.52 +# substrings are located, etc. should be done using i and p.
    1.53 +
    1.54 +# The flag characters are complex and a bit eclectic.  Generally speaking, 
    1.55 +# lowercase letters are compile options, uppercase are expected re_info
    1.56 +# bits, and nonalphabetics are match options, controls for how the test is 
    1.57 +# run, or testing options.  The one small surprise is that AREs are the
    1.58 +# default, and you must explicitly request lesser flavors of RE.  The flags
    1.59 +# are as follows.  It is admitted that some are not very mnemonic.
    1.60 +# There are some others which are purely debugging tools and are not
    1.61 +# useful in this file.
    1.62 +#
    1.63 +#	-	no-op (placeholder)
    1.64 +#	+	provide fake xy equivalence class and ch collating element
    1.65 +#	%	force small state-set cache in matcher (to test cache replace)
    1.66 +#	^	beginning of string is not beginning of line
    1.67 +#	$	end of string is not end of line
    1.68 +#	*	test is Unicode-specific, needs big character set
    1.69 +#
    1.70 +#	&	test as both ARE and BRE
    1.71 +#	b	BRE
    1.72 +#	e	ERE
    1.73 +#	a	turn advanced-features bit on (error unless ERE already)
    1.74 +#	q	literal string, no metacharacters at all
    1.75 +#
    1.76 +#	i	case-independent matching
    1.77 +#	o	("opaque") no subexpression capture
    1.78 +#	p	newlines are half-magic, excluded from . and [^ only
    1.79 +#	w	newlines are half-magic, significant to ^ and $ only
    1.80 +#	n	newlines are fully magic, both effects
    1.81 +#	x	expanded RE syntax
    1.82 +#	t	incomplete-match reporting
    1.83 +#
    1.84 +#	A	backslash-_a_lphanumeric seen
    1.85 +#	B	ERE/ARE literal-_b_race heuristic used
    1.86 +#	E	backslash (_e_scape) seen within []
    1.87 +#	H	looka_h_ead constraint seen
    1.88 +#	I	_i_mpossible to match
    1.89 +#	L	_l_ocale-specific construct seen
    1.90 +#	M	unportable (_m_achine-specific) construct seen
    1.91 +#	N	RE can match empty (_n_ull) string
    1.92 +#	P	non-_P_OSIX construct seen
    1.93 +#	Q	{} _q_uantifier seen
    1.94 +#	R	back _r_eference seen
    1.95 +#	S	POSIX-un_s_pecified syntax seen
    1.96 +#	T	prefers shortest (_t_iny)
    1.97 +#	U	saw original-POSIX botch:  unmatched right paren in ERE (_u_gh)
    1.98 +
    1.99 +# The one area we can't easily test is memory-allocation failures (which
   1.100 +# are hard to provoke on command).  Embedded NULs also are not tested at
   1.101 +# the moment, but this is a historical accident which should be fixed.
   1.102 +
   1.103 +
   1.104 +
   1.105 +# test procedures and related
   1.106 +
   1.107 +set ask "about"
   1.108 +set xflags "xflags"
   1.109 +set testbypassed 0
   1.110 +
   1.111 +# re_info abbreviation mapping table
   1.112 +set infonames(A) "REG_UBSALNUM"
   1.113 +set infonames(B) "REG_UBRACES"
   1.114 +set infonames(E) "REG_UBBS"
   1.115 +set infonames(H) "REG_ULOOKAHEAD"
   1.116 +set infonames(I) "REG_UIMPOSSIBLE"
   1.117 +set infonames(L) "REG_ULOCALE"
   1.118 +set infonames(M) "REG_UUNPORT"
   1.119 +set infonames(N) "REG_UEMPTYMATCH"
   1.120 +set infonames(P) "REG_UNONPOSIX"
   1.121 +set infonames(Q) "REG_UBOUNDS"
   1.122 +set infonames(R) "REG_UBACKREF"
   1.123 +set infonames(S) "REG_UUNSPEC"
   1.124 +set infonames(T) "REG_USHORTEST"
   1.125 +set infonames(U) "REG_UPBOTCH"
   1.126 +set infonameorder "RHQBAUEPSMLNIT"	;# must match bit order, lsb first
   1.127 +
   1.128 +# set major test number and description
   1.129 +proc doing {major desc} {
   1.130 +	global prefix description testbypassed
   1.131 +
   1.132 +	if {$testbypassed != 0} {
   1.133 +		puts stdout "!!! bypassed $testbypassed tests in\
   1.134 +					 $prefix, `$description'"
   1.135 +	}
   1.136 +
   1.137 +	set prefix reg-$major
   1.138 +	set description "reg $desc"
   1.139 +	set testbypassed 0
   1.140 +}
   1.141 +
   1.142 +# build test number (internal)
   1.143 +proc tno {testid} {
   1.144 +	return [join $testid .]
   1.145 +}
   1.146 +
   1.147 +# build description, with possible modifiers (internal)
   1.148 +proc desc {testid} {
   1.149 +	global description
   1.150 +
   1.151 +	set d $description
   1.152 +	if {[llength $testid] > 1} {
   1.153 +		set d "([lreplace $testid 0 0]) $d"
   1.154 +	}
   1.155 +	return $d
   1.156 +}
   1.157 +
   1.158 +# build trailing options and flags argument from a flags string (internal)
   1.159 +proc flags {fl} {
   1.160 +	global xflags
   1.161 +
   1.162 +	set args [list]
   1.163 +	set flags ""
   1.164 +	foreach f [split $fl ""] {
   1.165 +		switch -exact -- $f {
   1.166 +		"i" { lappend args "-nocase" }
   1.167 +		"x" { lappend args "-expanded" }
   1.168 +		"n" { lappend args "-line" }
   1.169 +		"p" { lappend args "-linestop" }
   1.170 +		"w" { lappend args "-lineanchor" }
   1.171 +		"-" { }
   1.172 +		default { append flags $f }
   1.173 +		}
   1.174 +	}
   1.175 +	if {[string compare $flags ""] != 0} {
   1.176 +		lappend args -$xflags $flags
   1.177 +	}
   1.178 +	return $args
   1.179 +}
   1.180 +
   1.181 +# build info-flags list from a flags string (internal)
   1.182 +proc infoflags {fl} {
   1.183 +	global infonames infonameorder
   1.184 +
   1.185 +	set ret [list]
   1.186 +	foreach f [split $infonameorder ""] {
   1.187 +		if {[string first $f $fl] >= 0} {
   1.188 +			lappend ret $infonames($f)
   1.189 +		}
   1.190 +	}
   1.191 +	return $ret
   1.192 +}
   1.193 +
   1.194 +# compilation error expected
   1.195 +proc e {testid flags re err} {
   1.196 +	global prefix ask errorCode
   1.197 +
   1.198 +	# Tcl locale stuff doesn't do the ch/xy test fakery yet
   1.199 +	if {[string first "+" $flags] >= 0} {
   1.200 +	    # This will register as a skipped test
   1.201 +	    test $prefix.[tno $testid] [desc $testid] localeRegexp {} {}
   1.202 +	    return
   1.203 +	}
   1.204 +
   1.205 +	# if &, test as both ARE and BRE
   1.206 +	set amp [string first "&" $flags]
   1.207 +	if {$amp >= 0} {
   1.208 +		set f [string range $flags 0 [expr $amp - 1]]
   1.209 +		append f [string range $flags [expr $amp + 1] end]
   1.210 +		e [linsert $testid end ARE] ${f} $re $err
   1.211 +		e [linsert $testid end BRE] ${f}b $re $err
   1.212 +		return
   1.213 +	}
   1.214 +
   1.215 +	set cmd [concat [list testregexp -$ask] [flags $flags] [list $re]]
   1.216 +	set run "list \[catch \{$cmd\}\] \[lindex \$errorCode 1\]"
   1.217 +	test $prefix.[tno $testid] [desc $testid] \
   1.218 +		{testregexp} $run [list 1 REG_$err]
   1.219 +}
   1.220 +
   1.221 +# match failure expected
   1.222 +proc f {testid flags re target args} {
   1.223 +	global prefix description ask
   1.224 +
   1.225 +	# Tcl locale stuff doesn't do the ch/xy test fakery yet
   1.226 +	if {[string first "+" $flags] >= 0} {
   1.227 +	    # This will register as a skipped test
   1.228 +	    test $prefix.[tno $testid] [desc $testid] localeRegexp {} {}
   1.229 +	    return
   1.230 +	}
   1.231 +
   1.232 +	# if &, test as both ARE and BRE
   1.233 +	set amp [string first "&" $flags]
   1.234 +	if {$amp >= 0} {
   1.235 +		set f [string range $flags 0 [expr $amp - 1]]
   1.236 +		append f [string range $flags [expr $amp + 1] end]
   1.237 +		eval [linsert $args 0 f [linsert $testid end ARE] ${f} $re \
   1.238 +								$target]
   1.239 +		eval [linsert $args 0 f [linsert $testid end BRE] ${f}b $re \
   1.240 +								$target]
   1.241 +		return
   1.242 +	}
   1.243 +
   1.244 +	set f [flags $flags]
   1.245 +	set infoflags [infoflags $flags]
   1.246 +	set ccmd [concat [list testregexp -$ask] $f [list $re]]
   1.247 +	set nsub [expr [llength $args] - 1]
   1.248 +	if {$nsub == -1} {
   1.249 +		# didn't tell us number of subexps
   1.250 +		set ccmd "lreplace \[$ccmd\] 0 0"
   1.251 +		set info [list $infoflags]
   1.252 +	} else {
   1.253 +		set info [list $nsub $infoflags]
   1.254 +	}
   1.255 +	lappend testid "compile"
   1.256 +	test $prefix.[tno $testid] [desc $testid] {testregexp} $ccmd $info
   1.257 +
   1.258 +	set testid [lreplace $testid end end "execute"]
   1.259 +	set ecmd [concat [list testregexp] $f [list $re $target]]
   1.260 +	test $prefix.[tno $testid] [desc $testid] {testregexp} $ecmd 0
   1.261 +}
   1.262 +
   1.263 +# match expected, internal routine that does the work
   1.264 +# parameters like the "real" routines except they don't have "opts",
   1.265 +#  which is a possibly-empty list of switches for the regexp match attempt
   1.266 +# The ! flag is used to indicate expected match failure (for REG_EXPECT,
   1.267 +#  which wants argument testing even in the event of failure).
   1.268 +proc matchexpected {opts testid flags re target args} {
   1.269 +	global prefix description ask regBug
   1.270 +
   1.271 +    if {[info exists regBug] && $regBug} {
   1.272 +	# This will register as a skipped test
   1.273 +	test $prefix.[tno $testid] [desc $testid] knownBug {format 0} {1}
   1.274 +	return
   1.275 +    }
   1.276 +
   1.277 +	# Tcl locale stuff doesn't do the ch/xy test fakery yet
   1.278 +	if {[string first "+" $flags] >= 0} {
   1.279 +	    # This will register as a skipped test
   1.280 +	    test $prefix.[tno $testid] [desc $testid] localeRegexp {} {}
   1.281 +	    return
   1.282 +	}
   1.283 +
   1.284 +	# if &, test as both BRE and ARE
   1.285 +	set amp [string first "&" $flags]
   1.286 +	if {$amp >= 0} {
   1.287 +		set f [string range $flags 0 [expr $amp - 1]]
   1.288 +		append f [string range $flags [expr $amp + 1] end]
   1.289 +		eval [concat [list matchexpected $opts \
   1.290 +			[linsert $testid end ARE] ${f} $re $target] $args]
   1.291 +		eval [concat [list matchexpected $opts \
   1.292 +			[linsert $testid end BRE] ${f}b $re $target] $args]
   1.293 +		return
   1.294 +	}
   1.295 +
   1.296 +	set f [flags $flags]
   1.297 +	set infoflags [infoflags $flags]
   1.298 +	set ccmd [concat [list testregexp -$ask] $f [list $re]]
   1.299 +	set ecmd [concat [list testregexp] $opts $f [list $re $target]]
   1.300 +
   1.301 +	set nsub [expr [llength $args] - 1]
   1.302 +	set names [list]
   1.303 +	set refs ""
   1.304 +	for {set i 0} {$i <= $nsub} {incr i} {
   1.305 +		if {$i == 0} {
   1.306 +			set name match
   1.307 +		} else {
   1.308 +			set name sub$i
   1.309 +		}
   1.310 +		lappend names $name
   1.311 +		append refs " \$$name"
   1.312 +		set $name ""
   1.313 +	}
   1.314 +	if {[string first "o" $flags] >= 0} {	;# REG_NOSUB kludge
   1.315 +		set nsub 0		;# unsigned value cannot be -1
   1.316 +	}
   1.317 +	if {[string first "t" $flags] >= 0} {	;# REG_EXPECT
   1.318 +		incr nsub -1		;# the extra does not count
   1.319 +	}
   1.320 +	set ecmd [concat $ecmd $names]
   1.321 +	set erun "list \[$ecmd\] $refs"
   1.322 +	set retcode [list 1]
   1.323 +	if {[string first "!" $flags] >= 0} {
   1.324 +		set retcode [list 0]
   1.325 +	}
   1.326 +	set result [concat $retcode $args]
   1.327 +
   1.328 +	set info [list $nsub $infoflags]
   1.329 +	lappend testid "compile"
   1.330 +	test $prefix.[tno $testid] [desc $testid] {testregexp} $ccmd $info
   1.331 +	set testid [lreplace $testid end end "execute"]
   1.332 +	test $prefix.[tno $testid] [desc $testid] {testregexp} $erun $result
   1.333 +}
   1.334 +
   1.335 +# match expected (no missing, empty, or ambiguous submatches)
   1.336 +# m testno flags re target mat submat ...
   1.337 +proc m {args} {
   1.338 +	eval matchexpected [linsert $args 0 [list]]
   1.339 +}
   1.340 +
   1.341 +# match expected (full fanciness)
   1.342 +# i testno flags re target mat submat ...
   1.343 +proc i {args} {
   1.344 +	eval matchexpected [linsert $args 0 [list "-indices"]]
   1.345 +}
   1.346 +
   1.347 +# partial match expected
   1.348 +# p testno flags re target mat "" ...
   1.349 +# Quirk:  number of ""s must be one more than number of subREs.
   1.350 +proc p {args} {
   1.351 +	set f [lindex $args 1]			;# add ! flag
   1.352 +	set args [lreplace $args 1 1 "!$f"]
   1.353 +	eval matchexpected [linsert $args 0 [list "-indices"]]
   1.354 +}
   1.355 +
   1.356 +# test is a knownBug
   1.357 +proc knownBug {args} {
   1.358 +    set ::regBug 1
   1.359 +    uplevel #0 $args
   1.360 +    set ::regBug 0
   1.361 +}
   1.362 +
   1.363 +
   1.364 +
   1.365 +# the tests themselves
   1.366 +
   1.367 +
   1.368 +
   1.369 +# support functions and preliminary misc.
   1.370 +# This is sensitive to changes in message wording, but we really have to
   1.371 +# test the code->message expansion at least once.
   1.372 +test reg-0.1 "regexp error reporting" {
   1.373 +	list [catch {regexp (*) ign} msg] $msg
   1.374 +} {1 {couldn't compile regular expression pattern: quantifier operand invalid}}
   1.375 +
   1.376 +
   1.377 +
   1.378 +doing 1 "basic sanity checks"
   1.379 +m  1	&	abc		abc	abc
   1.380 +f  2	&	abc		def
   1.381 +m  3	&	abc		xyabxabce	abc
   1.382 +
   1.383 +
   1.384 +
   1.385 +doing 2 "invalid option combinations"
   1.386 +e  1	qe	a		INVARG
   1.387 +e  2	qa	a		INVARG
   1.388 +e  3	qx	a		INVARG
   1.389 +e  4	qn	a		INVARG
   1.390 +e  5	ba	a		INVARG
   1.391 +
   1.392 +
   1.393 +
   1.394 +doing 3 "basic syntax"
   1.395 +i  1	&NS	""		a	{0 -1}
   1.396 +m  2	NS	a|		a	a
   1.397 +m  3	-	a|b		a	a
   1.398 +m  4	-	a|b		b	b
   1.399 +m  5	NS	a||b		b	b
   1.400 +m  6	&	ab		ab	ab
   1.401 +
   1.402 +
   1.403 +
   1.404 +doing 4 "parentheses"
   1.405 +m  1	-	(a)e		ae	ae	a
   1.406 +m  2	o	(a)e		ae
   1.407 +m  3	b	{\(a\)b}	ab	ab	a
   1.408 +m  4	-	a((b)c)		abc	abc	bc	b
   1.409 +m  5	-	a(b)(c)		abc	abc	b	c
   1.410 +e  6	-	a(b		EPAREN
   1.411 +e  7	b	{a\(b}		EPAREN
   1.412 +# sigh, we blew it on the specs here... someday this will be fixed in POSIX,
   1.413 +#  but meanwhile, it's fixed in AREs
   1.414 +m  8	eU	a)b		a)b	a)b
   1.415 +e  9	-	a)b		EPAREN
   1.416 +e 10	b	{a\)b}		EPAREN
   1.417 +m 11	P	a(?:b)c		abc	abc
   1.418 +e 12	e	a(?:b)c		BADRPT
   1.419 +i 13	S	a()b		ab	{0 1}	{1 0}
   1.420 +m 14	SP	a(?:)b		ab	ab
   1.421 +i 15	S	a(|b)c		ac	{0 1}	{1 0}
   1.422 +m 16	S	a(b|)c		abc	abc	b
   1.423 +
   1.424 +
   1.425 +
   1.426 +doing 5 "simple one-char matching"
   1.427 +# general case of brackets done later
   1.428 +m  1	&	a.b		axb	axb
   1.429 +f  2	&n	"a.b"		"a\nb"
   1.430 +m  3	&	{a[bc]d}	abd	abd
   1.431 +m  4	&	{a[bc]d}	acd	acd
   1.432 +f  5	&	{a[bc]d}	aed
   1.433 +f  6	&	{a[^bc]d}	abd
   1.434 +m  7	&	{a[^bc]d}	aed	aed
   1.435 +f  8	&p	"a\[^bc]d"	"a\nd"
   1.436 +
   1.437 +
   1.438 +
   1.439 +doing 6 "context-dependent syntax"
   1.440 +# plus odds and ends
   1.441 +e  1	-	*		BADRPT
   1.442 +m  2	b	*		*	*
   1.443 +m  3	b	{\(*\)}		*	*	*
   1.444 +e  4	-	(*)		BADRPT
   1.445 +m  5	b	^*		*	*
   1.446 +e  6	-	^*		BADRPT
   1.447 +f  7	&	^b		^b
   1.448 +m  8	b	x^		x^	x^
   1.449 +f  9	I	x^		x
   1.450 +m 10	n	"\n^"		"x\nb"	"\n"
   1.451 +f 11	bS	{\(^b\)}	^b
   1.452 +m 12	-	(^b)		b	b	b
   1.453 +m 13	&	{x$}		x	x
   1.454 +m 14	bS	{\(x$\)}	x	x	x
   1.455 +m 15	-	{(x$)}		x	x	x
   1.456 +m 16	b	{x$y}		"x\$y"	"x\$y"
   1.457 +f 17	I	{x$y}		xy
   1.458 +m 18	n	"x\$\n"		"x\n"	"x\n"
   1.459 +e 19	-	+		BADRPT
   1.460 +e 20	-	?		BADRPT
   1.461 +
   1.462 +
   1.463 +
   1.464 +doing 7 "simple quantifiers"
   1.465 +m  1	&N	a*		aa	aa
   1.466 +i  2	&N	a*		b	{0 -1}
   1.467 +m  3	-	a+		aa	aa
   1.468 +m  4	-	a?b		ab	ab
   1.469 +m  5	-	a?b		b	b
   1.470 +e  6	-	**		BADRPT
   1.471 +m  7	bN	**		***	***
   1.472 +e  8	&	a**		BADRPT
   1.473 +e  9	&	a**b		BADRPT
   1.474 +e 10	&	***		BADRPT
   1.475 +e 11	-	a++		BADRPT
   1.476 +e 12	-	a?+		BADRPT
   1.477 +e 13	-	a?*		BADRPT
   1.478 +e 14	-	a+*		BADRPT
   1.479 +e 15	-	a*+		BADRPT
   1.480 +
   1.481 +
   1.482 +
   1.483 +doing 8 "braces"
   1.484 +m  1	NQ	"a{0,1}"	""	""
   1.485 +m  2	NQ	"a{0,1}"	ac	a
   1.486 +e  3	-	"a{1,0}"	BADBR
   1.487 +e  4	-	"a{1,2,3}"	BADBR
   1.488 +e  5	-	"a{257}"	BADBR
   1.489 +e  6	-	"a{1000}"	BADBR
   1.490 +e  7	-	"a{1"		EBRACE
   1.491 +e  8	-	"a{1n}"		BADBR
   1.492 +m  9	BS	"a{b"		"a\{b"	"a\{b"
   1.493 +m 10	BS	"a{"		"a\{"	"a\{"
   1.494 +m 11	bQ	"a\\{0,1\\}b"	cb	b
   1.495 +e 12	b	"a\\{0,1"	EBRACE
   1.496 +e 13	-	"a{0,1\\"	BADBR
   1.497 +m 14	Q	"a{0}b"		ab	b
   1.498 +m 15	Q	"a{0,0}b"	ab	b
   1.499 +m 16	Q	"a{0,1}b"	ab	ab
   1.500 +m 17	Q	"a{0,2}b"	b	b
   1.501 +m 18	Q	"a{0,2}b"	aab	aab
   1.502 +m 19	Q	"a{0,}b"	aab	aab
   1.503 +m 20	Q	"a{1,1}b"	aab	ab
   1.504 +m 21	Q	"a{1,3}b"	aaaab	aaab
   1.505 +f 22	Q	"a{1,3}b"	b
   1.506 +m 23	Q	"a{1,}b"	aab	aab
   1.507 +f 24	Q	"a{2,3}b"	ab
   1.508 +m 25	Q	"a{2,3}b"	aaaab	aaab
   1.509 +f 26	Q	"a{2,}b"	ab
   1.510 +m 27	Q	"a{2,}b"	aaaab	aaaab
   1.511 +
   1.512 +
   1.513 +
   1.514 +doing 9 "brackets"
   1.515 +m  1	&	{a[bc]}		ac	ac
   1.516 +m  2	&	{a[-]}		a-	a-
   1.517 +m  3	&	{a[[.-.]]}	a-	a-
   1.518 +m  4	&L	{a[[.zero.]]}	a0	a0
   1.519 +m  5	&LM	{a[[.zero.]-9]}	a2	a2
   1.520 +m  6	&M	{a[0-[.9.]]}	a2	a2
   1.521 +m  7	&+L	{a[[=x=]]}	ax	ax
   1.522 +m  8	&+L	{a[[=x=]]}	ay	ay
   1.523 +f  9	&+L	{a[[=x=]]}	az
   1.524 +e 10	&	{a[0-[=x=]]}	ERANGE
   1.525 +m 11	&L	{a[[:digit:]]}	a0	a0
   1.526 +e 12	&	{a[[:woopsie:]]}	ECTYPE
   1.527 +f 13	&L	{a[[:digit:]]}	ab
   1.528 +e 14	&	{a[0-[:digit:]]}	ERANGE
   1.529 +m 15	&LP	{[[:<:]]a}	a	a
   1.530 +m 16	&LP	{a[[:>:]]}	a	a
   1.531 +e 17	&	{a[[..]]b}	ECOLLATE
   1.532 +e 18	&	{a[[==]]b}	ECOLLATE
   1.533 +e 19	&	{a[[::]]b}	ECTYPE
   1.534 +e 20	&	{a[[.a}		EBRACK
   1.535 +e 21	&	{a[[=a}		EBRACK
   1.536 +e 22	&	{a[[:a}		EBRACK
   1.537 +e 23	&	{a[}		EBRACK
   1.538 +e 24	&	{a[b}		EBRACK
   1.539 +e 25	&	{a[b-}		EBRACK
   1.540 +e 26	&	{a[b-c}		EBRACK
   1.541 +m 27	&M	{a[b-c]}	ab	ab
   1.542 +m 28	&	{a[b-b]}	ab	ab
   1.543 +m 29	&M	{a[1-2]}	a2	a2
   1.544 +e 30	&	{a[c-b]}	ERANGE
   1.545 +e 31	&	{a[a-b-c]}	ERANGE
   1.546 +m 32	&M	{a[--?]b}	a?b	a?b
   1.547 +m 33	&	{a[---]b}	a-b	a-b
   1.548 +m 34	&	{a[]b]c}	a]c	a]c
   1.549 +m 35	EP	{a[\]]b}	a]b	a]b
   1.550 +f 36	bE	{a[\]]b}	a]b
   1.551 +m 37	bE	{a[\]]b}	"a\\]b"	"a\\]b"
   1.552 +m 38	eE	{a[\]]b}	"a\\]b"	"a\\]b"
   1.553 +m 39	EP	{a[\\]b}	"a\\b"	"a\\b"
   1.554 +m 40	eE	{a[\\]b}	"a\\b"	"a\\b"
   1.555 +m 41	bE	{a[\\]b}	"a\\b"	"a\\b"
   1.556 +e 42	-	{a[\Z]b}	EESCAPE
   1.557 +m 43	&	{a[[b]c}	"a\[c"	"a\[c"
   1.558 +m 44	EMP*	{a[\u00fe-\u0507][\u00ff-\u0300]b} \
   1.559 +			"a\u0102\u02ffb"	"a\u0102\u02ffb"
   1.560 +
   1.561 +
   1.562 +
   1.563 +doing 10 "anchors and newlines"
   1.564 +m  1	&	^a		a	a
   1.565 +f  2	&^	^a		a
   1.566 +i  3	&N	^		a	{0 -1}
   1.567 +i  4	&	{a$}		aba	{2 2}
   1.568 +f  5	{&$}	{a$}		a
   1.569 +i  6	&N	{$}		ab	{2 1}
   1.570 +m  7	&n	^a		a	a
   1.571 +m  8	&n	"^a"		"b\na"	"a"
   1.572 +i  9	&w	"^a"		"a\na"	{0 0}
   1.573 +i 10	&n^	"^a"		"a\na"	{2 2}
   1.574 +m 11	&n	{a$}		a	a
   1.575 +m 12	&n	"a\$"		"a\nb"	"a"
   1.576 +i 13	&n	"a\$"		"a\na"	{0 0}
   1.577 +i 14	N	^^		a	{0 -1}
   1.578 +m 15	b	^^		^	^
   1.579 +i 16	N	{$$}		a	{1 0}
   1.580 +m 17	b	{$$}		"\$"	"\$"
   1.581 +m 18	&N	{^$}		""	""
   1.582 +f 19	&N	{^$}		a
   1.583 +i 20	&nN	"^\$"		"a\n\nb"	{2 1}
   1.584 +m 21	N	{$^}		""	""
   1.585 +m 22	b	{$^}		"\$^"	"\$^"
   1.586 +m 23	P	{\Aa}		a	a
   1.587 +m 24	^P	{\Aa}		a	a
   1.588 +f 25	^nP	{\Aa}		"b\na"
   1.589 +m 26	P	{a\Z}		a	a
   1.590 +m 27	{$P}	{a\Z}		a	a
   1.591 +f 28	{$nP}	{a\Z}		"a\nb"
   1.592 +e 29	-	^*		BADRPT
   1.593 +e 30	-	{$*}		BADRPT
   1.594 +e 31	-	{\A*}		BADRPT
   1.595 +e 32	-	{\Z*}		BADRPT
   1.596 +
   1.597 +
   1.598 +
   1.599 +doing 11 "boundary constraints"
   1.600 +m  1	&LP	{[[:<:]]a}	a	a
   1.601 +m  2	&LP	{[[:<:]]a}	-a	a
   1.602 +f  3	&LP	{[[:<:]]a}	ba
   1.603 +m  4	&LP	{a[[:>:]]}	a	a
   1.604 +m  5	&LP	{a[[:>:]]}	a-	a
   1.605 +f  6	&LP	{a[[:>:]]}	ab
   1.606 +m  7	bLP	{\<a}		a	a
   1.607 +f  8	bLP	{\<a}		ba
   1.608 +m  9	bLP	{a\>}		a	a
   1.609 +f 10	bLP	{a\>}		ab
   1.610 +m 11	LP	{\ya}		a	a
   1.611 +f 12	LP	{\ya}		ba
   1.612 +m 13	LP	{a\y}		a	a
   1.613 +f 14	LP	{a\y}		ab
   1.614 +m 15	LP	{a\Y}		ab	a
   1.615 +f 16	LP	{a\Y}		a-
   1.616 +f 17	LP	{a\Y}		a
   1.617 +f 18	LP	{-\Y}		-a
   1.618 +m 19	LP	{-\Y}		-%	-
   1.619 +f 20	LP	{\Y-}		a-
   1.620 +e 21	-	{[[:<:]]*}	BADRPT
   1.621 +e 22	-	{[[:>:]]*}	BADRPT
   1.622 +e 23	b	{\<*}		BADRPT
   1.623 +e 24	b	{\>*}		BADRPT
   1.624 +e 25	-	{\y*}		BADRPT
   1.625 +e 26	-	{\Y*}		BADRPT
   1.626 +m 27	LP	{\ma}		a	a
   1.627 +f 28	LP	{\ma}		ba
   1.628 +m 29	LP	{a\M}		a	a
   1.629 +f 30	LP	{a\M}		ab
   1.630 +f 31	ILP	{\Ma}		a
   1.631 +f 32	ILP	{a\m}		a
   1.632 +
   1.633 +
   1.634 +
   1.635 +doing 12 "character classes"
   1.636 +m  1	LP	{a\db}		a0b	a0b
   1.637 +f  2	LP	{a\db}		axb
   1.638 +f  3	LP	{a\Db}		a0b
   1.639 +m  4	LP	{a\Db}		axb	axb
   1.640 +m  5	LP	"a\\sb"		"a b"	"a b"
   1.641 +m  6	LP	"a\\sb"		"a\tb"	"a\tb"
   1.642 +m  7	LP	"a\\sb"		"a\nb"	"a\nb"
   1.643 +f  8	LP	{a\sb}		axb
   1.644 +m  9	LP	{a\Sb}		axb	axb
   1.645 +f 10	LP	"a\\Sb"		"a b"
   1.646 +m 11	LP	{a\wb}		axb	axb
   1.647 +f 12	LP	{a\wb}		a-b
   1.648 +f 13	LP	{a\Wb}		axb
   1.649 +m 14	LP	{a\Wb}		a-b	a-b
   1.650 +m 15	LP	{\y\w+z\y}	adze-guz	guz
   1.651 +m 16	LPE	{a[\d]b}	a1b	a1b
   1.652 +m 17	LPE	"a\[\\s]b"	"a b"	"a b"
   1.653 +m 18	LPE	{a[\w]b}	axb	axb
   1.654 +
   1.655 +
   1.656 +
   1.657 +doing 13 "escapes"
   1.658 +e  1	&	"a\\"		EESCAPE
   1.659 +m  2	-	{a\<b}		a<b	a<b
   1.660 +m  3	e	{a\<b}		a<b	a<b
   1.661 +m  4	bAS	{a\wb}		awb	awb
   1.662 +m  5	eAS	{a\wb}		awb	awb
   1.663 +m  6	PL	"a\\ab"		"a\007b"	"a\007b"
   1.664 +m  7	P	"a\\bb"		"a\bb"	"a\bb"
   1.665 +m  8	P	{a\Bb}		"a\\b"	"a\\b"
   1.666 +m  9	MP	"a\\chb"	"a\bb"	"a\bb"
   1.667 +m 10	MP	"a\\cHb"	"a\bb"	"a\bb"
   1.668 +m 11	LMP	"a\\e"		"a\033"	"a\033"
   1.669 +m 12	P	"a\\fb"		"a\fb"	"a\fb"
   1.670 +m 13	P	"a\\nb"		"a\nb"	"a\nb"
   1.671 +m 14	P	"a\\rb"		"a\rb"	"a\rb"
   1.672 +m 15	P	"a\\tb"		"a\tb"	"a\tb"
   1.673 +m 16	P	"a\\u0008x"	"a\bx"	"a\bx"
   1.674 +e 17	-	{a\u008x}	EESCAPE
   1.675 +m 18	P	"a\\u00088x"	"a\b8x"	"a\b8x"
   1.676 +m 19	P	"a\\U00000008x"	"a\bx"	"a\bx"
   1.677 +e 20	-	{a\U0000008x}	EESCAPE
   1.678 +m 21	P	"a\\vb"		"a\vb"	"a\vb"
   1.679 +m 22	MP	"a\\x08x"	"a\bx"	"a\bx"
   1.680 +e 23	-	{a\xq}		EESCAPE
   1.681 +m 24	MP	"a\\x0008x"	"a\bx"	"a\bx"
   1.682 +e 25	-	{a\z}		EESCAPE
   1.683 +m 26	MP	"a\\010b"	"a\bb"	"a\bb"
   1.684 +
   1.685 +
   1.686 +
   1.687 +doing 14 "back references"
   1.688 +# ugh
   1.689 +m  1	RP	{a(b*)c\1}	abbcbb	abbcbb	bb
   1.690 +m  2	RP	{a(b*)c\1}	ac	ac	""
   1.691 +f  3	RP	{a(b*)c\1}	abbcb
   1.692 +m  4	RP	{a(b*)\1}	abbcbb	abb	b
   1.693 +m  5	RP	{a(b|bb)\1}	abbcbb	abb	b
   1.694 +m  6	RP	{a([bc])\1}	abb	abb	b
   1.695 +f  7	RP	{a([bc])\1}	abc
   1.696 +m  8	RP	{a([bc])\1}	abcabb	abb	b
   1.697 +f  9	RP	{a([bc])*\1}	abc
   1.698 +f 10	RP	{a([bc])\1}	abB
   1.699 +m 11	iRP	{a([bc])\1}	abB	abB	b
   1.700 +m 12	RP	{a([bc])\1+}	abbb	abbb	b
   1.701 +m 13	QRP	"a(\[bc])\\1{3,4}"	abbbb	abbbb	b
   1.702 +f 14	QRP	"a(\[bc])\\1{3,4}"	abbb
   1.703 +m 15	RP	{a([bc])\1*}	abbb	abbb	b
   1.704 +m 16	RP	{a([bc])\1*}	ab	ab	b
   1.705 +m 17	RP	{a([bc])(\1*)}	ab	ab	b	""
   1.706 +e 18	-	{a((b)\1)}	ESUBREG
   1.707 +e 19	-	{a(b)c\2}	ESUBREG
   1.708 +m 20	bR	{a\(b*\)c\1}	abbcbb	abbcbb	bb
   1.709 +
   1.710 +
   1.711 +
   1.712 +doing 15 "octal escapes vs back references"
   1.713 +# initial zero is always octal
   1.714 +m  1	MP	"a\\010b"	"a\bb"	"a\bb"
   1.715 +m  2	MP	"a\\0070b"	"a\0070b"	"a\0070b"
   1.716 +m  3	MP	"a\\07b"	"a\007b"	"a\007b"
   1.717 +m  4	MP	"a(b)(b)(b)(b)(b)(b)(b)(b)(b)(b)\\07c"	"abbbbbbbbbb\007c" \
   1.718 +	"abbbbbbbbbb\007c"	"b"	"b"	"b"	"b"	"b"	"b" \
   1.719 +	"b"	"b"	"b"	"b"
   1.720 +# a single digit is always a backref
   1.721 +e  5	-	{a\7b}		ESUBREG
   1.722 +# otherwise it's a backref only if within range (barf!)
   1.723 +m  6	MP	"a\\10b"	"a\bb"	"a\bb"
   1.724 +m  7	MP	{a\101b}	aAb	aAb
   1.725 +m  8	RP	{a(b)(b)(b)(b)(b)(b)(b)(b)(b)(b)\10c}	abbbbbbbbbbbc \
   1.726 +	abbbbbbbbbbbc	b	b	b	b	b	b	b \
   1.727 +	b	b	b
   1.728 +# but we're fussy about border cases -- guys who want octal should use the zero
   1.729 +e  9	-	{a((((((((((b\10))))))))))c}	ESUBREG
   1.730 +# BREs don't have octal, EREs don't have backrefs
   1.731 +m 10	MP	"a\\12b"	"a\nb"	"a\nb"
   1.732 +e 11	b	{a\12b}		ESUBREG
   1.733 +m 12	eAS	{a\12b}		a12b	a12b
   1.734 +
   1.735 +
   1.736 +
   1.737 +doing 16 "expanded syntax"
   1.738 +m  1	xP	"a b c"		"abc"	"abc"
   1.739 +m  2	xP	"a b #oops\nc\td"	"abcd"	"abcd"
   1.740 +m  3	x	"a\\ b\\\tc"	"a b\tc"	"a b\tc"
   1.741 +m  4	xP	"a b\\#c"	"ab#c"	"ab#c"
   1.742 +m  5	xP	"a b\[c d]e"	"ab e"	"ab e"
   1.743 +m  6	xP	"a b\[c#d]e"	"ab#e"	"ab#e"
   1.744 +m  7	xP	"a b\[c#d]e"	"abde"	"abde"
   1.745 +m  8	xSPB	"ab{ d"		"ab\{d"	"ab\{d"
   1.746 +m  9	xPQ	"ab{ 1 , 2 }c"	"abc"	"abc"
   1.747 +
   1.748 +
   1.749 +
   1.750 +doing 17 "misc syntax"
   1.751 +m  1	P	a(?#comment)b	ab	ab
   1.752 +
   1.753 +
   1.754 +
   1.755 +doing 18 "unmatchable REs"
   1.756 +f  1	I	a^b		ab
   1.757 +
   1.758 +
   1.759 +
   1.760 +doing 19 "case independence"
   1.761 +m  1	&i	ab		Ab	Ab
   1.762 +m  2	&i	{a[bc]}		aC	aC
   1.763 +f  3	&i	{a[^bc]}	aB
   1.764 +m  4	&iM	{a[b-d]}	aC	aC
   1.765 +f  5	&iM	{a[^b-d]}	aC
   1.766 +
   1.767 +
   1.768 +
   1.769 +doing 20 "directors and embedded options"
   1.770 +e  1	&	***?		BADPAT
   1.771 +m  2	q	***?		***?	***?
   1.772 +m  3	&P	***=a*b		a*b	a*b
   1.773 +m  4	q	***=a*b		***=a*b	***=a*b
   1.774 +m  5	bLP	{***:\w+}	ab	ab
   1.775 +m  6	eLP	{***:\w+}	ab	ab
   1.776 +e  7	&	***:***=a*b	BADRPT
   1.777 +m  8	&P	***:(?b)a+b	a+b	a+b
   1.778 +m  9	P	(?b)a+b		a+b	a+b
   1.779 +e 10	e	{(?b)\w+}	BADRPT
   1.780 +m 11	bAS	{(?b)\w+}	(?b)w+	(?b)w+
   1.781 +m 12	iP	(?c)a		a	a
   1.782 +f 13	iP	(?c)a		A
   1.783 +m 14	APS	{(?e)\W+}	WW	WW
   1.784 +m 15	P	(?i)a+		Aa	Aa
   1.785 +f 16	P	"(?m)a.b"	"a\nb"
   1.786 +m 17	P	"(?m)^b"	"a\nb"	"b"
   1.787 +f 18	P	"(?n)a.b"	"a\nb"
   1.788 +m 19	P	"(?n)^b"	"a\nb"	"b"
   1.789 +f 20	P	"(?p)a.b"	"a\nb"
   1.790 +f 21	P	"(?p)^b"	"a\nb"
   1.791 +m 22	P	(?q)a+b		a+b	a+b
   1.792 +m 23	nP	"(?s)a.b"	"a\nb"	"a\nb"
   1.793 +m 24	xP	"(?t)a b"	"a b"	"a b"
   1.794 +m 25	P	"(?w)a.b"	"a\nb"	"a\nb"
   1.795 +m 26	P	"(?w)^b"	"a\nb"	"b"
   1.796 +m 27	P	"(?x)a b"	"ab"	"ab"
   1.797 +e 28	-	(?z)ab		BADOPT
   1.798 +m 29	P	(?ici)a+	Aa	Aa
   1.799 +e 30	P	(?i)(?q)a+	BADRPT
   1.800 +m 31	P	(?q)(?i)a+	(?i)a+	(?i)a+
   1.801 +m 32	P	(?qe)a+		a	a
   1.802 +m 33	xP	"(?q)a b"	"a b"	"a b"
   1.803 +m 34	P	"(?qx)a b"	"a b"	"a b"
   1.804 +m 35	P	(?qi)ab		Ab	Ab
   1.805 +
   1.806 +
   1.807 +
   1.808 +doing 21 "capturing"
   1.809 +m  1	-	a(b)c		abc	abc	b
   1.810 +m  2	P	a(?:b)c		xabc	abc
   1.811 +m  3	-	a((b))c		xabcy	abc	b	b
   1.812 +m  4	P	a(?:(b))c	abcy	abc	b
   1.813 +m  5	P	a((?:b))c	abc	abc	b
   1.814 +m  6	P	a(?:(?:b))c	abc	abc
   1.815 +i  7	Q	"a(b){0}c"	ac	{0 1}	{-1 -1}
   1.816 +m  8	-	a(b)c(d)e	abcde	abcde	b	d
   1.817 +m  9	-	(b)c(d)e	bcde	bcde	b	d
   1.818 +m 10	-	a(b)(d)e	abde	abde	b	d
   1.819 +m 11	-	a(b)c(d)	abcd	abcd	b	d
   1.820 +m 12	-	(ab)(cd)	xabcdy	abcd	ab	cd
   1.821 +m 13	-	a(b)?c		xabcy	abc	b
   1.822 +i 14	-	a(b)?c		xacy	{1 2}	{-1 -1}
   1.823 +m 15	-	a(b)?c(d)?e	xabcdey	abcde	b	d
   1.824 +i 16	-	a(b)?c(d)?e	xacdey	{1 4}	{-1 -1}	{3 3}
   1.825 +i 17	-	a(b)?c(d)?e	xabcey	{1 4}	{2 2}	{-1 -1}
   1.826 +i 18	-	a(b)?c(d)?e	xacey	{1 3}	{-1 -1}	{-1 -1}
   1.827 +m 19	-	a(b)*c		xabcy	abc	b
   1.828 +i 20	-	a(b)*c		xabbbcy	{1 5}	{4 4}
   1.829 +i 21	-	a(b)*c		xacy	{1 2}	{-1 -1}
   1.830 +m 22	-	a(b*)c		xabbbcy	abbbc	bbb
   1.831 +m 23	-	a(b*)c		xacy	ac	""
   1.832 +f 24	-	a(b)+c		xacy
   1.833 +m 25	-	a(b)+c		xabcy	abc	b
   1.834 +i 26	-	a(b)+c		xabbbcy	{1 5}	{4 4}
   1.835 +m 27	-	a(b+)c		xabbbcy	abbbc	bbb
   1.836 +i 28	Q	"a(b){2,3}c"	xabbbcy	{1 5}	{4 4}
   1.837 +i 29	Q	"a(b){2,3}c"	xabbcy	{1 4}	{3 3}
   1.838 +f 30	Q	"a(b){2,3}c"	xabcy
   1.839 +m 31	LP	"\\y(\\w+)\\y"	"-- abc-"	"abc"	"abc"
   1.840 +m 32	-	a((b|c)d+)+	abacdbd	acdbd	bd	b
   1.841 +m 33	N	(.*).*		abc	abc	abc
   1.842 +m 34	N	(a*)*		bc	""	""
   1.843 +
   1.844 +
   1.845 +
   1.846 +doing 22 "multicharacter collating elements"
   1.847 +# again ugh
   1.848 +m  1	&+L	{a[c]e}		ace	ace
   1.849 +f  2	&+IL	{a[c]h}		ach
   1.850 +m  3	&+L	{a[[.ch.]]}	ach	ach
   1.851 +f  4	&+L	{a[[.ch.]]}	ace
   1.852 +m  5	&+L	{a[c[.ch.]]}	ac	ac
   1.853 +m  6	&+L	{a[c[.ch.]]}	ace	ac
   1.854 +m  7	&+L	{a[c[.ch.]]}	ache	ach
   1.855 +f  8	&+L	{a[^c]e}	ace
   1.856 +m  9	&+L	{a[^c]e}	abe	abe
   1.857 +m 10	&+L	{a[^c]e}	ache	ache
   1.858 +f 11	&+L	{a[^[.ch.]]}	ach
   1.859 +m 12	&+L	{a[^[.ch.]]}	ace	ac
   1.860 +m 13	&+L	{a[^[.ch.]]}	ac	ac
   1.861 +m 14	&+L	{a[^[.ch.]]}	abe	ab
   1.862 +f 15	&+L	{a[^c[.ch.]]}	ach
   1.863 +f 16	&+L	{a[^c[.ch.]]}	ace
   1.864 +f 17	&+L	{a[^c[.ch.]]}	ac
   1.865 +m 18	&+L	{a[^c[.ch.]]}	abe	ab
   1.866 +m 19	&+L	{a[^b]}		ac	ac
   1.867 +m 20	&+L	{a[^b]}		ace	ac
   1.868 +m 21	&+L	{a[^b]}		ach	ach
   1.869 +f 22	&+L	{a[^b]}		abe
   1.870 +
   1.871 +
   1.872 +
   1.873 +doing 23 "lookahead constraints"
   1.874 +m  1	HP	a(?=b)b*	ab	ab
   1.875 +f  2	HP	a(?=b)b*	a
   1.876 +m  3	HP	a(?=b)b*(?=c)c*	abc	abc
   1.877 +f  4	HP	a(?=b)b*(?=c)c*	ab
   1.878 +f  5	HP	a(?!b)b*	ab
   1.879 +m  6	HP	a(?!b)b*	a	a
   1.880 +m  7	HP	(?=b)b		b	b
   1.881 +f  8	HP	(?=b)b		a
   1.882 +
   1.883 +
   1.884 +
   1.885 +doing 24 "non-greedy quantifiers"
   1.886 +m  1	PT	ab+?		abb	ab
   1.887 +m  2	PT	ab+?c		abbc	abbc
   1.888 +m  3	PT	ab*?		abb	a
   1.889 +m  4	PT	ab*?c		abbc	abbc
   1.890 +m  5	PT	ab??		ab	a
   1.891 +m  6	PT	ab??c		abc	abc
   1.892 +m  7	PQT	"ab{2,4}?"	abbbb	abb
   1.893 +m  8	PQT	"ab{2,4}?c"	abbbbc	abbbbc
   1.894 +m  9	-	3z*		123zzzz456	3zzzz
   1.895 +m 10	PT	3z*?		123zzzz456	3
   1.896 +m 11	-	z*4		123zzzz456	zzzz4
   1.897 +m 12	PT	z*?4		123zzzz456	zzzz4
   1.898 +
   1.899 +
   1.900 +
   1.901 +doing 25 "mixed quantifiers"
   1.902 +# this is very incomplete as yet
   1.903 +# should include |
   1.904 +m  1	PNT	{^(.*?)(a*)$}	xyza	xyza	xyz	a
   1.905 +m  2	PNT	{^(.*?)(a*)$}	xyzaa	xyzaa	xyz	aa
   1.906 +m  3	PNT	{^(.*?)(a*)$}	xyz	xyz	xyz	""
   1.907 +
   1.908 +
   1.909 +
   1.910 +doing 26 "tricky cases"
   1.911 +# attempts to trick the matcher into accepting a short match
   1.912 +m  1	-	(week|wee)(night|knights)	weeknights	weeknights \
   1.913 +	wee	knights
   1.914 +m  2	RP	{a(bc*).*\1}	abccbccb	abccbccb	b
   1.915 +m  3	-	{a(b.[bc]*)+}	abcbd	abcbd	bd
   1.916 +
   1.917 +
   1.918 +
   1.919 +doing 27 "implementation misc."
   1.920 +# duplicate arcs are suppressed
   1.921 +m  1	P	a(?:b|b)c	abc	abc
   1.922 +# make color/subcolor relationship go back and forth
   1.923 +m  2	&	{[ab][ab][ab]}	aba	aba
   1.924 +m  3	&	{[ab][ab][ab][ab][ab][ab][ab]}	abababa	abababa
   1.925 +
   1.926 +
   1.927 +
   1.928 +doing 28 "boundary busters etc."
   1.929 +# color-descriptor allocation changes at 10
   1.930 +m  1	&	abcdefghijkl	abcdefghijkl	abcdefghijkl
   1.931 +# so does arc allocation
   1.932 +m  2	P	a(?:b|c|d|e|f|g|h|i|j|k|l|m)n	agn	agn
   1.933 +# subexpression tracking also at 10
   1.934 +m  3	-	a(((((((((((((b)))))))))))))c	abc	abc	b	b	b	b	b	b	b	b	b	b	b	b	b
   1.935 +# state-set handling changes slightly at unsigned size (might be 64...)
   1.936 +# (also stresses arc allocation)
   1.937 +m  4	Q	"ab{1,100}c"	abbc	abbc
   1.938 +m  5	Q	"ab{1,100}c"	abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc \
   1.939 +	abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc
   1.940 +m  6	Q	"ab{1,100}c" \
   1.941 +	abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc \
   1.942 +	abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc
   1.943 +# force small cache and bust it, several ways
   1.944 +m  7	LP	{\w+abcdefgh}	xyzabcdefgh	xyzabcdefgh
   1.945 +m  8	%LP	{\w+abcdefgh}	xyzabcdefgh	xyzabcdefgh
   1.946 +m  9	%LP	{\w+abcdefghijklmnopqrst}	xyzabcdefghijklmnopqrst \
   1.947 +	xyzabcdefghijklmnopqrst
   1.948 +i 10	%LP	{\w+(abcdefgh)?}	xyz	{0 2}	{-1 -1}
   1.949 +i 11	%LP	{\w+(abcdefgh)?}	xyzabcdefg	{0 9}	{-1 -1}
   1.950 +i 12	%LP	{\w+(abcdefghijklmnopqrst)?}	xyzabcdefghijklmnopqrs \
   1.951 +	{0 21}	{-1 -1}
   1.952 +
   1.953 +
   1.954 +
   1.955 +doing 29 "incomplete matches"
   1.956 +p  1	t	def		abc	{3 2}	""
   1.957 +p  2	t	bcd		abc	{1 2}	""
   1.958 +p  3	t	abc		abab	{0 3}	""
   1.959 +p  4	t	abc		abdab	{3 4}	""
   1.960 +i  5	t	abc		abc	{0 2}	{0 2}
   1.961 +i  6	t	abc		xyabc	{2 4}	{2 4}
   1.962 +p  7	t	abc+		xyab	{2 3}	""
   1.963 +i  8	t	abc+		xyabc	{2 4}	{2 4}
   1.964 +knownBug i  9	t	abc+		xyabcd	{2 4}	{6 5}
   1.965 +i  10	t	abc+		xyabcdd	{2 4}	{7 6}
   1.966 +p  11	tPT	abc+?		xyab	{2 3}	""
   1.967 +# the retain numbers in these two may look wrong, but they aren't
   1.968 +i  12	tPT	abc+?		xyabc	{2 4}	{5 4}
   1.969 +i  13	tPT	abc+?		xyabcc	{2 4}	{6 5}
   1.970 +i  14	tPT	abc+?		xyabcd	{2 4}	{6 5}
   1.971 +i  15	tPT	abc+?		xyabcdd	{2 4}	{7 6}
   1.972 +i  16	t	abcd|bc		xyabc	{3 4}	{2 4}
   1.973 +p  17	tn	.*k		"xx\nyyy"	{3 5}	""
   1.974 +
   1.975 +
   1.976 +doing 30 "misc. oddities and old bugs"
   1.977 +e  1	&	***		BADRPT
   1.978 +m  2	N	a?b*		abb	abb
   1.979 +m  3	N	a?b*		bb	bb
   1.980 +m  4	&	a*b		aab	aab
   1.981 +m  5	&	^a*b		aaaab	aaaab
   1.982 +m  6	&M	{[0-6][1-2][0-3][0-6][1-6][0-6]}	010010	010010
   1.983 +# temporary REG_BOSONLY kludge
   1.984 +m  7	s	abc		abcd	abc
   1.985 +f  8	s	abc		xabcd
   1.986 +# back to normal stuff
   1.987 +m  9	HLP	{(?n)^(?![t#])\S+}	"tk\n\n#\n#\nit0"	it0
   1.988 +
   1.989 +
   1.990 +# flush any leftover complaints
   1.991 +doing 0 "flush"
   1.992 +
   1.993 +# Tests resulting from bugs reported by users
   1.994 +test reg-31.1 {[[:xdigit:]] behaves correctly when followed by [[:space:]]} {
   1.995 +    set str {2:::DebugWin32}
   1.996 +    set re {([[:xdigit:]])([[:space:]]*)}
   1.997 +    list [regexp $re $str match xdigit spaces] $match $xdigit $spaces
   1.998 +    # Code used to produce {1 2:::DebugWin32 2 :::DebugWin32} !!!
   1.999 +} {1 2 2 {}}
  1.1000 +
  1.1001 +test reg-32.1 {canmatch functionality -- at end} testregexp {
  1.1002 +    set pat {blah}
  1.1003 +    set line "asd asd"
  1.1004 +    # can match at the final d, if '%' follows
  1.1005 +    set res [testregexp -xflags -- c $pat $line resvar]
  1.1006 +    lappend res $resvar
  1.1007 +} {0 7}
  1.1008 +
  1.1009 +test reg-32.2 {canmatch functionality -- at end} testregexp {
  1.1010 +    set pat {s%$}
  1.1011 +    set line "asd asd"
  1.1012 +    # can only match after the end of the string
  1.1013 +    set res [testregexp -xflags -- c $pat $line resvar] 
  1.1014 +    lappend res $resvar
  1.1015 +} {0 7}
  1.1016 +
  1.1017 +test reg-32.3 {canmatch functionality -- not last char} testregexp {
  1.1018 +    set pat {[^d]%$}
  1.1019 +    set line "asd asd"
  1.1020 +    # can only match after the end of the string
  1.1021 +    set res [testregexp -xflags -- c $pat $line resvar]
  1.1022 +    lappend res $resvar
  1.1023 +} {0 7}
  1.1024 +
  1.1025 +test reg-32.3.1 {canmatch functionality -- no match} testregexp {
  1.1026 +    set pat {\Zx}
  1.1027 +    set line "asd asd"
  1.1028 +    # can match the last char, if followed by x
  1.1029 +    set res [testregexp -xflags -- c $pat $line resvar]
  1.1030 +    lappend res $resvar
  1.1031 +} {0 -1}
  1.1032 +
  1.1033 +test reg-32.4 {canmatch functionality -- last char} {knownBug} {
  1.1034 +    set pat {.x}
  1.1035 +    set line "asd asd"
  1.1036 +    # can match the last char, if followed by x
  1.1037 +    set res [testregexp -xflags -- c $pat $line resvar]
  1.1038 +    lappend res $resvar
  1.1039 +} {0 6}
  1.1040 +
  1.1041 +test reg-32.4.1 {canmatch functionality -- last char} {knownBug} {
  1.1042 +    set pat {.x$}
  1.1043 +    set line "asd asd"
  1.1044 +    # can match the last char, if followed by x
  1.1045 +    set res [testregexp -xflags -- c $pat $line resvar]
  1.1046 +    lappend res $resvar
  1.1047 +} {0 6}
  1.1048 +
  1.1049 +test reg-32.5 {canmatch functionality -- last char} {knownBug} {
  1.1050 +    set pat {.[^d]x$}
  1.1051 +    set line "asd asd"
  1.1052 +    # can match the last char, if followed by not-d and x.
  1.1053 +    set res [testregexp -xflags -- c $pat $line resvar]
  1.1054 +    lappend res $resvar
  1.1055 +} {0 6}
  1.1056 +
  1.1057 +test reg-32.6 {canmatch functionality -- last char} {knownBug} {
  1.1058 +    set pat {[^a]%[^\r\n]*$}
  1.1059 +    set line "asd asd"
  1.1060 +    # can match at the final d, if '%' follows
  1.1061 +    set res [testregexp -xflags -- c $pat $line resvar]
  1.1062 +    lappend res $resvar
  1.1063 +} {0 6}
  1.1064 +
  1.1065 +test reg-32.7 {canmatch functionality -- last char} {knownBug} {
  1.1066 +    set pat {[^a]%$}
  1.1067 +    set line "asd asd"
  1.1068 +    # can match at the final d, if '%' follows
  1.1069 +    set res [testregexp -xflags -- c $pat $line resvar]
  1.1070 +    lappend res $resvar
  1.1071 +} {0 6}
  1.1072 +
  1.1073 +test reg-32.8 {canmatch functionality -- last char} {knownBug} {
  1.1074 +    set pat {[^x]%$}
  1.1075 +    set line "asd asd"
  1.1076 +    # can match at the final d, if '%' follows
  1.1077 +    set res [testregexp -xflags -- c $pat $line resvar]
  1.1078 +    lappend res $resvar
  1.1079 +} {0 6}
  1.1080 +
  1.1081 +test reg-32.9 {canmatch functionality -- more complex case} {knownBug} {
  1.1082 +    set pat {((\B\B|\Bh+line)[ \t]*|[^\B]%[^\r\n]*)$}
  1.1083 +    set line "asd asd"
  1.1084 +    # can match at the final d, if '%' follows
  1.1085 +    set res [testregexp -xflags -- c $pat $line resvar]
  1.1086 +    lappend res $resvar
  1.1087 +} {0 6}
  1.1088 +
  1.1089 +# Tests reg-33.*: Checks for bug fixes
  1.1090 +
  1.1091 +test reg-33.1 {Bug 230589} {
  1.1092 +    regexp {[ ]*(^|[^%])%V} "*%V2" m s
  1.1093 +} 1
  1.1094 +
  1.1095 +test reg-33.2 {Bug 504785} {
  1.1096 +    regexp -inline {([^_.]*)([^.]*)\.(..)(.).*} bbcos_001_c01.q1la
  1.1097 +} {bbcos_001_c01.q1la bbcos _001_c01 q1 l}
  1.1098 +
  1.1099 +test reg-33.3 {Bug 505048} {
  1.1100 +    regexp {\A\s*[^<]*\s*<([^>]+)>} a<a>
  1.1101 +} 1
  1.1102 +
  1.1103 +test reg-33.4 {Bug 505048} {
  1.1104 +    regexp {\A\s*([^b]*)b} ab
  1.1105 +} 1
  1.1106 +
  1.1107 +test reg-33.5 {Bug 505048} {
  1.1108 +    regexp {\A\s*[^b]*(b)} ab
  1.1109 +} 1
  1.1110 +
  1.1111 +test reg-33.6 {Bug 505048} {
  1.1112 +    regexp {\A(\s*)[^b]*(b)} ab
  1.1113 +} 1
  1.1114 +
  1.1115 +test reg-33.7 {Bug 505048} {
  1.1116 +    regexp {\A\s*[^b]*b} ab
  1.1117 +} 1
  1.1118 +
  1.1119 +test reg-33.8 {Bug 505048} {
  1.1120 +    regexp -inline {\A\s*[^b]*b} ab
  1.1121 +} ab
  1.1122 +
  1.1123 +test reg-33.9 {Bug 505048} {
  1.1124 +    regexp -indices -inline {\A\s*[^b]*b} ab
  1.1125 +} {{0 1}}
  1.1126 +
  1.1127 +test reg-33.10 {Bug 840258} {
  1.1128 +    regsub {(^|\n)+\.*b} \n.b {} tmp
  1.1129 +} 1
  1.1130 +
  1.1131 +test reg-33.11 {Bug 840258} {
  1.1132 +    regsub {(^|[\n\r]+)\.*\?<.*?(\n|\r)+} \
  1.1133 +            "TQ\r\n.?<5000267>Test already stopped\r\n" {} tmp
  1.1134 +} 1
  1.1135 +
  1.1136 +# cleanup
  1.1137 +::tcltest::cleanupTests
  1.1138 +return