summaryrefslogtreecommitdiffstats
path: root/tests/regexp.test
diff options
context:
space:
mode:
authorstanton <stanton>1998-09-21 23:39:52 (GMT)
committerstanton <stanton>1998-09-21 23:39:52 (GMT)
commit494c2de3a748b449c69ce322a1a741f5a31fd4d5 (patch)
treec3ece48c0ae3f4ba54787e0e8e729b65752ef3f9 /tests/regexp.test
parent7a698c0488d99c0af42022714638ae1ba2afaa49 (diff)
downloadtcl-494c2de3a748b449c69ce322a1a741f5a31fd4d5.zip
tcl-494c2de3a748b449c69ce322a1a741f5a31fd4d5.tar.gz
tcl-494c2de3a748b449c69ce322a1a741f5a31fd4d5.tar.bz2
Added contents of Tcl 8.1a2
Diffstat (limited to 'tests/regexp.test')
-rw-r--r--tests/regexp.test34
1 files changed, 29 insertions, 5 deletions
diff --git a/tests/regexp.test b/tests/regexp.test
index 5fb785b..e39c96c 100644
--- a/tests/regexp.test
+++ b/tests/regexp.test
@@ -5,12 +5,12 @@
# generates output for errors. No output means no errors were found.
#
# Copyright (c) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994 Sun Microsystems, Inc.
+# Copyright (c) 1998 Sun Microsystems, Inc.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# SCCS: @(#) regexp.test 1.21 96/12/23 13:59:48
+# SCCS: @(#) regexp.test 1.27 98/01/28 18:07:48
if {[string compare test [info procs test]] == 1} then {source defs}
@@ -30,6 +30,15 @@ test regexp-1.4 {basic regexp operation} {
test regexp-1.5 {basic regexp operation} {
regexp {^([^ ]*)[ ]*([^ ]*)} "" a
} 1
+test regexp-1.6 {basic regexp operation} {
+ list [catch {regexp {} abc} msg] $msg
+} {0 1}
+test regexp-1.7 {regexp utf compliance} {
+ # if not UTF-8 aware, result is "0 1"
+ set foo "\u4e4eb q"
+ regexp "\u4e4eb q" "a\u4e4eb qw\u5e4e\x4e wq" bar
+ list [string compare $foo $bar] [regexp 4 $bar]
+} {0 0}
test regexp-2.1 {getting substrings back from regexp} {
set foo {}
@@ -120,10 +129,10 @@ test regexp-4.3 {-nocase option to regexp} {
} 1
set x abcdefghijklmnopqrstuvwxyz1234567890
set x $x$x$x$x$x$x$x$x$x$x$x$x
-test regexp-4.4 {case conversion in regsub} {
+test regexp-4.4 {case conversion in regexp} {
list [regexp -nocase $x $x foo] $foo
} "1 $x"
-unset x
+catch {unset x}
test regexp-5.1 {exercise cache of compiled expressions} {
regexp .*a b
@@ -186,8 +195,9 @@ test regexp-6.6 {regexp errors} {
} {0 1}
test regexp-6.7 {regexp errors} {
list [catch {regexp (x)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.) xyzzy} msg] $msg
-} {1 {couldn't compile regular expression pattern: too many ()}}
+} {0 0}
test regexp-6.8 {regexp errors} {
+ catch {unset f1}
set f1 44
list [catch {regexp abc abc f1(f2)} msg] $msg
} {1 {couldn't set variable "f1(f2)"}}
@@ -244,6 +254,12 @@ test regexp-7.16 {basic regsub operation} {
set foo xxx
list [regsub x "" y foo] $foo
} {0 {}}
+test regexp-7.17 {regsub utf compliance} {
+ # if not UTF-8 aware, result is "0 1"
+ set foo "xyz555ijka\u4e4ebpqr"
+ regsub a\u4e4eb xyza\u4e4ebijka\u4e4ebpqr 555 bar
+ list [string compare $foo $bar] [regexp 4 $bar]
+} {0 0}
test regexp-8.1 {case conversion in regsub} {
list [regsub -nocase a(a+) xaAAaAAay & foo] $foo
@@ -314,5 +330,13 @@ test regexp-10.6 {regsub errors} {
list [catch {regsub -nocase a( b c d} msg] $msg
} {1 {couldn't compile regular expression pattern: unmatched ()}}
test regexp-10.7 {regsub errors} {
+ catch {unset f1}
+ set f1 44
list [catch {regsub -nocase aaa aaa xxx f1(f2)} msg] $msg
} {1 {couldn't set variable "f1(f2)"}}
+
+test regexp-11.1 {Tcl_RegExpExec: large number of subexpressions} {
+ list [regexp (.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.) abcdefghijklmnopqrstuvwxyz all a b c d e f g h i j k l m n o p q r s t u v w x y z] $all $a $b $c $d $e $f $g $h $i $j $k $l $m $n $o $p $q $r $s $t $u $v $w $x $y $z
+} {1 abcdefghijklmnopqrstuvwxyz a b c d e f g h i j k l m n o p q r s t u v w x y z}
+
+return