You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/development/testing.md
+48-1Lines changed: 48 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,11 +2,12 @@
2
2
3
3
Tests are small programs that check that a particular, specific function works correctly. They are run automatically to check whether LiveCode works properly. They're really useful for ensuring that changes to one part of LiveCode don't break other things!
4
4
5
-
The main LiveCode engine repository contains four sets of tests ("test suites"):
5
+
The main LiveCode engine repository contains the following sets of tests ("test suites"):
6
6
7
7
***LiveCode Script tests:** script-only stacks that are run using the LiveCode standalone engine. They test features of the LiveCode Script language.
8
8
***LiveCode Builder tests:** LCB modules that are run using the **lc-run** tool. They test features of the LCB core language and standard library.
9
9
***LiveCode Builder Compiler Frontend tests:** Fragments of LCB code which are run through the compiler and check that the compile succeeds, or emits the correct warnings or errors.
10
+
***LiveCode Script parser tests:** Fragments of LCS code which are run through the parser and check that the compile succeeds, or emits the correct warnings or errors.
10
11
***C++ tests:** low-level tests written in C++ using [Google Test](https://github.com/google/googletest). These perform low-level checks for things that can't be tested any other way.
11
12
12
13
## Running the Tests
@@ -164,6 +165,52 @@ When compiled, lc-compile will emit an error on the 'put' line because tInnerVar
164
165
165
166
To help debug compiler tests, set the LCC_VERBOSE environment variable to 1 before running the compiler test. This will cause the compiler testrunner to emit diagnostic information, including the full output of the compile command which is being run.
166
167
168
+
### LiveCode Script Parser Tests
169
+
170
+
The syntax for LiveCode Script parser tests is the same as that of the
171
+
LCB compiler frontent tests above. LCS parser test files all have the
172
+
extension '.parsertest'.
173
+
174
+
Expected errors are referred to by their name in the parse errors
175
+
enumeration. For example the following tests the variable shadowing
176
+
parse error "local: name shadows another variable or constant":
177
+
178
+
%TEST ShadowVariable
179
+
local sVar
180
+
local %{BEFORE_SHADOW}sVar
181
+
%EXPECT PASS
182
+
%ERROR PE_LOCAL_SHADOW AT BEFORE_SHADOW
183
+
%ENDTEST
184
+
185
+
The directive `%SET` can be used to specify the value of global properties
186
+
used when running the test. In particular, it can be used to set the
187
+
value of the `explicitvariables` property. If the `explicitvariables`
188
+
property is not set then the test will be run with it set to `true` and
189
+
to `false`, and the test will fail if the result differs. For example:
190
+
191
+
%TEST CommentedContinuation
192
+
on compiler_test
193
+
-- comment \
194
+
with%{SYNTAX} continuation character
195
+
end compiler_test
196
+
%EXPECT PASS
197
+
%ERROR PE_EXPRESSION_NOTLITERAL AT SYNTAX
198
+
%ENDTEST
199
+
200
+
will fail with "error: test ambiguity with explicit vars".
201
+
202
+
%TEST CommentedContinuationExplicit
203
+
%SET explicitvariables true
204
+
on compiler_test
205
+
-- comment \
206
+
with %{SYNTAX}continuation character
207
+
end compiler_test
208
+
%EXPECT PASS
209
+
%ERROR PE_EXPRESSION_NOTLITERAL AT SYNTAX
210
+
%ENDTEST
211
+
212
+
will succeed.
213
+
167
214
### C++ tests with Google Test
168
215
169
216
In general, C++ tests should only be used for things that cannot be tested any other way.
0 commit comments