MCPcopy
hub / github.com/microsoft/SandDance / expectedException

Function expectedException

docs/tests/v2/es6/js/sanddance.js:8665–8687  ·  view source on GitHub ↗
(actual, expected)

Source from the content-addressed store, hash-verified

8663};
8664
8665function 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
8689function _tryBlock(block) {
8690 var error;

Callers 1

_throwsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected