os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/winDde.test
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 # This file tests the tclWinDde.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: winDde.test,v 1.13.2.2 2005/06/21 22:59:03 patthoyts Exp $
    13 
    14 if {[lsearch [namespace children] ::tcltest] == -1} {
    15     package require tcltest
    16     namespace import -force ::tcltest::*
    17 }
    18 
    19 if {$tcl_platform(platform) == "windows"} {
    20     if [catch {
    21 	set lib [lindex [glob -directory [file join [pwd] [file dirname \
    22 		[info nameofexecutable]]] tcldde*.dll] 0]
    23 	load $lib dde
    24     }] {
    25 	puts "WARNING: Unable to find the dde package. Skipping dde tests."
    26 	::tcltest::cleanupTests
    27 	return
    28     }
    29 }
    30 
    31 set scriptName script1.tcl
    32 
    33 proc createChildProcess { ddeServerName } {
    34     file delete -force $::scriptName
    35 
    36     set f [open $::scriptName w+]
    37     puts $f {
    38 	if {[lsearch [namespace children] ::tcltest] == -1} {
    39 	    package require tcltest
    40 	    namespace import -force ::tcltest::*
    41 	}
    42 	if [catch {
    43 	    set lib [lindex [glob -directory \
    44 		    [file join [pwd] [file dirname [info nameofexecutable]]] \
    45 		    tcldde*.dll] 0]
    46 	    load $lib dde
    47 	}] {
    48 	    puts "Unable to find the dde package. Skipping dde tests."
    49 	    ::tcltest::cleanupTests
    50 	    return
    51 	}
    52     }
    53     puts $f [list dde servername $ddeServerName]
    54     puts $f {
    55         after 200 {set ready 1}
    56         vwait ready
    57 	puts ready
    58 	vwait done
    59 	after 200 {set final 1}
    60         vwait final
    61 	exit
    62     }
    63     close $f
    64     
    65     set f [open |[list [interpreter] $::scriptName] r]
    66     fconfigure $f -buffering line -blocking 1
    67     gets $f
    68     return $f
    69 }
    70 
    71 test winDde-1.1 {Settings the server's topic name} {pcOnly} {
    72     list [dde servername foobar] [dde servername] [dde servername self]
    73 }  {foobar foobar self}
    74 
    75 test winDde-2.1 {Checking for other services} {pcOnly} {
    76     expr [llength [dde services {} {}]] >= 0
    77 } 1
    78 
    79 test winDde-2.2 {Checking for existence, with service and topic specified} \
    80 	{pcOnly} {
    81     llength [dde services TclEval self]
    82 } 1
    83 
    84 test winDde-2.3 {Checking for existence, with only the service specified} \
    85 	{pcOnly} {
    86     expr [llength [dde services TclEval {}]] >= 1
    87 } 1
    88 
    89 test winDde-3.1 {DDE execute locally} {pcOnly} {
    90     set a ""
    91     dde execute TclEval self {set a "foo"}
    92     set a
    93 } foo
    94 
    95 test winDde-3.2 {DDE execute -async locally} {pcOnly} {
    96     set a ""
    97     dde execute -async TclEval self {set a "foo"}
    98     update
    99     set a
   100 } foo
   101 
   102 test winDde-3.3 {DDE request locally} {pcOnly} {
   103     set a ""
   104     dde execute TclEval self {set a "foo"}
   105     dde request TclEval self a
   106 } foo
   107 
   108 test winDde-3.4 {DDE eval locally} {pcOnly} {
   109     set a ""
   110     dde eval self set a "foo"
   111 } foo
   112 
   113 test winDde-3.5 {DDE request locally} {pcOnly} {
   114     set a ""
   115     dde execute TclEval self {set a "foo"}
   116     dde request -binary TclEval self a
   117 } "foo\x00"
   118 
   119 test winDde-4.1 {DDE execute remotely} {stdio pcOnly} {
   120     list [catch {
   121         set a ""
   122         set child [createChildProcess child]
   123         dde execute TclEval child {set a "foo"}
   124         dde execute TclEval child {set done 1}
   125         set a
   126     } err] $err
   127 } [list 0 ""]
   128 
   129 test winDde-4.2 {DDE execute remotely} {stdio pcOnly} {
   130     list [catch {
   131         set a ""
   132         set child [createChildProcess child]
   133         dde execute -async TclEval child {set a "foo"}
   134         after 400 {set ::_dde_forever 1} ; vwait ::_dde_forever; #update
   135         dde execute TclEval child {set done 1}
   136         set a
   137     } err] $err
   138 } [list 0 ""]
   139 
   140 test winDde-4.3 {DDE request locally} {stdio pcOnly} {
   141     list [catch {
   142         set a ""
   143         set child [createChildProcess child]
   144         dde execute TclEval child {set a "foo"}
   145         set a [dde request TclEval child a]
   146         dde execute TclEval child {set done 1}
   147         set a
   148     } err] $err
   149 } [list 0 foo]
   150 
   151 test winDde-4.4 {DDE eval locally} {stdio pcOnly} {
   152     list [catch {
   153         set a ""
   154         set child [createChildProcess child]
   155         set a [dde eval child set a "foo"]
   156         dde execute TclEval child {set done 1}
   157         set a
   158     } err] $err
   159 } [list 0 foo]
   160 
   161 test winDde-5.1 {check for bad arguments} {pcOnly} {
   162     catch {dde execute "" "" "" ""} result
   163     set result
   164 } {wrong # args: should be "dde execute ?-async? serviceName topicName value"}
   165 
   166 test winDde-5.2 {check for bad arguments} {pcOnly} {
   167     catch {dde execute "" "" ""} result
   168     set result
   169 } {cannot execute null data}
   170 
   171 test winDde-5.3 {check for bad arguments} {pcOnly} {
   172     catch {dde execute -foo "" "" ""} result
   173     set result
   174 } {wrong # args: should be "dde execute ?-async? serviceName topicName value"}
   175 
   176 test winDde-5.4 {DDE eval bad arguments} {pcOnly} {
   177     list [catch {dde eval "" "foo"} msg] $msg
   178 } {1 {invalid service name ""}}
   179 
   180 #cleanup
   181 file delete -force $::scriptName
   182 ::tcltest::cleanupTests
   183 return