summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorandreas_kupries <akupries@shaw.ca>2008-04-10 20:53:45 (GMT)
committerandreas_kupries <akupries@shaw.ca>2008-04-10 20:53:45 (GMT)
commit79f2b1d44214dd346a198ac6dde940f3ad0532ea (patch)
tree847cade9325eb1a02f8576fa8f85c1fece6d6138 /tests
parent7771a657c1cab8174616928296ec54f956aae809 (diff)
downloadtcl-79f2b1d44214dd346a198ac6dde940f3ad0532ea.zip
tcl-79f2b1d44214dd346a198ac6dde940f3ad0532ea.tar.gz
tcl-79f2b1d44214dd346a198ac6dde940f3ad0532ea.tar.bz2
* generic/tclIOCmd.c (Tcl_FcopyObjCmd): Keeping check for negative
values, changed to not be an error, but behave like the special value -1 (copy all, default). * tests/iocmd.test (iocmd-15.{12,13}): Removed. * tests/io.test (io-52.5{,a,b}): Reverted last change, added comment regarding the meaning of -1, added two more testcases for other negative values, and input wrapped to negative.
Diffstat (limited to 'tests')
-rw-r--r--tests/io.test40
-rw-r--r--tests/ioCmd.test8
2 files changed, 38 insertions, 10 deletions
diff --git a/tests/io.test b/tests/io.test
index c6ef73d..519959a 100644
--- a/tests/io.test
+++ b/tests/io.test
@@ -13,7 +13,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: io.test,v 1.40.2.18 2008/04/09 19:52:51 andreas_kupries Exp $
+# RCS: @(#) $Id: io.test,v 1.40.2.19 2008/04/10 20:53:49 andreas_kupries Exp $
if {[catch {package require tcltest 2}]} {
puts stderr "Skipping tests in [info script]. tcltest 2 required."
@@ -6562,13 +6562,47 @@ test io-52.4 {TclCopyChannel} {fcopy} {
close $f2
lappend result [file size $path(test1)]
} {0 0 40}
-test io-52.5 {TclCopyChannel} {fcopy} {
+test io-52.5 {TclCopyChannel, all} {fcopy} {
file delete $path(test1)
set f1 [open $thisScript]
set f2 [open $path(test1) w]
fconfigure $f1 -translation lf -blocking 0
fconfigure $f2 -translation lf -blocking 0
- fcopy $f1 $f2 ;#-size -1
+ fcopy $f1 $f2 -size -1 ;# -1 means 'copy all', same as if no -size specified.
+ set result [list [fconfigure $f1 -blocking] [fconfigure $f2 -blocking]]
+ close $f1
+ close $f2
+ set s1 [file size $thisScript]
+ set s2 [file size $path(test1)]
+ if {"$s1" == "$s2"} {
+ lappend result ok
+ }
+ set result
+} {0 0 ok}
+test io-52.5a {TclCopyChannel, all, other negative value} {fcopy} {
+ file delete $path(test1)
+ set f1 [open $thisScript]
+ set f2 [open $path(test1) w]
+ fconfigure $f1 -translation lf -blocking 0
+ fconfigure $f2 -translation lf -blocking 0
+ fcopy $f1 $f2 -size -2 ;# < 0 behaves like -1, copy all
+ set result [list [fconfigure $f1 -blocking] [fconfigure $f2 -blocking]]
+ close $f1
+ close $f2
+ set s1 [file size $thisScript]
+ set s2 [file size $path(test1)]
+ if {"$s1" == "$s2"} {
+ lappend result ok
+ }
+ set result
+} {0 0 ok}
+test io-52.5b {TclCopyChannel, all, wrap to negative value} {fcopy} {
+ file delete $path(test1)
+ set f1 [open $thisScript]
+ set f2 [open $path(test1) w]
+ fconfigure $f1 -translation lf -blocking 0
+ fconfigure $f2 -translation lf -blocking 0
+ fcopy $f1 $f2 -size 3221176172 ;# Wrapped to < 0, behaves like -1, copy all
set result [list [fconfigure $f1 -blocking] [fconfigure $f2 -blocking]]
close $f1
close $f2
diff --git a/tests/ioCmd.test b/tests/ioCmd.test
index 979f3cc..aa7fd1e 100644
--- a/tests/ioCmd.test
+++ b/tests/ioCmd.test
@@ -13,7 +13,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: ioCmd.test,v 1.16.2.4 2008/04/09 18:35:28 andreas_kupries Exp $
+# RCS: @(#) $Id: ioCmd.test,v 1.16.2.5 2008/04/10 20:53:49 andreas_kupries Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -577,12 +577,6 @@ test iocmd-15.11 {Tcl_FcopyObjCmd} {fcopy} {
test iocmd-15.12 {Tcl_FcopyObjCmd} {fcopy} {
list [catch {fcopy $rfile $wfile -command bar -size foo} msg] $msg
} {1 {expected integer but got "foo"}}
-test iocmd-15.13 {Tcl_FcopyObjCmd} {fcopy} {
- list [catch {fcopy $rfile $wfile -command bar -size 3221176172} msg] $msg
-} {1 {integer value to large to represent as 32bit signed value}}
-test iocmd-15.14 {Tcl_FcopyObjCmd} {fcopy} {
- list [catch {fcopy $rfile $wfile -command bar -size -2} msg] $msg
-} {1 {negative size forbidden}}
close $rfile
close $wfile