diff options
Diffstat (limited to 'tests/env.test')
-rw-r--r-- | tests/env.test | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/env.test b/tests/env.test index 5317897..345567b 100644 --- a/tests/env.test +++ b/tests/env.test @@ -18,6 +18,11 @@ if {"::tcltest" ni [namespace children]} { source [file join [file dirname [info script]] tcltests.tcl] +testConstraint utf8system [string equal [encoding system] utf-8] +if {[llength [auto_execok bash]]} { + testConstraint haveBash 1 +} + # [exec] is required here to see the actual environment received by child # processes. proc getenv {} { @@ -411,6 +416,56 @@ test env-7.3 { }} } -cleanup cleanup1 -result 1 +test env-7.4 { + get env variable through upvar +} -setup setup1 -body { + apply {{} { + set ::env(test7_4) origvalue + upvar #0 env(test7_4) var + return $var + }} +} -cleanup cleanup1 -result origvalue + +test env-7.5 { + set env variable through upvar +} -setup setup1 -body { + apply {{} { + set ::env(test7_5) origvalue + upvar #0 env(test7_5) var + set var newvalue + return $::env(test7_5) + }} +} -cleanup cleanup1 -result newvalue + +test env-7.6 { + unset env variable through upvar +} -setup setup1 -body { + apply {{} { + set ::env(test7_6) origvalue + upvar #0 env(test7_6) var + unset var + return [array get env test7_6] + }} +} -cleanup cleanup1 -result {} + +test env-7.7 { + create new (unset) env variable through upvar +} -setup setup1 -body { + apply {{} { + unset -nocomplain ::env(test7_7) + upvar #0 env(test7_7) var + interp create interp1 + set var newvalue + set result [interp1 eval {info exists ::env(test7_7)}] + if {$result} { + lappend result [interp1 eval {set ::env(test7_7)}] + } + interp delete interp1 + return $result + }} +} -cleanup cleanup1 -result {1 newvalue} + + test env-8.0 { memory usage - valgrind does not report reachable memory } -body { @@ -458,6 +513,22 @@ test env-9.1 { } } -result {} +test env-10.0 { + Unequal environment strings test should test unequal +} -constraints {unix haveBash utf8system knownBug} -setup { + set tclScript [makeFile { + puts [string equal $env(XX) $env(YY)] + } tclScript] + set shellCode { + export XX=$'\351' + export YY=$'\303\251' + } + append shellCode "[info nameofexecutable] $tclScript\n" + set shScript [makeFile $shellCode shScript] +} -body { + exec {*}[auto_execok bash] $shScript +} -result 0 + # cleanup |