summaryrefslogtreecommitdiffstats
path: root/tests/main.test
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2003-09-05 22:44:39 (GMT)
committerdgp <dgp@users.sourceforge.net>2003-09-05 22:44:39 (GMT)
commit49a3761c9a6927ca9d137b388e2e98cd6c3cb6ae (patch)
tree576a4f9da303c7ad641eacb82f49ece804239611 /tests/main.test
parente361b905f57a0c438db0275dcb1db6d184ad3f70 (diff)
downloadtk-49a3761c9a6927ca9d137b388e2e98cd6c3cb6ae.zip
tk-49a3761c9a6927ca9d137b388e2e98cd6c3cb6ae.tar.gz
tk-49a3761c9a6927ca9d137b388e2e98cd6c3cb6ae.tar.bz2
* doc/wish.1: Implementation of TIPs 137/151.
* generic/tkMain.c (Tk_MainEx): Added recognition of the -encoding * tests/main.test: command line option by Tk_MainEx() and thus by wish, and any other program built on Tk_MainEx(). [Patch 800139]. This is a ***POTENTIAL INCOMPATIBILITY*** only for those C programs that embed Tcl and Tk, build on Tk_MainEx(), and make use of Tk_MainEx's former ability to pass a leading "-encoding" option to interactive shell operations.
Diffstat (limited to 'tests/main.test')
-rw-r--r--tests/main.test90
1 files changed, 81 insertions, 9 deletions
diff --git a/tests/main.test b/tests/main.test
index 17fbaf9..ff86dc2 100644
--- a/tests/main.test
+++ b/tests/main.test
@@ -8,24 +8,96 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: main.test,v 1.7 2003/04/01 21:06:41 dgp Exp $
+# RCS: @(#) $Id: main.test,v 1.8 2003/09/05 22:44:39 dgp Exp $
package require tcltest 2.1
eval tcltest::configure $argv
tcltest::loadTestedCommands
-test main-1.1 {StdinProc} {unix} {
+test main-1.1 {StdinProc} -constraints stdio -setup {
set script [makeFile {
close stdin; exit
} script]
- if {[catch {exec [interpreter] <$script} msg]} {
- set error 1
- } else {
- set error 0
- }
+} -body {
+ list [catch {exec [interpreter] <$script} msg] $msg
+} -cleanup {
removeFile script
- list $error $msg
-} {0 {}}
+} -result {0 {}}
+
+test main-2.1 {Tk_MainEx: -encoding option} -constraints {
+ stdio
+ } -setup {
+ set script [makeFile {} script]
+ removeFile script
+ set f [open $script w]
+ fconfigure $f -encoding utf-8
+ puts $f {puts [list $argv0 $argv $tcl_interactive]}
+ puts -nonewline $f {puts [string equal \u20ac }
+ puts $f "\u20ac]; exit"
+ close $f
+ catch {set f [open "|[list [interpreter] -encoding utf-8 script]" r]}
+ } -body {
+ read $f
+ } -cleanup {
+ close $f
+ removeFile script
+ } -result [list script {} 0]\n1\n
+
+test main-2.2 {Tk_MainEx: -encoding option} -constraints {
+ stdio
+ } -setup {
+ set script [makeFile {} script]
+ removeFile script
+ set f [open $script w]
+ fconfigure $f -encoding utf-8
+ puts $f {puts [list $argv0 $argv $tcl_interactive]}
+ puts -nonewline $f {puts [string equal \u20ac }
+ puts $f "\u20ac]; exit"
+ close $f
+ catch {set f [open "|[list [interpreter] -encoding ascii script]" r]}
+ } -body {
+ read $f
+ } -cleanup {
+ close $f
+ removeFile script
+ } -result [list script {} 0]\n0\n
+
+ # Procedure to simulate interactive typing of commands, line by line
+ proc type {chan script} {
+ foreach line [split $script \n] {
+ if {[catch {
+ puts $chan $line
+ flush $chan
+ }]} {
+ return
+ }
+ # Grrr... Behavior depends on this value.
+ after 1000
+ }
+ }
+
+test main-2.3 {Tk_MainEx: -encoding option} -constraints {
+ stdio
+ } -setup {
+ set script [makeFile {} script]
+ removeFile script
+ set f [open $script w]
+ fconfigure $f -encoding utf-8
+ puts $f {puts [list $argv0 $argv $tcl_interactive]}
+ puts -nonewline $f {puts [string equal \u20ac }
+ puts $f "\u20ac]"
+ close $f
+ catch {set f [open "|[list [interpreter] -enc utf-8 script]" r+]}
+ } -body {
+ type $f {
+ puts $argv
+ exit
+ }
+ list [catch {gets $f} line] $line
+ } -cleanup {
+ close $f
+ removeFile script
+ } -result {0 {-enc utf-8 script}}
# cleanup
cleanupTests