diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-04-12 12:00:11 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-04-12 12:00:11 (GMT) |
commit | ece45e7fb6469e3ee3ad49f168f8711fb36f93ce (patch) | |
tree | db4a77927de2a4d6c6cf2bc672ebda4098b9b1a0 /tests/env.test | |
parent | 6f3388528ef453d29fbddba3f5a054d2f5268207 (diff) | |
parent | 473bfc0f18451046035f638732a609fc86d5a0aa (diff) | |
download | tcl-ece45e7fb6469e3ee3ad49f168f8711fb36f93ce.zip tcl-ece45e7fb6469e3ee3ad49f168f8711fb36f93ce.tar.gz tcl-ece45e7fb6469e3ee3ad49f168f8711fb36f93ce.tar.bz2 |
merge trunkinitsubsystems
Diffstat (limited to 'tests/env.test')
-rw-r--r-- | tests/env.test | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/tests/env.test b/tests/env.test index 83d99e0..0dd4f98 100644 --- a/tests/env.test +++ b/tests/env.test @@ -19,7 +19,7 @@ if {[lsearch [namespace children] ::tcltest] == -1} { # Some tests require the "exec" command. # Skip them if exec is not defined. testConstraint exec [llength [info commands exec]] - + # # These tests will run on any platform (and indeed crashed on the Mac). So put # them before you test for the existance of exec. @@ -147,6 +147,7 @@ test env-2.2 {adding environment variables} -setup { } -result {NAME1=test string} test env-2.3 {adding environment variables} -setup { encoding system iso8859-1 + set env(NAME1) "test string" } -constraints {exec} -body { set env(NAME2) "more" getenv @@ -156,6 +157,8 @@ test env-2.3 {adding environment variables} -setup { NAME2=more} test env-2.4 {adding environment variables} -setup { encoding system iso8859-1 + set env(NAME1) "test string" + set env(NAME2) "more" } -constraints {exec} -body { set env(XYZZY) "garbage" getenv @@ -165,7 +168,9 @@ test env-2.4 {adding environment variables} -setup { NAME2=more XYZZY=garbage} +set env(NAME1) "test string" set env(NAME2) "new value" +set env(XYZZY) "garbage" test env-3.1 {changing environment variables} -setup { encoding system iso8859-1 } -constraints {exec} -body { @@ -177,6 +182,7 @@ test env-3.1 {changing environment variables} -setup { } -result {NAME1=test string NAME2=new value XYZZY=garbage} +unset -nocomplain env(NAME2) test env-4.1 {unsetting environment variables: default} -setup { encoding system iso8859-1 @@ -195,6 +201,7 @@ test env-4.2 {unsetting environment variables} -setup { unset env(XYZZY) encoding system $sysenc } -result {XYZZY=garbage} +unset -nocomplain env(NAME1) env(XYZZY) test env-4.3 {setting international environment variables} -setup { encoding system iso8859-1 } -constraints {exec} -body { @@ -213,6 +220,7 @@ test env-4.4 {changing international environment variables} -setup { } -result {\u00a7=\u00a7} test env-4.5 {unsetting international environment variables} -setup { encoding system iso8859-1 + set env(\ua7) \ua7 } -body { set env(\ub6) \ua7 unset env(\ua7) @@ -278,20 +286,20 @@ test env-5.4 {corner cases - unset the env array} -setup { } -cleanup { interp delete i } -result {1 a 1} -test env-5.5 {corner cases - cannot have null entries on Windows} {win} { +test env-5.5 {corner cases - cannot have null entries on Windows} -constraints win -body { set env() a catch {set env()} -} {1} +} -result 1 -test env-6.1 {corner cases - add lots of env variables} {} { +test env-6.1 {corner cases - add lots of env variables} -body { set size [array size env] for {set i 0} {$i < 100} {incr i} { set env(BOGUS$i) $i } expr {[array size env] - $size} -} 100 +} -result 100 -test env-7.1 {[219226]: whole env array should not be unset by read} { +test env-7.1 {[219226]: whole env array should not be unset by read} -body { set n [array size env] set s [array startsearch env] while {[array anymore env $s]} { @@ -300,20 +308,30 @@ test env-7.1 {[219226]: whole env array should not be unset by read} { } array donesearch env $s return $n -} 0 -test env-7.2 {[219226]: links to env elements should not be removed by read} { +} -result 0 + +test env-7.2 {[219226]: links to env elements should not be removed by read} -body { apply {{} { set ::env(test7_2) ok upvar env(test7_2) elem set ::env(PATH) - try { - return $elem - } finally { - unset ::env(test7_2) - } + return $elem }} -} ok +} -result ok +test env-7.3 {[9b4702]: testing existence of env(some_thing) should not destroy trace} -body { + apply {{} { + catch {unset ::env(test7_3)} + proc foo args { + set ::env(test7_3) ok + } + trace add variable ::env(not_yet_existent) write foo + info exists ::env(not_yet_existent) + set ::env(not_yet_existent) "Now I'm here"; + return [info exists ::env(test7_3)] + }} +} -result 1 + # Restore the environment variables at the end of the test. foreach name [array names env] { |