1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
# -*- tcl -*-
# Commands covered: random
#
# Copyright (C) 2004 Pat Thoyts <patthoyts@users.sourceforge.net>
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# $Id: random.test,v 1.2 2004/06/04 14:09:11 patthoyts Exp $
test random-1.0 {Create random devices} {
list [catch {
set chan [random]
close $chan
regsub -all {[0-9]} $chan {} chan
set chan
} msg] $msg
} {0 random}
test random-1.1 {Check tell on random devices} {
list [catch {
set chan [random]
set res [tell $chan]
close $chan
set res
} msg] $msg
} {0 -1}
test random-1.2 {Write, length, tell} {
list [catch {
set chan [random]
catch {seek $chan 0} res
close $chan
regsub -all $chan $res XXX res
set res
} msg] $msg
} {0 {error during seek on "XXX": invalid argument}}
test random-1.3 {Write, length and tell} {
list [catch {
set chan [random]
puts -nonewline $chan \x00\x01\x02\x03
set res [tell $chan]
close $chan
set res
} msg] $msg
} {0 -1}
test random-1.4 {Write and read} {
list [catch {
set chan [random]
puts -nonewline $chan \x00\x01\x02\x03
set res [tell $chan]
lappend res [string length [read $chan 64]]
close $chan
set res
} msg] $msg
} {0 {-1 64}}
test random-1.5 {presence of -delay option} {
list [catch {
set chan [random]
set res [lsearch -exact [fconfigure $chan] -delay]
close $chan
set res [expr {$res != -1}]
} msg] $msg
} {0 1}
test random-1.6 {read -delay option} {
list [catch {
set chan [random]
set res [fconfigure $chan -delay]
close $chan
set res
} msg] $msg
} {0 5}
test random-1.7 {change -delay option} {
list [catch {
set chan [random]
set res [fconfigure $chan -delay 1000]
lappend res [fconfigure $chan -delay]
close $chan
set res
} msg] $msg
} {0 {1000 1000}}
|