diff options
Diffstat (limited to 'tests/stringComp.test')
-rw-r--r-- | tests/stringComp.test | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/tests/stringComp.test b/tests/stringComp.test index 30a89db..cf22346 100644 --- a/tests/stringComp.test +++ b/tests/stringComp.test @@ -15,7 +15,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: stringComp.test,v 1.6.2.1 2004/10/28 00:01:12 dgp Exp $ +# RCS: @(#) $Id: stringComp.test,v 1.15 2007/12/13 15:26:07 dgp Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -24,17 +24,16 @@ if {[lsearch [namespace children] ::tcltest] == -1} { # Some tests require the testobj command -set ::tcltest::testConstraints(testobj) \ - [expr {[info commands testobj] != {}}] +testConstraint testobj [expr {[info commands testobj] != {}}] test stringComp-1.1 {error conditions} { proc foo {} {string gorp a b} list [catch {foo} msg] $msg -} {1 {bad option "gorp": must be bytelength, compare, equal, first, index, is, last, length, map, match, range, repeat, replace, tolower, toupper, totitle, trim, trimleft, trimright, wordend, or wordstart}} +} {1 {unknown or ambiguous subcommand "gorp": must be bytelength, compare, equal, first, index, is, last, length, map, match, range, repeat, replace, reverse, tolower, totitle, toupper, trim, trimleft, trimright, wordend, or wordstart}} test stringComp-1.2 {error conditions} { proc foo {} {string} list [catch {foo} msg] $msg -} {1 {wrong # args: should be "string option arg ?arg ...?"}} +} {1 {wrong # args: should be "string subcommand ?argument ...?"}} test stringComp-1.3 {error condition - undefined method during compile} { # We don't want this to complain about 'never' because it may never # be called, or string may get redefined. This must compile OK. @@ -223,15 +222,15 @@ test stringComp-3.8 {string equal with length, unequal strings} { test stringComp-4.1 {string first, too few args} { proc foo {} {string first a} list [catch {foo} msg] $msg -} {1 {wrong # args: should be "string first subString string ?startIndex?"}} +} {1 {wrong # args: should be "string first needleString haystackString ?startIndex?"}} test stringComp-4.2 {string first, bad args} { proc foo {} {string first a b c} list [catch {foo} msg] $msg -} {1 {bad index "c": must be integer or end?-integer?}} +} {1 {bad index "c": must be integer?[+-]integer? or end?[+-]integer?}} test stringComp-4.3 {string first, too many args} { proc foo {} {string first a b 5 d} list [catch {foo} msg] $msg -} {1 {wrong # args: should be "string first subString string ?startIndex?"}} +} {1 {wrong # args: should be "string first needleString haystackString ?startIndex?"}} test stringComp-4.4 {string first} { proc foo {} {string first bq abcdefgbcefgbqrs} foo @@ -304,7 +303,7 @@ test stringComp-5.6 {string index} { test stringComp-5.7 {string index} { proc foo {} {string index a xyz} list [catch {foo} msg] $msg -} {1 {bad index "xyz": must be integer or end?-integer?}} +} {1 {bad index "xyz": must be integer?[+-]integer? or end?[+-]integer?}} test stringComp-5.8 {string index} { proc foo {} {string index abc end} foo @@ -350,14 +349,14 @@ test stringComp-5.16 {string index, bytearray object with string obj shimmering} } foo } 0 -test stringComp-5.17 {string index, bad integer} { - proc foo {} {string index "abc" 08} +test stringComp-5.17 {string index, bad integer} -body { + proc foo {} {string index "abc" 0o8} list [catch {foo} msg] $msg -} {1 {bad index "08": must be integer or end?-integer? (looks like invalid octal number)}} -test stringComp-5.18 {string index, bad integer} { - proc foo {} {string index "abc" end-00289} +} -match glob -result {1 {*invalid octal number*}} +test stringComp-5.18 {string index, bad integer} -body { + proc foo {} {string index "abc" end-0o0289} list [catch {foo} msg] $msg -} {1 {bad index "end-00289": must be integer or end?-integer? (looks like invalid octal number)}} +} -match glob -result {1 {*invalid octal number*}} test stringComp-5.19 {string index, bytearray object out of bounds} { proc foo {} {string index [binary format I* {0x50515253 0x52}] -1} foo |