diff options
author | Kevin B Kenny <kennykb@acm.org> | 2007-05-04 14:59:06 (GMT) |
---|---|---|
committer | Kevin B Kenny <kennykb@acm.org> | 2007-05-04 14:59:06 (GMT) |
commit | 45ba16a3055b23da16e3275473875be2d863443e (patch) | |
tree | 6b08e2b80a6ce52cf0aee7b58f37d945387ceb74 /tests/encoding.test | |
parent | 97fe528dbd35dd9aa9d10366f9d9c6a5b6a45a87 (diff) | |
download | tcl-45ba16a3055b23da16e3275473875be2d863443e.zip tcl-45ba16a3055b23da16e3275473875be2d863443e.tar.gz tcl-45ba16a3055b23da16e3275473875be2d863443e.tar.bz2 |
* tests/encoding.test: Modified so that encoding tests happen
in a private namespace, to avoid polluting the global one. This
problem was discovered when running the test suite '-singleproc 1
-skip exec.test' because the 'path' variable in encoding.test
conflicted with the one in io.test.
* tests/io.test: Made more of the working variables private to the
namespace.
Diffstat (limited to 'tests/encoding.test')
-rw-r--r-- | tests/encoding.test | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/tests/encoding.test b/tests/encoding.test index 36eb475..a11f5cd 100644 --- a/tests/encoding.test +++ b/tests/encoding.test @@ -8,20 +8,28 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: encoding.test,v 1.26 2006/11/03 00:34:52 hobbs Exp $ +# RCS: @(#) $Id: encoding.test,v 1.27 2007/05/04 14:59:06 kennykb Exp $ package require tcltest 2 + +namespace eval ::tcl::test::encoding { + variable x + namespace import -force ::tcltest::* proc toutf {args} { - global x + variable x lappend x "toutf $args" } proc fromutf {args} { - global x + variable x lappend x "fromutf $args" } +proc runtests {} { + + variable x + # Some tests require the testencoding command testConstraint testencoding [llength [info commands testencoding]] testConstraint exec [llength [info commands exec]] @@ -30,7 +38,7 @@ testConstraint exec [llength [info commands exec]] # TclFinalizeEncodingSubsystem is not currently tested test encoding-1.1 {Tcl_GetEncoding: system encoding} {testencoding} { - testencoding create foo toutf fromutf + testencoding create foo [namespace origin toutf] [namespace origin fromutf] set old [encoding system] encoding system foo set x {} @@ -40,7 +48,7 @@ test encoding-1.1 {Tcl_GetEncoding: system encoding} {testencoding} { set x } {{fromutf }} test encoding-1.2 {Tcl_GetEncoding: existing encoding} {testencoding} { - testencoding create foo toutf fromutf + testencoding create foo [namespace origin toutf] [namespace origin fromutf] set x {} encoding convertto foo abcd testencoding delete foo @@ -125,7 +133,8 @@ test encoding-5.2 {Tcl_SetSystemEncoding: test ref count} { } {0} test encoding-6.1 {Tcl_CreateEncoding: new} {testencoding} { - testencoding create foo {toutf 1} {fromutf 2} + testencoding create foo [namespace code {toutf 1}] \ + [namespace code {fromutf 2}] set x {} encoding convertfrom foo abcd encoding convertto foo abcd @@ -133,7 +142,8 @@ test encoding-6.1 {Tcl_CreateEncoding: new} {testencoding} { set x } {{toutf 1} {fromutf 2}} test encoding-6.2 {Tcl_CreateEncoding: replace encoding} {testencoding} { - testencoding create foo {toutf a} {fromutf b} + testencoding create foo [namespace code {toutf a}] \ + [namespace code {fromutf b}] set x {} encoding convertfrom foo abcd encoding convertto foo abcd @@ -329,14 +339,14 @@ test encoding-21.1 {EscapeToUtfProc} { test encoding-22.1 {EscapeFromUtfProc} { } {} -set ::iso2022encData "\u001b\$B;d\$I\$b\$G\$O!\"%A%C%W\$49XF~;~\$K\$4EPO?\$\$\$?\$@\$\$\$?\$4=;=j\$r%-%c%C%7%e%\"%&%H\$N:]\$N\u001b(B +set iso2022encData "\u001b\$B;d\$I\$b\$G\$O!\"%A%C%W\$49XF~;~\$K\$4EPO?\$\$\$?\$@\$\$\$?\$4=;=j\$r%-%c%C%7%e%\"%&%H\$N:]\$N\u001b(B \u001b\$B>.@Z<jAwIU@h\$H\$7\$F;HMQ\$7\$F\$*\$j\$^\$9!#62\$lF~\$j\$^\$9\$,!\"@5\$7\$\$=;=j\$r\$4EPO?\$7\$J\$*\u001b(B \u001b\$B\$*4j\$\$\$\$\$?\$7\$^\$9!#\$^\$?!\"BgJQ62=L\$G\$9\$,!\"=;=jJQ99\$N\$\"\$H!\"F|K\\8l%5!<%S%9It!J\u001b(B casino_japanese@___.com \u001b\$B!K\$^\$G\$4=;=jJQ99:Q\$NO\"Mm\$r\$\$\$?\$@\$1\$J\$\$\$G\u001b(B \u001b\$B\$7\$g\$&\$+!)\u001b(B" -set ::iso2022uniData [encoding convertfrom iso2022-jp $::iso2022encData] -set ::iso2022uniData2 "\u79c1\u3069\u3082\u3067\u306f\u3001\u30c1\u30c3\u30d7\u3054\u8cfc\u5165\u6642\u306b\u3054\u767b\u9332\u3044\u305f\u3060\u3044\u305f\u3054\u4f4f\u6240\u3092\u30ad\u30e3\u30c3\u30b7\u30e5\u30a2\u30a6\u30c8\u306e\u969b\u306e +set iso2022uniData [encoding convertfrom iso2022-jp $iso2022encData] +set iso2022uniData2 "\u79c1\u3069\u3082\u3067\u306f\u3001\u30c1\u30c3\u30d7\u3054\u8cfc\u5165\u6642\u306b\u3054\u767b\u9332\u3044\u305f\u3060\u3044\u305f\u3054\u4f4f\u6240\u3092\u30ad\u30e3\u30c3\u30b7\u30e5\u30a2\u30a6\u30c8\u306e\u969b\u306e \u5c0f\u5207\u624b\u9001\u4ed8\u5148\u3068\u3057\u3066\u4f7f\u7528\u3057\u3066\u304a\u308a\u307e\u3059\u3002\u6050\u308c\u5165\u308a\u307e\u3059\u304c\u3001\u6b63\u3057\u3044\u4f4f\u6240\u3092\u3054\u767b\u9332\u3057\u306a\u304a \u304a\u9858\u3044\u3044\u305f\u3057\u307e\u3059\u3002\u307e\u305f\u3001\u5927\u5909\u6050\u7e2e\u3067\u3059\u304c\u3001\u4f4f\u6240\u5909\u66f4\u306e\u3042\u3068\u3001\u65e5\u672c\u8a9e\u30b5\u30fc\u30d3\u30b9\u90e8\uff08 \u0063\u0061\u0073\u0069\u006e\u006f\u005f\u006a\u0061\u0070\u0061\u006e\u0065\u0073\u0065\u0040\u005f\u005f\u005f\u002e\u0063\u006f\u006d\u0020\uff09\u307e\u3067\u3054\u4f4f\u6240\u5909\u66f4\u6e08\u306e\u9023\u7d61\u3092\u3044\u305f\u3060\u3051\u306a\u3044\u3067 @@ -345,11 +355,11 @@ set ::iso2022uniData2 "\u79c1\u3069\u3082\u3067\u306f\u3001\u30c1\u30c3\u30d7\u3 cd [temporaryDirectory] set fid [open iso2022.txt w] fconfigure $fid -encoding binary -puts -nonewline $fid $::iso2022encData +puts -nonewline $fid $iso2022encData close $fid test encoding-23.1 {iso2022-jp escape encoding test} { - string equal $::iso2022uniData $::iso2022uniData2 + string equal $iso2022uniData $iso2022uniData2 } 1 test encoding-23.2 {iso2022-jp escape encoding test} { # This checks that 'gets' isn't resetting the encoding inappropriately. @@ -367,11 +377,11 @@ test encoding-23.2 {iso2022-jp escape encoding test} { incr count $num } close $fid - if {[string compare $::iso2022uniData $out]} { + if {[string compare $iso2022uniData $out]} { return -code error "iso2022-jp read in doesn't match original" } list $count $out -} [list [string length $::iso2022uniData] $::iso2022uniData] +} [list [string length $iso2022uniData] $iso2022uniData] test encoding-23.3 {iso2022-jp escape encoding test} { # read $fis <size> reads size in chars, not raw bytes. set fid [open iso2022.txt r] @@ -379,7 +389,7 @@ test encoding-23.3 {iso2022-jp escape encoding test} { set data [read $fid 50] close $fid set data -} [string range $::iso2022uniData 0 49] ; # 0 .. 49 inclusive == 50 +} [string range $iso2022uniData 0 49] ; # 0 .. 49 inclusive == 50 cd [workingDirectory] test encoding-24.1 {EscapeFreeProc on open channels} -constraints { @@ -575,7 +585,12 @@ file delete {*}[glob -directory [temporaryDirectory] *.chars *.tcltestout] # EscapeFreeProc, GetTableEncoding, unilen # are fully tested by the rest of this file +} +runtests + +} # cleanup +namespace delete ::tcl::test::encoding ::tcltest::cleanupTests return |