Skip to content

Commit

Permalink
.throw() should check that given object is a function. Fix shouldjs#27
Browse files Browse the repository at this point in the history
  • Loading branch information
btd committed Dec 8, 2014
1 parent 1f07d24 commit 481ab87
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/ext/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ module.exports = function(should, Assertion) {
, errorInfo = ''
, thrown = false;

this.is.a.Function;

var errorMatched = true;

try {
Expand Down
4 changes: 4 additions & 0 deletions test/ext/error.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ var err = require('../util').err,

describe('error', function() {
it('test throw()', function() {
err(function() {
'a'.should.throw();
}, "expected 'a' to be a function");

(function(){}).should.not.throw();
(function(){ throw new Error('fail') }).should.throw();

Expand Down

0 comments on commit 481ab87

Please sign in to comment.