diff --git a/lib/util.js b/lib/util.js index f8049ad..23aaaca 100644 --- a/lib/util.js +++ b/lib/util.js @@ -228,7 +228,7 @@ exports.propCopy = function( props, dest, result_data ) } else { - throw new Error( + throw new TypeError( "Cannot override property '" + name + "' with method" ); } @@ -339,7 +339,7 @@ function method_override( // that of its supertype if ( arg_len < super_method.definition.length ) { - throw new Error( + throw new TypeError( "Declaration of " + name + " must be compatiable " + "with that of its supertype" ); diff --git a/test/test-class-abstract.js b/test/test-class-abstract.js index 98ebd59..732ec7f 100644 --- a/test/test-class-abstract.js +++ b/test/test-class-abstract.js @@ -172,14 +172,18 @@ assert.throws( function() }); }, Error, "Concrete methods must implement the proper number of argments" ); -assert.throws( function() -{ - AbstractFoo.extend( +assert.throws( + function() { - // incorrect number of arguments - method: abstractMethod(), - }); -}, Error, "Abstract methods of subtypes must implement the proper number of argments" ); + AbstractFoo.extend( + { + // incorrect number of arguments + method: abstractMethod(), + }); + }, + TypeError, + "Abstract methods of subtypes must implement the proper number of argments" +); assert.doesNotThrow( function() @@ -205,7 +209,8 @@ assert.doesNotThrow( { }, }); - }, Error, + }, + Error, "Concrete methods needn't implement the proper number of arguments if " + "no definition was provided" ); diff --git a/test/test-class-extend.js b/test/test-class-extend.js index 7a84f75..49e99f0 100644 --- a/test/test-class-extend.js +++ b/test/test-class-extend.js @@ -133,5 +133,5 @@ assert.throws( function() { foo: function() {}, }); -}, Error, "Cannot override property with a method" ); +}, TypeError, "Cannot override property with a method" );