Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #11 from gusaaaaa/master

assertThrow should rise an error if expected and thrown errors don't match
  • Loading branch information...
commit ba3a1879ba8507d35485266d29dd48696a21b71a 2 parents 555c375 + 1ce01fd
@elcuervo authored
Showing with 14 additions and 2 deletions.
  1. +1 −1  lib/gerbil.js
  2. +13 −1 test/gerbil.js
View
2  lib/gerbil.js
@@ -260,7 +260,7 @@ Gerbil.Test.prototype = {
fn();
errorMessage = expectedError.name + " was expected but not raised.";
} catch(exception) {
- if (typeof exception === typeof expectedError) {
+ if (!(exception instanceof expectedError)) {
errorMessage = expectedError.name + " was expected but " + exception.name + " was raised.";
}
}
View
14 test/gerbil.js
@@ -30,7 +30,19 @@ scenario("Gerbil - Assertions", {
g.assertThrow(Error, function() {
g.assertType(Function, 42);
});
- }
+ },
+
+ "should rise an error if expected and thrown errors don't match": function(g) {
+ function CustomError1() {}
+ function CustomError2() {}
+
+ g.assertThrow(Error, function() {
+ g.assertThrow(CustomError1, function(){
+ throw new CustomError2();
+ });
+ });
+ },
+
});
scenario("Gerbil - setTimeout", {
Please sign in to comment.
Something went wrong with that request. Please try again.