|
197 | 197 | # (test:expect (return_true) "return true"}) |
198 | 198 | # =end |
199 | 199 | # @author https://github.com/SuperFola |
200 | | -(macro test:expect (_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 | | - (testing:_report_success)) }}) |
| 200 | +(macro test:expect (_cond ..._desc) { |
| 201 | + { |
| 202 | + (set testing:_cond_res ($as-is _cond)) |
| 203 | + (if (!= true testing:_cond_res) |
| 204 | + (testing:_report_error true testing:_cond_res "true" ($repr _cond) _desc) |
| 205 | + (testing:_report_success)) } }) |
205 | 206 |
|
206 | 207 | (mut _cond_res nil) |
207 | 208 | (mut _expr_res nil) |
|
219 | 220 | # (test:eq 5 (foo) "foo should return 5")}) |
220 | 221 | # =end |
221 | 222 | # @author https://github.com/SuperFola |
222 | | -(macro test:eq (_expr _expected ..._desc) {{ |
223 | | - (set testing:_expected_res ($as-is _expected)) |
224 | | - (set testing:_expr_res ($as-is _expr)) |
225 | | - (if (= testing:_expected_res testing:_expr_res) |
226 | | - (testing:_report_success) |
227 | | - (testing:_report_error testing:_expected_res testing:_expr_res ($repr _expected) ($repr _expr) _desc)) }}) |
| 223 | +(macro test:eq (_expr _expected ..._desc) { |
| 224 | + { |
| 225 | + (set testing:_expected_res ($as-is _expected)) |
| 226 | + (set testing:_expr_res ($as-is _expr)) |
| 227 | + (if (= testing:_expected_res testing:_expr_res) |
| 228 | + (testing:_report_success) |
| 229 | + (testing:_report_error testing:_expected_res testing:_expr_res ($repr _expected) ($repr _expr) _desc)) } }) |
228 | 230 |
|
229 | 231 | # @brief Compare two values that should **not** be equal and generate a test case |
230 | 232 | # @param _value tested value |
|
235 | 237 | # (test:neq 0 (my_function 1 2 3))}) |
236 | 238 | # =end |
237 | 239 | # @author https://github.com/SuperFola |
238 | | -(macro test:neq (_value _unexpected ..._desc) {{ |
239 | | - (set testing:_unexpected_res ($as-is _unexpected)) |
240 | | - (set testing:_value_res ($as-is _value)) |
241 | | - (if (!= testing:_unexpected_res testing:_value_res) |
242 | | - (testing:_report_success) |
243 | | - (testing:_report_error testing:_unexpected_res testing:_value_res ($repr _unexpected) ($repr _value) _desc)) }}) |
| 240 | +(macro test:neq (_value _unexpected ..._desc) { |
| 241 | + { |
| 242 | + (set testing:_unexpected_res ($as-is _unexpected)) |
| 243 | + (set testing:_value_res ($as-is _value)) |
| 244 | + (if (!= testing:_unexpected_res testing:_value_res) |
| 245 | + (testing:_report_success) |
| 246 | + (testing:_report_error testing:_unexpected_res testing:_value_res ($repr _unexpected) ($repr _value) _desc)) } }) |
244 | 247 |
|
245 | 248 | # @brief Generate the code for a test suite |
246 | 249 | # @details Create two variables: _name-output (a list: [successes, failures]) and _name-status (boolean, true on success) |
|
258 | 261 | (set testing:_suite (testing:_make_suite ($repr _name))) |
259 | 262 |
|
260 | 263 | (let ($symcat _name "-output") (testing:_runner |
261 | | - ($repr _name) |
262 | | - (fun () ($as-is |
263 | | - { |
264 | | - _body })))) |
| 264 | + ($repr _name) |
| 265 | + (fun () ($as-is |
| 266 | + { |
| 267 | + _body })))) |
265 | 268 | (let ($symcat _name "-status") (= 0 (@ ($symcat _name "-output") 1))) }) |
0 commit comments