This repository was archived by the owner on Sep 7, 2021. It is now read-only.
forked from livecode/livecode-ide
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecution.livecodescript
More file actions
317 lines (238 loc) · 10.2 KB
/
Copy pathexecution.livecodescript
File metadata and controls
317 lines (238 loc) · 10.2 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
script "MessageBoxExecution"
/*
Copyright (C) 2015 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/>. */
local sSupportStack
on TestSetup
set the itemdelimiter to slash
local tSupportStack
put the filename of me into tSupportStack
put "_support.livecodescript" into item -1 of tSupportStack
put tSupportStack into sSupportStack
start using stack sSupportStack
put empty into msg
MessageBoxSetEmpty
end TestSetup
on TestTeardown
stop using stack sSupportStack
end TestTeardown
on TestBug16281
local tValidScript, tButton
create button
put the long id of it into tButton
ideExecuteScript "hilite" && tButton, empty, empty, false, tValidScript
TestAssert "hilite command in msg box", the hilite of tButton
end TestBug16281
on TestBug15832
local tStack
create stack
put the short name of it into tStack
-- Create button and field on the stack
set the defaultStack to tStack
create button
create field
-- Change the defaultStack
create stack
set the defaultStack to the short name of it
local tValidScript
ideExecuteScript "put the name of button 1; put the name of control 2;", tStack, empty, false, tValidScript
TestAssert "; in single line message box", word 1 of msg is "field"
end TestBug15832
on TestBug16863
local tStack
create stack
put the short name of it into tStack
## Create a button on the stack
set the defaultStack to tStack
create button
set the name of it to "test"
local tValidScript, tScript
put "there is a button" && quote & "test" & quote into tScript
ideExecuteScript tScript, tStack, empty, false, tValidScript
TestAssert "boolean expression value with 'put' prepended", msg is "true"
TestAssert "boolean expression executed with 'put' prepended", tValidScript is ("put" && tScript)
end TestBug16863
on TestGlobalPropertyCompleted
local tValidScript
ideExecuteScript "backdrop", empty, empty, false, tValidScript
TestAssert "global prop value with 'put the' prepended", msg is "none"
TestAssert "global prop executed with 'put the' prepended", tValidScript is "put the backdrop"
put empty into msg
ideExecuteScript "the backdrop", empty, empty, false, tValidScript
TestAssert "global prop value with 'put' prepended", msg is "none"
TestAssert "global prop executed with 'put' prepended", tValidScript is "put the backdrop"
end TestGlobalPropertyCompleted
on TestIntelligenceObjectMultilineCommand
local tScript
put "on valueCommand; return" && quote & "value" & quote & "; end valueCommand" into tScript
local tStack
create stack
put it into tStack
set the script of tStack to tScript
local tValidScript
ideExecuteScript "valueCommand; put the result", empty, tStack, false, tValidScript
TestAssert "intelligence object multiple command result", msg is "value"
TestAssert "intelligence object multiple command executed", tValidScript is "valueCommand; put the result"
end TestIntelligenceObjectMultilineCommand
on TestIntelligenceObjectMultilineFunction
local tScript
put "function valueFunction; return" && quote & "value" & quote & "; end valueFunction" into tScript
local tStack
create stack
put it into tStack
set the script of tStack to tScript
local tValidScript
ideExecuteScript "put valueFunction(); put msg", empty, tStack, false, tValidScript
TestAssert "intelligence object multiple function result", msg is "value"
TestAssert "intelligence object multiple function executed", tValidScript is "put valueFunction(); put msg"
end TestIntelligenceObjectMultilineFunction
on TestIntelligenceObject
local tScript
put "on valueCommand; set the cValue of me to" && quote & "value" & quote & "; end valueCommand" into tScript
put return & "function valueFunction; return" && quote & "value" & quote & "; end valueFunction" after tScript
local tStack
create stack
put it into tStack
set the script of tStack to tScript
local tValidScript
ideExecuteScript "valueCommand", empty, tStack, false, tValidScript
TestAssert "intelligence object command result", the cValue of tStack is "value"
TestAssert "intelligence object command executed", tValidScript is "valueCommand"
put empty into msg
ideExecuteScript "valueFunction()", empty, tStack, false, tValidScript
TestAssert "intelligence object function in msg box", msg is "value"
TestAssert "intelligence object function executed", tValidScript is "put valueFunction()"
end TestIntelligenceObject
on TestIntelligenceObjectMultipleCommand
local tScript
put "on firstCommand; ; end firstCommand" into tScript
put return & "on secondCommand; set the cValue of me to" && quote & "value" & quote & "; end secondCommand" after tScript
local tStack
create stack
put it into tStack
set the script of tStack to tScript
local tValidScript
ideExecuteScript "firstCommand; secondCommand", empty, tStack, false, tValidScript
TestAssert "intelligence object mutiple commands", the cValue of tStack is "value"
end TestIntelligenceObjectMultipleCommand
on TestDefaultStackCardScript
local tScript
put "on preOpenCard; set the cValue of this stack to" && quote & "value" & quote && "; end preOpenCard" into tScript
local tStack
create stack
put the long id of it into tStack
set the script of card 1 of tStack to tScript
local tValidScript
ideExecuteScript "preOpenCard", tStack, empty, false, tValidScript
TestAssert "intelligence object command result", the cValue of tStack is "value"
TestAssert "intelligence object command executed", tValidScript is "preOpenCard"
end TestDefaultStackCardScript
on TestIntelligenceObjectPutFunction
local tScript
put "function valueFunction; return" && quote & "value" & quote & "; end valueFunction" into tScript
local tStack
create stack
put it into tStack
set the script of tStack to tScript
local tValidScript
ideExecuteScript "put valueFunction()", empty, tStack, false, tValidScript
TestAssert "intelligence object put function", msg is "value"
end TestIntelligenceObjectPutFunction
on TestIntelligenceObjectGetFunction
local tScript
put "function valueFunction; return" && quote & "value" & quote & "; end valueFunction" into tScript
local tStack
create stack
put it into tStack
set the script of tStack to tScript
local tValidScript
ideExecuteScript "get valueFunction(); put it", empty, tStack, false, tValidScript
TestAssert "intelligence object get function result", msg is "value"
end TestIntelligenceObjectGetFunction
on TestCustomCommandWithStringLiteral
local tScript
put "on valueCommand pValue; set the cValue of me to pValue; end valueCommand" into tScript
local tStack
create stack
put it into tStack
set the script of tStack to tScript
local tValidScript, tToExecute
put "valueCommand" && quote & "value" & quote into tToExecute
ideExecuteScript tToExecute, empty, tStack, false, tValidScript
TestAssert "command with string literal result", the cValue of tStack is "value"
TestAssert "command with string literal executed", tValidScript is tToExecute
end TestCustomCommandWithStringLiteral
-- Bug 17240
on TestIntelligenceObjectPutFunctionWithParam
local tScript
put "function valueFunction pParam; return pParam; end valueFunction" into tScript
local tStack
create stack
put it into tStack
set the script of tStack to tScript
local tValidScript
ideExecuteScript "put valueFunction(" & quote & "hello world" & quote & ")", empty, tStack, false, tValidScript
TestAssert "intelligence object put function with single segment param with spaces", msg is "hello world"
end TestIntelligenceObjectPutFunctionWithParam
-- Bug 17241
on TestIntelligenceObjectPutFunctionWithParamError
local tScript
put "function valueFunction pParam; return pParam; end valueFunction" into tScript
local tStack
create stack
put it into tStack
set the script of tStack to tScript
local tValidScript
ideExecuteScript "put valueFunction(hello world)", empty, tStack, false, tValidScript
TestAssert "intelligence object put function with multi-segment param error", the result contains "error"
TestAssert "intelligence object put function with multi-segment param invalid", tValidScript is empty
end TestIntelligenceObjectPutFunctionWithParamError
on TestIntelligenceObjectPropertyCompleted
local tButton, tButtonName
create button
put it into tButton
put the name of tButton into tButtonName
local tValidScript
ideExecuteScript "width", empty, tButton, false, tValidScript
TestAssert "intelligence object property autocomplete result", the result is empty
TestAssert "intelligence object property autocomplete executed", tValidScript is "put the width of" && tButtonName
end TestIntelligenceObjectPropertyCompleted
-- Bug 17549
on TestIntelligenceObjectFunctionNotFirstLine
local tScript
put "function incr x; return x+1; end incr" into tScript
local tStack
create stack
put it into tStack
set the script of tStack to tScript
local tValidScript, tToExecute
put "global z" into tToExecute
put return & "put 1 into z" after tToExecute
put return & "put incr(z)" after tToExecute
ideExecuteScript tToExecute, empty, tStack, false, tValidScript
TestAssert "intelligence object command result", msg is 2
TestAssert "intelligence object command executed", tValidScript is tToExecute
end TestIntelligenceObjectFunctionNotFirstLine
-- Bug 17800
on TestIntelligenceObjectCommandWithTwoParams
local tScript, tStack
put "on testParameters p1, p2; put p2; end testParameters" \
into tScript
create stack
put it into tStack
set the script of tStack to tScript
local tToExecute, tValidScript
put "testParameters 1, 2" into tToExecute
ideExecuteScript tToExecute, empty, tStack, false, tValidScript
TestAssert "intelligence object command two params result", msg is 2
TestAssert "intelligence object command two params executed", tValidScript is tToExecute
end TestIntelligenceObjectCommandWithTwoParams