* Create a synchronous test * * @param {TestFunction} func - Test function. This is executed * immediately. If it returns without error, the test status is * set to ``PASS``. If it throws an :js:class:`AssertionError`, or * any other exception, the test status is set to ``FA
(func, name, properties)
| 622 | * given file and must be invariant between runs. |
| 623 | */ |
| 624 | function test(func, name, properties) |
| 625 | { |
| 626 | if (tests.promise_setup_called) { |
| 627 | tests.status.status = tests.status.ERROR; |
| 628 | tests.status.message = '`test` invoked after `promise_setup`'; |
| 629 | tests.complete(); |
| 630 | } |
| 631 | var test_name = get_test_name(func, name); |
| 632 | var test_obj = new Test(test_name, properties); |
| 633 | var value = test_obj.step(func, test_obj, test_obj); |
| 634 | |
| 635 | if (value !== undefined) { |
| 636 | var msg = 'Test named "' + test_name + |
| 637 | '" passed a function to `test` that returned a value.'; |
| 638 | |
| 639 | try { |
| 640 | if (value && typeof value.then === 'function') { |
| 641 | msg += ' Consider using `promise_test` instead when ' + |
| 642 | 'using Promises or async/await.'; |
| 643 | } |
| 644 | } catch (err) {} |
| 645 | |
| 646 | tests.status.status = tests.status.ERROR; |
| 647 | tests.status.message = msg; |
| 648 | } |
| 649 | |
| 650 | if (test_obj.phase === test_obj.phases.STARTED) { |
| 651 | test_obj.done(); |
| 652 | } |
| 653 | } |
| 654 | |
| 655 | /** |
| 656 | * Create an asynchronous test |
no test coverage detected