| 8663 | }; |
| 8664 | |
| 8665 | function expectedException(actual, expected) { |
| 8666 | if (!actual || !expected) { |
| 8667 | return false; |
| 8668 | } |
| 8669 | |
| 8670 | if (Object.prototype.toString.call(expected) == '[object RegExp]') { |
| 8671 | return expected.test(actual); |
| 8672 | } |
| 8673 | |
| 8674 | try { |
| 8675 | if (actual instanceof expected) { |
| 8676 | return true; |
| 8677 | } |
| 8678 | } catch (e) { |
| 8679 | // Ignore. The instanceof check doesn't work for arrow functions. |
| 8680 | } |
| 8681 | |
| 8682 | if (Error.isPrototypeOf(expected)) { |
| 8683 | return false; |
| 8684 | } |
| 8685 | |
| 8686 | return expected.call({}, actual) === true; |
| 8687 | } |
| 8688 | |
| 8689 | function _tryBlock(block) { |
| 8690 | var error; |