Skip to content

Commit

Permalink
[Tests] add a test for the wrong kind of error
Browse files Browse the repository at this point in the history
Related to #479.
  • Loading branch information
ljharb committed Jul 29, 2019
1 parent 2b5046e commit 44cbbf5
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions test/throws.js
Expand Up @@ -164,10 +164,20 @@ tap.test('failures', function (tt) {
+ 'ok 12 getter is still the same\n'
+ '# throws null\n'
+ 'ok 13 throws null\n'
+ '\n1..13\n'
+ '# tests 13\n'
+ '# wrong type of error\n'
+ 'not ok 14 throws actual\n'
+ ' ---\n'
+ ' operator: throws\n'
+ ' expected: |-\n'
+ ' [Function: TypeError]\n'
+ ' actual: |-\n'
+ ' [Function: RangeError]\n'
+ ' at: Test.<anonymous> ($TEST/throws.js:$LINE:$COL)\n'
+ ' ...\n'
+ '\n1..14\n'
+ '# tests 14\n'
+ '# pass 4\n'
+ '# fail 9\n'
+ '# fail 10\n'
);
}));

Expand Down Expand Up @@ -200,4 +210,11 @@ tap.test('failures', function (tt) {
t.throws(function () { throw null; }, 'throws null');
t.end();
});

test('wrong type of error', function (t) {
t.plan(1);
var actual = new RangeError('actual!');
t.throws(function () { throw actual; }, TypeError, 'throws actual');
t.end();
});
});

0 comments on commit 44cbbf5

Please sign in to comment.