diff options
Diffstat (limited to 'tests/chan.test')
| -rw-r--r-- | tests/chan.test | 80 |
1 files changed, 17 insertions, 63 deletions
diff --git a/tests/chan.test b/tests/chan.test index 4155c36..f5e35bc 100644 --- a/tests/chan.test +++ b/tests/chan.test @@ -2,13 +2,13 @@ # command. Sourcing this file into Tcl runs the tests and generates # output for errors. No output means no errors were found. # -# Copyright © 2005 Donal K. Fellows +# Copyright (c) 2005 Donal K. Fellows # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -if {"::tcltest" ni [namespace children]} { - package require tcltest 2.5 +if {[lsearch [namespace children] ::tcltest] == -1} { + package require tcltest 2 namespace import -force ::tcltest::* } @@ -19,49 +19,37 @@ if {"::tcltest" ni [namespace children]} { test chan-1.1 {chan command general syntax} -body { chan -} -returnCodes error -result "wrong # args: should be \"chan subcommand ?arg ...?\"" +} -returnCodes error -result "wrong # args: should be \"chan subcommand ?argument ...?\"" test chan-1.2 {chan command general syntax} -body { chan FOOBAR -} -returnCodes error -match glob -result "unknown or ambiguous subcommand \"FOOBAR\": must be *" +} -returnCodes error -result "unknown or ambiguous subcommand \"FOOBAR\": must be blocked, close, configure, copy, create, eof, event, flush, gets, names, pending, postevent, puts, read, seek, tell, or truncate" test chan-2.1 {chan command: blocked subcommand} -body { chan blocked foo bar } -returnCodes error -result "wrong # args: should be \"chan blocked channelId\"" + test chan-3.1 {chan command: close subcommand} -body { - chan close foo bar zet -} -returnCodes error -result "wrong # args: should be \"chan close channelId ?direction?\"" -test chan-3.2 {chan command: close subcommand} -setup { - set chan [open [info script] r] -} -body { - chan close $chan bar -} -cleanup { - close $chan -} -returnCodes error -result "bad direction \"bar\": must be read or write" -test chan-3.3 {chan command: close subcommand} -setup { - set chan [open [info script] r] -} -body { - chan close $chan write -} -cleanup { - close $chan -} -returnCodes error -result "Half-close of write-side not possible, side not opened or already closed" + chan close foo bar +} -returnCodes error -result "wrong # args: should be \"chan close channelId\"" + test chan-4.1 {chan command: configure subcommand} -body { chan configure -} -returnCodes error -result "wrong # args: should be \"chan configure channelId ?-option value ...?\"" +} -returnCodes error -result "wrong # args: should be \"chan configure channelId ?optionName? ?value? ?optionName value?...\"" test chan-4.2 {chan command: [Bug 800753]} -body { - chan configure stdout -eofchar Ā + chan configure stdout -eofchar \u0100 } -returnCodes error -match glob -result {bad value*} test chan-4.3 {chan command: [Bug 800753]} -body { - chan configure stdout -eofchar \x00 + chan configure stdout -eofchar \u0000 } -returnCodes error -match glob -result {bad value*} test chan-4.4 {chan command: check valid inValue, no outValue} -body { chan configure stdout -eofchar [list \x27 {}] -} -result {} +} -returnCodes ok -result {} test chan-4.5 {chan command: check valid inValue, invalid outValue} -body { chan configure stdout -eofchar [list \x27 \x80] } -returnCodes error -match glob -result {bad value for -eofchar:*} test chan-4.6 {chan command: check no inValue, valid outValue} -body { chan configure stdout -eofchar [list {} \x27] -} -result {} -cleanup {chan configure stdout -eofchar [list {} {}]} +} -returnCodes ok -result {} test chan-5.1 {chan command: copy subcommand} -body { chan copy foo @@ -135,7 +123,7 @@ test chan-16.4 {chan command: pending subcommand} -body { chan pending {input output} stdout } -returnCodes error -result "bad mode \"input output\": must be input or output" test chan-16.5 {chan command: pending input subcommand} -body { - chan pending input stdout + chan pending input stdout } -result -1 test chan-16.6 {chan command: pending input subcommand} -body { chan pending input stdin @@ -173,7 +161,7 @@ test chan-16.9 {chan command: pending input subcommand} -setup { lappend ::chan-16.9-data $r $l $e $b $i - if {$r >= 0 || $e || $l || !$b || $i > 128} { + if {$r != -1 || $e || $l || !$b || $i > 128} { set data [read $sock $i] lappend ::chan-16.9-data [string range $data 0 2] lappend ::chan-16.9-data [string range $data end-2 end] @@ -194,7 +182,7 @@ test chan-16.9 {chan command: pending input subcommand} -setup { set ::chan-16.9-data [list] set ::chan-16.9-done 0 } -body { - after idle chan-16.9-client + after idle chan-16.9-client vwait ::chan-16.9-done set ::chan-16.9-data } -result {-1 0 0 1 36 -1 0 0 1 72 -1 0 0 1 108 -1 0 0 1 144 ABC 890} -cleanup { @@ -233,40 +221,6 @@ test chan-16.13 {chan command: pending output subcommand} -setup { catch {removeFile $file} } -# TIP 304: chan pipe - -test chan-17.1 {chan command: pipe subcommand} -body { - chan pipe foo -} -returnCodes error -result "wrong # args: should be \"chan pipe \"" - -test chan-17.2 {chan command: pipe subcommand} -body { - chan pipe foo bar -} -returnCodes error -result "wrong # args: should be \"chan pipe \"" - -test chan-17.3 {chan command: pipe subcommand} -body { - set l [chan pipe] - foreach {pr pw} $l break - list [llength $l] [fconfigure $pr -blocking] [fconfigure $pw -blocking] -} -result [list 2 1 1] -cleanup { - close $pw - close $pr -} - -test chan-17.4 {chan command: pipe subcommand} -body { - set ::done 0 - foreach {::pr ::pw} [chan pipe] break - after 100 {puts $::pw foo;flush $::pw} - fileevent $::pr readable {set ::done 1} - after 500 {set ::done -1} - vwait ::done - set out nope - if {$::done==1} {gets $::pr out} - list $::done $out -} -result [list 1 foo] -cleanup { - close $::pw - close $::pr -} - cleanupTests return |
