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
{{ message }}
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
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
@@ -163,6 +164,52 @@ When compiled, lc-compile will emit an error on the 'put' line because tInnerVar
163
164
164
165
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.
165
166
167
+
### LiveCode Script Parser Tests
168
+
169
+
The syntax for LiveCode Script parser tests is the same as that of the
170
+
LCB compiler frontent tests above. LCS parser test files all have the
171
+
extension '.parsertest'.
172
+
173
+
Expected errors are referred to by their name in the parse errors
174
+
enumeration. For example the following tests the variable shadowing
175
+
parse error "local: name shadows another variable or constant":
176
+
177
+
%TEST ShadowVariable
178
+
local sVar
179
+
local %{BEFORE_SHADOW}sVar
180
+
%EXPECT PASS
181
+
%ERROR PE_LOCAL_SHADOW AT BEFORE_SHADOW
182
+
%ENDTEST
183
+
184
+
The directive `%SET` can be used to specify the value of global properties
185
+
used when running the test. In particular, it can be used to set the
186
+
value of the `explicitvariables` property. If the `explicitvariables`
187
+
property is not set then the test will be run with it set to `true` and
188
+
to `false`, and the test will fail if the result differs. For example:
189
+
190
+
%TEST CommentedContinuation
191
+
on compiler_test
192
+
-- comment \
193
+
with%{SYNTAX} continuation character
194
+
end compiler_test
195
+
%EXPECT PASS
196
+
%ERROR PE_EXPRESSION_NOTLITERAL AT SYNTAX
197
+
%ENDTEST
198
+
199
+
will fail with "error: test ambiguity with explicit vars".
200
+
201
+
%TEST CommentedContinuationExplicit
202
+
%SET explicitvariables true
203
+
on compiler_test
204
+
-- comment \
205
+
with %{SYNTAX}continuation character
206
+
end compiler_test
207
+
%EXPECT PASS
208
+
%ERROR PE_EXPRESSION_NOTLITERAL AT SYNTAX
209
+
%ENDTEST
210
+
211
+
will succeed.
212
+
166
213
### C++ tests with Google Test
167
214
168
215
In general, C++ tests should only be used for things that cannot be tested any other way.
0 commit comments