forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend.livecodescript
More file actions
132 lines (107 loc) · 3.49 KB
/
Copy pathsend.livecodescript
File metadata and controls
132 lines (107 loc) · 3.49 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
script "CoreEngineSend"
/*
Copyright (C) 2016 LiveCode Ltd.
This file is part of LiveCode.
LiveCode is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License v3 as published by the Free
Software Foundation.
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
on TestSendParams
local tScript, tStack
put "on testParameters p1, p2; return p2; end testParameters" \
into tScript
create stack
put it into tStack
set the script of tStack to tScript
local tSendScript
put "--ensure this is executed as script not a handler name" \
into tSendScript
put return & "testParameters 1, 2" after tSendScript
send tSendScript to tStack
TestAssert "send script with multiple params", the result is "2"
end TestSendParams
/*
It is known that there is code in the wild relying on the following
(undocumented) form of the send command, so we add a test here to ensure
backwards compatibility until such a point as it is deemed possible or
necessary to break.
*/
on TestSendLegacy
local tStack
create stack
put it into tStack
set the defaultStack to the short name of tStack
local tButton
create button
put it into tButton
local tSendScript
put "delete tButton" into tSendScript
send tSendScript to tStack
TestAssert "send script as chunk of script legacy", \
there is not a button 1 of tStack
end TestSendLegacy
private function MessageExists pId
repeat for each line tLine in the pendingMessages
if item 1 of tLine is pId then
return true
end if
end repeat
return false
end MessageExists
on TestSendToSubobj
local tStack, tMsgId
create stack
put the short name of it into tStack
set the defaultStack to tStack
create button
send "mouseUp" to it in 5 millisecs
put the result into tMsgId
delete stack tStack
TestAssert "message canceled on delete", not MessageExists(tMsgId)
end TestSendToSubobj
on __SendError
send "--execute this" & return & "put the name of stack nonexistent"
end __SendError
on TestSendError
TestAssertThrow "send throws correct error", __SendError, \
the long id of me, "EE_CHUNK_NOSTACK"
end TestSendError
on TestSendDeleteMe
local tStack
create stack
send "--execute this" & return & "delete me" to it
TestAssert "execute 'delete me' using send", there is not a stack it
end TestSendDeleteMe
on TestSendScript
local tStack
create stack
put it into tStack
set the defaultStack to the short name of tStack
create button
local tSendScript
put "delete button 1 of me" into tSendScript
send script tSendScript to tStack
TestAssert "send script to object", \
there is not a button 1 of tStack
end TestSendScript
on TestSendScriptEvaluation
local tVar
put "Something" into tVar
local tStack
create stack
put it into tStack
set the script of tStack to "on setVar pValue; set the cVar of me to pValue; end setVar"
-- tVar should be treated as UQL in target context
send script "setVar tVar" to tStack
TestAssert "send script param evaluated in target context", \
the cVar of tStack is "tVar"
-- tVar should be evaluated in the current context
send "setVar tVar" to tStack
TestAssert "send param evaluated in current context", \
the cVar of tStack is "Something"
end TestSendScriptEvaluation