|
198 | 198 | # =end |
199 | 199 | # @author https://github.com/SuperFola |
200 | 200 | (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) |
204 | 204 | (testing:_report_success)) }}) |
205 | 205 |
|
| 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 | + |
206 | 212 | # @brief Compare two values that should be equal and generate a test case |
207 | 213 | # @param _expr computed value to test |
208 | 214 | # @param _expected expected value |
|
214 | 220 | # =end |
215 | 221 | # @author https://github.com/SuperFola |
216 | 222 | (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) |
220 | 226 | (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)) }}) |
222 | 228 |
|
223 | 229 | # @brief Compare two values that should **not** be equal and generate a test case |
224 | 230 | # @param _value tested value |
|
230 | 236 | # =end |
231 | 237 | # @author https://github.com/SuperFola |
232 | 238 | (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) |
236 | 242 | (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)) }}) |
238 | 244 |
|
239 | 245 | # @brief Generate the code for a test suite |
240 | 246 | # @details Create two variables: _name-output (a list: [successes, failures]) and _name-status (boolean, true on success) |
|
0 commit comments