(shouldThrow, block, expected, message)
| 9857 | } |
| 9858 | |
| 9859 | function _throws(shouldThrow, block, expected, message) { |
| 9860 | var actual; |
| 9861 | |
| 9862 | if (util.isString(expected)) { |
| 9863 | message = expected; |
| 9864 | expected = null; |
| 9865 | } |
| 9866 | |
| 9867 | try { |
| 9868 | block(); |
| 9869 | } catch (e) { |
| 9870 | actual = e; |
| 9871 | } |
| 9872 | |
| 9873 | message = (expected && expected.name ? ' (' + expected.name + ').' : '.') + |
| 9874 | (message ? ' ' + message : '.'); |
| 9875 | |
| 9876 | if (shouldThrow && !actual) { |
| 9877 | fail(actual, expected, 'Missing expected exception' + message); |
| 9878 | } |
| 9879 | |
| 9880 | if (!shouldThrow && expectedException(actual, expected)) { |
| 9881 | fail(actual, expected, 'Got unwanted exception' + message); |
| 9882 | } |
| 9883 | |
| 9884 | if ((shouldThrow && actual && expected && |
| 9885 | !expectedException(actual, expected)) || (!shouldThrow && actual)) { |
| 9886 | throw actual; |
| 9887 | } |
| 9888 | } |
| 9889 | |
| 9890 | assert.throws = function(block, /*optional*/error, /*optional*/message) { |
| 9891 | _throws.apply(this, [true].concat(pSlice.call(arguments))); |
nothing calls this directly
no test coverage detected