diff options
author | stanton <stanton> | 1999-06-17 19:31:50 (GMT) |
---|---|---|
committer | stanton <stanton> | 1999-06-17 19:31:50 (GMT) |
commit | 0db76eb23cf35b0d912eb915711eecbe51c65ac1 (patch) | |
tree | 29a224f2498f9498a9df621c37555bc827b4eaee /tests | |
parent | 36fade5673a2b490fdbcdb5e782dcd8c906304d2 (diff) | |
download | tcl-0db76eb23cf35b0d912eb915711eecbe51c65ac1.zip tcl-0db76eb23cf35b0d912eb915711eecbe51c65ac1.tar.gz tcl-0db76eb23cf35b0d912eb915711eecbe51c65ac1.tar.bz2 |
* tests/regexp.test:
* generic/tclCmdMZ.c:
* generic/tclCmdIL.c: Changed to use new regexp interfaces. Added
-expanded, -line, -linestop, and -lineanchor switches to regsub.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/regexp.test | 51 |
1 files changed, 37 insertions, 14 deletions
diff --git a/tests/regexp.test b/tests/regexp.test index c6c5b40..781cf24 100644 --- a/tests/regexp.test +++ b/tests/regexp.test @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: regexp.test,v 1.5 1999/05/22 01:20:14 stanton Exp $ +# RCS: @(#) $Id: regexp.test,v 1.6 1999/06/17 19:31:50 stanton Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { source [file join [pwd] [file dirname [info script]] defs.tcl] @@ -317,35 +317,56 @@ test regexp-9.6 {-all option to regsub} { list [regsub -all ^ xxx 123 foo] $foo } {1 123xxx} -test regexp-10.1 {regsub errors} { +test regexp-10.1 {expanded syntax in regsub} { + set foo xxx + list [regsub -expanded ". \#comment\n . \#comment2" abc def foo] $foo +} {1 defc} +test regexp-10.2 {newline sensitivity in regsub} { + set foo xxx + list [regsub -line {^a.*b$} "dabc\naxyb\n" 123 foo] $foo +} "1 {dabc\n123\n}" +test regexp-10.3 {newline sensitivity in regsub} { + set foo xxx + list [regsub -line {^a.*b$} "dabc\naxyb\nxb" 123 foo] $foo +} "1 {dabc\n123\nxb}" +test regexp-10.4 {partial newline sensitivity in regsub} { + set foo xxx + list [regsub -lineanchor {^a.*b$} "da\naxyb\nxb" 123 foo] $foo +} "1 {da\n123}" +test regexp-10.5 {inverse partial newline sensitivity in regsub} { + set foo xxx + list [regsub -linestop {a.*b} "da\nbaxyb\nxb" 123 foo] $foo +} "1 {da\nb123\nxb}" + +test regexp-11.1 {regsub errors} { list [catch {regsub a b c} msg] $msg } {1 {wrong # args: should be "regsub ?switches? exp string subSpec varName"}} -test regexp-10.2 {regsub errors} { +test regexp-11.2 {regsub errors} { list [catch {regsub -nocase a b c} msg] $msg } {1 {wrong # args: should be "regsub ?switches? exp string subSpec varName"}} -test regexp-10.3 {regsub errors} { +test regexp-11.3 {regsub errors} { list [catch {regsub -nocase -all a b c} msg] $msg } {1 {wrong # args: should be "regsub ?switches? exp string subSpec varName"}} -test regexp-10.4 {regsub errors} { +test regexp-11.4 {regsub errors} { list [catch {regsub a b c d e f} msg] $msg } {1 {wrong # args: should be "regsub ?switches? exp string subSpec varName"}} -test regexp-10.5 {regsub errors} { +test regexp-11.5 {regsub errors} { list [catch {regsub -gorp a b c} msg] $msg -} {1 {bad switch "-gorp": must be -all, -nocase, or --}} -test regexp-10.6 {regsub errors} { +} {1 {bad switch "-gorp": must be -all, -nocase, -expanded, -line, -linestop, -lineanchor, or --}} +test regexp-11.6 {regsub errors} { list [catch {regsub -nocase a( b c d} msg] $msg } {1 {couldn't compile regular expression pattern: parentheses () not balanced}} -test regexp-10.7 {regsub errors} { +test regexp-11.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} { +test regexp-12.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} -test regexp-12.1 {regsub of a very large string} { +test regexp-13.1 {regsub of a very large string} { # This test is designed to stress the memory subsystem in order # to catch Bug #933. It only fails if the Tcl memory allocator # is in use. @@ -361,7 +382,7 @@ test regexp-12.1 {regsub of a very large string} { set x done } {done} -test regexp-13.1 {CompileRegexp: regexp cache} { +test regexp-14.1 {CompileRegexp: regexp cache} { regexp .*a b regexp .*b c regexp .*c d @@ -371,7 +392,7 @@ test regexp-13.1 {CompileRegexp: regexp cache} { append x *a regexp $x bbba } 1 -test regexp-13.2 {CompileRegexp: regexp cache, different flags} { +test regexp-14.2 {CompileRegexp: regexp cache, different flags} { regexp .*a b regexp .*b c regexp .*c d @@ -381,7 +402,7 @@ test regexp-13.2 {CompileRegexp: regexp cache, different flags} { append x *a regexp -nocase $x bbba } 1 -test regexp-13.3 {CompileRegexp: regexp cache, empty regexp and empty cache} { +test regexp-14.3 {CompileRegexp: regexp cache, empty regexp and empty cache} { makeFile {puts [regexp {} foo]} junk.tcl exec $tcltest junk.tcl } 1 @@ -405,3 +426,5 @@ return + + |