forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathengine.livecodescript
More file actions
209 lines (168 loc) · 6.82 KB
/
Copy pathengine.livecodescript
File metadata and controls
209 lines (168 loc) · 6.82 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
script "CoreEngineExtensionsEngineModule"
/*
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 TestSetup
TestSkipIfNot "lcb"
TestLoadAuxiliaryExtension "_engine"
TestLoadAuxiliaryExtension "_widget_engine"
end TestSetup
on TestExtensionLibraryDelimiterAccess
set the itemDelimiter to "a"
set the lineDelimiter to "b"
set the columnDelimiter to "c"
set the rowDelimiter to "d"
local tDelimiters
put TestExtensionDelimiterAccess() into tDelimiters
combine tDelimiters with comma
TestDiagnostic tDelimiters
TestAssert "library handler can access delimiters", tDelimiters is "a,b,c,d"
end TestExtensionLibraryDelimiterAccess
//////////
on TestExtensionExecuteScript
-- Implicit object in libraries is this card of the defaultStack
TestExtensionExecuteScript_Do "return the long id of this card", empty, empty
TestAssert "execute script in library works", the result is the long id of this card of the defaultStack
-- Implicit object in widgets is the widget
local tWidget
create widget as "com.livecode.lcs_tests.core.engine_lcb.widget_engine"
put it into tWidget
set the scriptString of tWidget to "return the long id of me"
TestAssert "execute script in widget works", the scriptResult of tWidget is tWidget
local tParams
put "foobar" into tParams[1]
set the scriptParams of tWidget to tParams
set the scriptString of tWidget to "set the uTest of me to param(1)"
get the scriptResult of tWidget
TestAssert "execute script in widget with params works", the uTest of tWidget is "foobar"
create stack "TempStack"
TestExtensionExecuteScript_Do "return the short name of me", the long id of stack "TempStack", empty
TestAssert "execute script in object works", the result is the short name of stack "TempStack"
delete stack "TempStack"
local tArgs
put 200 into tArgs[1]
TestExtensionExecuteScript_Do "return param(1)", empty, tArgs
TestAssert "execute script with arguments works", the result is 200
create stack "TempStack2"
TestExtensionExecuteScript_Do "return the short name of me & param(1)", the long id of stack "TempStack2", tArgs
TestAssert "execute script in object with arguments works", the result is "TempStack2200"
delete stack "TempStack2"
end TestExtensionExecuteScript
/////////
/*
On server, extension logs go directly to stderr, so skip these tests.
*/
local sLastLog
on logChanged pMsg
put pMsg into sLastLog
end logChanged
on TestExtensionLogInteger
TestSkipIf "environment", "server"
// log 1
get TestExtensionLog_Integer()
wait for 0 with messages
TestAssert "extension log integer", sLastLog is 1
end TestExtensionLogInteger
on TestExtensionLogList
TestSkipIf "environment", "server"
// log [1,2,3]
get TestExtensionLog_List()
wait for 0 with messages
TestAssert "extension log list", sLastLog is "[1, 2, 3]"
end TestExtensionLogList
on TestExtensionLogArray
TestSkipIf "environment", "server"
// log {a: 1}
get TestExtensionLog_Array()
wait for 0 with messages
TestAssert "extension log array", sLastLog is "{a: 1}"
end TestExtensionLogArray
on TestExtensionLogString
TestSkipIf "environment", "server"
// log "log"
get TestExtensionLog_String()
wait for 0 with messages
TestAssert "extension log string", sLastLog is quote & "log" & quote
end TestExtensionLogString
on TestExtensionLogScriptObject
TestSkipIf "environment", "server"
// resolve script object "button 1"
// log the result
create button
get TestExtensionLog_ScriptObject()
wait for 0 with messages
TestDiagnostic sLastLog
TestAssert "extension log unnamed scriptobject", \
sLastLog is format("<script object button id %d of card id %d of stack %s>", \
the id of button 1, \
the id of this card, \
quote & the short name of this stack & quote)
set the name of button 1 to "foo"
get TestExtensionLog_ScriptObject()
wait for 0 with messages
TestDiagnostic sLastLog
TestAssert "extension log named scriptobject", \
sLastLog is format("<script object button %s of card id %d of stack %s>", \
quote & the short name of button 1 & quote, \
the id of this card, \
quote & the short name of this stack & quote)
get TestExtensionLog_DeletedScriptObject()
wait for 0 with messages
TestDiagnostic sLastLog
TestAssert "extension log deleted scriptobject", sLastLog is "<deleted script object>"
end TestExtensionLogScriptObject
local sCallbackTarget
on CallerCallback
TestDiagnostic "called"
put the long id of the target into sCallbackTarget
end CallerCallback
on TestEngineCaller
local tButton
create button
put it into tButton
set the script of tButton to "on doTest;TestEngine_Caller" \
&& quote & "CallerCallback" & quote & ";end doTest"
send "doTest" to tButton
TestAssert "library handler can get caller", \
the long id of sCallbackTarget is the long id of tButton
end TestEngineCaller
//////////
on TestEngineResolvePath
local tDefaultStack
put the defaultStack into tDefaultStack
local tWidget
create widget as "com.livecode.lcs_tests.core.engine_lcb.widget_engine"
put it into tWidget
local tPath
set the pathExplicit of tWidget to "_testrunner.livecodescript"
put the pathExplicit of tWidget into tPath
TestAssert \
"resolve path relative to explicit object in widget", \
tPath is the filename of stack "TestRunner"
TestAssert \
"resolve path relative to explicit object in library", \
TestEngine_ResolveFile("_testrunner.livecodescript", \
the long id of stack "TestRunner") \
is the filename of stack "TestRunner"
TestAssert \
"resolve path relative to implicit object in library", \
TestEngine_ResolveFile("engine.livecodescript", "") \
is the filename of me
-- test implicit widget with the default stack elsewhere
set the defaultStack to "TestRunner"
set the pathImplicit of tWidget to "engine.livecodescript"
put the pathImplicit of tWidget into tPath
TestAssert \
"resolve path relative to implicit widget", \
tPath is the filename of me
set the defaultStack to tDefaultStack
end TestEngineResolvePath