1
0
Fork 0

Using TypeError instead of Error for property type inconsistiencies

closure/master
Mike Gerwitz 2010-12-10 00:00:47 -05:00
parent 25dc7e031e
commit 5126c71a2d
3 changed files with 16 additions and 11 deletions

View File

@ -228,7 +228,7 @@ exports.propCopy = function( props, dest, result_data )
} }
else else
{ {
throw new Error( throw new TypeError(
"Cannot override property '" + name + "' with method" "Cannot override property '" + name + "' with method"
); );
} }
@ -339,7 +339,7 @@ function method_override(
// that of its supertype // that of its supertype
if ( arg_len < super_method.definition.length ) if ( arg_len < super_method.definition.length )
{ {
throw new Error( throw new TypeError(
"Declaration of " + name + " must be compatiable " + "Declaration of " + name + " must be compatiable " +
"with that of its supertype" "with that of its supertype"
); );

View File

@ -172,14 +172,18 @@ assert.throws( function()
}); });
}, Error, "Concrete methods must implement the proper number of argments" ); }, Error, "Concrete methods must implement the proper number of argments" );
assert.throws( function() assert.throws(
{ function()
{
AbstractFoo.extend( AbstractFoo.extend(
{ {
// incorrect number of arguments // incorrect number of arguments
method: abstractMethod(), method: abstractMethod(),
}); });
}, Error, "Abstract methods of subtypes must implement the proper number of argments" ); },
TypeError,
"Abstract methods of subtypes must implement the proper number of argments"
);
assert.doesNotThrow( assert.doesNotThrow(
function() function()
@ -205,7 +209,8 @@ assert.doesNotThrow(
{ {
}, },
}); });
}, Error, },
Error,
"Concrete methods needn't implement the proper number of arguments if " + "Concrete methods needn't implement the proper number of arguments if " +
"no definition was provided" "no definition was provided"
); );

View File

@ -133,5 +133,5 @@ assert.throws( function()
{ {
foo: function() {}, foo: function() {},
}); });
}, Error, "Cannot override property with a method" ); }, TypeError, "Cannot override property with a method" );