winConsole.test
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:1k
源码类别:

通讯编程

开发平台:

Visual C++

  1. # This file tests the tclWinConsole.c file.
  2. #
  3. # This file contains a collection of tests for one or more of the Tcl
  4. # built-in commands.  Sourcing this file into Tcl runs the tests and
  5. # generates output for errors.  No output means no errors were found.
  6. #
  7. # Copyright (c) 1999 by Scriptics Corporation.
  8. #
  9. # See the file "license.terms" for information on usage and redistribution
  10. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  11. #
  12. # RCS: @(#) $Id: winConsole.test,v 1.5 2000/04/10 17:19:06 ericm Exp $
  13. if {[lsearch [namespace children] ::tcltest] == -1} {
  14.     package require tcltest
  15.     namespace import -force ::tcltest::*
  16. }
  17. test winConsole-1.1 {Console file channel: non-blocking gets} 
  18. {pcOnly interactive} {
  19.     
  20.     set oldmode [fconfigure stdin]
  21.     puts stdout "Enter abcdef<return> now: " nonewline
  22.     flush stdout
  23.     fileevent stdin readable {
  24. if {[gets stdin line] >= 0} {
  25.     set result $line
  26. } else {
  27.     set result "gets failed"
  28. }
  29.     }
  30.     fconfigure stdin -blocking 0 -buffering line
  31.     set result {}
  32.     vwait result
  33.     #cleanup the fileevent
  34.     fileevent stdin readable {}
  35.     eval fconfigure stdin $oldmode
  36.     set result
  37. }  "abcdef"
  38. #cleanup
  39. ::tcltest::cleanupTests
  40. return