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