diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2023-05-31 10:39:28 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2023-05-31 10:39:28 (GMT) |
commit | 18961ef11c430806656055c71158e9ac2e39e13e (patch) | |
tree | cb0bfcd6b2bc9ea39a8670a04601bc25cafb13c1 /tests/ioCmd.test | |
parent | 38c9c34398bc61793d4794a1c4dadb3a36f23847 (diff) | |
download | tcl-18961ef11c430806656055c71158e9ac2e39e13e.zip tcl-18961ef11c430806656055c71158e9ac2e39e13e.tar.gz tcl-18961ef11c430806656055c71158e9ac2e39e13e.tar.bz2 |
swap foreachLine argument order in tests
Diffstat (limited to 'tests/ioCmd.test')
-rw-r--r-- | tests/ioCmd.test | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/tests/ioCmd.test b/tests/ioCmd.test index c7f58e6..7138ecd 100644 --- a/tests/ioCmd.test +++ b/tests/ioCmd.test @@ -4034,28 +4034,35 @@ test iocmd.writeFile-2.3 "readFile procedure: behaviour" -setup { test iocmd.foreachLine-1.1 "foreachLine procedure: syntax" -returnCodes error -body { foreachLine -} -result {wrong # args: should be "foreachLine filename varName body"} +} -result {wrong # args: should be "foreachLine varName filename body"} test iocmd.foreachLine-1.2 "foreachLine procedure: syntax" -returnCodes error -body { foreachLine a b c d -} -result {wrong # args: should be "foreachLine filename varName body"} -test iocmd.foreachLine-1.3 "foreachLine procedure: syntax" -setup { +} -result {wrong # args: should be "foreachLine varName filename body"} +test iocmd.foreachLine-1.3 "foreachLine procedure: basic errors" -setup { set f [makeFile foreachLine13.txt ""] } -body { apply {filename { array set b {1 1} - foreachLine $filename b {} + foreachLine b $filename {} }} $f } -cleanup { removeFile $f } -returnCodes error -result {can't set "line": variable is array} +set f [makeFile foreachLine14.txt ""] +removeFile $f +test iocmd.foreachLine-1.4 "foreachLine procedure: basic errors" -body { + apply {filename { + foreachLine var $filename {} + }} $f +} -returnCodes error -result "couldn't open \"$f\": no such file or directory" test iocmd.foreachLine-2.1 "foreachLine procedure: behaviour" -setup { set f [makeFile foreachLine21.txt "a\nb\nc"] } -body { apply {filename { set lines {} - foreachLine $filename v { - lappend lines $v + foreachLine var $filename { + lappend lines $var } }} $f } -cleanup { @@ -4066,9 +4073,9 @@ test iocmd.foreachLine-2.2 "foreachLine procedure: behaviour" -setup { } -body { apply {filename { set lines {} - foreachLine $filename v { - if {[string length $v] == 1} continue - lappend lines $v + foreachLine var $filename { + if {[string length $var] == 1} continue + lappend lines $var } return $lines }} $f @@ -4080,9 +4087,9 @@ test iocmd.foreachLine-2.3 "foreachLine procedure: behaviour" -setup { } -body { apply {filename { set lines {} - foreachLine $filename v { - if {[string length $v] > 2} break - lappend lines $v + foreachLine var $filename { + if {[string length $var] > 2} break + lappend lines $var } return $lines }} $f @@ -4094,11 +4101,11 @@ test iocmd.foreachLine-2.4 "foreachLine procedure: behaviour" -setup { } -body { apply {filename { set lines {} - foreachLine $filename v { - if {[string length $v] > 2} { - return $v + foreachLine var $filename { + if {[string length $var] > 2} { + return $var } - lappend lines $v + lappend lines $var } return $lines }} $f @@ -4110,11 +4117,11 @@ test iocmd.foreachLine-2.5 "foreachLine procedure: behaviour" -setup { } -body { apply {filename { set lines {} - foreachLine $filename v { - if {[string length $v] > 2} { + foreachLine var $filename { + if {[string length $var] > 2} { error "line too long" } - lappend lines $v + lappend lines $var } return $lines }} $f |