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