diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2004-05-19 20:15:29 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2004-05-19 20:15:29 (GMT) |
commit | e52d9cbf151b4d4106c36834e820db9442ec9a3b (patch) | |
tree | b07002700fcbcc6b4ed86c424196b744184971a1 /tests/stringObj.test | |
parent | cc56afda247802cb646330c25f3f03db20b1a43d (diff) | |
download | tcl-e52d9cbf151b4d4106c36834e820db9442ec9a3b.zip tcl-e52d9cbf151b4d4106c36834e820db9442ec9a3b.tar.gz tcl-e52d9cbf151b4d4106c36834e820db9442ec9a3b.tar.bz2 |
Massive test cleanup; all tests are run, and constraints are used where necessary.
Diffstat (limited to 'tests/stringObj.test')
-rw-r--r-- | tests/stringObj.test | 131 |
1 files changed, 64 insertions, 67 deletions
diff --git a/tests/stringObj.test b/tests/stringObj.test index e3bdbee..90ec9c3 100644 --- a/tests/stringObj.test +++ b/tests/stringObj.test @@ -12,27 +12,22 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: stringObj.test,v 1.15 2003/02/11 18:46:33 hobbs Exp $ +# RCS: @(#) $Id: stringObj.test,v 1.16 2004/05/19 20:15:32 dkf Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest namespace import -force ::tcltest::* } -if {[info commands testobj] == {}} { - puts "This application hasn't been compiled with the \"testobj\"" - puts "command, so I can't test the Tcl type and object support." - ::tcltest::cleanupTests - return -} +testConstraint testobj [llength [info commands testobj]] -test stringObj-1.1 {string type registration} { +test stringObj-1.1 {string type registration} testobj { set t [testobj types] set first [string first "string" $t] set result [expr {$first != -1}] } {1} -test stringObj-2.1 {Tcl_NewStringObj} { +test stringObj-2.1 {Tcl_NewStringObj} testobj { set result "" lappend result [testobj freeallvars] lappend result [teststringobj set 1 abcd] @@ -40,7 +35,7 @@ test stringObj-2.1 {Tcl_NewStringObj} { lappend result [testobj refcount 1] } {{} abcd string 2} -test stringObj-3.1 {Tcl_SetStringObj, existing "empty string" object} { +test stringObj-3.1 {Tcl_SetStringObj, existing "empty string" object} testobj { set result "" lappend result [testobj freeallvars] lappend result [testobj newobj 1] @@ -48,7 +43,7 @@ test stringObj-3.1 {Tcl_SetStringObj, existing "empty string" object} { lappend result [testobj type 1] lappend result [testobj refcount 1] } {{} {} xyz string 2} -test stringObj-3.2 {Tcl_SetStringObj, existing non-"empty string" object} { +test stringObj-3.2 {Tcl_SetStringObj, existing non-"empty string" object} testobj { set result "" lappend result [testobj freeallvars] lappend result [testintobj set 1 512] @@ -57,47 +52,47 @@ test stringObj-3.2 {Tcl_SetStringObj, existing non-"empty string" object} { lappend result [testobj refcount 1] } {{} 512 foo string 2} -test stringObj-4.1 {Tcl_SetObjLength procedure, string gets shorter} { +test stringObj-4.1 {Tcl_SetObjLength procedure, string gets shorter} testobj { testobj freeallvars teststringobj set 1 test teststringobj setlength 1 3 list [teststringobj length 1] [teststringobj length2 1] \ [teststringobj get 1] } {3 4 tes} -test stringObj-4.2 {Tcl_SetObjLength procedure, string gets longer} { +test stringObj-4.2 {Tcl_SetObjLength procedure, string gets longer} testobj { testobj freeallvars teststringobj set 1 abcdef teststringobj setlength 1 10 list [teststringobj length 1] [teststringobj length2 1] } {10 10} -test stringObj-4.3 {Tcl_SetObjLength procedure, string gets longer} { +test stringObj-4.3 {Tcl_SetObjLength procedure, string gets longer} testobj { testobj freeallvars teststringobj set 1 abcdef teststringobj append 1 xyzq -1 list [teststringobj length 1] [teststringobj length2 1] \ [teststringobj get 1] } {10 20 abcdefxyzq} -test stringObj-4.4 {Tcl_SetObjLength procedure, "expty string", length 0} { +test stringObj-4.4 {Tcl_SetObjLength procedure, "expty string", length 0} testobj { testobj freeallvars testobj newobj 1 teststringobj setlength 1 0 list [teststringobj length2 1] [teststringobj get 1] } {0 {}} -test stringObj-5.1 {Tcl_AppendToObj procedure, type conversion} { +test stringObj-5.1 {Tcl_AppendToObj procedure, type conversion} testobj { testobj freeallvars testintobj set2 1 43 teststringobj append 1 xyz -1 teststringobj get 1 } {43xyz} -test stringObj-5.2 {Tcl_AppendToObj procedure, length calculation} { +test stringObj-5.2 {Tcl_AppendToObj procedure, length calculation} testobj { testobj freeallvars teststringobj set 1 {x y } teststringobj append 1 bbCCddEE 4 teststringobj append 1 123 -1 teststringobj get 1 } {x y bbCC123} -test stringObj-5.3 {Tcl_AppendToObj procedure, reallocating space} { +test stringObj-5.3 {Tcl_AppendToObj procedure, reallocating space} testobj { testobj freeallvars teststringobj set 1 xyz teststringobj setlength 1 15 @@ -111,37 +106,37 @@ test stringObj-5.3 {Tcl_AppendToObj procedure, reallocating space} { [teststringobj get 1] } {15 15 16 32 xy12345678abcdef} -test stringObj-6.1 {Tcl_AppendStringsToObj procedure, type conversion} { +test stringObj-6.1 {Tcl_AppendStringsToObj procedure, type conversion} testobj { testobj freeallvars teststringobj set2 1 [list a b] teststringobj appendstrings 1 xyz { 1234 } foo teststringobj get 1 } {a bxyz 1234 foo} -test stringObj-6.2 {Tcl_AppendStringsToObj procedure, counting space} { +test stringObj-6.2 {Tcl_AppendStringsToObj procedure, counting space} testobj { testobj freeallvars teststringobj set 1 abc teststringobj appendstrings 1 list [teststringobj length 1] [teststringobj get 1] } {3 abc} -test stringObj-6.3 {Tcl_AppendStringsToObj procedure, counting space} { +test stringObj-6.3 {Tcl_AppendStringsToObj procedure, counting space} testobj { testobj freeallvars teststringobj set 1 abc teststringobj appendstrings 1 {} {} {} {} list [teststringobj length 1] [teststringobj get 1] } {3 abc} -test stringObj-6.4 {Tcl_AppendStringsToObj procedure, counting space} { +test stringObj-6.4 {Tcl_AppendStringsToObj procedure, counting space} testobj { testobj freeallvars teststringobj set 1 abc teststringobj appendstrings 1 { 123 } abcdefg list [teststringobj length 1] [teststringobj get 1] } {15 {abc 123 abcdefg}} -test stringObj-6.5 {Tcl_AppendStringsToObj procedure, don't double space if initial string empty} { +test stringObj-6.5 {Tcl_AppendStringsToObj procedure, don't double space if initial string empty} testobj { testobj freeallvars testobj newobj 1 teststringobj appendstrings 1 123 abcdefg list [teststringobj length 1] [teststringobj length2 1] [teststringobj get 1] } {10 10 123abcdefg} -test stringObj-6.6 {Tcl_AppendStringsToObj procedure, space reallocation} { +test stringObj-6.6 {Tcl_AppendStringsToObj procedure, space reallocation} testobj { testobj freeallvars teststringobj set 1 abc teststringobj setlength 1 10 @@ -150,7 +145,7 @@ test stringObj-6.6 {Tcl_AppendStringsToObj procedure, space reallocation} { list [teststringobj length 1] [teststringobj length2 1] \ [teststringobj get 1] } {10 10 ab34567890} -test stringObj-6.7 {Tcl_AppendStringsToObj procedure, space reallocation} { +test stringObj-6.7 {Tcl_AppendStringsToObj procedure, space reallocation} testobj { testobj freeallvars teststringobj set 1 abc teststringobj setlength 1 10 @@ -159,39 +154,39 @@ test stringObj-6.7 {Tcl_AppendStringsToObj procedure, space reallocation} { list [teststringobj length 1] [teststringobj length2 1] \ [teststringobj get 1] } {11 22 ab34567890x} -test stringObj-6.8 {Tcl_AppendStringsToObj procedure, object totally empty} { +test stringObj-6.8 {Tcl_AppendStringsToObj procedure, object totally empty} testobj { testobj freeallvars testobj newobj 1 teststringobj appendstrings 1 {} list [teststringobj length2 1] [teststringobj get 1] } {0 {}} -test stringObj-7.1 {SetStringFromAny procedure} { +test stringObj-7.1 {SetStringFromAny procedure} testobj { testobj freeallvars teststringobj set2 1 [list a b] teststringobj append 1 x -1 list [teststringobj length 1] [teststringobj length2 1] \ [teststringobj get 1] } {4 8 {a bx}} -test stringObj-7.2 {SetStringFromAny procedure, null object} { +test stringObj-7.2 {SetStringFromAny procedure, null object} testobj { testobj freeallvars testobj newobj 1 teststringobj appendstrings 1 {} list [teststringobj length 1] [teststringobj length2 1] \ [teststringobj get 1] } {0 0 {}} -test stringObj-7.3 {SetStringFromAny called with non-string obj} { +test stringObj-7.3 {SetStringFromAny called with non-string obj} testobj { set x 2345 list [incr x] [testobj objtype $x] [string index $x end] \ [testobj objtype $x] } {2346 int 6 string} -test stringObj-7.4 {SetStringFromAny called with string obj} { +test stringObj-7.4 {SetStringFromAny called with string obj} testobj { set x "abcdef" list [string length $x] [testobj objtype $x] \ [string length $x] [testobj objtype $x] } {6 string 6 string} -test stringObj-8.1 {DupStringInternalRep procedure} { +test stringObj-8.1 {DupStringInternalRep procedure} testobj { testobj freeallvars teststringobj set 1 {} teststringobj append 1 abcde -1 @@ -201,28 +196,28 @@ test stringObj-8.1 {DupStringInternalRep procedure} { [teststringobj length 2] [teststringobj length2 2] \ [teststringobj ualloc 2] [teststringobj get 2] } {5 10 0 abcde 5 5 0 abcde} -test stringObj-8.2 {DupUnicodeInternalRep, mixed width chars} { +test stringObj-8.2 {DupUnicodeInternalRep, mixed width chars} testobj { set x abcï¿®ghi string length $x set y $x list [testobj objtype $x] [testobj objtype $y] [append x "®¿ï"] \ [set y] [testobj objtype $x] [testobj objtype $y] } {string string abcï¿®ghi®¿ï abcï¿®ghi string string} -test stringObj-8.3 {DupUnicodeInternalRep, mixed width chars} { +test stringObj-8.3 {DupUnicodeInternalRep, mixed width chars} testobj { set x abcï¿®ghi set y $x string length $x list [testobj objtype $x] [testobj objtype $y] [append x "®¿ï"] \ [set y] [testobj objtype $x] [testobj objtype $y] } {string string abcï¿®ghi®¿ï abcï¿®ghi string string} -test stringObj-8.4 {DupUnicodeInternalRep, all byte-size chars} { +test stringObj-8.4 {DupUnicodeInternalRep, all byte-size chars} testobj { set x abcdefghi string length $x set y $x list [testobj objtype $x] [testobj objtype $y] [append x jkl] \ [set y] [testobj objtype $x] [testobj objtype $y] } {string string abcdefghijkl abcdefghi string string} -test stringObj-8.5 {DupUnicodeInternalRep, all byte-size chars} { +test stringObj-8.5 {DupUnicodeInternalRep, all byte-size chars} testobj { set x abcdefghi set y $x string length $x @@ -230,14 +225,14 @@ test stringObj-8.5 {DupUnicodeInternalRep, all byte-size chars} { [set y] [testobj objtype $x] [testobj objtype $y] } {string string abcdefghijkl abcdefghi string string} -test stringObj-9.1 {TclAppendObjToObj, mixed src & dest} { +test stringObj-9.1 {TclAppendObjToObj, mixed src & dest} testobj { set x abcï¿®ghi set y ®¿ï string length $x list [testobj objtype $x] [testobj objtype $y] [append x $y] \ [set y] [testobj objtype $x] [testobj objtype $y] } {string none abcï¿®ghi®¿ï ®¿ï string none} -test stringObj-9.2 {TclAppendObjToObj, mixed src & dest} { +test stringObj-9.2 {TclAppendObjToObj, mixed src & dest} testobj { set x abcï¿®ghi string length $x list [testobj objtype $x] [append x $x] [testobj objtype $x] \ @@ -245,61 +240,61 @@ test stringObj-9.2 {TclAppendObjToObj, mixed src & dest} { } {string abcï¿®ghiabcï¿®ghi string\ abcï¿®ghiabcï¿®ghiabcï¿®ghiabcï¿®ghi\ string} -test stringObj-9.3 {TclAppendObjToObj, mixed src & 1-byte dest} { +test stringObj-9.3 {TclAppendObjToObj, mixed src & 1-byte dest} testobj { set x abcdefghi set y ®¿ï string length $x list [testobj objtype $x] [testobj objtype $y] [append x $y] \ [set y] [testobj objtype $x] [testobj objtype $y] } {string none abcdefghi®¿ï ®¿ï string none} -test stringObj-9.4 {TclAppendObjToObj, 1-byte src & dest} { +test stringObj-9.4 {TclAppendObjToObj, 1-byte src & dest} testobj { set x abcdefghi set y jkl string length $x list [testobj objtype $x] [testobj objtype $y] [append x $y] \ [set y] [testobj objtype $x] [testobj objtype $y] } {string none abcdefghijkl jkl string none} -test stringObj-9.5 {TclAppendObjToObj, 1-byte src & dest} { +test stringObj-9.5 {TclAppendObjToObj, 1-byte src & dest} testobj { set x abcdefghi string length $x list [testobj objtype $x] [append x $x] [testobj objtype $x] \ [append x $x] [testobj objtype $x] } {string abcdefghiabcdefghi string abcdefghiabcdefghiabcdefghiabcdefghi\ string} -test stringObj-9.6 {TclAppendObjToObj, 1-byte src & mixed dest} { +test stringObj-9.6 {TclAppendObjToObj, 1-byte src & mixed dest} testobj { set x abcï¿®ghi set y jkl string length $x list [testobj objtype $x] [testobj objtype $y] [append x $y] \ [set y] [testobj objtype $x] [testobj objtype $y] } {string none abcï¿®ghijkl jkl string none} -test stringObj-9.7 {TclAppendObjToObj, integer src & dest} { +test stringObj-9.7 {TclAppendObjToObj, integer src & dest} testobj { set x [expr {4 * 5}] set y [expr {4 + 5}] list [testobj objtype $x] [testobj objtype $y] [append x $y] \ [testobj objtype $x] [append x $y] [testobj objtype $x] \ [testobj objtype $y] } {int int 209 string 2099 string int} -test stringObj-9.8 {TclAppendObjToObj, integer src & dest} { +test stringObj-9.8 {TclAppendObjToObj, integer src & dest} testobj { set x [expr {4 * 5}] list [testobj objtype $x] [append x $x] [testobj objtype $x] \ [append x $x] [testobj objtype $x] } {int 2020 string 20202020 string} -test stringObj-9.9 {TclAppendObjToObj, integer src & 1-byte dest} { +test stringObj-9.9 {TclAppendObjToObj, integer src & 1-byte dest} testobj { set x abcdefghi set y [expr {4 + 5}] string length $x list [testobj objtype $x] [testobj objtype $y] [append x $y] \ [set y] [testobj objtype $x] [testobj objtype $y] } {string int abcdefghi9 9 string int} -test stringObj-9.10 {TclAppendObjToObj, integer src & mixed dest} { +test stringObj-9.10 {TclAppendObjToObj, integer src & mixed dest} testobj { set x abcï¿®ghi set y [expr {4 + 5}] string length $x list [testobj objtype $x] [testobj objtype $y] [append x $y] \ [set y] [testobj objtype $x] [testobj objtype $y] } {string int abcï¿®ghi9 9 string int} -test stringObj-9.11 {TclAppendObjToObj, mixed src & 1-byte dest index check} { +test stringObj-9.11 {TclAppendObjToObj, mixed src & 1-byte dest index check} testobj { # bug 2678, in <=8.2.0, the second obj (the one to append) in # Tcl_AppendObjToObj was not correctly checked to see if it was # all one byte chars, so a unicode string would be added as one @@ -317,12 +312,12 @@ test stringObj-9.11 {TclAppendObjToObj, mixed src & 1-byte dest index check} { set q } {a b c d e f a ü b å c ï} -test stringObj-10.1 {Tcl_GetRange with all byte-size chars} { +test stringObj-10.1 {Tcl_GetRange with all byte-size chars} testobj { set x "abcdef" list [testobj objtype $x] [set y [string range $x 1 end-1]] \ [testobj objtype $x] [testobj objtype $y] } [list none bcde string string] -test stringObj-10.2 {Tcl_GetRange with some mixed width chars} { +test stringObj-10.2 {Tcl_GetRange with some mixed width chars} testobj { # Because this test does not use \uXXXX notation below instead of # hardcoding the values, it may fail in multibyte locales. However, # we need to test that the parser produces untyped objects even when there @@ -332,7 +327,7 @@ test stringObj-10.2 {Tcl_GetRange with some mixed width chars} { list [testobj objtype $x] [set y [string range $x 1 end-1]] \ [testobj objtype $x] [testobj objtype $y] } [list none "bc\u00EF\u00EFde" string string] -test stringObj-10.3 {Tcl_GetRange with some mixed width chars} { +test stringObj-10.3 {Tcl_GetRange with some mixed width chars} testobj { # set x "abcïïdef" # Use \uXXXX notation below instead of hardcoding the values, otherwise # the test will fail in multibyte locales. @@ -341,7 +336,7 @@ test stringObj-10.3 {Tcl_GetRange with some mixed width chars} { list [testobj objtype $x] [set y [string range $x 1 end-1]] \ [testobj objtype $x] [testobj objtype $y] } [list string "bc\u00EF\u00EFde" string string] -test stringObj-10.4 {Tcl_GetRange with some mixed width chars} { +test stringObj-10.4 {Tcl_GetRange with some mixed width chars} testobj { # set a "ïa¿b®cï¿d®" # Use \uXXXX notation below instead of hardcoding the values, otherwise # the test will fail in multibyte locales. @@ -358,71 +353,71 @@ test stringObj-10.4 {Tcl_GetRange with some mixed width chars} { \u00AEc \ {}] -test stringObj-11.1 {UpdateStringOfString} { +test stringObj-11.1 {UpdateStringOfString} testobj { set x 2345 list [string index $x end] [testobj objtype $x] [incr x] \ [testobj objtype $x] } {5 string 2346 int} -test stringObj-12.1 {Tcl_GetUniChar with byte-size chars} { +test stringObj-12.1 {Tcl_GetUniChar with byte-size chars} testobj { set x "abcdefghi" list [string index $x 0] [string index $x 1] } {a b} -test stringObj-12.2 {Tcl_GetUniChar with byte-size chars} { +test stringObj-12.2 {Tcl_GetUniChar with byte-size chars} testobj { set x "abcdefghi" list [string index $x 3] [string index $x end] } {d i} -test stringObj-12.3 {Tcl_GetUniChar with byte-size chars} { +test stringObj-12.3 {Tcl_GetUniChar with byte-size chars} testobj { set x "abcdefghi" list [string index $x end] [string index $x end-1] } {i h} -test stringObj-12.4 {Tcl_GetUniChar with mixed width chars} { +test stringObj-12.4 {Tcl_GetUniChar with mixed width chars} testobj { string index "ïa¿b®c®¿dï" 0 } "ï" -test stringObj-12.5 {Tcl_GetUniChar} { +test stringObj-12.5 {Tcl_GetUniChar} testobj { set x "ïa¿b®c®¿dï" list [string index $x 4] [string index $x 0] } {® ï} -test stringObj-12.6 {Tcl_GetUniChar} { +test stringObj-12.6 {Tcl_GetUniChar} testobj { string index "ïa¿b®cï¿d®" end } "®" -test stringObj-13.1 {Tcl_GetCharLength with byte-size chars} { +test stringObj-13.1 {Tcl_GetCharLength with byte-size chars} testobj { set a "" list [string length $a] [string length $a] } {0 0} -test stringObj-13.2 {Tcl_GetCharLength with byte-size chars} { +test stringObj-13.2 {Tcl_GetCharLength with byte-size chars} testobj { string length "a" } 1 -test stringObj-13.3 {Tcl_GetCharLength with byte-size chars} { +test stringObj-13.3 {Tcl_GetCharLength with byte-size chars} testobj { set a "abcdef" list [string length $a] [string length $a] } {6 6} -test stringObj-13.4 {Tcl_GetCharLength with mixed width chars} { +test stringObj-13.4 {Tcl_GetCharLength with mixed width chars} testobj { string length "®" } 1 -test stringObj-13.5 {Tcl_GetCharLength with mixed width chars} { +test stringObj-13.5 {Tcl_GetCharLength with mixed width chars} testobj { # string length "○○" # Use \uXXXX notation below instead of hardcoding the values, otherwise # the test will fail in multibyte locales. string length "\u00EF\u00BF\u00AE\u00EF\u00BF\u00AE" } 6 -test stringObj-13.6 {Tcl_GetCharLength with mixed width chars} { +test stringObj-13.6 {Tcl_GetCharLength with mixed width chars} testobj { # set a "ïa¿b®cï¿d®" # Use \uXXXX notation below instead of hardcoding the values, otherwise # the test will fail in multibyte locales. set a "\u00EFa\u00BFb\u00AEc\u00EF\u00BFd\u00AE" list [string length $a] [string length $a] } {10 10} -test stringObj-13.7 {Tcl_GetCharLength with identity nulls} { +test stringObj-13.7 {Tcl_GetCharLength with identity nulls} testobj { # SF bug #684699 string length [encoding convertfrom identity \x00] } 1 -test stringObj-13.8 {Tcl_GetCharLength with identity nulls} { +test stringObj-13.8 {Tcl_GetCharLength with identity nulls} testobj { string length [encoding convertfrom identity \x01\x00\x02] } 3 -test stringObj-14.1 {Tcl_SetObjLength on pure unicode object} { +test stringObj-14.1 {Tcl_SetObjLength on pure unicode object} testobj { teststringobj set 1 foo teststringobj getunicode 1 teststringobj append 1 bar -1 @@ -433,7 +428,9 @@ test stringObj-14.1 {Tcl_SetObjLength on pure unicode object} { teststringobj get 1 } {bar} -testobj freeallvars +if {[testConstraint testobj]} { + testobj freeallvars +} # cleanup ::tcltest::cleanupTests |