* Like assert_throws_exactly but allows specifying the assertion type * (assert_throws_exactly or promise_rejects_exactly, in practice).
(exception, func, description,
assertion_type)
| 1793 | * (assert_throws_exactly or promise_rejects_exactly, in practice). |
| 1794 | */ |
| 1795 | function assert_throws_exactly_impl(exception, func, description, |
| 1796 | assertion_type) |
| 1797 | { |
| 1798 | try { |
| 1799 | func.call(this); |
| 1800 | assert(false, assertion_type, description, |
| 1801 | "${func} did not throw", {func:func}); |
| 1802 | } catch (e) { |
| 1803 | if (e instanceof AssertionError) { |
| 1804 | throw e; |
| 1805 | } |
| 1806 | |
| 1807 | assert(same_value(e, exception), assertion_type, description, |
| 1808 | "${func} threw ${e} but we expected it to throw ${exception}", |
| 1809 | {func:func, e:e, exception:exception}); |
| 1810 | } |
| 1811 | } |
| 1812 | |
| 1813 | function assert_unreached(description) { |
| 1814 | assert(false, "assert_unreached", description, |
no test coverage detected