summaryrefslogtreecommitdiffstats
path: root/tests/env.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/env.test')
-rw-r--r--tests/env.test107
1 files changed, 74 insertions, 33 deletions
diff --git a/tests/env.test b/tests/env.test
index 043748a..7d7e5fa 100644
--- a/tests/env.test
+++ b/tests/env.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: env.test,v 1.30 2008/07/19 21:47:55 dkf Exp $
+# RCS: @(#) $Id: env.test,v 1.31 2009/05/07 10:34:42 dkf Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -61,6 +61,7 @@ test env-1.3 {reflection of env by "array names"} -setup {
} -result {1}
set printenvScript [makeFile {
+ encoding system iso8859-1
proc lrem {listname name} {
upvar $listname list
set i [lsearch -nocase $list $name]
@@ -71,7 +72,7 @@ set printenvScript [makeFile {
}
proc mangle s {
regsub -all {\[|\\|\]} $s {\\&} s
- regsub -all {[\u007f-\uffff]} $s {[manglechar &]} s
+ regsub -all {[\u0000-\u001f\u007f-\uffff]} $s {[manglechar &]} s
return [subst -novariables $s]
}
proc manglechar c {
@@ -125,60 +126,100 @@ foreach name [array names env] {
}
}
-test env-2.1 {adding environment variables} {exec} {
+# Need to run 'getenv' in known encoding, so save the current one here...
+set sysenc [encoding system]
+
+test env-2.1 {adding environment variables} -setup {
+ encoding system iso8859-1
+} -constraints {exec} -body {
getenv
-} {}
-set env(NAME1) "test string"
-test env-2.2 {adding environment variables} {exec} {
+} -cleanup {
+ encoding system $sysenc
+} -result {}
+test env-2.2 {adding environment variables} -setup {
+ encoding system iso8859-1
+} -constraints {exec} -body {
+ set env(NAME1) "test string"
getenv
-} {NAME1=test string}
-set env(NAME2) "more"
-test env-2.3 {adding environment variables} {exec} {
+} -cleanup {
+ encoding system $sysenc
+} -result {NAME1=test string}
+test env-2.3 {adding environment variables} -setup {
+ encoding system iso8859-1
+} -constraints {exec} -body {
+ set env(NAME2) "more"
getenv
-} {NAME1=test string
+} -cleanup {
+ encoding system $sysenc
+} -result {NAME1=test string
NAME2=more}
-set env(XYZZY) "garbage"
-test env-2.4 {adding environment variables} {exec} {
+test env-2.4 {adding environment variables} -setup {
+ encoding system iso8859-1
+} -constraints {exec} -body {
+ set env(XYZZY) "garbage"
getenv
-} {NAME1=test string
+} -cleanup {
+ encoding system $sysenc
+} -result {NAME1=test string
NAME2=more
XYZZY=garbage}
set env(NAME2) "new value"
-test env-3.1 {changing environment variables} {exec} {
+test env-3.1 {changing environment variables} -setup {
+ encoding system iso8859-1
+} -constraints {exec} -body {
set result [getenv]
unset env(NAME2)
set result
-} {NAME1=test string
+} -cleanup {
+ encoding system $sysenc
+} -result {NAME1=test string
NAME2=new value
XYZZY=garbage}
-test env-4.1 {unsetting environment variables} {exec} {
- set result [getenv]
- unset env(NAME1)
- set result
-} {NAME1=test string
+test env-4.1 {unsetting environment variables: default} -setup {
+ encoding system iso8859-1
+} -constraints {exec} -body {
+ getenv
+} -cleanup {
+ encoding system $sysenc
+} -result {NAME1=test string
XYZZY=garbage}
-test env-4.2 {unsetting environment variables} {exec} {
- set result [getenv]
+test env-4.2 {unsetting environment variables} -setup {
+ encoding system iso8859-1
+} -constraints {exec} -body {
+ unset env(NAME1)
+ getenv
+} -cleanup {
unset env(XYZZY)
- set result
-} {XYZZY=garbage}
-test env-4.3 {setting international environment variables} {exec} {
+ encoding system $sysenc
+} -result {XYZZY=garbage}
+test env-4.3 {setting international environment variables} -setup {
+ encoding system iso8859-1
+} -constraints {exec} -body {
set env(\ua7) \ub6
getenv
-} {\u00a7=\u00b6}
-test env-4.4 {changing international environment variables} {exec} {
+} -cleanup {
+ encoding system $sysenc
+} -result {\u00a7=\u00b6}
+test env-4.4 {changing international environment variables} -setup {
+ encoding system iso8859-1
+} -constraints {exec} -body {
set env(\ua7) \ua7
getenv
-} {\u00a7=\u00a7}
-test env-4.5 {unsetting international environment variables} {exec} {
+} -cleanup {
+ encoding system $sysenc
+} -result {\u00a7=\u00a7}
+test env-4.5 {unsetting international environment variables} -setup {
+ encoding system iso8859-1
+} -body {
set env(\ub6) \ua7
unset env(\ua7)
- set result [getenv]
+ getenv
+} -constraints {exec} -cleanup {
+ encoding system $sysenc
unset env(\ub6)
- set result
-} {\u00b6=\u00a7}
+} -result {\u00b6=\u00a7}
test env-5.0 {corner cases - set a value, it should exist} -body {
set env(temp) a
@@ -212,7 +253,7 @@ test env-5.2 {corner cases - unset the env array} -setup {
} -cleanup {
interp delete i
} -result {0}
-test env-5.3 {corner cases - unset the env in master should unset child} -setup {
+test env-5.3 {corner cases: unset the env in master should unset child} -setup {
interp create i
} -body {
# Variables deleted in a master interp should be deleted in child interp