* Like assert_throws_exactly but allows specifying the assertion type * (assert_throws_exactly or promise_rejects_exactly, in practice).
(exception, func, description,
assertion_type)
| 2596 | * (assert_throws_exactly or promise_rejects_exactly, in practice). |
| 2597 | */ |
| 2598 | function assert_throws_exactly_impl(exception, func, description, |
| 2599 | assertion_type) |
| 2600 | { |
| 2601 | try { |
| 2602 | func.call(this); |
| 2603 | assert(false, assertion_type, description, |
| 2604 | "${func} did not throw", {func:func}); |
| 2605 | } catch (e) { |
| 2606 | if (e instanceof AssertionError) { |
| 2607 | throw e; |
| 2608 | } |
| 2609 | |
| 2610 | assert(same_value(e, exception), assertion_type, description, |
| 2611 | "${func} threw ${e} but we expected it to throw ${exception}", |
| 2612 | {func:func, e:e, exception:exception}); |
| 2613 | } |
| 2614 | } |
| 2615 | |
| 2616 | /** |
| 2617 | * Asserts if called. Used to ensure that a specific codepath is |
no test coverage detected