| Line |   | 
|---|
| 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.8 2006/11/03 00:34:53 hobbs Exp $ | 
|---|
| 13 |  | 
|---|
| 14 | if {[lsearch [namespace children] ::tcltest] == -1} { | 
|---|
| 15 |     package require tcltest | 
|---|
| 16 |     namespace import -force ::tcltest::* | 
|---|
| 17 | } | 
|---|
| 18 |  | 
|---|
| 19 |  | 
|---|
| 20 | test winConsole-1.1 {Console file channel: non-blocking gets} {win interactive} { | 
|---|
| 21 |     set oldmode [fconfigure stdin] | 
|---|
| 22 |  | 
|---|
| 23 |     puts stdout "Enter abcdef<return> now: " nonewline | 
|---|
| 24 |     flush stdout | 
|---|
| 25 |     fileevent stdin readable { | 
|---|
| 26 |         if {[gets stdin line] >= 0} { | 
|---|
| 27 |             set result $line | 
|---|
| 28 |         } else { | 
|---|
| 29 |             set result "gets failed" | 
|---|
| 30 |         } | 
|---|
| 31 |     } | 
|---|
| 32 |  | 
|---|
| 33 |     fconfigure stdin -blocking 0 -buffering line | 
|---|
| 34 |  | 
|---|
| 35 |     set result {} | 
|---|
| 36 |     vwait result | 
|---|
| 37 |  | 
|---|
| 38 |     #cleanup the fileevent | 
|---|
| 39 |     fileevent stdin readable {} | 
|---|
| 40 |     fconfigure stdin {*}$oldmode | 
|---|
| 41 |  | 
|---|
| 42 |     set result | 
|---|
| 43 |  | 
|---|
| 44 | }  "abcdef" | 
|---|
| 45 |  | 
|---|
| 46 | #cleanup | 
|---|
| 47 |  | 
|---|
| 48 | ::tcltest::cleanupTests | 
|---|
| 49 | return | 
|---|
| 50 |  | 
|---|
       
      
      Note: See 
TracBrowser
        for help on using the repository browser.