Skip to content

Commit 36ee48c

Browse files
committed
fix(testing): evaluating the expressions once inside (mut) nodes caused problems ; storing them permanently and setting variables works better
1 parent 8f4500b commit 36ee48c

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

Testing.ark

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,17 @@
198198
# =end
199199
# @author https://github.com/SuperFola
200200
(macro test:expect (_cond ..._desc) {{
201-
(mut _cond_res ($as-is _cond))
202-
(if (!= true _cond_res)
203-
(testing:_report_error true _cond_res "true" ($repr _cond) _desc)
201+
(set testing:_cond_res ($as-is _cond))
202+
(if (!= true testing:_cond_res)
203+
(testing:_report_error true testing:_cond_res "true" ($repr _cond) _desc)
204204
(testing:_report_success)) }})
205205

206+
(mut _cond_res nil)
207+
(mut _expr_res nil)
208+
(mut _expected_res nil)
209+
(mut _unexpected_res nil)
210+
(mut _value_res nil)
211+
206212
# @brief Compare two values that should be equal and generate a test case
207213
# @param _expr computed value to test
208214
# @param _expected expected value
@@ -214,11 +220,11 @@
214220
# =end
215221
# @author https://github.com/SuperFola
216222
(macro test:eq (_expr _expected ..._desc) {{
217-
(mut _expected_res ($as-is _expected))
218-
(mut _expr_res ($as-is _expr))
219-
(if (= _expected_res _expr_res)
223+
(set testing:_expected_res ($as-is _expected))
224+
(set testing:_expr_res ($as-is _expr))
225+
(if (= testing:_expected_res testing:_expr_res)
220226
(testing:_report_success)
221-
(testing:_report_error _expected_res _expr_res ($repr _expected) ($repr _expr) _desc)) }})
227+
(testing:_report_error testing:_expected_res testing:_expr_res ($repr _expected) ($repr _expr) _desc)) }})
222228

223229
# @brief Compare two values that should **not** be equal and generate a test case
224230
# @param _value tested value
@@ -230,11 +236,11 @@
230236
# =end
231237
# @author https://github.com/SuperFola
232238
(macro test:neq (_value _unexpected ..._desc) {{
233-
(mut _unexpected_res ($as-is _unexpected))
234-
(mut _value_res ($as-is _value))
235-
(if (!= _unexpected_res _value_res)
239+
(set testing:_unexpected_res ($as-is _unexpected))
240+
(set testing:_value_res ($as-is _value))
241+
(if (!= testing:_unexpected_res testing:_value_res)
236242
(testing:_report_success)
237-
(testing:_report_error _unexpected_res _value_res ($repr _unexpected) ($repr _value) _desc)) }})
243+
(testing:_report_error testing:_unexpected_res testing:_value_res ($repr _unexpected) ($repr _value) _desc)) }})
238244

239245
# @brief Generate the code for a test suite
240246
# @details Create two variables: _name-output (a list: [successes, failures]) and _name-status (boolean, true on success)

0 commit comments

Comments
 (0)