Diff
Not logged in

Differences From Artifact [c5bae2aa46]:

To Artifact [e53938e766]:


8
9
10
11
12
13
14
15

16
17
18
19
20
21
22
8
9
10
11
12
13
14

15
16
17
18
19
20
21
22







-
+







# Copyright (c) 1991-1994 The Regents of the University of California.
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
#
# 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 2003/02/25 22:03:38 andreas_kupries Exp $
# RCS: @(#) $Id: io.test,v 1.40.2.1 2003/10/07 14:55:49 dgp Exp $

if {[catch {package require tcltest 2}]} {
    puts stderr "Skipping tests in [info script].  tcltest 2 required."
    return
}
namespace eval ::tcl::test::io {

5213
5214
5215
5216
5217
5218
5219
5220

5221
5222
5223
5224
5225

5226
5227
5228
5229

5230
5231
5232
5233
5234
5235
5236
5213
5214
5215
5216
5217
5218
5219

5220
5221
5222
5223
5224

5225




5226
5227
5228
5229
5230
5231
5232
5233







-
+




-
+
-
-
-
-
+







    set x ""
    seek $f 6 current
    lappend x [gets $f]
    lappend x [gets $f]
    close $f
    set x
} {{new line} abc}
test io-40.6 {POSIX open access modes: EXCL} {
test io-40.6 {POSIX open access modes: EXCL} -match regexp -body {
    removeFile test3
    set f [open $path(test3) w]
    puts $f xyzzy
    close $f
    set msg [list [catch {open $path(test3) {WRONLY CREAT EXCL}} msg] $msg]
    open $path(test3) {WRONLY CREAT EXCL}
    regsub " already " $msg " " msg
    regsub [file join {} $path(test3)] $msg "test3" msg
    string tolower $msg
} {1 {couldn't open "test3": file exists}}
} -returnCodes error -result {(?i)couldn't open ".*test3": file (already )?exists}
test io-40.7 {POSIX open access modes: EXCL} {
    removeFile test3
    set f [open $path(test3) {WRONLY CREAT EXCL}]
    fconfigure $f -eofchar {}
    puts $f "A test line"
    close $f
    viewFile test3
5266
5267
5268
5269
5270
5271
5272
5273

5274
5275

5276
5277
5278
5279


5280
5281

5282
5283
5284

5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297

5298
5299

5300
5301
5302

5303
5304
5305
5306
5307
5308
5309
5263
5264
5265
5266
5267
5268
5269

5270
5271

5272




5273
5274
5275

5276



5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289

5290
5291

5292



5293
5294
5295
5296
5297
5298
5299
5300







-
+

-
+
-
-
-
-
+
+

-
+
-
-
-
+












-
+

-
+
-
-
-
+







    set f [open $path(test1) RDONLY]
    set x [list [gets $f] [catch {puts $f Test} msg] $msg]
    close $f
    string compare [string tolower $x] \
	[list {two lines: this one} 1 \
		[format "channel \"%s\" wasn't opened for writing" $f]]
} 0
test io-40.11 {POSIX open access modes: RDONLY} {
test io-40.11 {POSIX open access modes: RDONLY} -match regexp -body {
    removeFile test3
    set msg [list [catch {open $path(test3) RDONLY} msg] $msg]
    open $path(test3) RDONLY
    regsub [file join {} $path(test3)] $msg "test3" msg
	string tolower $msg
} {1 {couldn't open "test3": no such file or directory}}
test io-40.12 {POSIX open access modes: WRONLY} {
} -returnCodes error -result {(?i)couldn't open ".*test3": no such file or directory}
test io-40.12 {POSIX open access modes: WRONLY} -match regexp -body {
    removeFile test3
    set msg [list [catch {open $path(test3) WRONLY} msg] $msg]
    open $path(test3) WRONLY
    regsub [file join {} $path(test3)] $msg "test3" msg
	string tolower $msg
} {1 {couldn't open "test3": no such file or directory}}
} -returnCodes error -result {(?i)couldn't open ".*test3": no such file or directory}
test io-40.13 {POSIX open access modes: WRONLY} {
    makeFile xyzzy test3
    set f [open $path(test3) WRONLY]
    fconfigure $f -eofchar {}
    puts -nonewline $f "ab"
    seek $f 0 current
    set x [list [catch {gets $f} msg] $msg]
    close $f
    lappend x [viewFile test3]
    string compare [string tolower $x] \
	[list 1 "channel \"$f\" wasn't opened for reading" abzzy]
} 0
test io-40.14 {POSIX open access modes: RDWR} {
test io-40.14 {POSIX open access modes: RDWR} -match regexp -body {
    removeFile test3
    set msg [list [catch {open $path(test3) RDWR} msg] $msg]
    open $path(test3) RDWR
    regsub [file join {} $path(test3)] $msg "test3" msg
	string tolower $msg
} {1 {couldn't open "test3": no such file or directory}}
} -returnCodes error -result {(?i)couldn't open ".*test3": no such file or directory}
test io-40.15 {POSIX open access modes: RDWR} {
    makeFile xyzzy test3
    set f [open $path(test3) RDWR]
    puts -nonewline $f "ab"
    seek $f 0 current
    set x [gets $f]
    close $f